less copy protection, more size visualization
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

393 líneas
12 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. function makeObjects() {
  37. const results = [];
  38. results.push({
  39. name: "Soda Can",
  40. constructor: () => makeObject(
  41. "Soda Can",
  42. {
  43. front: {
  44. height: math.unit(4.83, "inches"),
  45. mass: math.unit(15, "grams"),
  46. image: { source: "./media/objects/soda-can.svg" },
  47. name: "Side"
  48. }
  49. }
  50. )
  51. });
  52. results.push({
  53. name: "Sewing Pin",
  54. constructor: () => makeObject(
  55. "Sewing Pin",
  56. {
  57. side: {
  58. height: math.unit(1.5, "inches"),
  59. image: { source: "./media/objects/sewing-pin.svg" },
  60. name: "Side"
  61. },
  62. top: {
  63. height: math.unit(2, "millimeters"),
  64. image: { source: "./media/objects/pin-head.svg" },
  65. name: "Head"
  66. }
  67. }
  68. )
  69. });
  70. results.push({
  71. name: "Lamp",
  72. constructor: () => makeObject(
  73. "Lamp",
  74. {
  75. lamp: {
  76. height: math.unit(30, "inches"),
  77. mass: math.unit(10, "lbs"),
  78. image: { source: "./media/objects/lamp.svg" },
  79. name: "Lamp"
  80. }
  81. }
  82. )
  83. });
  84. results.push({
  85. name: "Human",
  86. constructor: () => makeObject(
  87. "Human",
  88. {
  89. woman1: {
  90. height: math.unit(5 + 4/12, "feet"),
  91. mass: math.unit(140, "lbs"),
  92. image: { source: "./media/objects/humans/woman-1.svg" },
  93. name: "Woman 1"
  94. },
  95. man1: {
  96. height: math.unit(5 + 6/12, "feet"),
  97. mass: math.unit(150, "lbs"),
  98. image: { source: "./media/objects/humans/man-1.svg" },
  99. name: "Man 1"
  100. },
  101. }
  102. )
  103. });
  104. results.push({
  105. name: "Nail Polish",
  106. constructor: () => makeObject(
  107. "Nail Polish",
  108. {
  109. bottle: {
  110. height: math.unit(3.25, "inches"),
  111. mass: math.unit(66, "g"),
  112. image: { source: "./media/objects/nail-polish.svg" },
  113. name: "Bottle"
  114. }
  115. }
  116. )
  117. });
  118. results.push({
  119. name: "Shot Glass",
  120. constructor: () => makeObject(
  121. "Shot Glass",
  122. {
  123. glass: {
  124. height: math.unit(2 + 3/8, "inches"),
  125. mass: math.unit(75, "g"),
  126. image: { source: "./media/objects/shot-glass.svg" },
  127. name: "Bottle"
  128. }
  129. }
  130. )
  131. });
  132. results.push({
  133. name: "Beer Bottle",
  134. constructor: () => makeObject(
  135. "Beer Bottle",
  136. {
  137. longneck: {
  138. height: math.unit(9, "inches"),
  139. mass: math.unit(200, "g"),
  140. image: { source: "./media/objects/beer-bottle.svg" },
  141. name: "Longneck Bottle"
  142. }
  143. }
  144. )
  145. });
  146. results.push({
  147. name: "Coin",
  148. constructor: () => makeObject(
  149. "Coin",
  150. {
  151. penny: {
  152. height: math.unit(0.75, "inches"),
  153. mass: math.unit(2.5, "g"),
  154. image: { source: "./media/objects/circle.svg" },
  155. name: "Penny",
  156. rename: true
  157. },
  158. nickel: {
  159. height: math.unit(0.835, "inches"),
  160. mass: math.unit(5, "g"),
  161. image: { source: "./media/objects/circle.svg" },
  162. name: "Nickel",
  163. rename: true
  164. },
  165. dime: {
  166. height: math.unit(0.705, "inches"),
  167. mass: math.unit(2.268, "g"),
  168. image: { source: "./media/objects/circle.svg" },
  169. name: "Dime",
  170. rename: true
  171. },
  172. quarter: {
  173. height: math.unit(0.955, "inches"),
  174. mass: math.unit(5.67, "g"),
  175. image: { source: "./media/objects/circle.svg" },
  176. name: "Quarter",
  177. rename: true
  178. },
  179. dollar: {
  180. height: math.unit(1.043, "inches"),
  181. mass: math.unit(8.1, "g"),
  182. image: { source: "./media/objects/circle.svg" },
  183. name: "Dollar Coin",
  184. rename: true
  185. },
  186. }
  187. )
  188. });
  189. results.push({
  190. name: "Pencil",
  191. constructor: () => makeObject(
  192. "Pencil",
  193. {
  194. pencil: {
  195. height: math.unit(7.5, "inches"),
  196. mass: math.unit(7, "g"),
  197. image: { source: "./media/objects/pencil.svg" },
  198. name: "Pencil"
  199. }
  200. }
  201. )
  202. });
  203. results.push({
  204. name: "Balls",
  205. constructor: () => makeObject(
  206. "Balls",
  207. {
  208. golf: {
  209. height: math.unit(1.62, "inches"),
  210. mass: math.unit(45, "g"),
  211. image: { source: "./media/objects/circle.svg" },
  212. name: "Golfball",
  213. rename: true
  214. },
  215. tennis: {
  216. height: math.unit(2.6, "inches"),
  217. mass: math.unit(57, "g"),
  218. image: { source: "./media/objects/circle.svg" },
  219. name: "Tennisball",
  220. rename: true
  221. },
  222. baseball: {
  223. height: math.unit(2.9, "inches"),
  224. mass: math.unit(145, "g"),
  225. image: { source: "./media/objects/circle.svg" },
  226. name: "Baseball",
  227. rename: true
  228. },
  229. volleyball: {
  230. height: math.unit(8, "inches"),
  231. mass: math.unit(270, "g"),
  232. image: { source: "./media/objects/circle.svg" },
  233. name: "Volleyball",
  234. rename: true
  235. }
  236. }
  237. )
  238. });
  239. results.push({
  240. name: "Paperclip",
  241. constructor: () => makeObject(
  242. "Paperclip",
  243. {
  244. paperclip: {
  245. height: math.unit(1.834, "inches"),
  246. mass: math.unit(1, "g"),
  247. image: { source: "./media/objects/paperclip.svg" },
  248. name: "Paperclip"
  249. }
  250. }
  251. )
  252. });
  253. results.push({
  254. name: "Pebbles",
  255. constructor: () => makeObject(
  256. "Pebbles",
  257. {
  258. gravelGrain: {
  259. height: math.unit(20, "mm"),
  260. image: { source: "./media/objects/pebble.svg" },
  261. name: "Grain of gravel",
  262. rename: true
  263. },
  264. sandGrain: {
  265. height: math.unit(0.5, "mm"),
  266. image: { source: "./media/objects/pebble.svg" },
  267. name: "Grain of sand",
  268. rename: true
  269. },
  270. siltGrain: {
  271. height: math.unit(0.03, "mm"),
  272. image: { source: "./media/objects/pebble.svg" },
  273. name: "Grain of silt",
  274. rename: true
  275. },
  276. }
  277. )
  278. });
  279. results.push({
  280. name: "Credit Card",
  281. constructor: () => makeObject(
  282. "Credit Card",
  283. {
  284. creditCard: {
  285. height: math.unit(53.98, "mm"),
  286. image: { source: "./media/objects/credit-card.svg" },
  287. name: "Credit card",
  288. },
  289. creditCardVertical: {
  290. height: math.unit(85.60, "mm"),
  291. image: { source: "./media/objects/credit-card-vertical.svg" },
  292. name: "Credit card (vertical)",
  293. },
  294. }
  295. )
  296. });
  297. results.push({
  298. name: "Molecular",
  299. constructor: () => makeObject(
  300. "Molecular",
  301. {
  302. hydrogen: {
  303. height: math.unit(1.06e-10, "mm"),
  304. mass: math.unit(1, "dalton"),
  305. image: { source: "./media/objects/circle.svg" },
  306. name: "Hydrogen atom",
  307. rename: true
  308. },
  309. proton: {
  310. height: math.unit(1e-15, "mm"),
  311. mass: math.unit(1, "dalton"),
  312. image: { source: "./media/objects/circle.svg" },
  313. name: "Proton",
  314. rename: true
  315. },
  316. }
  317. )
  318. });
  319. results.push({
  320. name: "Fruit",
  321. constructor: () => makeObject(
  322. "Fruit",
  323. {
  324. banana: {
  325. height: math.unit(3.5, "inches"),
  326. image: { source: "./media/objects/fruits/banana.svg" },
  327. name: "Banana",
  328. rename: true
  329. },
  330. bananaVertical: {
  331. height: math.unit(7, "inches"),
  332. image: { source: "./media/objects/fruits/banana-vertical.svg" },
  333. name: "Banana (Vertical)",
  334. rename: true
  335. },
  336. lemon: {
  337. height: math.unit(3.5, "inches"),
  338. image: { source: "./media/objects/fruits/lemon.svg" },
  339. name: "Lemon",
  340. rename: true
  341. },
  342. orange: {
  343. height: math.unit(2.8, "inches"),
  344. image: { source: "./media/objects/fruits/orange.svg" },
  345. name: "Orange",
  346. rename: true
  347. },
  348. grape: {
  349. height: math.unit(0.8, "inches"),
  350. image: { source: "./media/objects/fruits/grape.svg" },
  351. name: "Grape",
  352. rename: true
  353. },
  354. pineapple: {
  355. height: math.unit(17, "inches"),
  356. image: { source: "./media/objects/fruits/pineapple.svg" },
  357. name: "Pineapple",
  358. rename: true
  359. },
  360. }
  361. )
  362. });
  363. results.sort((b1, b2) => {
  364. e1 = b1.constructor();
  365. e2 = b2.constructor();
  366. return -math.subtract(e1.views[e1.defaultView].height, e2.views[e2.defaultView].height).value;
  367. });
  368. return results;
  369. }