如何设置与添加的网格相同的 Object3D 位置和旋转?[三.js] [英] How to set the Object3D position and rotation same as the added mesh ? [three.js]

查看:37
本文介绍了如何设置与添加的网格相同的 Object3D 位置和旋转?[三.js]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建一个 Object3D 模型并向其添加网格时,如何将添加的网格的位置和旋转设置为与 Object3D 模型相同,例如当我旋转和定位 Object3D 时,角度应该没有差异Object3D 和添加的网格之间的旋转.我如何获得这样的结果?

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?

推荐答案

如果你的 Object3D 模型被称为 obj,那么在 obj.add(mesh) 之后,任何更改为obj (position/rotation/scale) 会以同样的方式改变mesh.

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.

如果您不想将 mesh 附加到 obj,但您仍然希望它们具有相同的位置和旋转,则可以尝试

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;

希望这有帮助!

这篇关于如何设置与添加的网格相同的 Object3D 位置和旋转?[三.js]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆