less copy protection, more size visualization
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

202 lines
5.7 KiB

  1. function makeObject(name, viewInfo) {
  2. views = {};
  3. Object.entries(viewInfo).forEach(([key, value]) => {
  4. views[key] = {
  5. attributes: {
  6. height: {
  7. name: "Height",
  8. power: 1,
  9. type: "length",
  10. base: value.height
  11. }
  12. },
  13. image: value.image,
  14. name: value.name,
  15. rename: value.rename
  16. }
  17. if (value.mass) {
  18. views[key].attributes.mass = {
  19. name: "Mass",
  20. power: 3,
  21. type: "mass",
  22. base: value.mass
  23. };
  24. }
  25. });
  26. return makeEntity({ name: name }, views);
  27. }
  28. function makeObjects() {
  29. const results = [];
  30. results.push({
  31. name: "Soda Can",
  32. constructor: () => makeObject(
  33. "Soda Can",
  34. {
  35. front: {
  36. height: math.unit(4.83, "inches"),
  37. mass: math.unit(15, "grams"),
  38. image: { source: "./media/objects/soda-can.svg" },
  39. name: "Side"
  40. }
  41. }
  42. )
  43. });
  44. results.push({
  45. name: "Sewing Pin",
  46. constructor: () => makeObject(
  47. "Sewing Pin",
  48. {
  49. side: {
  50. height: math.unit(1.5, "inches"),
  51. image: { source: "./media/objects/sewing-pin.svg" },
  52. name: "Side"
  53. },
  54. top: {
  55. height: math.unit(2, "millimeters"),
  56. image: { source: "./media/objects/pin-head.svg" },
  57. name: "Head"
  58. }
  59. }
  60. )
  61. });
  62. results.push({
  63. name: "Lamp",
  64. constructor: () => makeObject(
  65. "Lamp",
  66. {
  67. lamp: {
  68. height: math.unit(30, "inches"),
  69. mass: math.unit(10, "lbs"),
  70. image: { source: "./media/objects/lamp.svg" },
  71. name: "Lamp"
  72. }
  73. }
  74. )
  75. });
  76. results.push({
  77. name: "Human",
  78. constructor: () => makeObject(
  79. "Human",
  80. {
  81. woman1: {
  82. height: math.unit(5 + 4/12, "feet"),
  83. mass: math.unit(140, "lbs"),
  84. image: { source: "./media/objects/humans/woman-1.svg" },
  85. name: "Woman 1"
  86. },
  87. man1: {
  88. height: math.unit(5 + 6/12, "feet"),
  89. mass: math.unit(150, "lbs"),
  90. image: { source: "./media/objects/humans/man-1.svg" },
  91. name: "Man 1"
  92. },
  93. }
  94. )
  95. });
  96. results.push({
  97. name: "Nail Polish",
  98. constructor: () => makeObject(
  99. "Nail Polish",
  100. {
  101. bottle: {
  102. height: math.unit(3.25, "inches"),
  103. mass: math.unit(66, "g"),
  104. image: { source: "./media/objects/nail-polish.svg" },
  105. name: "Bottle"
  106. }
  107. }
  108. )
  109. });
  110. results.push({
  111. name: "Shot Glass",
  112. constructor: () => makeObject(
  113. "Shot Glass",
  114. {
  115. glass: {
  116. height: math.unit(2 + 3/8, "inches"),
  117. mass: math.unit(75, "g"),
  118. image: { source: "./media/objects/shot-glass.svg" },
  119. name: "Bottle"
  120. }
  121. }
  122. )
  123. });
  124. results.push({
  125. name: "Beer Bottle",
  126. constructor: () => makeObject(
  127. "Beer Bottle",
  128. {
  129. longneck: {
  130. height: math.unit(9, "inches"),
  131. mass: math.unit(200, "g"),
  132. image: { source: "./media/objects/beer-bottle.svg" },
  133. name: "Longneck Bottle"
  134. }
  135. }
  136. )
  137. });
  138. results.push({
  139. name: "Coin",
  140. constructor: () => makeObject(
  141. "Coin",
  142. {
  143. penny: {
  144. height: math.unit(0.75, "inches"),
  145. mass: math.unit(2.5, "g"),
  146. image: { source: "./media/objects/circle.svg" },
  147. name: "Penny",
  148. rename: true
  149. },
  150. nickel: {
  151. height: math.unit(0.835, "inches"),
  152. mass: math.unit(5, "g"),
  153. image: { source: "./media/objects/circle.svg" },
  154. name: "Nickel",
  155. rename: true
  156. },
  157. dime: {
  158. height: math.unit(0.705, "inches"),
  159. mass: math.unit(2.268, "g"),
  160. image: { source: "./media/objects/circle.svg" },
  161. name: "Dime",
  162. rename: true
  163. },
  164. quarter: {
  165. height: math.unit(0.955, "inches"),
  166. mass: math.unit(5.67, "g"),
  167. image: { source: "./media/objects/circle.svg" },
  168. name: "Quarter",
  169. rename: true
  170. },
  171. dollar: {
  172. height: math.unit(1.043, "inches"),
  173. mass: math.unit(8.1, "g"),
  174. image: { source: "./media/objects/circle.svg" },
  175. name: "Dollar Coin",
  176. rename: true
  177. },
  178. }
  179. )
  180. });
  181. results.sort((b1, b2) => {
  182. e1 = b1.constructor();
  183. e2 = b2.constructor();
  184. return -math.subtract(e1.views[e1.defaultView].height, e2.views[e2.defaultView].height).value;
  185. });
  186. return results;
  187. }