less copy protection, more size visualization
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

142 строки
3.8 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. }
  16. if (value.mass) {
  17. views[key].attributes[key] = {
  18. name: "Mass",
  19. power: 3,
  20. type: "mass",
  21. base: value.mass
  22. };
  23. }
  24. });
  25. return makeEntity({ name: name }, views);
  26. }
  27. function makeObjects() {
  28. const results = [];
  29. results.push({
  30. name: "Soda Can",
  31. constructor: () => makeObject(
  32. "Soda Can",
  33. {
  34. front: {
  35. height: math.unit(4.83, "inches"),
  36. mass: math.unit(15, "grams"),
  37. image: { source: "./media/objects/soda-can.svg" },
  38. name: "Side"
  39. }
  40. }
  41. )
  42. });
  43. results.push({
  44. name: "Sewing Pin",
  45. constructor: () => makeObject(
  46. "Sewing Pin",
  47. {
  48. side: {
  49. height: math.unit(1.5, "inches"),
  50. image: { source: "./media/objects/sewing-pin.svg" },
  51. name: "Side"
  52. },
  53. top: {
  54. height: math.unit(2, "millimeters"),
  55. image: { source: "./media/objects/pin-head.svg" },
  56. name: "Head"
  57. }
  58. }
  59. )
  60. });
  61. results.push({
  62. name: "Lamp",
  63. constructor: () => makeObject(
  64. "Lamp",
  65. {
  66. lamp: {
  67. height: math.unit(30, "inches"),
  68. mass: math.unit(10, "lbs"),
  69. image: { source: "./media/objects/lamp.svg" },
  70. name: "Lamp"
  71. }
  72. }
  73. )
  74. });
  75. results.push({
  76. name: "Human",
  77. constructor: () => makeObject(
  78. "Human",
  79. {
  80. woman1: {
  81. height: math.unit(5 + 4/12, "feet"),
  82. mass: math.unit(140, "lbs"),
  83. image: { source: "./media/objects/humans/woman-1.svg" },
  84. name: "Woman 1"
  85. },
  86. man1: {
  87. height: math.unit(5 + 6/12, "feet"),
  88. mass: math.unit(150, "lbs"),
  89. image: { source: "./media/objects/humans/man-1.svg" },
  90. name: "Man 1"
  91. },
  92. }
  93. )
  94. });
  95. results.push({
  96. name: "Nail Polish",
  97. constructor: () => makeObject(
  98. "Nail Polish",
  99. {
  100. bottle: {
  101. height: math.unit(3.25, "inches"),
  102. mass: math.unit(66, "g"),
  103. image: { source: "./media/objects/nail-polish.svg" },
  104. name: "Bottle"
  105. }
  106. }
  107. )
  108. });
  109. results.push({
  110. name: "Shot Glass",
  111. constructor: () => makeObject(
  112. "Shot Glass",
  113. {
  114. bottle: {
  115. height: math.unit(2 + 3/8, "inches"),
  116. mass: math.unit(75, "g"),
  117. image: { source: "./media/objects/shot-glass.svg" },
  118. name: "Bottle"
  119. }
  120. }
  121. )
  122. });
  123. results.sort((b1, b2) => {
  124. e1 = b1.constructor();
  125. e2 = b2.constructor();
  126. return -math.subtract(e1.views[e1.defaultView].height, e2.views[e2.defaultView].height).value;
  127. });
  128. return results;
  129. }