问题
After applying a matrix to mesh I print its rotation parameters. After resetting mesh rotation, scale and position and re-applying the same matrix - rotation parameters aren't equal to previous ones.
var ctm1 = new THREE.Matrix4();
var ctm2 = new THREE.Matrix4();
ctm1.set(...............);
ctm2.set(...............);
function reset(mesh)
{
mesh.position.set(0,0,0);
mesh.scale.set(5,5,5);
mesh.rotation.set(0,0,0);
}
reset(myMesh);
myMesh.applyMatrix(ctm1);
console.log(myMesh.rotation.x);
reset(myMesh);
myMesh.applyMatrix(ctm2);
reset(myMesh);
myMesh.applyMatrix(ctm1);
console.log(myMesh.rotation.x); //Isn't equal to previous output !!!
Three.js r.58
回答1:
The three.js renderer handles updating the object matrix
, so that the matrix is consistent with the object's position
, rotation
, and scale.
Since you do not make a render()
call, you need to add mesh.updateMatrix()
as the last line of your reset()
function.
three.js r.58
来源:https://stackoverflow.com/questions/17221738/three-js-chaotic-mesh-rotation-after-applymatrix