I'm using three.js combined with face recognition, I want to rotate a sphere that displays my input video according to the detected eye location, the face recognition gives me a X,Y on the texture mapped to the sphere, what is the right way to find the matching angles on the sphere?
I've tried the next code that I've found -
function convert2d3d(r1, r2, x, y) {
// r1 - texture size ?
// r2 - sphere size
// x,y - position I want to reach on the sphere
let z = -1 + 2 * x / r1;
let phi = 2 * Math.PI * y / r1;
let theta = Math.asin(z);
return {
x: r2 * Math.cos(theta) * Math.cos(phi),
y: r2 * Math.cos(theta) * Math.sin(phi),
z: r2 * z,
}
}
But I think I'm not getting the result I need