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.
 
 
 

106 lignes
2.7 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. return results;
  96. }