Translate a vector from global space to local vector in three.js

回眸只為那壹抹淺笑 提交于 2019-12-14 03:54:07

问题


With a rotated object in my scene, how can I translate a global vector into the local space of that rotated object, so that they are rendered in the same spot of the global vector?

Take for example a cube that is rotated but at the global origin. Now I would like to render lines for each global dimension (x, y, z), but added as children to the rotated cube, not the global scene. How do I calculate and in three.js implement the rotation of those vectors so they will line up?


回答1:


You want to add an object as a child of a parent object such that the world position and orientation of the child do not change.

You can do that using the following pattern:

parent.attach( object );

three.js r.107



来源:https://stackoverflow.com/questions/26400570/translate-a-vector-from-global-space-to-local-vector-in-three-js

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