将孩子从一个父母移动到另一个父母,同时保持世界坐标相同

时间:2017-03-02 05:30:14

标签: three.js

我正试图从一个偏离中心并且可能轮换的父母那里带一个孩子;但是,当我从这个节点中取一个孩子并将其作为子节点添加到另一个节点时,我想更新一些基本属性,如位置,比例和旋转。

有什么想法吗?

2 个答案:

答案 0 :(得分:1)

首先使用分离然后附加在对象上将起作用。

WATCH OUT:两种方法都没有相同的参数顺序。

// remove child from parent and add it to scene
THREE.SceneUtils.detach( child, parent, scene );

// remove child from scene and add it to parent
THREE.SceneUtils.attach( child, scene, parent );

答案 1 :(得分:1)

THREE.SceneUtils已过时。您应该使用:

// remove child from parent and add it to scene
scene.attach( child );

// remove child from scene and add it to parent
parent.attach( child );