简体   繁体   English

如何设置与添加的网格相同的Object3D位置和旋转? [three.js]

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

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. 当我创建一个Object3D模型并向其添加网格时,如何将添加的网格的位置和旋转设置为与Object3D模型相同,就像当我旋转并放置Object3D时,两者之间的旋转角度应该没有差异Object3D和添加的网格。 How do I achieve such result? 我如何获得这样的结果?

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. 如果您的Object3D模型称为obj ,那么在obj.add(mesh)之后,对obj任何更改(位置/旋转/比例)都会以相同的方式更改mesh

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附加到obj ,但仍然希望它们具有相同的位置和旋转度,则可以尝试

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

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM