mrdoob/three.js — Issue #1226: Updating mesh matrix question...
Author: jayfield1979
Created: 2012-02-01 10:48:52+00:00
State: open

Hey,

I am trying to get the jiglibjs2 3D Phyisics engine to work with Three.js and I have managed to recreate the demo given on the jiglibjs2 projects home page but the version of Three.js used was r36 and I'm guessing things have changed dramatically.

I have already updated all the constructors but there's a problem with updating objects positions/rotations.

Not been familiar with any version of Three.js older than r46 I am stuck with this piece of code:

```javascript```

for ( var i = 0, l = scene.objects.length; i < l; i ++ ) {

var mesh = scene.objects[i];

if (mesh.rigidBody) {

var pos = mesh.rigidBody.get_currentState().position;
var dir = mesh.rigidBody.get_currentState().orientation.get_rawData();

var matrix = new THREE.Matrix4();
matrix.setTranslation( pos.x, pos.y, pos.z );
var rotate = new THREE.Matrix4(dir[0], dir[1], dir[2], dir[3], dir[4], dir[5], dir[6], dir[7], dir[8], dir[9], dir[10], dir[11], dir[12], dir[13], dir[14], dir[15]);
matrix.multiplySelf(rotate);

mesh.matrix = matrix;
mesh.update(false, true, camera);
}
}
```
Basically, mesh.update() is no longer a method and I need to know what the equivalent is in r46. I have read the article about dynamically updating object's and I understand it a little but can't seem to work out how to apply it to the above situation.

p.s. all geometry added to the scene to be used in the rigid body has matrixAutoUpdate set to FALSE.

Thanks for your time.