Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextGeometry to always face user?

Tags:

three.js

I've added some text to my scene with THREE.TextGeometry, and the text seems to be stuck in whichever xy plane I place it. Any way to have it adjust to always be in plane with the screen- readable for the user?

like image 388
user1750723 Avatar asked Oct 16 '12 16:10

user1750723


2 Answers

Try

mesh.lookAt( camera.position );

The local z-axis of the mesh should then point toward the camera.

like image 132
WestLangley Avatar answered Sep 20 '22 11:09

WestLangley


To make the text always face the screen (rather than the camera):

mesh.quaternion.copy(camera.quaternion);

Note that this differs from object.lookAt(camera); since this will result in different orientation depending on where on the screen the object is located. Object3D.onBeforeRender can be used to update the orientation on each frame. It might be useful to disable frustum culling using Object3D.frustumCulled = false; to ensure that the callback always is triggered.

like image 21
larsmoa Avatar answered Sep 19 '22 11:09

larsmoa