如何在three.js中使用3X3矩阵进行旋转 [英] How to make rotation use 3X3 matrix in three.js
本文介绍了如何在three.js中使用3X3矩阵进行旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 3X3 矩阵,如下所示:
I have a 3X3 matrix, like this:
[ a11 a12 a13 ]
[ a21 a22 a23 ]
[ a31 a32 a33 ]
但是我怎样才能在 THREE.js 中使用这个矩阵来旋转网格.
but how can I make rotation use this matrix to a mesh in THREE.js.
推荐答案
您想通过矩阵指定网格的方向.为此,您可以使用以下两种模式之一:
You want to specify a mesh's orientation via a matrix. To do so, you can use one of the following two patterns:
var matrix = new THREE.Matrix4(); // create once and reuse it
matrix.set(
a11, a12, a13, 0,
a21, a22, a23, 0,
a31, a32, a33, 0,
0, 0, 0, 1
);
如果你知道矩阵是一个旋转矩阵(即不涉及缩放),
If you know the matrix is a rotation matrix (i.e., no scaling involved),
mesh = new THREE.Mesh( geometry, material );
mesh.quaternion.setFromRotationMatrix( matrix );
否则,
mesh = new THREE.Mesh( geometry, material );
mesh.applyMatrix( matrix );
three.js r.94
three.js r.94
这篇关于如何在three.js中使用3X3矩阵进行旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文