less copy protection, more size visualization
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

739 lignes
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({
  393. name: "Flagpole",
  394. constructor: () => makeObject(
  395. "Flagpole",
  396. {
  397. residential: {
  398. height: math.unit(20, "feet"),
  399. image: { source: "./media/objects/flagpole.svg" },
  400. name: "Residential"
  401. },
  402. medium: {
  403. height: math.unit(50, "feet"),
  404. image: { source: "./media/objects/flagpole.svg" },
  405. name: "Medium"
  406. },
  407. large: {
  408. height: math.unit(100, "feet"),
  409. image: { source: "./media/objects/flagpole.svg" },
  410. name: "Large"
  411. },
  412. }
  413. )
  414. });
  415. results.push({
  416. name: "Vending Machine",
  417. constructor: () => makeObject(
  418. "Vending Machine",
  419. {
  420. object: {
  421. height: math.unit(183, "cm"),
  422. mass: math.unit(347, "kg"),
  423. image: { source: "./media/objects/vending-machine.svg" },
  424. name: "Vending Machine"
  425. }
  426. }
  427. )
  428. })
  429. results.push({
  430. name: "International Space Station",
  431. constructor: () => makeObject(
  432. "International Space Station",
  433. {
  434. object: {
  435. height: math.unit(209, "feet"),
  436. mass: math.unit(925300, "lbs"),
  437. image: { source: "./media/objects/international-space-station.svg" },
  438. name: "International Space Station"
  439. }
  440. }
  441. )
  442. })
  443. results.push(makeHeight(
  444. [
  445. ["king", 4, "inches"],
  446. ["queen", 351 / 407 * 4, "inches"],
  447. ["bishop", 340 / 407 * 4, "inches"],
  448. ["knight", 309 / 407 * 4, "inches"],
  449. ["rook", 271 / 407 * 4, "inches"],
  450. ["pawn", 197 / 407 * 4, "inches"],
  451. ],
  452. "Chess Pieces",
  453. "chess_"
  454. ));
  455. results.push({
  456. name: "Strand",
  457. constructor: () => {
  458. views = {};
  459. viewInfo = {
  460. opticalFibre: {
  461. name: "Optical Fibre",
  462. thickness: math.unit(0.375, "mm")
  463. },
  464. hair: {
  465. name: "Hair",
  466. thickness: math.unit(0.07, "mm")
  467. },
  468. spiderSilk: {
  469. name: "Spider Silk",
  470. thickness: math.unit(0.003, "mm")
  471. },
  472. suspensionCables: {
  473. name: "Suspension Bridge Cables",
  474. thickness: math.unit(3, "feet")
  475. },
  476. capillary: {
  477. name: "Capillary",
  478. thickness: math.unit(7.5, "micrometers")
  479. },
  480. vein: {
  481. name: "Vein",
  482. thickness: math.unit(10, "mm")
  483. },
  484. thread: {
  485. name: "Thread",
  486. thickness: math.unit(0.4, "mm")
  487. },
  488. powerCord: {
  489. name: "Power Cord",
  490. thickness: math.unit(0.25, "inches")
  491. },
  492. pianoWireBass: {
  493. name: "Piano Wire (Bass)",
  494. thickness: math.unit(8.5, "mm")
  495. },
  496. pianoWireTreble: {
  497. name: "Piano Wire (Treble)",
  498. thickness: math.unit(0.85, "mm")
  499. },
  500. guitarString: {
  501. name: "Guitar String",
  502. thickness: math.unit(0.03, "inches")
  503. },
  504. powerLineThin: {
  505. name: "Power Line (Thin)",
  506. thickness: math.unit(0.325, "inches")
  507. },
  508. powerLineThick: {
  509. name: "Power Line (Thick)",
  510. thickness: math.unit(0.720, "inches")
  511. },
  512. carbonNanotube: {
  513. name: "Carbon Nanotube",
  514. thickness: math.unit(4, "nm")
  515. }
  516. }
  517. Object.entries(viewInfo).forEach(([key, value]) => {
  518. views[key] = {
  519. attributes: {
  520. height: {
  521. name: "Height",
  522. power: 1,
  523. type: "length",
  524. base: math.multiply(value.thickness, 253.4385 / 5)
  525. },
  526. thickness: {
  527. name: "Thickness",
  528. power: 1,
  529. type: "length",
  530. base: value.thickness
  531. },
  532. },
  533. image: {
  534. source: "./media/objects/strand.svg"
  535. },
  536. name: value.name,
  537. rename: true
  538. }
  539. if (value.mass) {
  540. views[key].attributes.mass = {
  541. name: "Mass",
  542. power: 3,
  543. type: "mass",
  544. base: value.mass
  545. };
  546. }
  547. });
  548. return makeEntity({ name: "Strand" }, views);
  549. }
  550. })
  551. results.push(makeHeight(
  552. [
  553. ["mitochondria", 0.5, "micrometer"],
  554. ["bacteria", 0.3, "micrometer"],
  555. ["sperm", 4.65, "micrometers"],
  556. ["red-blood-cell", 6.5, "micrometer"],
  557. ["white-blood-cell", 13, "micrometer"],
  558. ["animal-cell", 25, "micrometers"],
  559. ["plant-cell", 75, "micrometers"],
  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. }