Three.js:applyMatrix之后的混沌网格旋转 [英] Three.js: chaotic mesh rotation after applyMatrix

查看:594
本文介绍了Three.js:applyMatrix之后的混沌网格旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

Three.js r.58

推荐答案

Three.js渲染器处理对象matrix的更新,以使矩阵与对象的positionrotation

The three.js renderer handles updating the object matrix, so that the matrix is consistent with the object's position, rotation, and scale.

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

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

three.js r.58

这篇关于Three.js:applyMatrix之后的混沌网格旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆