less copy protection, more size visualization
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 

187 рядки
4.1 KiB

  1. function makeBuilding(name, height, image) {
  2. views = {
  3. building: {
  4. attributes: {
  5. height: {
  6. name: "Height",
  7. power: 1,
  8. type: "length",
  9. base: height
  10. }
  11. },
  12. image: image,
  13. name: "building"
  14. },
  15. };
  16. return makeEntity({ name: name }, views);
  17. }
  18. function makeSkyscraper(name, image) {
  19. views = {
  20. building: {
  21. attributes: {
  22. height: {
  23. name: "Height",
  24. power: 1,
  25. type: "length",
  26. base: math.unit(1, "meter")
  27. }
  28. },
  29. image: image,
  30. name: "building"
  31. },
  32. };
  33. const sizes = [];
  34. sizes.push({
  35. name: "Short",
  36. height: math.unit(15, "stories")
  37. });
  38. sizes.push({
  39. name: "Medium",
  40. height: math.unit(40, "stories"),
  41. default: true
  42. });
  43. sizes.push({
  44. name: "Supertall",
  45. height: math.unit(350, "meters")
  46. });
  47. sizes.push({
  48. name: "Megatall",
  49. height: math.unit(650, "meters")
  50. });
  51. const entity = makeEntity({ name: name }, views, sizes);
  52. return entity;
  53. }
  54. function makeBuildings() {
  55. const results = [];
  56. results.push({
  57. name: "Two-Story Home",
  58. constructor: () => makeBuilding(
  59. "Two-Story Home",
  60. math.unit(25, "feet"),
  61. { source: "./media/buildings/house.svg" }
  62. )
  63. });
  64. results.push({
  65. name: "Mobile Home",
  66. constructor: () => makeBuilding(
  67. "Mobile Home",
  68. math.unit(10, "feet"),
  69. { source: "./media/buildings/mobile-home.svg" }
  70. )
  71. });
  72. results.push({
  73. name: "Mailbox",
  74. constructor: () => makeBuilding(
  75. "Mailbox",
  76. math.unit(5.1, "feet"),
  77. { source: "./media/buildings/mailbox.svg" }
  78. )
  79. });
  80. results.push({
  81. name: "Bus Stop",
  82. constructor: () => makeBuilding(
  83. "Bus Stop",
  84. math.unit(8, "feet"),
  85. { source: "./media/buildings/bus-stop.svg" }
  86. )
  87. });
  88. results.push(
  89. {
  90. name: "Wide Skyscraper",
  91. constructor: () => makeSkyscraper(
  92. "Wide Skyscraper",
  93. { source: "./media/buildings/skyscrapers/wide.svg" }
  94. )
  95. }
  96. );
  97. results.push(
  98. {
  99. name: "Skyscraper",
  100. constructor: () => makeSkyscraper(
  101. "Skyscraper",
  102. { source: "./media/buildings/skyscrapers/medium.svg" }
  103. )
  104. }
  105. );
  106. results.push(
  107. {
  108. name: "Slender Skyscraper",
  109. constructor: () => makeSkyscraper(
  110. "Slender Skyscraper",
  111. { source: "./media/buildings/skyscrapers/slender.svg" }
  112. )
  113. }
  114. );
  115. results.push(
  116. {
  117. name: "Narrow Skyscraper",
  118. constructor: () => makeSkyscraper(
  119. "Narrow Skyscraper",
  120. { source: "./media/buildings/skyscrapers/narrow.svg" }
  121. )
  122. }
  123. );
  124. results.push(
  125. makeHeight(
  126. [
  127. ["four-lane-highway", 27.432, "meters"],
  128. ["sidewalk", 24, "feet"]
  129. ],
  130. "Roads",
  131. "",
  132. "buildings"
  133. )
  134. )
  135. results.push(
  136. makeHeight(
  137. [
  138. ["residential", 12, "feet"],
  139. ["freeway", 50, "feet"]
  140. ],
  141. "Street Lamps",
  142. "",
  143. "buildings"
  144. )
  145. )
  146. results.push(
  147. makeHeight(
  148. [
  149. ["manhattan", 141.8, "meters"],
  150. ["houston", 93, "meters"]
  151. ],
  152. "City Blocks",
  153. "",
  154. "buildings"
  155. )
  156. )
  157. results.sort((b1, b2) => {
  158. e1 = b1.constructor();
  159. e2 = b2.constructor();
  160. return -math.subtract(e1.views[e1.defaultView].height, e2.views[e2.defaultView].height).value;
  161. });
  162. return results;
  163. }