less copy protection, more size visualization
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

70 lines
1.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. return results;
  62. }