0
votes

i have got a moving and rotating mesh, i would like to add an absolute positioned / rotated child to the parent Object3D and it should keep its position when the parent element changes position or rotation.

parent_ = new THREE.Object3D()
parent_.add( new THREE.Mesh(new THREE.CubeGeometry(2, 20, 2), new THREE.MeshNormalMaterial()))
child_ = new THREE.Mesh(new THREE.CubeGeometry(30, 3, 30), new THREE.MeshNormalMaterial())
child_.position.set(1,10,1)
parent_.add(child_)
scene.add(parent_);

fiddle

how can i calculate the position / rotation relative to the parent object3d from an absolute positioned / rotated object so it keeps it absolute position?

1
` should keep its position when the parent...` Should keep its absolute position? Then why make it a child of that parent?leonbloy
i know it's circular but still i would like to know how it's done properly.supernova

1 Answers

1
votes

In order to convert between an Object3D's local coordinate system and the world coordinate system, there are methods worldToLocal and localToWorld, see the source code at:

http://github.com/mrdoob/three.js/blob/master/src/core/Object3D.js

for details.