less copy protection, more size visualization
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

607 linhas
18 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. });
  26. return makeEntity({ name: name }, views);
  27. }
  28. SHOE_REFERENCE = 60
  29. function addShoeView(object, name, points) {
  30. object[name] = {
  31. height: math.unit(points / SHOE_REFERENCE, "inches"),
  32. image: { source: "./media/objects/shoes/shoe_" + name + ".svg" },
  33. name: name.replace(/-/g, " ").replace(/\b\w/g, x => x.toUpperCase()),
  34. rename: true
  35. }
  36. }
  37. function makeHeight(info, category, prefix = "", type = "objects") {
  38. const views = {};
  39. info.forEach(object => {
  40. let src;
  41. // this lets us provide our own source if needed
  42. // useful for reusing existing art
  43. if (object[3]) {
  44. src = object[3];
  45. } else {
  46. src = "./media/" + type + "/" + category.replace(/ /g, "-").toLowerCase() + "/" + prefix + object[0] + ".svg";
  47. }
  48. views[object[0]] = {
  49. height: math.unit(object[1], object[2]),
  50. image: { source: src },
  51. name: object[0].replace(/-/g, " ").replace(/\b\w/g, x => x.toUpperCase()),
  52. rename: true
  53. }
  54. });
  55. return {
  56. name: category,
  57. constructor: () => makeObject(
  58. category,
  59. views
  60. )
  61. }
  62. }
  63. function makeHeightWeight(info, category, prefix = "", type = "objects") {
  64. const views = {};
  65. info.forEach(object => {
  66. let src;
  67. // this lets us provide our own source if needed
  68. // useful for reusing existing art
  69. if (object[5]) {
  70. src = object[5];
  71. } else {
  72. src = "./media/" + type + "/" + category.replace(/ /g, "-").toLowerCase() + "/" + prefix + object[0] + ".svg";
  73. }
  74. views[object[0]] = {
  75. height: math.unit(object[1], object[2]),
  76. mass: math.unit(object[3], object[4]),
  77. image: { source: src },
  78. name: object[0].replace(/-/g, " ").replace(/\b\w/g, x => x.toUpperCase()),
  79. rename: true
  80. }
  81. });
  82. return {
  83. name: category,
  84. constructor: () => makeObject(
  85. category,
  86. views
  87. )
  88. }
  89. }
  90. function makeShoes() {
  91. const views = {};
  92. [
  93. ["flip-flops", 154.239],
  94. ["knee-boots", 841.827],
  95. ["trainers", 260.607],
  96. ["stilettos", 418.839]
  97. ].forEach(shoe => {
  98. addShoeView(views, shoe[0], shoe[1])
  99. });
  100. return {
  101. name: "Shoes",
  102. constructor: () => makeObject(
  103. "Shoes",
  104. views
  105. )
  106. }
  107. }
  108. function makeObjects() {
  109. const results = [];
  110. results.push({
  111. name: "Soda Can",
  112. constructor: () => makeObject(
  113. "Soda Can",
  114. {
  115. front: {
  116. height: math.unit(4.83, "inches"),
  117. mass: math.unit(15, "grams"),
  118. image: { source: "./media/objects/soda-can.svg" },
  119. name: "Side"
  120. }
  121. }
  122. )
  123. });
  124. results.push({
  125. name: "Sewing Pin",
  126. constructor: () => makeObject(
  127. "Sewing Pin",
  128. {
  129. side: {
  130. height: math.unit(1.5, "inches"),
  131. image: { source: "./media/objects/sewing-pin.svg" },
  132. name: "Side"
  133. },
  134. top: {
  135. height: math.unit(2, "millimeters"),
  136. image: { source: "./media/objects/pin-head.svg" },
  137. name: "Head"
  138. }
  139. }
  140. )
  141. });
  142. results.push({
  143. name: "Lamp",
  144. constructor: () => makeObject(
  145. "Lamp",
  146. {
  147. lamp: {
  148. height: math.unit(30, "inches"),
  149. mass: math.unit(10, "lbs"),
  150. image: { source: "./media/objects/lamp.svg" },
  151. name: "Lamp"
  152. }
  153. }
  154. )
  155. });
  156. results.push({
  157. name: "Nail Polish",
  158. constructor: () => makeObject(
  159. "Nail Polish",
  160. {
  161. bottle: {
  162. height: math.unit(3.25, "inches"),
  163. mass: math.unit(66, "g"),
  164. image: { source: "./media/objects/nail-polish.svg" },
  165. name: "Bottle"
  166. }
  167. }
  168. )
  169. });
  170. results.push({
  171. name: "Shot Glass",
  172. constructor: () => makeObject(
  173. "Shot Glass",
  174. {
  175. glass: {
  176. height: math.unit(2 + 3 / 8, "inches"),
  177. mass: math.unit(75, "g"),
  178. image: { source: "./media/objects/shot-glass.svg" },
  179. name: "Bottle"
  180. }
  181. }
  182. )
  183. });
  184. results.push({
  185. name: "Beer Bottle",
  186. constructor: () => makeObject(
  187. "Beer Bottle",
  188. {
  189. longneck: {
  190. height: math.unit(9, "inches"),
  191. mass: math.unit(200, "g"),
  192. image: { source: "./media/objects/beer-bottle.svg" },
  193. name: "Longneck Bottle"
  194. }
  195. }
  196. )
  197. });
  198. results.push({
  199. name: "Coin",
  200. constructor: () => makeObject(
  201. "Coin",
  202. {
  203. penny: {
  204. height: math.unit(0.75, "inches"),
  205. mass: math.unit(2.5, "g"),
  206. image: { source: "./media/objects/circle.svg" },
  207. name: "Penny",
  208. rename: true
  209. },
  210. nickel: {
  211. height: math.unit(0.835, "inches"),
  212. mass: math.unit(5, "g"),
  213. image: { source: "./media/objects/circle.svg" },
  214. name: "Nickel",
  215. rename: true
  216. },
  217. dime: {
  218. height: math.unit(0.705, "inches"),
  219. mass: math.unit(2.268, "g"),
  220. image: { source: "./media/objects/circle.svg" },
  221. name: "Dime",
  222. rename: true
  223. },
  224. quarter: {
  225. height: math.unit(0.955, "inches"),
  226. mass: math.unit(5.67, "g"),
  227. image: { source: "./media/objects/circle.svg" },
  228. name: "Quarter",
  229. rename: true
  230. },
  231. dollar: {
  232. height: math.unit(1.043, "inches"),
  233. mass: math.unit(8.1, "g"),
  234. image: { source: "./media/objects/circle.svg" },
  235. name: "Dollar Coin",
  236. rename: true
  237. },
  238. }
  239. )
  240. });
  241. results.push({
  242. name: "Pencil",
  243. constructor: () => makeObject(
  244. "Pencil",
  245. {
  246. pencil: {
  247. height: math.unit(7.5, "inches"),
  248. mass: math.unit(7, "g"),
  249. image: { source: "./media/objects/pencil.svg" },
  250. name: "Pencil"
  251. }
  252. }
  253. )
  254. });
  255. results.push({
  256. name: "Balls",
  257. constructor: () => makeObject(
  258. "Balls",
  259. {
  260. golf: {
  261. height: math.unit(1.62, "inches"),
  262. mass: math.unit(45, "g"),
  263. image: { source: "./media/objects/circle.svg" },
  264. name: "Golfball",
  265. rename: true
  266. },
  267. tennis: {
  268. height: math.unit(2.6, "inches"),
  269. mass: math.unit(57, "g"),
  270. image: { source: "./media/objects/circle.svg" },
  271. name: "Tennisball",
  272. rename: true
  273. },
  274. baseball: {
  275. height: math.unit(2.9, "inches"),
  276. mass: math.unit(145, "g"),
  277. image: { source: "./media/objects/circle.svg" },
  278. name: "Baseball",
  279. rename: true
  280. },
  281. volleyball: {
  282. height: math.unit(8, "inches"),
  283. mass: math.unit(270, "g"),
  284. image: { source: "./media/objects/circle.svg" },
  285. name: "Volleyball",
  286. rename: true
  287. }
  288. }
  289. )
  290. });
  291. results.push({
  292. name: "Paperclip",
  293. constructor: () => makeObject(
  294. "Paperclip",
  295. {
  296. paperclip: {
  297. height: math.unit(1.834, "inches"),
  298. mass: math.unit(1, "g"),
  299. image: { source: "./media/objects/paperclip.svg" },
  300. name: "Paperclip"
  301. }
  302. }
  303. )
  304. });
  305. results.push({
  306. name: "Pebbles",
  307. constructor: () => makeObject(
  308. "Pebbles",
  309. {
  310. gravelGrain: {
  311. height: math.unit(20, "mm"),
  312. image: { source: "./media/objects/pebble.svg" },
  313. name: "Grain of gravel",
  314. rename: true
  315. },
  316. sandGrain: {
  317. height: math.unit(0.5, "mm"),
  318. image: { source: "./media/objects/pebble.svg" },
  319. name: "Grain of sand",
  320. rename: true
  321. },
  322. siltGrain: {
  323. height: math.unit(0.03, "mm"),
  324. image: { source: "./media/objects/pebble.svg" },
  325. name: "Grain of silt",
  326. rename: true
  327. },
  328. }
  329. )
  330. });
  331. results.push({
  332. name: "Credit Card",
  333. constructor: () => makeObject(
  334. "Credit Card",
  335. {
  336. creditCard: {
  337. height: math.unit(53.98, "mm"),
  338. image: { source: "./media/objects/credit-card.svg" },
  339. name: "Credit card",
  340. },
  341. creditCardVertical: {
  342. height: math.unit(85.60, "mm"),
  343. image: { source: "./media/objects/credit-card-vertical.svg" },
  344. name: "Credit card (vertical)",
  345. },
  346. }
  347. )
  348. });
  349. results.push({
  350. name: "Molecular",
  351. constructor: () => makeObject(
  352. "Molecular",
  353. {
  354. hydrogen: {
  355. height: math.unit(1.06e-10, "mm"),
  356. mass: math.unit(1, "dalton"),
  357. image: { source: "./media/objects/circle.svg" },
  358. name: "Hydrogen atom",
  359. rename: true
  360. },
  361. proton: {
  362. height: math.unit(1e-15, "mm"),
  363. mass: math.unit(1, "dalton"),
  364. image: { source: "./media/objects/circle.svg" },
  365. name: "Proton",
  366. rename: true
  367. },
  368. }
  369. )
  370. });
  371. results.push(makeShoes());
  372. results.push({
  373. name: "Flagpole",
  374. constructor: () => makeObject(
  375. "Flagpole",
  376. {
  377. residential: {
  378. height: math.unit(20, "feet"),
  379. image: { source: "./media/objects/flagpole.svg" },
  380. name: "Residential"
  381. },
  382. medium: {
  383. height: math.unit(50, "feet"),
  384. image: { source: "./media/objects/flagpole.svg" },
  385. name: "Medium"
  386. },
  387. large: {
  388. height: math.unit(100, "feet"),
  389. image: { source: "./media/objects/flagpole.svg" },
  390. name: "Large"
  391. },
  392. }
  393. )
  394. });
  395. results.push({
  396. name: "Vending Machine",
  397. constructor: () => makeObject(
  398. "Vending Machine",
  399. {
  400. object: {
  401. height: math.unit(183, "cm"),
  402. mass: math.unit(347, "kg"),
  403. image: { source: "./media/objects/vending-machine.svg" },
  404. name: "Vending Machine"
  405. }
  406. }
  407. )
  408. })
  409. results.push({
  410. name: "International Space Station",
  411. constructor: () => makeObject(
  412. "International Space Station",
  413. {
  414. object: {
  415. height: math.unit(209, "feet"),
  416. mass: math.unit(925300, "lbs"),
  417. image: { source: "./media/objects/international-space-station.svg" },
  418. name: "International Space Station"
  419. }
  420. }
  421. )
  422. })
  423. results.push(makeHeight(
  424. [
  425. ["king", 4, "inches"],
  426. ["queen", 351 / 407 * 4, "inches"],
  427. ["bishop", 340 / 407 * 4, "inches"],
  428. ["knight", 309 / 407 * 4, "inches"],
  429. ["rook", 271 / 407 * 4, "inches"],
  430. ["pawn", 197 / 407 * 4, "inches"],
  431. ],
  432. "Chess Pieces",
  433. "chess_"
  434. ));
  435. results.push({
  436. name: "Strand",
  437. constructor: () => {
  438. views = {};
  439. viewInfo = {
  440. opticalFibre: {
  441. name: "Optical Fibre",
  442. thickness: math.unit(0.375, "mm")
  443. },
  444. hair: {
  445. name: "Hair",
  446. thickness: math.unit(0.07, "mm")
  447. },
  448. spiderSilk: {
  449. name: "Spider Silk",
  450. thickness: math.unit(0.003, "mm")
  451. },
  452. suspensionCables: {
  453. name: "Suspension Bridge Cables",
  454. thickness: math.unit(3, "feet")
  455. },
  456. capillary: {
  457. name: "Capillary",
  458. thickness: math.unit(7.5, "micrometers")
  459. },
  460. vein: {
  461. name: "Vein",
  462. thickness: math.unit(10, "mm")
  463. },
  464. thread: {
  465. name: "Thread",
  466. thickness: math.unit(0.4, "mm")
  467. },
  468. powerCord: {
  469. name: "Power Cord",
  470. thickness: math.unit(0.25, "inches")
  471. },
  472. pianoWireBass: {
  473. name: "Piano Wire (Bass)",
  474. thickness: math.unit(8.5, "mm")
  475. },
  476. pianoWireTreble: {
  477. name: "Piano Wire (Treble)",
  478. thickness: math.unit(0.85, "mm")
  479. },
  480. guitarString: {
  481. name: "Guitar String",
  482. thickness: math.unit(0.03, "inches")
  483. },
  484. powerLineThin: {
  485. name: "Power Line (Thin)",
  486. thickness: math.unit(0.325, "inches")
  487. },
  488. powerLineThick: {
  489. name: "Power Line (Thick)",
  490. thickness: math.unit(0.720, "inches")
  491. },
  492. carbonNanotube: {
  493. name: "Carbon Nanotube",
  494. thickness: math.unit(4, "nm")
  495. }
  496. }
  497. Object.entries(viewInfo).forEach(([key, value]) => {
  498. views[key] = {
  499. attributes: {
  500. height: {
  501. name: "Height",
  502. power: 1,
  503. type: "length",
  504. base: math.multiply(value.thickness, 253.4385 / 5)
  505. },
  506. thickness: {
  507. name: "Thickness",
  508. power: 1,
  509. type: "length",
  510. base: value.thickness
  511. },
  512. },
  513. image: {
  514. source: "./media/objects/strand.svg"
  515. },
  516. name: value.name,
  517. rename: true
  518. }
  519. if (value.mass) {
  520. views[key].attributes.mass = {
  521. name: "Mass",
  522. power: 3,
  523. type: "mass",
  524. base: value.mass
  525. };
  526. }
  527. });
  528. return makeEntity({ name: "Strand" }, views);
  529. }
  530. })
  531. results.push(makeHeight(
  532. [
  533. ["animal-cell", 25, "micrometers"],
  534. ["plant-cell", 75, "micrometers"],
  535. ["mitochondria", 0.5, "micrometer"],
  536. ["bacteria", 0.3, "micrometer"],
  537. ["red-blood-cell", 6.5, "micrometer"],
  538. ["white-blood-cell", 13, "micrometer"],
  539. ["amoeba-proteus", 500, "micrometers"],
  540. ["chaos-carolinensis", 1500, "micrometers"]
  541. ],
  542. "Cells",
  543. "cell_"
  544. ))
  545. results.push(makeHeight(
  546. [
  547. ["stop-sign", 36, "inches"],
  548. ["yield-sign", 36, "inches"],
  549. ["pedestrian-crossing", 30, "inches"],
  550. ["highway-exit", 150, "inches"]
  551. ],
  552. "Signs",
  553. ""
  554. ))
  555. results.sort((b1, b2) => {
  556. e1 = b1.constructor();
  557. e2 = b2.constructor();
  558. return -math.subtract(e1.views[e1.defaultView].height, e2.views[e2.defaultView].height).value;
  559. });
  560. return results;
  561. }