Three.js:applyMatrix之后的混乱网格旋转

Pau*_*aul 1 transformation mesh matrix three.js

将矩阵应用于网格后,我打印其旋转参数.重置网格旋转后,缩放和定位并重新应用相同的矩阵 - 旋转参数不等于先前的参数.

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 !!!
Run Code Online (Sandbox Code Playgroud)

Three.js r.58

Wes*_*ley 5

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

由于您没有render()拨打电话,因此需要添加mesh.updateMatrix()为功能的最后一行reset().

three.js r.58