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.
 
 
 

587 lignes
17 KiB

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