film_adapter/layout.js

36 lines
910 B
JavaScript

function rotatePoint(centerX, centerY, distance, angleInDegrees) {
const angleInRadians = angleInDegrees * (Math.PI / 180);
const x = centerX + (distance * Math.cos(angleInRadians));
const y = centerY + (distance * Math.sin(angleInRadians));
return { x, y, z : 0 };
}
let plastic = [
'gray_plastic2',
'yellow_plastic',
'neonblue_plastic'
]
let obj = [
'adapter_16mm_core',
'adapter_16mm_to_super8_reel',
'adapter_super8_to_16mm_core'
];
let meta = {
objects : []
}
let starting = -45; //33/2; //(360 / (obj.length * 2));
for (let i = 0; i < obj.length; i++) {
meta.objects.push ({
name : obj[i],
material : plastic[i],
position : rotatePoint(0, 0, 40, starting + (i * (360 / obj.length))),
rotation : {
x : 0,
y : 0,
z : starting + (i * (360 / obj.length))
}
});
}
console.log(JSON.stringify(meta, null, '\t'))