How to set the Object3D position and rotation same as the added mesh ? [three.js]

血红的双手。 提交于 2019-12-25 04:12:24

问题


When I create an Object3D model and add the meshes to it, how do I set the position and rotation of the added mesh to same as the Object3D model, like when I rotate and position the Object3D there should be no difference in angle of rotation between the Object3D and the added mesh. How do I achieve such result?


回答1:


If your Object3D model is called obj, then after obj.add(mesh) any changes to obj (position/rotation/scale) will change mesh in the same way.

If instead you don't want mesh to be attached to obj, but you still want them to have the same position and rotation, you could try

mesh.position = obj.position;
mesh.rotation = obj.rotation;

Hope this helps!



来源:https://stackoverflow.com/questions/17147385/how-to-set-the-object3d-position-and-rotation-same-as-the-added-mesh-three-js

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