I'm trying to convert a 3D point on a sphere into a UV point on the sphere's texture. Can someone provide guidance or a pure math solution?
Edit:
Currently, I have this code snippet, but it doesn't give the correct UV coordinate.
Here, p represents the 3D point on the sphere, and mesh.position is the position of the sphere.
var x = (p.x - mesh.position.x) / 500;
var y = (p.y - mesh.position.y) / 500;
var z = (p.z - mesh.position.z) / 500;
var u = Math.atan2(x, z) / (2 * Math.PI) + 0.5;
var v = Math.asin(y) / Math.PI + 0.5;