Matrix3.setFromMatrix4(matrix)
方法用于将4x4矩阵转换为3x3矩阵。
matrix
:矩阵(Matrix4
类型)- 要转换为3x3矩阵的4x4矩阵。以下示例将4x4矩阵转换为3x3矩阵:
var matrix4 = new THREE.Matrix4();
var matrix3 = new THREE.Matrix3();
// set values of matrix4
matrix3.setFromMatrix4(matrix4);
该方法没有返回值。它会将原始矩阵转换为3x3矩阵。
以下示例将一个旋转矩阵转换为3x3矩阵:
var matrix4 = new THREE.Matrix4();
matrix4.makeRotationY(Math.PI / 4); // rotate 45 degrees around Y-axis
var matrix3 = new THREE.Matrix3();
matrix3.setFromMatrix4(matrix4);
console.log(matrix3.elements); // outputs "0.7071067811865475,0,0,0,1,0,0,0,0.7071067811865475"