Disclaimer: I don't know anything about three.js . I just did a bit of OpenGL.
Your Euler angles come from the projected image on the model (lines 74-80). I do not see this logic.
If your div is on the surface of the sphere, then it should be oriented along the normal of the sphere at the location of the div. Fortunately, you already have these angles. They are called rotation .
If you replace the Euler angles in lines 82-84 with the rotation angles used to place the div, then in my browser the div appears on the edge when it is on the edge of the circle, and collide with it when it is in the center. It looks like it is moving in a circle, moving to the screen. Is this the effect you want?
My change to the related code:
82 var rotX = (rotation.x * (180/ Math.PI)); 83 var rotY = (rotation.y * (180/ Math.PI)); 84 var rotZ = 0;
EDIT
Oh good. The rotation variable is just a camera. He controls the tangent at the equator. You also need to change the accounting orientation for latitude.
Make rotY equal to negative your latitude. Then make sure that this rotation occurs before the equatorial rotation. Rotations are not commutative.
In general, the changes from the code https://jsfiddle.net/ao5wdm04/1/ are as follows:
27 var lat = 45 * Math.PI / 180; ... 82 var rotX = (rotation.x * (180/ Math.PI)); 83 var rotY = - 45; ... 88 document.getElementById('face').style.webkitTransform = 'translate3d(' + x + 'px,' + y + 'px,0px) rotateY('+rotX+'deg) rotateX('+rotY+'deg)';
I don't know how latitude should spread between init and render functions. As I said, I am not familiar with the language.
Bill
source share