Reputation: 13
I have a 3X3 matrix, like this:
[ a11 a12 a13 ]
[ a21 a22 a23 ]
[ a31 a32 a33 ]
but how can I make rotation use this matrix to a mesh in THREE.js.
Upvotes: 0
Views: 430
Reputation: 104833
You want to specify a mesh's orientation via a matrix. To do so, you can use one of the following two patterns:
var matrix = new THREE.Matrix4(); // create once and reuse it
matrix.set(
a11, a12, a13, 0,
a21, a22, a23, 0,
a31, a32, a33, 0,
0, 0, 0, 1
);
If you know the matrix is a rotation matrix (i.e., no scaling involved),
mesh = new THREE.Mesh( geometry, material );
mesh.quaternion.setFromRotationMatrix( matrix );
Otherwise,
mesh = new THREE.Mesh( geometry, material );
mesh.applyMatrix( matrix );
three.js r.94
Upvotes: 2