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

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