I'm trying to plot country names of the globe, so the text meshes will be aligned with the surface, but I'm failing to calculate proper rotations. For text I'm using THREE.TextGeometry. The name appears on the click of the mesh of the country at the point of intersection using raycasting. I'm lacking knowledge of how to turn these coordinates to proper rotation angles. I'm not posting my code, as it's complete mess and I believe for a knowldgeable person will be easier to explain how to achieve this in general.
Here is desired result:
The other solution, which I tried (and which, of course, is not the ultimate), based on this SO answer. The idea is to use the normal of the face you intersect with the raycaster.
Seems long, but actually it makes not so much of code:
and in the animation loop:
jsfiddle exmaple
The method works with meshes of any geometry (checked with spheres and boxes though ;) ). And I'm sure there are another better methods.
very interesting question.I have tried this way, we can regard the text as a plane. lets define a normal vector
n
from your sphere center(or position) to point on the sphere surface where you want to display text. I have a simple way to make normal vector right. 1. put the text mesh on sphere center.text.position.copy(sphere.position)
2. make text to the point on sphere surface,text.lookAt(point)
3.relocate text to the point.text.position.copy(point)