My math skills aren't the best, and I'm finding this to be a challenge.
I have managed to convert latitude and longitude into a target:
lat = Math.max(-85, Math.min(85, lat));
phi = THREE.Math.degToRad(90 - lat);
theta = THREE.Math.degToRad(lon);
target.x = 512 * Math.sin(phi) * Math.cos(theta);
target.y = 512 * Math.cos(phi);
target.z = 512 * Math.sin(phi) * Math.sin(theta);
Could someone guide me on how I can reverse this process, specifically converting a Vector back into latitude and longitude?