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.
 
 
 

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