2013-06-20 21 views
1

将矩阵应用到网格后,我打印其旋转参数。 重置网格旋转后,缩放和位置并重新应用相同的矩阵 - 旋转参数不等于先前的参数。Three.js:applyMatrix后的混沌网格旋转

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

+0

您研究过'Object3D.applyMatrix()'的源代码吗? – WestLangley

+1

不,看来我必须。 – Paul

+0

@WestLangley:所以,你想说的是'm1'无法重置? – Paul

回答

4

的three.js所渲染处理更新对象matrix,从而使基体与对象的positionrotation一致,scale.

既然你做不拨打render()电话,您需要将mesh.updateMatrix()作为reset()功能的最后一行。

three.js r.58