[Solved] How to get camera position with mouse move event and transform into screen coordinates in three.js? [closed]


I guess, you want the point you are looking at your sphere (probably with earth texture) to be shown on google maps google which requires latitude and longitude. Using 2D screen coordinates seems a weird method to me.

Your camera is probably around the sphere which is at the center of the coordinate system. I would transform the camera position to polar/spherical coordinates, which are to angles (radius doesn’t matter). Then you almost got the lat and long.

polar coordinates

Conversion from your camera position (x,y,z): (Conversion between Spherical and Cartesian Coordinates Systems)

phi angle

theta angle

You need to swap y and z in the formulas and the graphic, because in three.js y is up (and maybe you need to invert z).

Now, you need to tranform phi (ranging from 0 to 2*PI) and theta (0 to PI) to longitude (-180° to 180°) and latitude (-90° to 90°), which should rather easy.

Your greenwich meridian on your sphere should face to the positive x-axis.

(Please correct me, if I’m wrong.)

2

solved How to get camera position with mouse move event and transform into screen coordinates in three.js? [closed]