|
|
@@ -1,25 +1,33 @@ |
|
|
function makeObject(name, height, mass, image) { |
|
|
|
|
|
views = { |
|
|
|
|
|
object: { |
|
|
|
|
|
|
|
|
function makeObject(name, viewInfo) { |
|
|
|
|
|
views = {}; |
|
|
|
|
|
console.log(viewInfo) |
|
|
|
|
|
|
|
|
|
|
|
Object.entries(viewInfo).forEach(([key, value]) => { |
|
|
|
|
|
console.log(key) |
|
|
|
|
|
views[key] = { |
|
|
attributes: { |
|
|
attributes: { |
|
|
height: { |
|
|
height: { |
|
|
name: "Height", |
|
|
name: "Height", |
|
|
power: 1, |
|
|
power: 1, |
|
|
type: "length", |
|
|
type: "length", |
|
|
base: height |
|
|
|
|
|
}, |
|
|
|
|
|
mass: { |
|
|
|
|
|
name: "Mass", |
|
|
|
|
|
power: 3, |
|
|
|
|
|
type: "mass", |
|
|
|
|
|
base: mass |
|
|
|
|
|
|
|
|
base: value.height |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
image: image, |
|
|
|
|
|
|
|
|
image: value.image, |
|
|
name: "Object" |
|
|
name: "Object" |
|
|
} |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (value.mass) { |
|
|
|
|
|
views[key].attributes[key] = { |
|
|
|
|
|
name: "Mass", |
|
|
|
|
|
power: 3, |
|
|
|
|
|
type: "mass", |
|
|
|
|
|
base: value.mass |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
console.log(views) |
|
|
return makeEntity(name, "Object", views); |
|
|
return makeEntity(name, "Object", views); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -30,9 +38,30 @@ function makeObjects() { |
|
|
name: "Soda Can", |
|
|
name: "Soda Can", |
|
|
constructor: () => makeObject( |
|
|
constructor: () => makeObject( |
|
|
"Soda Can", |
|
|
"Soda Can", |
|
|
math.unit(4.83, "inches"), |
|
|
|
|
|
math.unit(15, "grams"), |
|
|
|
|
|
{ source: "./media/objects/soda-can.svg" } |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
front: { |
|
|
|
|
|
height: math.unit(4.83, "inches"), |
|
|
|
|
|
mass: math.unit(15, "grams"), |
|
|
|
|
|
image: { source: "./media/objects/soda-can.svg" } |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
results.push({ |
|
|
|
|
|
name: "Sewing Pin", |
|
|
|
|
|
constructor: () => makeObject( |
|
|
|
|
|
"Sewing Pin", |
|
|
|
|
|
{ |
|
|
|
|
|
side: { |
|
|
|
|
|
height: math.unit(1.5, "inches"), |
|
|
|
|
|
image: { source: "./media/objects/sewing-pin.svg" } |
|
|
|
|
|
}, |
|
|
|
|
|
top: { |
|
|
|
|
|
height: math.unit(2, "millimeters"), |
|
|
|
|
|
image: { source: "./media/objects/pin-head.svg" } |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
) |
|
|
) |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|