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.
 
 
 

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