JSFiddle - React, Tailwind, and code Playground
by Michael Prosser
JavaScript
var constellations = Array(
{
point: {
x: -1,
y: 0,
z: 0
},
hand: { // rotation of controller at this point in time
x: 0,
y: -1,
z: 0
}
},
{
point: {
x: 0,
y: 0,
z: 0
},
hand: { // rotation of controller at this point in time
x: 0,
y: 0,
z: 0
}
},
{
point: {
x: 0,
y: 1,
z: 0
},
hand: { // rotation of controller at this point in time
x: 0.5,
y: 0,
z: 0
}
},
{
point: {
x: 1,
y: 1,
z: 0
},
hand: { // rotation of controller at this point in time
x: 0.5,
y: 0.5,
z: 0
}
}
);
function getPointFromAngles(rotation){
var point = {
x: rotation.y,
y: rotation.x
}
return point;
}
function mapUVs(data){
var points = Array();
var start = getPointFromAngles(data[0].hand);
for(var i=0;i<data.length;i++){
if(i<3){
points.push(getPointFromAngles(data[i].hand));
} else {
points.push(getPointFromAngles(data[0].hand));
points.push(getPointFromAngles(data[i-1].hand));
points.push(getPointFromAngles(data[i].hand));
}
}
return points;
}
console.log(mapUVs(constellations));