less copy protection, more size visualization
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

738 行
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. ["animal-cell", 25, "micrometers"],
  554. ["plant-cell", 75, "micrometers"],
  555. ["mitochondria", 0.5, "micrometer"],
  556. ["bacteria", 0.3, "micrometer"],
  557. ["red-blood-cell", 6.5, "micrometer"],
  558. ["white-blood-cell", 13, "micrometer"],
  559. ["amoeba-proteus", 500, "micrometers"],
  560. ["chaos-carolinensis", 1500, "micrometers"]
  561. ],
  562. "Cells",
  563. "cell_"
  564. ))
  565. results.push(makeHeight(
  566. [
  567. ["stop-sign", 36, "inches"],
  568. ["yield-sign", 36, "inches"],
  569. ["pedestrian-crossing", 30, "inches"],
  570. ["highway-exit", 150, "inches"]
  571. ],
  572. "Signs",
  573. ""
  574. ))
  575. results.push({
  576. name: "Game Consoles",
  577. constructor: () => makeVehicleGroup([
  578. {
  579. name: "Switch",
  580. mass: math.unit(10.48, "ounces"),
  581. sides: {
  582. "Front": { height: math.unit(4.01, "inches") },
  583. "Top": { height: math.unit(1.13, "inches") },
  584. "Side": { height: math.unit(4.01, "inches") },
  585. }
  586. }
  587. ],
  588. "Game Consoles",
  589. "",
  590. "objects")
  591. })
  592. results.push({
  593. name: "Electromagnetic Waves",
  594. constructor: () => {
  595. views = {};
  596. viewInfo = [
  597. ["Gamma rays", math.unit(1, "pm")],
  598. ["Hard X-rays", math.unit(20, "pm")],
  599. ["Soft X-rays", math.unit(1, "nm")],
  600. ["Extreme-ultraviolet", math.unit(50, "nm")],
  601. ["UVC", math.unit(200, "nm")],
  602. ["UVB", math.unit(295, "nm")],
  603. ["UVA", math.unit(350, "nm")],
  604. ["Violet", math.unit(415, "nm")],
  605. ["Blue", math.unit(470, "nm")],
  606. ["Cyan", math.unit(490, "nm")],
  607. ["Green", math.unit(530, "nm")],
  608. ["Yellow", math.unit(580, "nm")],
  609. ["Orange", math.unit(610, "nm")],
  610. ["Red", math.unit(690, "nm")],
  611. ["Near-infrared", math.unit(1.2, "um")],
  612. ["Short-wavelength infrared", math.unit(2.2, "um")],
  613. ["Mid-wavelength infrared", math.unit(6.5, "um")],
  614. ["Long-wavelength infrared", math.unit(12, "um")],
  615. ["Far infrared", math.unit(500, "um")],
  616. ["D-band microwaves (mm-wave)", math.unit(2, "mm")],
  617. ["S-band microwaves (ovens, wifi)", math.unit(11, "cm")],
  618. ["L-band microwaves (GPS)", math.unit(22, "cm")],
  619. ["UHF", math.unit(50, "cm")],
  620. ["FM radio", math.unit(3.5, "m")],
  621. ["VHF", math.unit(5, "m")],
  622. ["HF", math.unit(50, "m")],
  623. ["AM radio", math.unit(250, "m")],
  624. ["MF", math.unit(500, "m")],
  625. ["LF", math.unit(5, "km")],
  626. ["VLF", math.unit(50, "km")],
  627. ["ULF", math.unit(500, "km")],
  628. ["SLF", math.unit(5000, "km")],
  629. ["ELF", math.unit(50000, "km")],
  630. ]
  631. viewInfo.forEach(([name, length]) => {
  632. views[name] = {
  633. attributes: {
  634. height: {
  635. name: "Height",
  636. power: 1,
  637. type: "length",
  638. base: math.multiply(length, 2)
  639. }
  640. },
  641. image: {
  642. source: "./media/objects/sine-wave.svg"
  643. },
  644. name: name,
  645. rename: true,
  646. default: name === "Green"
  647. }
  648. });
  649. return makeEntity({ name: "Electromagnetic Waves" }, views);
  650. }
  651. })
  652. results.push(makeHeight(
  653. [
  654. [".308 Winchester", 71.374, "mm", "./media/objects/ammunition/.308 Winchester.svg"],
  655. [".22 LR", 25.40, "mm", "./media/objects/ammunition/.22 LR.svg"],
  656. ["9mm Luger", 29.69, "mm", "./media/objects/ammunition/9mm Luger.svg"],
  657. [".223 Remington", 2.260, "inches", "./media/objects/ammunition/.223 Remington.svg"],
  658. [".30-06 Springfield", 3.340, "inches", "./media/objects/ammunition/.30-06 Springfield.svg"],
  659. ],
  660. "Ammunition",
  661. "",
  662. "objects",
  663. false
  664. ))
  665. results.push(makeHeight(
  666. [
  667. ["No. 1 (11 Oz.)", 4, "inches", "./media/objects/tin-cans/No. 1 (11 Oz.).svg"],
  668. ["No. 2 (20 Oz.)", 4 + 9/16, "inches", "./media/objects/tin-cans/No. 2 (20 Oz.).svg"],
  669. ["No. 3 (52 Oz.)", 7, "inches", "./media/objects/tin-cans/No. 3 (52 Oz.).svg"],
  670. ["No. 5 (60 Oz.)", 5 + 5/8, "inches", "./media/objects/tin-cans/No. 5 (60 Oz.).svg"],
  671. ["No. 10 (110 Oz.)", 7, "inches", "./media/objects/tin-cans/No. 10 (110 Oz.).svg"],
  672. ],
  673. "Tin Cans",
  674. ""
  675. ))
  676. results.sort((b1, b2) => {
  677. e1 = b1.constructor();
  678. e2 = b2.constructor();
  679. return -math.subtract(e1.views[e1.defaultView].height, e2.views[e2.defaultView].height).value;
  680. });
  681. return results;
  682. }