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.
 
 
 

599 lines
18 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. math.createUnit("solarradii", {
  10. definition: "695990 km",
  11. prefixes: "long"
  12. });
  13. function makeObject(name, viewInfo) {
  14. views = {};
  15. Object.entries(viewInfo).forEach(([key, value]) => {
  16. views[key] = {
  17. attributes: {
  18. height: {
  19. name: "Height",
  20. power: 1,
  21. type: "length",
  22. base: value.height
  23. }
  24. },
  25. image: value.image,
  26. name: value.name,
  27. rename: value.rename
  28. }
  29. if (value.mass) {
  30. views[key].attributes.mass = {
  31. name: "Mass",
  32. power: 3,
  33. type: "mass",
  34. base: value.mass
  35. };
  36. }
  37. });
  38. return makeEntity({ name: name }, views);
  39. }
  40. SHOE_REFERENCE = 60
  41. function addShoeView(object, name, points) {
  42. object[name] = {
  43. height: math.unit(points / SHOE_REFERENCE, "inches"),
  44. image: { source: "./media/objects/shoes/shoe_" + name + ".svg" },
  45. name: name.replace(/-/g, " ").replace(/\b\w/g, x => x.toUpperCase()),
  46. rename: true
  47. }
  48. }
  49. function makeHeight(info, category, prefix="", type="objects") {
  50. const views = {};
  51. info.forEach(object => {
  52. views[object[0]] = {
  53. height: math.unit(object[1], object[2]),
  54. image: { source: "./media/" + type + "/" + category.replace(/ /g, "-").toLowerCase() + "/" + prefix + object[0] + ".svg" },
  55. name: object[0].replace(/-/g, " ").replace(/\b\w/g, x => x.toUpperCase()),
  56. rename: true
  57. }
  58. });
  59. return {
  60. name: category,
  61. constructor: () => makeObject(
  62. category,
  63. views
  64. )
  65. }
  66. }
  67. function makeHeightWeight(info, category, prefix="", type="objects") {
  68. const views = {};
  69. info.forEach(object => {
  70. let src;
  71. // this lets us provide our own source if needed
  72. // useful for reusing existing art
  73. if (object[5]) {
  74. src = object[5];
  75. } else {
  76. src = "./media/" + type + "/" + category.replace(/ /g, "-").toLowerCase() + "/" + prefix + object[0] + ".svg";
  77. }
  78. views[object[0]] = {
  79. height: math.unit(object[1], object[2]),
  80. mass: math.unit(object[3], object[4]),
  81. image: { source: src },
  82. name: object[0].replace(/-/g, " ").replace(/\b\w/g, x => x.toUpperCase()),
  83. rename: true
  84. }
  85. });
  86. return {
  87. name: category,
  88. constructor: () => makeObject(
  89. category,
  90. views
  91. )
  92. }
  93. }
  94. function makeShoes() {
  95. const views = {};
  96. [
  97. ["flip-flops", 154.239],
  98. ["knee-boots", 841.827],
  99. ["trainers", 260.607],
  100. ["stilettos", 418.839]
  101. ].forEach(shoe => {
  102. addShoeView(views, shoe[0], shoe[1])
  103. });
  104. return {
  105. name: "Shoes",
  106. constructor: () => makeObject(
  107. "Shoes",
  108. views
  109. )
  110. }
  111. }
  112. function makeObjects() {
  113. const results = [];
  114. results.push({
  115. name: "Soda Can",
  116. constructor: () => makeObject(
  117. "Soda Can",
  118. {
  119. front: {
  120. height: math.unit(4.83, "inches"),
  121. mass: math.unit(15, "grams"),
  122. image: { source: "./media/objects/soda-can.svg" },
  123. name: "Side"
  124. }
  125. }
  126. )
  127. });
  128. results.push({
  129. name: "Sewing Pin",
  130. constructor: () => makeObject(
  131. "Sewing Pin",
  132. {
  133. side: {
  134. height: math.unit(1.5, "inches"),
  135. image: { source: "./media/objects/sewing-pin.svg" },
  136. name: "Side"
  137. },
  138. top: {
  139. height: math.unit(2, "millimeters"),
  140. image: { source: "./media/objects/pin-head.svg" },
  141. name: "Head"
  142. }
  143. }
  144. )
  145. });
  146. results.push({
  147. name: "Lamp",
  148. constructor: () => makeObject(
  149. "Lamp",
  150. {
  151. lamp: {
  152. height: math.unit(30, "inches"),
  153. mass: math.unit(10, "lbs"),
  154. image: { source: "./media/objects/lamp.svg" },
  155. name: "Lamp"
  156. }
  157. }
  158. )
  159. });
  160. results.push({
  161. name: "Nail Polish",
  162. constructor: () => makeObject(
  163. "Nail Polish",
  164. {
  165. bottle: {
  166. height: math.unit(3.25, "inches"),
  167. mass: math.unit(66, "g"),
  168. image: { source: "./media/objects/nail-polish.svg" },
  169. name: "Bottle"
  170. }
  171. }
  172. )
  173. });
  174. results.push({
  175. name: "Shot Glass",
  176. constructor: () => makeObject(
  177. "Shot Glass",
  178. {
  179. glass: {
  180. height: math.unit(2 + 3/8, "inches"),
  181. mass: math.unit(75, "g"),
  182. image: { source: "./media/objects/shot-glass.svg" },
  183. name: "Bottle"
  184. }
  185. }
  186. )
  187. });
  188. results.push({
  189. name: "Beer Bottle",
  190. constructor: () => makeObject(
  191. "Beer Bottle",
  192. {
  193. longneck: {
  194. height: math.unit(9, "inches"),
  195. mass: math.unit(200, "g"),
  196. image: { source: "./media/objects/beer-bottle.svg" },
  197. name: "Longneck Bottle"
  198. }
  199. }
  200. )
  201. });
  202. results.push({
  203. name: "Coin",
  204. constructor: () => makeObject(
  205. "Coin",
  206. {
  207. penny: {
  208. height: math.unit(0.75, "inches"),
  209. mass: math.unit(2.5, "g"),
  210. image: { source: "./media/objects/circle.svg" },
  211. name: "Penny",
  212. rename: true
  213. },
  214. nickel: {
  215. height: math.unit(0.835, "inches"),
  216. mass: math.unit(5, "g"),
  217. image: { source: "./media/objects/circle.svg" },
  218. name: "Nickel",
  219. rename: true
  220. },
  221. dime: {
  222. height: math.unit(0.705, "inches"),
  223. mass: math.unit(2.268, "g"),
  224. image: { source: "./media/objects/circle.svg" },
  225. name: "Dime",
  226. rename: true
  227. },
  228. quarter: {
  229. height: math.unit(0.955, "inches"),
  230. mass: math.unit(5.67, "g"),
  231. image: { source: "./media/objects/circle.svg" },
  232. name: "Quarter",
  233. rename: true
  234. },
  235. dollar: {
  236. height: math.unit(1.043, "inches"),
  237. mass: math.unit(8.1, "g"),
  238. image: { source: "./media/objects/circle.svg" },
  239. name: "Dollar Coin",
  240. rename: true
  241. },
  242. }
  243. )
  244. });
  245. results.push({
  246. name: "Pencil",
  247. constructor: () => makeObject(
  248. "Pencil",
  249. {
  250. pencil: {
  251. height: math.unit(7.5, "inches"),
  252. mass: math.unit(7, "g"),
  253. image: { source: "./media/objects/pencil.svg" },
  254. name: "Pencil"
  255. }
  256. }
  257. )
  258. });
  259. results.push({
  260. name: "Balls",
  261. constructor: () => makeObject(
  262. "Balls",
  263. {
  264. golf: {
  265. height: math.unit(1.62, "inches"),
  266. mass: math.unit(45, "g"),
  267. image: { source: "./media/objects/circle.svg" },
  268. name: "Golfball",
  269. rename: true
  270. },
  271. tennis: {
  272. height: math.unit(2.6, "inches"),
  273. mass: math.unit(57, "g"),
  274. image: { source: "./media/objects/circle.svg" },
  275. name: "Tennisball",
  276. rename: true
  277. },
  278. baseball: {
  279. height: math.unit(2.9, "inches"),
  280. mass: math.unit(145, "g"),
  281. image: { source: "./media/objects/circle.svg" },
  282. name: "Baseball",
  283. rename: true
  284. },
  285. volleyball: {
  286. height: math.unit(8, "inches"),
  287. mass: math.unit(270, "g"),
  288. image: { source: "./media/objects/circle.svg" },
  289. name: "Volleyball",
  290. rename: true
  291. }
  292. }
  293. )
  294. });
  295. results.push({
  296. name: "Paperclip",
  297. constructor: () => makeObject(
  298. "Paperclip",
  299. {
  300. paperclip: {
  301. height: math.unit(1.834, "inches"),
  302. mass: math.unit(1, "g"),
  303. image: { source: "./media/objects/paperclip.svg" },
  304. name: "Paperclip"
  305. }
  306. }
  307. )
  308. });
  309. results.push({
  310. name: "Pebbles",
  311. constructor: () => makeObject(
  312. "Pebbles",
  313. {
  314. gravelGrain: {
  315. height: math.unit(20, "mm"),
  316. image: { source: "./media/objects/pebble.svg" },
  317. name: "Grain of gravel",
  318. rename: true
  319. },
  320. sandGrain: {
  321. height: math.unit(0.5, "mm"),
  322. image: { source: "./media/objects/pebble.svg" },
  323. name: "Grain of sand",
  324. rename: true
  325. },
  326. siltGrain: {
  327. height: math.unit(0.03, "mm"),
  328. image: { source: "./media/objects/pebble.svg" },
  329. name: "Grain of silt",
  330. rename: true
  331. },
  332. }
  333. )
  334. });
  335. results.push({
  336. name: "Credit Card",
  337. constructor: () => makeObject(
  338. "Credit Card",
  339. {
  340. creditCard: {
  341. height: math.unit(53.98, "mm"),
  342. image: { source: "./media/objects/credit-card.svg" },
  343. name: "Credit card",
  344. },
  345. creditCardVertical: {
  346. height: math.unit(85.60, "mm"),
  347. image: { source: "./media/objects/credit-card-vertical.svg" },
  348. name: "Credit card (vertical)",
  349. },
  350. }
  351. )
  352. });
  353. results.push({
  354. name: "Molecular",
  355. constructor: () => makeObject(
  356. "Molecular",
  357. {
  358. hydrogen: {
  359. height: math.unit(1.06e-10, "mm"),
  360. mass: math.unit(1, "dalton"),
  361. image: { source: "./media/objects/circle.svg" },
  362. name: "Hydrogen atom",
  363. rename: true
  364. },
  365. proton: {
  366. height: math.unit(1e-15, "mm"),
  367. mass: math.unit(1, "dalton"),
  368. image: { source: "./media/objects/circle.svg" },
  369. name: "Proton",
  370. rename: true
  371. },
  372. }
  373. )
  374. });
  375. results.push(makeShoes());
  376. results.push({
  377. name: "Flagpole",
  378. constructor: () => makeObject(
  379. "Flagpole",
  380. {
  381. residential: {
  382. height: math.unit(20, "feet"),
  383. image: { source: "./media/objects/flagpole.svg" },
  384. name: "Residential"
  385. },
  386. medium: {
  387. height: math.unit(50, "feet"),
  388. image: { source: "./media/objects/flagpole.svg" },
  389. name: "Medium"
  390. },
  391. large: {
  392. height: math.unit(100, "feet"),
  393. image: { source: "./media/objects/flagpole.svg" },
  394. name: "Large"
  395. },
  396. }
  397. )
  398. });
  399. results.push({
  400. name: "Vending Machine",
  401. constructor: () => makeObject(
  402. "Vending Machine",
  403. {
  404. object: {
  405. height: math.unit(183, "cm"),
  406. mass: math.unit(347, "kg"),
  407. image: { source: "./media/objects/vending-machine.svg" },
  408. name: "Vending Machine"
  409. }
  410. }
  411. )
  412. })
  413. results.push({
  414. name: "International Space Station",
  415. constructor: () => makeObject(
  416. "International Space Station",
  417. {
  418. object: {
  419. height: math.unit(209, "feet"),
  420. mass: math.unit(925300, "lbs"),
  421. image: { source: "./media/objects/international-space-station.svg" },
  422. name: "International Space Station"
  423. }
  424. }
  425. )
  426. })
  427. results.push(makeHeight(
  428. [
  429. ["king", 4, "inches"],
  430. ["queen", 351/407*4, "inches"],
  431. ["bishop", 340/407*4, "inches"],
  432. ["knight", 309/407*4, "inches"],
  433. ["rook", 271/407*4, "inches"],
  434. ["pawn", 197/407*4, "inches"],
  435. ],
  436. "Chess Pieces",
  437. "chess_"
  438. ));
  439. results.push({
  440. name: "Strand",
  441. constructor: () => {
  442. views = {};
  443. viewInfo = {
  444. opticalFibre: {
  445. name: "Optical Fibre",
  446. thickness: math.unit(0.375, "mm")
  447. },
  448. hair: {
  449. name: "Hair",
  450. thickness: math.unit(0.07, "mm")
  451. },
  452. spiderSilk: {
  453. name: "Spider Silk",
  454. thickness: math.unit(0.003, "mm")
  455. },
  456. suspensionCables: {
  457. name: "Suspension Bridge Cables",
  458. thickness: math.unit(3, "feet")
  459. },
  460. capillary: {
  461. name: "Capillary",
  462. thickness: math.unit(7.5, "micrometers")
  463. },
  464. vein: {
  465. name: "Vein",
  466. thickness: math.unit(10, "mm")
  467. },
  468. thread: {
  469. name: "Thread",
  470. thickness: math.unit(0.4, "mm")
  471. },
  472. powerCord: {
  473. name: "Power Cord",
  474. thickness: math.unit(0.25, "inches")
  475. },
  476. pianoWireBass: {
  477. name: "Piano Wire (Bass)",
  478. thickness: math.unit(8.5, "mm")
  479. },
  480. pianoWireTreble: {
  481. name: "Piano Wire (Treble)",
  482. thickness: math.unit(0.85, "mm")
  483. },
  484. guitarString: {
  485. name: "Guitar String",
  486. thickness: math.unit(0.03, "inches")
  487. },
  488. powerLineThin: {
  489. name: "Power Line (Thin)",
  490. thickness: math.unit(0.325, "inches")
  491. },
  492. powerLineThick: {
  493. name: "Power Line (Thick)",
  494. thickness: math.unit(0.720, "inches")
  495. },
  496. carbonNanotube: {
  497. name: "Carbon Nanotube",
  498. thickness: math.unit(4, "nm")
  499. }
  500. }
  501. Object.entries(viewInfo).forEach(([key, value]) => {
  502. views[key] = {
  503. attributes: {
  504. height: {
  505. name: "Height",
  506. power: 1,
  507. type: "length",
  508. base: math.multiply(value.thickness, 253.4385 / 5)
  509. },
  510. thickness: {
  511. name: "Thickness",
  512. power: 1,
  513. type: "length",
  514. base: value.thickness
  515. },
  516. },
  517. image: {
  518. source: "./media/objects/strand.svg"
  519. },
  520. name: value.name,
  521. rename: true
  522. }
  523. if (value.mass) {
  524. views[key].attributes.mass = {
  525. name: "Mass",
  526. power: 3,
  527. type: "mass",
  528. base: value.mass
  529. };
  530. }
  531. });
  532. return makeEntity({ name: "Strand" }, views);
  533. }
  534. })
  535. results.push(makeHeight(
  536. [
  537. ["animal-cell", 25, "micrometers"],
  538. ["plant-cell", 75, "micrometers"],
  539. ["mitochondria", 0.5, "micrometer"],
  540. ["bacteria", 0.3, "micrometer"],
  541. ["red-blood-cell", 6.5, "micrometer"],
  542. ["white-blood-cell", 13, "micrometer"],
  543. ["amoeba-proteus", 500, "micrometers"],
  544. ["chaos-carolinensis", 1500, "micrometers"]
  545. ],
  546. "Cells",
  547. "cell_"
  548. ))
  549. results.sort((b1, b2) => {
  550. e1 = b1.constructor();
  551. e2 = b2.constructor();
  552. return -math.subtract(e1.views[e1.defaultView].height, e2.views[e2.defaultView].height).value;
  553. });
  554. return results;
  555. }