less copy protection, more size visualization
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

542 行
16 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 makeHeightWeight(info, category, prefix="") {
  46. const views = {};
  47. info.forEach(object => {
  48. views[object[0]] = {
  49. height: math.unit(object[1], "meters"),
  50. mass: math.unit(object[2], "kilograms"),
  51. image: { source: "./media/objects/" + category.replace(/ /g, "-").toLowerCase() + "/" + prefix + object[0] + ".svg" },
  52. name: object[0].replace(/-/g, " ").replace(/\b\w/g, x => x.toUpperCase()),
  53. rename: true
  54. }
  55. });
  56. return {
  57. name: category,
  58. constructor: () => makeObject(
  59. category,
  60. views
  61. )
  62. }
  63. }
  64. function makeShoes() {
  65. const views = {};
  66. [
  67. ["flip-flops", 154.239],
  68. ["knee-boots", 841.827],
  69. ["trainers", 260.607],
  70. ["stilettos", 418.839]
  71. ].forEach(shoe => {
  72. addShoeView(views, shoe[0], shoe[1])
  73. });
  74. return {
  75. name: "Shoes",
  76. constructor: () => makeObject(
  77. "Shoes",
  78. views
  79. )
  80. }
  81. }
  82. function makeObjects() {
  83. const results = [];
  84. results.push({
  85. name: "Soda Can",
  86. constructor: () => makeObject(
  87. "Soda Can",
  88. {
  89. front: {
  90. height: math.unit(4.83, "inches"),
  91. mass: math.unit(15, "grams"),
  92. image: { source: "./media/objects/soda-can.svg" },
  93. name: "Side"
  94. }
  95. }
  96. )
  97. });
  98. results.push({
  99. name: "Sewing Pin",
  100. constructor: () => makeObject(
  101. "Sewing Pin",
  102. {
  103. side: {
  104. height: math.unit(1.5, "inches"),
  105. image: { source: "./media/objects/sewing-pin.svg" },
  106. name: "Side"
  107. },
  108. top: {
  109. height: math.unit(2, "millimeters"),
  110. image: { source: "./media/objects/pin-head.svg" },
  111. name: "Head"
  112. }
  113. }
  114. )
  115. });
  116. results.push({
  117. name: "Lamp",
  118. constructor: () => makeObject(
  119. "Lamp",
  120. {
  121. lamp: {
  122. height: math.unit(30, "inches"),
  123. mass: math.unit(10, "lbs"),
  124. image: { source: "./media/objects/lamp.svg" },
  125. name: "Lamp"
  126. }
  127. }
  128. )
  129. });
  130. results.push({
  131. name: "Human",
  132. constructor: () => makeObject(
  133. "Human",
  134. {
  135. woman1: {
  136. height: math.unit(5 + 4/12, "feet"),
  137. mass: math.unit(140, "lbs"),
  138. image: { source: "./media/objects/humans/woman-1.svg" },
  139. name: "Woman 1"
  140. },
  141. man1: {
  142. height: math.unit(5 + 6/12, "feet"),
  143. mass: math.unit(150, "lbs"),
  144. image: { source: "./media/objects/humans/man-1.svg" },
  145. name: "Man 1"
  146. },
  147. }
  148. )
  149. });
  150. results.push({
  151. name: "Nail Polish",
  152. constructor: () => makeObject(
  153. "Nail Polish",
  154. {
  155. bottle: {
  156. height: math.unit(3.25, "inches"),
  157. mass: math.unit(66, "g"),
  158. image: { source: "./media/objects/nail-polish.svg" },
  159. name: "Bottle"
  160. }
  161. }
  162. )
  163. });
  164. results.push({
  165. name: "Shot Glass",
  166. constructor: () => makeObject(
  167. "Shot Glass",
  168. {
  169. glass: {
  170. height: math.unit(2 + 3/8, "inches"),
  171. mass: math.unit(75, "g"),
  172. image: { source: "./media/objects/shot-glass.svg" },
  173. name: "Bottle"
  174. }
  175. }
  176. )
  177. });
  178. results.push({
  179. name: "Beer Bottle",
  180. constructor: () => makeObject(
  181. "Beer Bottle",
  182. {
  183. longneck: {
  184. height: math.unit(9, "inches"),
  185. mass: math.unit(200, "g"),
  186. image: { source: "./media/objects/beer-bottle.svg" },
  187. name: "Longneck Bottle"
  188. }
  189. }
  190. )
  191. });
  192. results.push({
  193. name: "Coin",
  194. constructor: () => makeObject(
  195. "Coin",
  196. {
  197. penny: {
  198. height: math.unit(0.75, "inches"),
  199. mass: math.unit(2.5, "g"),
  200. image: { source: "./media/objects/circle.svg" },
  201. name: "Penny",
  202. rename: true
  203. },
  204. nickel: {
  205. height: math.unit(0.835, "inches"),
  206. mass: math.unit(5, "g"),
  207. image: { source: "./media/objects/circle.svg" },
  208. name: "Nickel",
  209. rename: true
  210. },
  211. dime: {
  212. height: math.unit(0.705, "inches"),
  213. mass: math.unit(2.268, "g"),
  214. image: { source: "./media/objects/circle.svg" },
  215. name: "Dime",
  216. rename: true
  217. },
  218. quarter: {
  219. height: math.unit(0.955, "inches"),
  220. mass: math.unit(5.67, "g"),
  221. image: { source: "./media/objects/circle.svg" },
  222. name: "Quarter",
  223. rename: true
  224. },
  225. dollar: {
  226. height: math.unit(1.043, "inches"),
  227. mass: math.unit(8.1, "g"),
  228. image: { source: "./media/objects/circle.svg" },
  229. name: "Dollar Coin",
  230. rename: true
  231. },
  232. }
  233. )
  234. });
  235. results.push({
  236. name: "Pencil",
  237. constructor: () => makeObject(
  238. "Pencil",
  239. {
  240. pencil: {
  241. height: math.unit(7.5, "inches"),
  242. mass: math.unit(7, "g"),
  243. image: { source: "./media/objects/pencil.svg" },
  244. name: "Pencil"
  245. }
  246. }
  247. )
  248. });
  249. results.push({
  250. name: "Balls",
  251. constructor: () => makeObject(
  252. "Balls",
  253. {
  254. golf: {
  255. height: math.unit(1.62, "inches"),
  256. mass: math.unit(45, "g"),
  257. image: { source: "./media/objects/circle.svg" },
  258. name: "Golfball",
  259. rename: true
  260. },
  261. tennis: {
  262. height: math.unit(2.6, "inches"),
  263. mass: math.unit(57, "g"),
  264. image: { source: "./media/objects/circle.svg" },
  265. name: "Tennisball",
  266. rename: true
  267. },
  268. baseball: {
  269. height: math.unit(2.9, "inches"),
  270. mass: math.unit(145, "g"),
  271. image: { source: "./media/objects/circle.svg" },
  272. name: "Baseball",
  273. rename: true
  274. },
  275. volleyball: {
  276. height: math.unit(8, "inches"),
  277. mass: math.unit(270, "g"),
  278. image: { source: "./media/objects/circle.svg" },
  279. name: "Volleyball",
  280. rename: true
  281. }
  282. }
  283. )
  284. });
  285. results.push({
  286. name: "Paperclip",
  287. constructor: () => makeObject(
  288. "Paperclip",
  289. {
  290. paperclip: {
  291. height: math.unit(1.834, "inches"),
  292. mass: math.unit(1, "g"),
  293. image: { source: "./media/objects/paperclip.svg" },
  294. name: "Paperclip"
  295. }
  296. }
  297. )
  298. });
  299. results.push({
  300. name: "Pebbles",
  301. constructor: () => makeObject(
  302. "Pebbles",
  303. {
  304. gravelGrain: {
  305. height: math.unit(20, "mm"),
  306. image: { source: "./media/objects/pebble.svg" },
  307. name: "Grain of gravel",
  308. rename: true
  309. },
  310. sandGrain: {
  311. height: math.unit(0.5, "mm"),
  312. image: { source: "./media/objects/pebble.svg" },
  313. name: "Grain of sand",
  314. rename: true
  315. },
  316. siltGrain: {
  317. height: math.unit(0.03, "mm"),
  318. image: { source: "./media/objects/pebble.svg" },
  319. name: "Grain of silt",
  320. rename: true
  321. },
  322. }
  323. )
  324. });
  325. results.push({
  326. name: "Credit Card",
  327. constructor: () => makeObject(
  328. "Credit Card",
  329. {
  330. creditCard: {
  331. height: math.unit(53.98, "mm"),
  332. image: { source: "./media/objects/credit-card.svg" },
  333. name: "Credit card",
  334. },
  335. creditCardVertical: {
  336. height: math.unit(85.60, "mm"),
  337. image: { source: "./media/objects/credit-card-vertical.svg" },
  338. name: "Credit card (vertical)",
  339. },
  340. }
  341. )
  342. });
  343. results.push({
  344. name: "Molecular",
  345. constructor: () => makeObject(
  346. "Molecular",
  347. {
  348. hydrogen: {
  349. height: math.unit(1.06e-10, "mm"),
  350. mass: math.unit(1, "dalton"),
  351. image: { source: "./media/objects/circle.svg" },
  352. name: "Hydrogen atom",
  353. rename: true
  354. },
  355. proton: {
  356. height: math.unit(1e-15, "mm"),
  357. mass: math.unit(1, "dalton"),
  358. image: { source: "./media/objects/circle.svg" },
  359. name: "Proton",
  360. rename: true
  361. },
  362. }
  363. )
  364. });
  365. results.push({
  366. name: "Fruit",
  367. constructor: () => makeObject(
  368. "Fruit",
  369. {
  370. banana: {
  371. height: math.unit(3.5, "inches"),
  372. image: { source: "./media/objects/fruits/banana.svg" },
  373. name: "Banana",
  374. rename: true
  375. },
  376. bananaVertical: {
  377. height: math.unit(7, "inches"),
  378. image: { source: "./media/objects/fruits/banana-vertical.svg" },
  379. name: "Banana (Vertical)",
  380. rename: true
  381. },
  382. lemon: {
  383. height: math.unit(3.5, "inches"),
  384. image: { source: "./media/objects/fruits/lemon.svg" },
  385. name: "Lemon",
  386. rename: true
  387. },
  388. orange: {
  389. height: math.unit(2.8, "inches"),
  390. image: { source: "./media/objects/fruits/orange.svg" },
  391. name: "Orange",
  392. rename: true
  393. },
  394. grape: {
  395. height: math.unit(0.8, "inches"),
  396. image: { source: "./media/objects/fruits/grape.svg" },
  397. name: "Grape",
  398. rename: true
  399. },
  400. pineapple: {
  401. height: math.unit(17, "inches"),
  402. image: { source: "./media/objects/fruits/pineapple.svg" },
  403. name: "Pineapple",
  404. rename: true
  405. },
  406. }
  407. )
  408. });
  409. results.push(makeShoes());
  410. results.push({
  411. name: "Flagpole",
  412. constructor: () => makeObject(
  413. "Flagpole",
  414. {
  415. residential: {
  416. height: math.unit(20, "feet"),
  417. image: { source: "./media/objects/flagpole.svg" },
  418. name: "Residential"
  419. },
  420. medium: {
  421. height: math.unit(50, "feet"),
  422. image: { source: "./media/objects/flagpole.svg" },
  423. name: "Medium"
  424. },
  425. large: {
  426. height: math.unit(100, "feet"),
  427. image: { source: "./media/objects/flagpole.svg" },
  428. name: "Large"
  429. },
  430. }
  431. )
  432. });
  433. results.push({
  434. name: "Trees",
  435. constructor: () => makeObject(
  436. "Trees",
  437. {
  438. sycamore: {
  439. height: math.unit(35, "meters"),
  440. image: { source: "./media/objects/plants/sycamore-tree.svg" },
  441. name: "Sycamore",
  442. rename: true
  443. }
  444. }
  445. )
  446. })
  447. results.push({
  448. name: "Vending Machine",
  449. constructor: () => makeObject(
  450. "Vending Machine",
  451. {
  452. object: {
  453. height: math.unit(183, "cm"),
  454. mass: math.unit(347, "kg"),
  455. image: { source: "./media/objects/vending-machine.svg" },
  456. name: "Vending Machine"
  457. }
  458. }
  459. )
  460. })
  461. results.push({
  462. name: "International Space Station",
  463. constructor: () => makeObject(
  464. "International Space Station",
  465. {
  466. object: {
  467. height: math.unit(209, "feet"),
  468. mass: math.unit(925300, "lbs"),
  469. image: { source: "./media/objects/international-space-station.svg" },
  470. name: "International Space Station"
  471. }
  472. }
  473. )
  474. })
  475. results.push(
  476. makeHeightWeight([
  477. ["blue-whale", 4.5, 125e3],
  478. ["sperm-whale", 3, 42e3],
  479. ["dairy-cow", 1.7, 800],
  480. ["horse", 2.08, 550],
  481. ["african-elephant", 3.2, 4000]
  482. ],
  483. "Animals"
  484. ));
  485. results.push(
  486. makeHeightWeight([
  487. ["brachiosaurus", 13, 56e3],
  488. ["pterodactyl", 2.3, 200],
  489. ["stegosaurus", 4.5, 7e3],
  490. ["tyrannosaurus", 5.2, 14e3],
  491. ["velociraptor", 1.6, 15]
  492. ],
  493. "Dinosaurs"
  494. ));
  495. results.sort((b1, b2) => {
  496. e1 = b1.constructor();
  497. e2 = b2.constructor();
  498. return -math.subtract(e1.views[e1.defaultView].height, e2.views[e2.defaultView].height).value;
  499. });
  500. return results;
  501. }