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.
 
 
 

452 lines
13 KiB

  1. math.createUnit("dalton", {
  2. definition: "1.66e-27 kg",
  3. prefixes: "long"
  4. });
  5. math.createUnit("daltons", {
  6. definition: "1.66e-27 kg",
  7. prefixes: "long"
  8. });
  9. function makeObject(name, viewInfo) {
  10. views = {};
  11. Object.entries(viewInfo).forEach(([key, value]) => {
  12. views[key] = {
  13. attributes: {
  14. height: {
  15. name: "Height",
  16. power: 1,
  17. type: "length",
  18. base: value.height
  19. }
  20. },
  21. image: value.image,
  22. name: value.name,
  23. rename: value.rename
  24. }
  25. if (value.mass) {
  26. views[key].attributes.mass = {
  27. name: "Mass",
  28. power: 3,
  29. type: "mass",
  30. base: value.mass
  31. };
  32. }
  33. });
  34. return makeEntity({ name: name }, views);
  35. }
  36. SHOE_REFERENCE = 60
  37. function addShoeView(object, name, points) {
  38. object[name] = {
  39. height: math.unit(points / SHOE_REFERENCE, "inches"),
  40. image: { source: "./media/objects/shoes/shoe_" + name + ".svg" },
  41. name: name.replace(/-/g, " ").replace(/\b\w/g, x => x.toUpperCase()),
  42. rename: true
  43. }
  44. }
  45. function makeHeightWeight(info, category, prefix="") {
  46. const views = {};
  47. info.forEach(object => {
  48. views[object[0]] = {
  49. height: math.unit(object[1], "meters"),
  50. mass: math.unit(object[2], "kilograms"),
  51. image: { source: "./media/objects/" + category.replace(/ /g, "-").toLowerCase() + "/" + prefix + object[0] + ".svg" },
  52. name: object[0].replace(/-/g, " ").replace(/\b\w/g, x => x.toUpperCase()),
  53. rename: true
  54. }
  55. });
  56. return {
  57. name: category,
  58. constructor: () => makeObject(
  59. category,
  60. views
  61. )
  62. }
  63. }
  64. function makeShoes() {
  65. const views = {};
  66. [
  67. ["flip-flops", 154.239],
  68. ["knee-boots", 841.827],
  69. ["trainers", 260.607],
  70. ["stilettos", 418.839]
  71. ].forEach(shoe => {
  72. addShoeView(views, shoe[0], shoe[1])
  73. });
  74. return {
  75. name: "Shoes",
  76. constructor: () => makeObject(
  77. "Shoes",
  78. views
  79. )
  80. }
  81. }
  82. function makeObjects() {
  83. const results = [];
  84. results.push({
  85. name: "Soda Can",
  86. constructor: () => makeObject(
  87. "Soda Can",
  88. {
  89. front: {
  90. height: math.unit(4.83, "inches"),
  91. mass: math.unit(15, "grams"),
  92. image: { source: "./media/objects/soda-can.svg" },
  93. name: "Side"
  94. }
  95. }
  96. )
  97. });
  98. results.push({
  99. name: "Sewing Pin",
  100. constructor: () => makeObject(
  101. "Sewing Pin",
  102. {
  103. side: {
  104. height: math.unit(1.5, "inches"),
  105. image: { source: "./media/objects/sewing-pin.svg" },
  106. name: "Side"
  107. },
  108. top: {
  109. height: math.unit(2, "millimeters"),
  110. image: { source: "./media/objects/pin-head.svg" },
  111. name: "Head"
  112. }
  113. }
  114. )
  115. });
  116. results.push({
  117. name: "Lamp",
  118. constructor: () => makeObject(
  119. "Lamp",
  120. {
  121. lamp: {
  122. height: math.unit(30, "inches"),
  123. mass: math.unit(10, "lbs"),
  124. image: { source: "./media/objects/lamp.svg" },
  125. name: "Lamp"
  126. }
  127. }
  128. )
  129. });
  130. results.push({
  131. name: "Nail Polish",
  132. constructor: () => makeObject(
  133. "Nail Polish",
  134. {
  135. bottle: {
  136. height: math.unit(3.25, "inches"),
  137. mass: math.unit(66, "g"),
  138. image: { source: "./media/objects/nail-polish.svg" },
  139. name: "Bottle"
  140. }
  141. }
  142. )
  143. });
  144. results.push({
  145. name: "Shot Glass",
  146. constructor: () => makeObject(
  147. "Shot Glass",
  148. {
  149. glass: {
  150. height: math.unit(2 + 3/8, "inches"),
  151. mass: math.unit(75, "g"),
  152. image: { source: "./media/objects/shot-glass.svg" },
  153. name: "Bottle"
  154. }
  155. }
  156. )
  157. });
  158. results.push({
  159. name: "Beer Bottle",
  160. constructor: () => makeObject(
  161. "Beer Bottle",
  162. {
  163. longneck: {
  164. height: math.unit(9, "inches"),
  165. mass: math.unit(200, "g"),
  166. image: { source: "./media/objects/beer-bottle.svg" },
  167. name: "Longneck Bottle"
  168. }
  169. }
  170. )
  171. });
  172. results.push({
  173. name: "Coin",
  174. constructor: () => makeObject(
  175. "Coin",
  176. {
  177. penny: {
  178. height: math.unit(0.75, "inches"),
  179. mass: math.unit(2.5, "g"),
  180. image: { source: "./media/objects/circle.svg" },
  181. name: "Penny",
  182. rename: true
  183. },
  184. nickel: {
  185. height: math.unit(0.835, "inches"),
  186. mass: math.unit(5, "g"),
  187. image: { source: "./media/objects/circle.svg" },
  188. name: "Nickel",
  189. rename: true
  190. },
  191. dime: {
  192. height: math.unit(0.705, "inches"),
  193. mass: math.unit(2.268, "g"),
  194. image: { source: "./media/objects/circle.svg" },
  195. name: "Dime",
  196. rename: true
  197. },
  198. quarter: {
  199. height: math.unit(0.955, "inches"),
  200. mass: math.unit(5.67, "g"),
  201. image: { source: "./media/objects/circle.svg" },
  202. name: "Quarter",
  203. rename: true
  204. },
  205. dollar: {
  206. height: math.unit(1.043, "inches"),
  207. mass: math.unit(8.1, "g"),
  208. image: { source: "./media/objects/circle.svg" },
  209. name: "Dollar Coin",
  210. rename: true
  211. },
  212. }
  213. )
  214. });
  215. results.push({
  216. name: "Pencil",
  217. constructor: () => makeObject(
  218. "Pencil",
  219. {
  220. pencil: {
  221. height: math.unit(7.5, "inches"),
  222. mass: math.unit(7, "g"),
  223. image: { source: "./media/objects/pencil.svg" },
  224. name: "Pencil"
  225. }
  226. }
  227. )
  228. });
  229. results.push({
  230. name: "Balls",
  231. constructor: () => makeObject(
  232. "Balls",
  233. {
  234. golf: {
  235. height: math.unit(1.62, "inches"),
  236. mass: math.unit(45, "g"),
  237. image: { source: "./media/objects/circle.svg" },
  238. name: "Golfball",
  239. rename: true
  240. },
  241. tennis: {
  242. height: math.unit(2.6, "inches"),
  243. mass: math.unit(57, "g"),
  244. image: { source: "./media/objects/circle.svg" },
  245. name: "Tennisball",
  246. rename: true
  247. },
  248. baseball: {
  249. height: math.unit(2.9, "inches"),
  250. mass: math.unit(145, "g"),
  251. image: { source: "./media/objects/circle.svg" },
  252. name: "Baseball",
  253. rename: true
  254. },
  255. volleyball: {
  256. height: math.unit(8, "inches"),
  257. mass: math.unit(270, "g"),
  258. image: { source: "./media/objects/circle.svg" },
  259. name: "Volleyball",
  260. rename: true
  261. }
  262. }
  263. )
  264. });
  265. results.push({
  266. name: "Paperclip",
  267. constructor: () => makeObject(
  268. "Paperclip",
  269. {
  270. paperclip: {
  271. height: math.unit(1.834, "inches"),
  272. mass: math.unit(1, "g"),
  273. image: { source: "./media/objects/paperclip.svg" },
  274. name: "Paperclip"
  275. }
  276. }
  277. )
  278. });
  279. results.push({
  280. name: "Pebbles",
  281. constructor: () => makeObject(
  282. "Pebbles",
  283. {
  284. gravelGrain: {
  285. height: math.unit(20, "mm"),
  286. image: { source: "./media/objects/pebble.svg" },
  287. name: "Grain of gravel",
  288. rename: true
  289. },
  290. sandGrain: {
  291. height: math.unit(0.5, "mm"),
  292. image: { source: "./media/objects/pebble.svg" },
  293. name: "Grain of sand",
  294. rename: true
  295. },
  296. siltGrain: {
  297. height: math.unit(0.03, "mm"),
  298. image: { source: "./media/objects/pebble.svg" },
  299. name: "Grain of silt",
  300. rename: true
  301. },
  302. }
  303. )
  304. });
  305. results.push({
  306. name: "Credit Card",
  307. constructor: () => makeObject(
  308. "Credit Card",
  309. {
  310. creditCard: {
  311. height: math.unit(53.98, "mm"),
  312. image: { source: "./media/objects/credit-card.svg" },
  313. name: "Credit card",
  314. },
  315. creditCardVertical: {
  316. height: math.unit(85.60, "mm"),
  317. image: { source: "./media/objects/credit-card-vertical.svg" },
  318. name: "Credit card (vertical)",
  319. },
  320. }
  321. )
  322. });
  323. results.push({
  324. name: "Molecular",
  325. constructor: () => makeObject(
  326. "Molecular",
  327. {
  328. hydrogen: {
  329. height: math.unit(1.06e-10, "mm"),
  330. mass: math.unit(1, "dalton"),
  331. image: { source: "./media/objects/circle.svg" },
  332. name: "Hydrogen atom",
  333. rename: true
  334. },
  335. proton: {
  336. height: math.unit(1e-15, "mm"),
  337. mass: math.unit(1, "dalton"),
  338. image: { source: "./media/objects/circle.svg" },
  339. name: "Proton",
  340. rename: true
  341. },
  342. }
  343. )
  344. });
  345. results.push(makeShoes());
  346. results.push({
  347. name: "Flagpole",
  348. constructor: () => makeObject(
  349. "Flagpole",
  350. {
  351. residential: {
  352. height: math.unit(20, "feet"),
  353. image: { source: "./media/objects/flagpole.svg" },
  354. name: "Residential"
  355. },
  356. medium: {
  357. height: math.unit(50, "feet"),
  358. image: { source: "./media/objects/flagpole.svg" },
  359. name: "Medium"
  360. },
  361. large: {
  362. height: math.unit(100, "feet"),
  363. image: { source: "./media/objects/flagpole.svg" },
  364. name: "Large"
  365. },
  366. }
  367. )
  368. });
  369. results.push({
  370. name: "Trees",
  371. constructor: () => makeObject(
  372. "Trees",
  373. {
  374. sycamore: {
  375. height: math.unit(35, "meters"),
  376. image: { source: "./media/objects/plants/sycamore-tree.svg" },
  377. name: "Sycamore",
  378. rename: true
  379. }
  380. }
  381. )
  382. })
  383. results.push({
  384. name: "Vending Machine",
  385. constructor: () => makeObject(
  386. "Vending Machine",
  387. {
  388. object: {
  389. height: math.unit(183, "cm"),
  390. mass: math.unit(347, "kg"),
  391. image: { source: "./media/objects/vending-machine.svg" },
  392. name: "Vending Machine"
  393. }
  394. }
  395. )
  396. })
  397. results.push({
  398. name: "International Space Station",
  399. constructor: () => makeObject(
  400. "International Space Station",
  401. {
  402. object: {
  403. height: math.unit(209, "feet"),
  404. mass: math.unit(925300, "lbs"),
  405. image: { source: "./media/objects/international-space-station.svg" },
  406. name: "International Space Station"
  407. }
  408. }
  409. )
  410. })
  411. results.sort((b1, b2) => {
  412. e1 = b1.constructor();
  413. e2 = b2.constructor();
  414. return -math.subtract(e1.views[e1.defaultView].height, e2.views[e2.defaultView].height).value;
  415. });
  416. return results;
  417. }