less copy protection, more size visualization
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

151 líneas
3.6 KiB

  1. math.createUnit("story", {
  2. definition: "12 feet",
  3. prefixes: "long"
  4. });
  5. math.createUnit("stories", {
  6. definition: "12 feet",
  7. prefixes: "long"
  8. });
  9. function makeBuilding(name, height, image) {
  10. views = {
  11. building: {
  12. attributes: {
  13. height: {
  14. name: "Height",
  15. power: 1,
  16. type: "length",
  17. base: height
  18. }
  19. },
  20. image: image,
  21. name: "building"
  22. },
  23. };
  24. return makeEntity(name, "Building", views);
  25. }
  26. function makeSkyscraper(name, image, startingSize) {
  27. views = {
  28. building: {
  29. attributes: {
  30. height: {
  31. name: "Height",
  32. power: 1,
  33. type: "length",
  34. base: math.unit(1, "meter")
  35. }
  36. },
  37. image: image,
  38. name: "building"
  39. },
  40. };
  41. const entity = makeEntity(name, "Skyscraper", views);
  42. entity.defaults.push({
  43. name: "Short",
  44. height: math.unit(15, "stories")
  45. });
  46. entity.defaults.push({
  47. name: "Medium",
  48. height: math.unit(40, "stories")
  49. });
  50. entity.defaults.push({
  51. name: "Supertall",
  52. height: math.unit(350, "meters")
  53. });
  54. entity.defaults.push({
  55. name: "Megatall",
  56. height: math.unit(650, "meters")
  57. });
  58. entity.views[entity.defaultView].height = startingSize;
  59. return entity;
  60. }
  61. function makeBuildings() {
  62. const results = [];
  63. results.push({
  64. name: "Two-Story Home",
  65. constructor: () => makeBuilding(
  66. "House",
  67. math.unit(25, "feet"),
  68. { source: "./media/buildings/house.svg" }
  69. )
  70. });
  71. results.push({
  72. name: "Mobile Home",
  73. constructor: () => makeBuilding(
  74. "Mobile Home",
  75. math.unit(10, "feet"),
  76. { source: "./media/buildings/mobile-home.svg" }
  77. )
  78. });
  79. results.push({
  80. name: "Mailbox",
  81. constructor: () => makeBuilding(
  82. "Mailbox",
  83. math.unit(5.1, "feet"),
  84. { source: "./media/buildings/mailbox.svg" }
  85. )
  86. });
  87. results.push(
  88. {
  89. name: "Wide Skyscraper",
  90. constructor: () => makeSkyscraper(
  91. "Wide Skyscraper",
  92. { source: "./media/buildings/skyscrapers/wide.svg" },
  93. math.unit(40, "stories")
  94. )
  95. }
  96. );
  97. results.push(
  98. {
  99. name: "Skyscraper",
  100. constructor: () => makeSkyscraper(
  101. "Skyscraper",
  102. { source: "./media/buildings/skyscrapers/medium.svg" },
  103. math.unit(40, "stories")
  104. )
  105. }
  106. );
  107. results.push(
  108. {
  109. name: "Slender Skyscraper",
  110. constructor: () => makeSkyscraper(
  111. "Slender Skyscraper",
  112. { source: "./media/buildings/skyscrapers/slender.svg" },
  113. math.unit(40, "stories")
  114. )
  115. }
  116. );
  117. results.push(
  118. {
  119. name: "Narrow Skyscraper",
  120. constructor: () => makeSkyscraper(
  121. "Narrow Skyscraper",
  122. { source: "./media/buildings/skyscrapers/narrow.svg" },
  123. math.unit(40, "stories")
  124. )
  125. }
  126. );
  127. results.sort((b1, b2) => {
  128. e1 = b1.constructor();
  129. e2 = b2.constructor();
  130. return -math.subtract(e1.views[e1.defaultView].height, e2.views[e2.defaultView].height).value;
  131. });
  132. return results;
  133. }