Rotate text to face user when camera is rotated

送分小仙女□ 提交于 2020-01-03 04:54:10

问题


If you take a look at my fiddle:

http://jsfiddle.net/jmg157/Y35cQ/1/

You'll see I have grid labels on the cube axes. What I'd like to do is whenever the user rotates around the cube, have the text rotate as well so that the numbers are always facing the user.

I tried things like xMarks.rotation = camera.rotation, where xMarksare the text objects, but no success. Any suggestions would be greatly appreciated.


回答1:


three.js is now quaternion-based.

To make the text created with THREE.PlaneGeometry face the camera, do this:

mesh.quaternion = camera.quaternion; // EDIT - see note below

Updated fiddle: http://jsfiddle.net/Y35cQ/2/

An alternative is to use THREE.Sprite, which always faces the camera.

three.js r.63


EDIT - mesh.quaternion = camera.quaternion; no longer works. You must use this pattern instead:

mesh.quaternion.copy( camera.quaternion );

three.js r.67



来源:https://stackoverflow.com/questions/20470516/rotate-text-to-face-user-when-camera-is-rotated

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!