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.
 
 
 

739 lines
23 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. if (value.volume) {
  26. views[key].attributes.capacity = {
  27. name: "Volume",
  28. power: 3,
  29. type: "volume",
  30. base: value.volume
  31. }
  32. }
  33. if (value.energy) {
  34. views[key].attributes.capacity = {
  35. name: "Energy",
  36. power: 3,
  37. type: "energy",
  38. base: value.energy
  39. }
  40. }
  41. });
  42. return makeEntity({ name: name }, views);
  43. }
  44. function makeHeight(info, category, prefix = "", type = "objects", rename = true) {
  45. const views = {};
  46. info.forEach(object => {
  47. let src;
  48. // this lets us provide our own source if needed
  49. // useful for reusing existing art
  50. if (object[3]) {
  51. src = object[3];
  52. } else {
  53. src = "./media/" + type + "/" + category.replace(/ /g, "-").toLowerCase() + "/" + prefix + object[0] + ".svg";
  54. }
  55. views[object[0]] = {
  56. height: math.unit(object[1], object[2]),
  57. image: { source: src },
  58. name: rename ? object[0].replace(/-/g, " ").replace(/\b\w/g, x => x.toUpperCase()).replace(/'[A-Z]/g, x => x.toLowerCase()) : object[0],
  59. rename: true
  60. }
  61. });
  62. return {
  63. name: category,
  64. constructor: () => makeObject(
  65. category,
  66. views
  67. )
  68. }
  69. }
  70. function makeHeightWeight(info, category, prefix = "", type = "objects") {
  71. const views = {};
  72. info.forEach(object => {
  73. let src;
  74. // this lets us provide our own source if needed
  75. // useful for reusing existing art
  76. if (object[5]) {
  77. src = object[5];
  78. } else {
  79. src = "./media/" + type + "/" + category.replace(/ /g, "-").toLowerCase() + "/" + prefix + object[0] + ".svg";
  80. }
  81. views[object[0]] = {
  82. height: math.unit(object[1], object[2]),
  83. mass: math.unit(object[3], object[4]),
  84. image: { source: src },
  85. name: object[0].replace(/-/g, " ").replace(/\b\w/g, x => x.toUpperCase()),
  86. rename: true
  87. }
  88. });
  89. return {
  90. name: category,
  91. constructor: () => makeObject(
  92. category,
  93. views
  94. )
  95. }
  96. }
  97. function makeHeightWeightSphere(info, category, prefix = "", type = "objects") {
  98. const views = {};
  99. info.forEach(object => {
  100. let src;
  101. // this lets us provide our own source if needed
  102. // useful for reusing existing art
  103. if (object[5]) {
  104. src = object[5];
  105. } else {
  106. src = "./media/" + type + "/" + category.replace(/ /g, "-").toLowerCase() + "/" + prefix + object[0] + ".svg";
  107. }
  108. views[object[0]] = {
  109. height: math.unit(object[1], object[2]),
  110. mass: math.unit(object[3], object[4]),
  111. volume: math.unit(Math.PI * 4 / 3 * Math.pow((object[1]/2), 3), object[2] + "^3"),
  112. image: { source: src },
  113. name: object[0].replace(/-/g, " ").replace(/\b\w/g, x => x.toUpperCase()),
  114. rename: true
  115. }
  116. if (object[6]) {
  117. views[object[0]].image.extra = object[6]
  118. views[object[0]].image.bottom = object[7]
  119. }
  120. });
  121. return {
  122. name: category,
  123. constructor: () => makeObject(
  124. category,
  125. views
  126. )
  127. }
  128. }
  129. function makeObjects() {
  130. const results = [];
  131. results.push({
  132. name: "Soda Can",
  133. constructor: () => makeObject(
  134. "Soda Can",
  135. {
  136. front: {
  137. height: math.unit(4.83, "inches"),
  138. mass: math.unit(15, "grams"),
  139. image: { source: "./media/objects/soda-can.svg" },
  140. name: "Side"
  141. }
  142. }
  143. )
  144. });
  145. results.push({
  146. name: "Sewing Pin",
  147. constructor: () => makeObject(
  148. "Sewing Pin",
  149. {
  150. side: {
  151. height: math.unit(1.5, "inches"),
  152. image: { source: "./media/objects/sewing-pin.svg" },
  153. name: "Side"
  154. },
  155. top: {
  156. height: math.unit(2, "millimeters"),
  157. image: { source: "./media/objects/pin-head.svg" },
  158. name: "Head"
  159. }
  160. }
  161. )
  162. });
  163. results.push({
  164. name: "Lamp",
  165. constructor: () => makeObject(
  166. "Lamp",
  167. {
  168. lamp: {
  169. height: math.unit(30, "inches"),
  170. mass: math.unit(10, "lbs"),
  171. image: { source: "./media/objects/lamp.svg" },
  172. name: "Lamp"
  173. }
  174. }
  175. )
  176. });
  177. results.push({
  178. name: "Nail Polish",
  179. constructor: () => makeObject(
  180. "Nail Polish",
  181. {
  182. bottle: {
  183. height: math.unit(3.25, "inches"),
  184. mass: math.unit(66, "g"),
  185. image: { source: "./media/objects/nail-polish.svg" },
  186. name: "Bottle"
  187. }
  188. }
  189. )
  190. });
  191. results.push({
  192. name: "Shot Glass",
  193. constructor: () => makeObject(
  194. "Shot Glass",
  195. {
  196. glass: {
  197. height: math.unit(2 + 3 / 8, "inches"),
  198. mass: math.unit(75, "g"),
  199. image: { source: "./media/objects/shot-glass.svg" },
  200. name: "Bottle"
  201. }
  202. }
  203. )
  204. });
  205. results.push({
  206. name: "Beer Bottle",
  207. constructor: () => makeObject(
  208. "Beer Bottle",
  209. {
  210. longneck: {
  211. height: math.unit(9, "inches"),
  212. mass: math.unit(200, "g"),
  213. image: { source: "./media/objects/beer-bottle.svg" },
  214. name: "Longneck Bottle"
  215. }
  216. }
  217. )
  218. });
  219. results.push({
  220. name: "Coin",
  221. constructor: () => makeObject(
  222. "Coin",
  223. {
  224. penny: {
  225. height: math.unit(0.75, "inches"),
  226. mass: math.unit(2.5, "g"),
  227. image: { source: "./media/objects/circle.svg" },
  228. name: "Penny",
  229. rename: true
  230. },
  231. nickel: {
  232. height: math.unit(0.835, "inches"),
  233. mass: math.unit(5, "g"),
  234. image: { source: "./media/objects/circle.svg" },
  235. name: "Nickel",
  236. rename: true
  237. },
  238. dime: {
  239. height: math.unit(0.705, "inches"),
  240. mass: math.unit(2.268, "g"),
  241. image: { source: "./media/objects/circle.svg" },
  242. name: "Dime",
  243. rename: true
  244. },
  245. quarter: {
  246. height: math.unit(0.955, "inches"),
  247. mass: math.unit(5.67, "g"),
  248. image: { source: "./media/objects/circle.svg" },
  249. name: "Quarter",
  250. rename: true
  251. },
  252. dollar: {
  253. height: math.unit(1.043, "inches"),
  254. mass: math.unit(8.1, "g"),
  255. image: { source: "./media/objects/circle.svg" },
  256. name: "Dollar Coin",
  257. rename: true
  258. },
  259. }
  260. )
  261. });
  262. results.push({
  263. name: "Pencil",
  264. constructor: () => makeObject(
  265. "Pencil",
  266. {
  267. pencil: {
  268. height: math.unit(7.5, "inches"),
  269. mass: math.unit(7, "g"),
  270. image: { source: "./media/objects/pencil.svg" },
  271. name: "Pencil"
  272. }
  273. }
  274. )
  275. });
  276. results.push({
  277. name: "Balls",
  278. constructor: () => makeObject(
  279. "Balls",
  280. {
  281. golf: {
  282. height: math.unit(1.62, "inches"),
  283. mass: math.unit(45, "g"),
  284. image: { source: "./media/objects/circle.svg" },
  285. name: "Golfball",
  286. rename: true
  287. },
  288. tennis: {
  289. height: math.unit(2.6, "inches"),
  290. mass: math.unit(57, "g"),
  291. image: { source: "./media/objects/circle.svg" },
  292. name: "Tennisball",
  293. rename: true
  294. },
  295. baseball: {
  296. height: math.unit(2.9, "inches"),
  297. mass: math.unit(145, "g"),
  298. image: { source: "./media/objects/circle.svg" },
  299. name: "Baseball",
  300. rename: true
  301. },
  302. volleyball: {
  303. height: math.unit(8, "inches"),
  304. mass: math.unit(270, "g"),
  305. image: { source: "./media/objects/circle.svg" },
  306. name: "Volleyball",
  307. rename: true
  308. }
  309. }
  310. )
  311. });
  312. results.push({
  313. name: "Paperclip",
  314. constructor: () => makeObject(
  315. "Paperclip",
  316. {
  317. paperclip: {
  318. height: math.unit(1.834, "inches"),
  319. mass: math.unit(1, "g"),
  320. image: { source: "./media/objects/paperclip.svg" },
  321. name: "Paperclip"
  322. }
  323. }
  324. )
  325. });
  326. results.push({
  327. name: "Pebbles",
  328. constructor: () => makeObject(
  329. "Pebbles",
  330. {
  331. gravelGrain: {
  332. height: math.unit(20, "mm"),
  333. image: { source: "./media/objects/pebble.svg" },
  334. name: "Grain of gravel",
  335. rename: true
  336. },
  337. sandGrain: {
  338. height: math.unit(0.5, "mm"),
  339. image: { source: "./media/objects/pebble.svg" },
  340. name: "Grain of sand",
  341. rename: true
  342. },
  343. siltGrain: {
  344. height: math.unit(0.03, "mm"),
  345. image: { source: "./media/objects/pebble.svg" },
  346. name: "Grain of silt",
  347. rename: true
  348. },
  349. }
  350. )
  351. });
  352. results.push({
  353. name: "Credit Card",
  354. constructor: () => makeObject(
  355. "Credit Card",
  356. {
  357. creditCard: {
  358. height: math.unit(53.98, "mm"),
  359. image: { source: "./media/objects/credit-card.svg" },
  360. name: "Credit card",
  361. },
  362. creditCardVertical: {
  363. height: math.unit(85.60, "mm"),
  364. image: { source: "./media/objects/credit-card-vertical.svg" },
  365. name: "Credit card (vertical)",
  366. },
  367. }
  368. )
  369. });
  370. results.push({
  371. name: "Molecular",
  372. constructor: () => makeObject(
  373. "Molecular",
  374. {
  375. hydrogen: {
  376. height: math.unit(1.06e-10, "m"),
  377. mass: math.unit(1, "dalton"),
  378. image: { source: "./media/objects/circle.svg" },
  379. name: "Hydrogen atom",
  380. rename: true
  381. },
  382. proton: {
  383. height: math.unit(0.877e-15, "m"),
  384. mass: math.unit(1, "dalton"),
  385. image: { source: "./media/objects/circle.svg" },
  386. name: "Proton",
  387. rename: true
  388. },
  389. }
  390. )
  391. });
  392. results.push(makeShoes());
  393. results.push({
  394. name: "Flagpole",
  395. constructor: () => makeObject(
  396. "Flagpole",
  397. {
  398. residential: {
  399. height: math.unit(20, "feet"),
  400. image: { source: "./media/objects/flagpole.svg" },
  401. name: "Residential"
  402. },
  403. medium: {
  404. height: math.unit(50, "feet"),
  405. image: { source: "./media/objects/flagpole.svg" },
  406. name: "Medium"
  407. },
  408. large: {
  409. height: math.unit(100, "feet"),
  410. image: { source: "./media/objects/flagpole.svg" },
  411. name: "Large"
  412. },
  413. }
  414. )
  415. });
  416. results.push({
  417. name: "Vending Machine",
  418. constructor: () => makeObject(
  419. "Vending Machine",
  420. {
  421. object: {
  422. height: math.unit(183, "cm"),
  423. mass: math.unit(347, "kg"),
  424. image: { source: "./media/objects/vending-machine.svg" },
  425. name: "Vending Machine"
  426. }
  427. }
  428. )
  429. })
  430. results.push({
  431. name: "International Space Station",
  432. constructor: () => makeObject(
  433. "International Space Station",
  434. {
  435. object: {
  436. height: math.unit(209, "feet"),
  437. mass: math.unit(925300, "lbs"),
  438. image: { source: "./media/objects/international-space-station.svg" },
  439. name: "International Space Station"
  440. }
  441. }
  442. )
  443. })
  444. results.push(makeHeight(
  445. [
  446. ["king", 4, "inches"],
  447. ["queen", 351 / 407 * 4, "inches"],
  448. ["bishop", 340 / 407 * 4, "inches"],
  449. ["knight", 309 / 407 * 4, "inches"],
  450. ["rook", 271 / 407 * 4, "inches"],
  451. ["pawn", 197 / 407 * 4, "inches"],
  452. ],
  453. "Chess Pieces",
  454. "chess_"
  455. ));
  456. results.push({
  457. name: "Strand",
  458. constructor: () => {
  459. views = {};
  460. viewInfo = {
  461. opticalFibre: {
  462. name: "Optical Fibre",
  463. thickness: math.unit(0.375, "mm")
  464. },
  465. hair: {
  466. name: "Hair",
  467. thickness: math.unit(0.07, "mm")
  468. },
  469. spiderSilk: {
  470. name: "Spider Silk",
  471. thickness: math.unit(0.003, "mm")
  472. },
  473. suspensionCables: {
  474. name: "Suspension Bridge Cables",
  475. thickness: math.unit(3, "feet")
  476. },
  477. capillary: {
  478. name: "Capillary",
  479. thickness: math.unit(7.5, "micrometers")
  480. },
  481. vein: {
  482. name: "Vein",
  483. thickness: math.unit(10, "mm")
  484. },
  485. thread: {
  486. name: "Thread",
  487. thickness: math.unit(0.4, "mm")
  488. },
  489. powerCord: {
  490. name: "Power Cord",
  491. thickness: math.unit(0.25, "inches")
  492. },
  493. pianoWireBass: {
  494. name: "Piano Wire (Bass)",
  495. thickness: math.unit(8.5, "mm")
  496. },
  497. pianoWireTreble: {
  498. name: "Piano Wire (Treble)",
  499. thickness: math.unit(0.85, "mm")
  500. },
  501. guitarString: {
  502. name: "Guitar String",
  503. thickness: math.unit(0.03, "inches")
  504. },
  505. powerLineThin: {
  506. name: "Power Line (Thin)",
  507. thickness: math.unit(0.325, "inches")
  508. },
  509. powerLineThick: {
  510. name: "Power Line (Thick)",
  511. thickness: math.unit(0.720, "inches")
  512. },
  513. carbonNanotube: {
  514. name: "Carbon Nanotube",
  515. thickness: math.unit(4, "nm")
  516. }
  517. }
  518. Object.entries(viewInfo).forEach(([key, value]) => {
  519. views[key] = {
  520. attributes: {
  521. height: {
  522. name: "Height",
  523. power: 1,
  524. type: "length",
  525. base: math.multiply(value.thickness, 253.4385 / 5)
  526. },
  527. thickness: {
  528. name: "Thickness",
  529. power: 1,
  530. type: "length",
  531. base: value.thickness
  532. },
  533. },
  534. image: {
  535. source: "./media/objects/strand.svg"
  536. },
  537. name: value.name,
  538. rename: true
  539. }
  540. if (value.mass) {
  541. views[key].attributes.mass = {
  542. name: "Mass",
  543. power: 3,
  544. type: "mass",
  545. base: value.mass
  546. };
  547. }
  548. });
  549. return makeEntity({ name: "Strand" }, views);
  550. }
  551. })
  552. results.push(makeHeight(
  553. [
  554. ["animal-cell", 25, "micrometers"],
  555. ["plant-cell", 75, "micrometers"],
  556. ["mitochondria", 0.5, "micrometer"],
  557. ["bacteria", 0.3, "micrometer"],
  558. ["red-blood-cell", 6.5, "micrometer"],
  559. ["white-blood-cell", 13, "micrometer"],
  560. ["amoeba-proteus", 500, "micrometers"],
  561. ["chaos-carolinensis", 1500, "micrometers"]
  562. ],
  563. "Cells",
  564. "cell_"
  565. ))
  566. results.push(makeHeight(
  567. [
  568. ["stop-sign", 36, "inches"],
  569. ["yield-sign", 36, "inches"],
  570. ["pedestrian-crossing", 30, "inches"],
  571. ["highway-exit", 150, "inches"]
  572. ],
  573. "Signs",
  574. ""
  575. ))
  576. results.push({
  577. name: "Game Consoles",
  578. constructor: () => makeVehicleGroup([
  579. {
  580. name: "Switch",
  581. mass: math.unit(10.48, "ounces"),
  582. sides: {
  583. "Front": { height: math.unit(4.01, "inches") },
  584. "Top": { height: math.unit(1.13, "inches") },
  585. "Side": { height: math.unit(4.01, "inches") },
  586. }
  587. }
  588. ],
  589. "Game Consoles",
  590. "",
  591. "objects")
  592. })
  593. results.push({
  594. name: "Electromagnetic Waves",
  595. constructor: () => {
  596. views = {};
  597. viewInfo = [
  598. ["Gamma rays", math.unit(1, "pm")],
  599. ["Hard X-rays", math.unit(20, "pm")],
  600. ["Soft X-rays", math.unit(1, "nm")],
  601. ["Extreme-ultraviolet", math.unit(50, "nm")],
  602. ["UVC", math.unit(200, "nm")],
  603. ["UVB", math.unit(295, "nm")],
  604. ["UVA", math.unit(350, "nm")],
  605. ["Violet", math.unit(415, "nm")],
  606. ["Blue", math.unit(470, "nm")],
  607. ["Cyan", math.unit(490, "nm")],
  608. ["Green", math.unit(530, "nm")],
  609. ["Yellow", math.unit(580, "nm")],
  610. ["Orange", math.unit(610, "nm")],
  611. ["Red", math.unit(690, "nm")],
  612. ["Near-infrared", math.unit(1.2, "um")],
  613. ["Short-wavelength infrared", math.unit(2.2, "um")],
  614. ["Mid-wavelength infrared", math.unit(6.5, "um")],
  615. ["Long-wavelength infrared", math.unit(12, "um")],
  616. ["Far infrared", math.unit(500, "um")],
  617. ["D-band microwaves (mm-wave)", math.unit(2, "mm")],
  618. ["S-band microwaves (ovens, wifi)", math.unit(11, "cm")],
  619. ["L-band microwaves (GPS)", math.unit(22, "cm")],
  620. ["UHF", math.unit(50, "cm")],
  621. ["FM radio", math.unit(3.5, "m")],
  622. ["VHF", math.unit(5, "m")],
  623. ["HF", math.unit(50, "m")],
  624. ["AM radio", math.unit(250, "m")],
  625. ["MF", math.unit(500, "m")],
  626. ["LF", math.unit(5, "km")],
  627. ["VLF", math.unit(50, "km")],
  628. ["ULF", math.unit(500, "km")],
  629. ["SLF", math.unit(5000, "km")],
  630. ["ELF", math.unit(50000, "km")],
  631. ]
  632. viewInfo.forEach(([name, length]) => {
  633. views[name] = {
  634. attributes: {
  635. height: {
  636. name: "Height",
  637. power: 1,
  638. type: "length",
  639. base: math.multiply(length, 2)
  640. }
  641. },
  642. image: {
  643. source: "./media/objects/sine-wave.svg"
  644. },
  645. name: name,
  646. rename: true,
  647. default: name === "Green"
  648. }
  649. });
  650. return makeEntity({ name: "Electromagnetic Waves" }, views);
  651. }
  652. })
  653. results.push(makeHeight(
  654. [
  655. [".308 Winchester", 71.374, "mm", "./media/objects/ammunition/.308 Winchester.svg"],
  656. [".22 LR", 25.40, "mm", "./media/objects/ammunition/.22 LR.svg"],
  657. ["9mm Luger", 29.69, "mm", "./media/objects/ammunition/9mm Luger.svg"],
  658. [".223 Remington", 2.260, "inches", "./media/objects/ammunition/.223 Remington.svg"],
  659. [".30-06 Springfield", 3.340, "inches", "./media/objects/ammunition/.30-06 Springfield.svg"],
  660. ],
  661. "Ammunition",
  662. "",
  663. "objects",
  664. false
  665. ))
  666. results.push(makeHeight(
  667. [
  668. ["No. 1 (11 Oz.)", 4, "inches", "./media/objects/tin-cans/No. 1 (11 Oz.).svg"],
  669. ["No. 2 (20 Oz.)", 4 + 9/16, "inches", "./media/objects/tin-cans/No. 2 (20 Oz.).svg"],
  670. ["No. 3 (52 Oz.)", 7, "inches", "./media/objects/tin-cans/No. 3 (52 Oz.).svg"],
  671. ["No. 5 (60 Oz.)", 5 + 5/8, "inches", "./media/objects/tin-cans/No. 5 (60 Oz.).svg"],
  672. ["No. 10 (110 Oz.)", 7, "inches", "./media/objects/tin-cans/No. 10 (110 Oz.).svg"],
  673. ],
  674. "Tin Cans",
  675. ""
  676. ))
  677. results.sort((b1, b2) => {
  678. e1 = b1.constructor();
  679. e2 = b2.constructor();
  680. return -math.subtract(e1.views[e1.defaultView].height, e2.views[e2.defaultView].height).value;
  681. });
  682. return results;
  683. }