【问题标题】:Three.js: chaotic mesh rotation after applyMatrixThree.js:applyMatrix后的混乱网格旋转
【发布时间】:2013-06-17 18:54:32
【问题描述】:

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

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

【问题讨论】:

  • 你研究过Object3D.applyMatrix()的源码吗?
  • 没有。看来我不得不这样做了。
  • @WestLangley:所以,你想说的是m1 无法重置?

标签: matrix three.js transformation mesh


【解决方案1】:

three.js 渲染器处理更新对象matrix,使矩阵与对象的positionrotationscale.保持一致

由于您没有进行render() 调用,因此您需要将mesh.updateMatrix() 添加为reset() 函数的最后一行。

three.js r.58

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-19
    • 2013-04-11
    • 1970-01-01
    • 1970-01-01
    • 2015-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多