Reputation: 1044
I'm trying to make bones and then transform the vertices of each bone, but I can't figure out what syntax I need to use. For example I tried:
var v = new THREE.Vector3(0,0,0);
var b = new THREE.Bone();
b.position.x = 5;
b.position.y = 5;
b.position.z = 5;
b.updateMatrix();
v.applyMatrix4(b.matrixWorld);
console.log(v);
Expecting the new coordinates of vector v to be (5,5,5), however the console.log output is (0,0,0). Is there something I'm missing?
Upvotes: 1
Views: 1786
Reputation: 211277
See THREE.Object3D:
updateMatrix()
updates the local transformation (Object3D.matrix
), but updateMatrixWorld()
update the global transform of the object and its children (Object3D.matrix
and Object3D.matrixWorld
).
This means, that you either have to use the Object3D.matrix
property:
b.updateMatrix();
v.applyMatrix4(b.matrix);
Or you have to updateMatrixWorld()
:
b.updateMatrixWorld();
v.applyMatrix4(b.matrixWorld);
Upvotes: 1