less copy protection, more size visualization
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

163 行
3.8 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: name }, 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 sizes = [];
  42. sizes.push({
  43. name: "Short",
  44. height: math.unit(15, "stories")
  45. });
  46. sizes.push({
  47. name: "Medium",
  48. height: math.unit(40, "stories")
  49. });
  50. sizes.push({
  51. name: "Supertall",
  52. height: math.unit(350, "meters")
  53. });
  54. sizes.push({
  55. name: "Megatall",
  56. height: math.unit(650, "meters")
  57. });
  58. const entity = makeEntity({ name: name }, views, sizes);
  59. entity.views[entity.defaultView].height = startingSize;
  60. return entity;
  61. }
  62. function makeBuildings() {
  63. const results = [];
  64. results.push({
  65. name: "Two-Story Home",
  66. constructor: () => makeBuilding(
  67. "Two-Story Home",
  68. math.unit(25, "feet"),
  69. { source: "./media/buildings/house.svg" }
  70. )
  71. });
  72. results.push({
  73. name: "Mobile Home",
  74. constructor: () => makeBuilding(
  75. "Mobile Home",
  76. math.unit(10, "feet"),
  77. { source: "./media/buildings/mobile-home.svg" }
  78. )
  79. });
  80. results.push({
  81. name: "Mailbox",
  82. constructor: () => makeBuilding(
  83. "Mailbox",
  84. math.unit(5.1, "feet"),
  85. { source: "./media/buildings/mailbox.svg" }
  86. )
  87. });
  88. results.push({
  89. name: "Bus Stop",
  90. constructor: () => makeBuilding(
  91. "Bus Stop",
  92. math.unit(8, "feet"),
  93. { source: "./media/buildings/bus-stop.svg" }
  94. )
  95. });
  96. results.push(
  97. {
  98. name: "Wide Skyscraper",
  99. constructor: () => makeSkyscraper(
  100. "Wide Skyscraper",
  101. { source: "./media/buildings/skyscrapers/wide.svg" },
  102. math.unit(40, "stories")
  103. )
  104. }
  105. );
  106. results.push(
  107. {
  108. name: "Skyscraper",
  109. constructor: () => makeSkyscraper(
  110. "Skyscraper",
  111. { source: "./media/buildings/skyscrapers/medium.svg" },
  112. math.unit(40, "stories")
  113. )
  114. }
  115. );
  116. results.push(
  117. {
  118. name: "Slender Skyscraper",
  119. constructor: () => makeSkyscraper(
  120. "Slender Skyscraper",
  121. { source: "./media/buildings/skyscrapers/slender.svg" },
  122. math.unit(40, "stories")
  123. )
  124. }
  125. );
  126. results.push(
  127. {
  128. name: "Narrow Skyscraper",
  129. constructor: () => makeSkyscraper(
  130. "Narrow Skyscraper",
  131. { source: "./media/buildings/skyscrapers/narrow.svg" },
  132. math.unit(40, "stories")
  133. )
  134. }
  135. );
  136. results.sort((b1, b2) => {
  137. e1 = b1.constructor();
  138. e2 = b2.constructor();
  139. return -math.subtract(e1.views[e1.defaultView].height, e2.views[e2.defaultView].height).value;
  140. });
  141. return results;
  142. }