less copy protection, more size visualization
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

790 строки
24 KiB

  1. function makeObject(name, viewInfo, sizes = []) {
  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, sizes);
  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. football: {
  282. height: math.unit("6.7", "inches"),
  283. mass: math.unit(415, "grams"),
  284. image: { source: "./media/objects/balls/football.svg"},
  285. name: "Football",
  286. rename: true
  287. },
  288. golf: {
  289. height: math.unit(1.62, "inches"),
  290. mass: math.unit(45, "g"),
  291. image: { source: "./media/objects/circle.svg" },
  292. name: "Golfball",
  293. rename: true
  294. },
  295. tennis: {
  296. height: math.unit(2.6, "inches"),
  297. mass: math.unit(57, "g"),
  298. image: { source: "./media/objects/circle.svg" },
  299. name: "Tennisball",
  300. rename: true
  301. },
  302. baseball: {
  303. height: math.unit(2.9, "inches"),
  304. mass: math.unit(145, "g"),
  305. image: { source: "./media/objects/circle.svg" },
  306. name: "Baseball",
  307. rename: true
  308. },
  309. volleyball: {
  310. height: math.unit(8, "inches"),
  311. mass: math.unit(270, "g"),
  312. image: { source: "./media/objects/circle.svg" },
  313. name: "Volleyball",
  314. rename: true
  315. }
  316. }
  317. )
  318. });
  319. results.push({
  320. name: "Paperclip",
  321. constructor: () => makeObject(
  322. "Paperclip",
  323. {
  324. paperclip: {
  325. height: math.unit(1.834, "inches"),
  326. mass: math.unit(1, "g"),
  327. image: { source: "./media/objects/paperclip.svg" },
  328. name: "Paperclip"
  329. }
  330. }
  331. )
  332. });
  333. results.push({
  334. name: "Pebbles",
  335. constructor: () => makeObject(
  336. "Pebbles",
  337. {
  338. gravelGrain: {
  339. height: math.unit(20, "mm"),
  340. image: { source: "./media/objects/pebble.svg" },
  341. name: "Grain of gravel",
  342. rename: true
  343. },
  344. sandGrain: {
  345. height: math.unit(0.5, "mm"),
  346. image: { source: "./media/objects/pebble.svg" },
  347. name: "Grain of sand",
  348. rename: true
  349. },
  350. siltGrain: {
  351. height: math.unit(0.03, "mm"),
  352. image: { source: "./media/objects/pebble.svg" },
  353. name: "Grain of silt",
  354. rename: true
  355. },
  356. }
  357. )
  358. });
  359. results.push({
  360. name: "Credit Card",
  361. constructor: () => makeObject(
  362. "Credit Card",
  363. {
  364. creditCard: {
  365. height: math.unit(53.98, "mm"),
  366. image: { source: "./media/objects/credit-card.svg" },
  367. name: "Credit card",
  368. },
  369. creditCardVertical: {
  370. height: math.unit(85.60, "mm"),
  371. image: { source: "./media/objects/credit-card-vertical.svg" },
  372. name: "Credit card (vertical)",
  373. },
  374. }
  375. )
  376. });
  377. results.push({
  378. name: "Molecular",
  379. constructor: () => makeObject(
  380. "Molecular",
  381. {
  382. hydrogen: {
  383. height: math.unit(1.06e-10, "m"),
  384. mass: math.unit(1, "dalton"),
  385. image: { source: "./media/objects/circle.svg" },
  386. name: "Hydrogen atom",
  387. rename: true
  388. },
  389. proton: {
  390. height: math.unit(0.877e-15, "m"),
  391. mass: math.unit(1, "dalton"),
  392. image: { source: "./media/objects/circle.svg" },
  393. name: "Proton",
  394. rename: true
  395. },
  396. }
  397. )
  398. });
  399. results.push({
  400. name: "Flagpole",
  401. constructor: () => makeObject(
  402. "Flagpole",
  403. {
  404. residential: {
  405. height: math.unit(20, "feet"),
  406. image: { source: "./media/objects/flagpole.svg" },
  407. name: "Residential"
  408. },
  409. medium: {
  410. height: math.unit(50, "feet"),
  411. image: { source: "./media/objects/flagpole.svg" },
  412. name: "Medium"
  413. },
  414. large: {
  415. height: math.unit(100, "feet"),
  416. image: { source: "./media/objects/flagpole.svg" },
  417. name: "Large"
  418. },
  419. }
  420. )
  421. });
  422. results.push({
  423. name: "Vending Machine",
  424. constructor: () => makeObject(
  425. "Vending Machine",
  426. {
  427. object: {
  428. height: math.unit(183, "cm"),
  429. mass: math.unit(347, "kg"),
  430. image: { source: "./media/objects/vending-machine.svg" },
  431. name: "Vending Machine"
  432. }
  433. }
  434. )
  435. })
  436. results.push({
  437. name: "International Space Station",
  438. constructor: () => makeObject(
  439. "International Space Station",
  440. {
  441. object: {
  442. height: math.unit(209, "feet"),
  443. mass: math.unit(925300, "lbs"),
  444. image: { source: "./media/objects/international-space-station.svg" },
  445. name: "International Space Station"
  446. }
  447. }
  448. )
  449. })
  450. results.push(makeHeight(
  451. [
  452. ["king", 4, "inches"],
  453. ["queen", 351 / 407 * 4, "inches"],
  454. ["bishop", 340 / 407 * 4, "inches"],
  455. ["knight", 309 / 407 * 4, "inches"],
  456. ["rook", 271 / 407 * 4, "inches"],
  457. ["pawn", 197 / 407 * 4, "inches"],
  458. ],
  459. "Chess Pieces",
  460. "chess_"
  461. ));
  462. results.push({
  463. name: "Strand",
  464. constructor: () => {
  465. views = {};
  466. viewInfo = {
  467. opticalFibre: {
  468. name: "Optical Fibre",
  469. thickness: math.unit(0.375, "mm")
  470. },
  471. hair: {
  472. name: "Hair",
  473. thickness: math.unit(0.07, "mm")
  474. },
  475. spiderSilk: {
  476. name: "Spider Silk",
  477. thickness: math.unit(0.003, "mm")
  478. },
  479. suspensionCables: {
  480. name: "Suspension Bridge Cables",
  481. thickness: math.unit(3, "feet")
  482. },
  483. capillary: {
  484. name: "Capillary",
  485. thickness: math.unit(7.5, "micrometers")
  486. },
  487. vein: {
  488. name: "Vein",
  489. thickness: math.unit(10, "mm")
  490. },
  491. thread: {
  492. name: "Thread",
  493. thickness: math.unit(0.4, "mm")
  494. },
  495. powerCord: {
  496. name: "Power Cord",
  497. thickness: math.unit(0.25, "inches")
  498. },
  499. pianoWireBass: {
  500. name: "Piano Wire (Bass)",
  501. thickness: math.unit(8.5, "mm")
  502. },
  503. pianoWireTreble: {
  504. name: "Piano Wire (Treble)",
  505. thickness: math.unit(0.85, "mm")
  506. },
  507. guitarString: {
  508. name: "Guitar String",
  509. thickness: math.unit(0.03, "inches")
  510. },
  511. powerLineThin: {
  512. name: "Power Line (Thin)",
  513. thickness: math.unit(0.325, "inches")
  514. },
  515. powerLineThick: {
  516. name: "Power Line (Thick)",
  517. thickness: math.unit(0.720, "inches")
  518. },
  519. carbonNanotube: {
  520. name: "Carbon Nanotube",
  521. thickness: math.unit(4, "nm")
  522. }
  523. }
  524. Object.entries(viewInfo).forEach(([key, value]) => {
  525. views[key] = {
  526. attributes: {
  527. height: {
  528. name: "Height",
  529. power: 1,
  530. type: "length",
  531. base: math.multiply(value.thickness, 253.4385 / 5)
  532. },
  533. thickness: {
  534. name: "Thickness",
  535. power: 1,
  536. type: "length",
  537. base: value.thickness
  538. },
  539. },
  540. image: {
  541. source: "./media/objects/strand.svg"
  542. },
  543. name: value.name,
  544. rename: true
  545. }
  546. if (value.mass) {
  547. views[key].attributes.mass = {
  548. name: "Mass",
  549. power: 3,
  550. type: "mass",
  551. base: value.mass
  552. };
  553. }
  554. });
  555. return makeEntity({ name: "Strand" }, views);
  556. }
  557. })
  558. results.push(makeHeight(
  559. [
  560. ["mitochondria", 0.5, "micrometer"],
  561. ["bacteria", 0.3, "micrometer"],
  562. ["sperm", 4.65, "micrometers"],
  563. ["red-blood-cell", 6.5, "micrometer"],
  564. ["white-blood-cell", 13, "micrometer"],
  565. ["animal-cell", 25, "micrometers"],
  566. ["plant-cell", 75, "micrometers"],
  567. ["amoeba-proteus", 500, "micrometers"],
  568. ["chaos-carolinensis", 1500, "micrometers"],
  569. ],
  570. "Cells",
  571. "cell_"
  572. ))
  573. results.push(makeHeight(
  574. [
  575. ["stop-sign", 36, "inches"],
  576. ["yield-sign", 36, "inches"],
  577. ["pedestrian-crossing", 30, "inches"],
  578. ["highway-exit", 150, "inches"]
  579. ],
  580. "Signs",
  581. ""
  582. ))
  583. results.push({
  584. name: "Game Consoles",
  585. constructor: () => makeVehicleGroup([
  586. {
  587. name: "Switch",
  588. mass: math.unit(10.48, "ounces"),
  589. sides: {
  590. "Front": { height: math.unit(4.01, "inches") },
  591. "Top": { height: math.unit(1.13, "inches") },
  592. "Side": { height: math.unit(4.01, "inches") },
  593. }
  594. }
  595. ],
  596. "Game Consoles",
  597. "",
  598. "objects")
  599. })
  600. results.push({
  601. name: "Electromagnetic Waves",
  602. constructor: () => {
  603. views = {};
  604. viewInfo = [
  605. ["Gamma rays", math.unit(1, "pm")],
  606. ["Hard X-rays", math.unit(20, "pm")],
  607. ["Soft X-rays", math.unit(1, "nm")],
  608. ["Extreme-ultraviolet", math.unit(50, "nm")],
  609. ["UVC", math.unit(200, "nm")],
  610. ["UVB", math.unit(295, "nm")],
  611. ["UVA", math.unit(350, "nm")],
  612. ["Violet", math.unit(415, "nm")],
  613. ["Blue", math.unit(470, "nm")],
  614. ["Cyan", math.unit(490, "nm")],
  615. ["Green", math.unit(530, "nm")],
  616. ["Yellow", math.unit(580, "nm")],
  617. ["Orange", math.unit(610, "nm")],
  618. ["Red", math.unit(690, "nm")],
  619. ["Near-infrared", math.unit(1.2, "um")],
  620. ["Short-wavelength infrared", math.unit(2.2, "um")],
  621. ["Mid-wavelength infrared", math.unit(6.5, "um")],
  622. ["Long-wavelength infrared", math.unit(12, "um")],
  623. ["Far infrared", math.unit(500, "um")],
  624. ["D-band microwaves (mm-wave)", math.unit(2, "mm")],
  625. ["S-band microwaves (ovens, wifi)", math.unit(11, "cm")],
  626. ["L-band microwaves (GPS)", math.unit(22, "cm")],
  627. ["UHF", math.unit(50, "cm")],
  628. ["FM radio", math.unit(3.5, "m")],
  629. ["VHF", math.unit(5, "m")],
  630. ["HF", math.unit(50, "m")],
  631. ["AM radio", math.unit(250, "m")],
  632. ["MF", math.unit(500, "m")],
  633. ["LF", math.unit(5, "km")],
  634. ["VLF", math.unit(50, "km")],
  635. ["ULF", math.unit(500, "km")],
  636. ["SLF", math.unit(5000, "km")],
  637. ["ELF", math.unit(50000, "km")],
  638. ]
  639. viewInfo.forEach(([name, length]) => {
  640. views[name] = {
  641. attributes: {
  642. height: {
  643. name: "Height",
  644. power: 1,
  645. type: "length",
  646. base: math.multiply(length, 2)
  647. }
  648. },
  649. image: {
  650. source: "./media/objects/sine-wave.svg"
  651. },
  652. name: name,
  653. rename: true,
  654. default: name === "Green"
  655. }
  656. });
  657. return makeEntity({ name: "Electromagnetic Waves" }, views);
  658. }
  659. })
  660. results.push(makeHeight(
  661. [
  662. [".308 Winchester", 71.374, "mm", "./media/objects/ammunition/.308 Winchester.svg"],
  663. [".22 LR", 25.40, "mm", "./media/objects/ammunition/.22 LR.svg"],
  664. ["9mm Luger", 29.69, "mm", "./media/objects/ammunition/9mm Luger.svg"],
  665. [".223 Remington", 2.260, "inches", "./media/objects/ammunition/.223 Remington.svg"],
  666. [".30-06 Springfield", 3.340, "inches", "./media/objects/ammunition/.30-06 Springfield.svg"],
  667. ],
  668. "Ammunition",
  669. "",
  670. "objects",
  671. false
  672. ))
  673. results.push(makeHeight(
  674. [
  675. ["No. 1 (11 Oz.)", 4, "inches", "./media/objects/tin-cans/No. 1 (11 Oz.).svg"],
  676. ["No. 2 (20 Oz.)", 4 + 9/16, "inches", "./media/objects/tin-cans/No. 2 (20 Oz.).svg"],
  677. ["No. 3 (52 Oz.)", 7, "inches", "./media/objects/tin-cans/No. 3 (52 Oz.).svg"],
  678. ["No. 5 (60 Oz.)", 5 + 5/8, "inches", "./media/objects/tin-cans/No. 5 (60 Oz.).svg"],
  679. ["No. 10 (110 Oz.)", 7, "inches", "./media/objects/tin-cans/No. 10 (110 Oz.).svg"],
  680. ],
  681. "Tin Cans",
  682. ""
  683. ))
  684. results.push(makeHeight(
  685. [
  686. ["Garden Hose", 0.875, "inches"],
  687. ["1 Inch Fire Hose", 1.25, "inches"],
  688. ["1.5 Inch Fire Hose", 1.85, "inches"],
  689. ["1.75 Inch Fire Hose", 2.1, "inches"],
  690. ["2.5 Inch Fire Hose", 3, "inches"],
  691. ["4 Inch Fire Hose", 4.5, "inches"],
  692. ["5 Inch Fire Hose", 5.6, "inches"],
  693. ],
  694. "Hoses",
  695. ""
  696. ))
  697. results.push(makeHeight(
  698. [
  699. ["12 Inch Culvert", 14.75, "inches"],
  700. ["24 Inch Culvert", 26.75, "inches"],
  701. ],
  702. "Pipes",
  703. ""
  704. ))
  705. results.push(makeHeight(
  706. [
  707. ["000 Capsule", 26.1, "mm"],
  708. ["00E Capsule", 25.3, "mm"],
  709. ["00 Capsule", 23.4, "mm"],
  710. ["0E Capsule", 23.5, "mm"],
  711. ["0 Capsule", 21.6, "mm"],
  712. ["1 Capsule", 19.4, "mm"],
  713. ["2 Capsule", 17.6, "mm"],
  714. ["3 Capsule", 15.7, "mm"],
  715. ["4 Capsule", 14.3, "mm"],
  716. ["5 Capsule", 11.1, "mm"],
  717. ],
  718. "Pills",
  719. ""
  720. ));
  721. console.log(results[results.length - 1])
  722. results.sort((b1, b2) => {
  723. e1 = b1.constructor();
  724. e2 = b2.constructor();
  725. return -math.subtract(e1.views[e1.defaultView].height, e2.views[e2.defaultView].height).value;
  726. });
  727. return results;
  728. }