问题描述
将矩阵应用于网格后,我将打印其旋转参数.重置网格旋转后,缩放比例和位置并重新应用相同的矩阵-旋转参数不等于先前的参数.
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
的更新,以使矩阵与对象的position
,rotation
和
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之后的混沌网格旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!