设置three.js投影矩阵方向

时间:2022-06-26 04:13:46

I read following codes writing for webgl, and I want rewrite it using three.js. But I could not find any way to do so, please help me.

我读了下面为webgl写的代码,我想用three.js重写它。但我找不到任何办法,请帮助我。

pMatrix = mat4.create();
mat4.perspective(pMatrix,1.01,gl.drawingBufferWidth/gl.drawingBufferHeight, 10.0, 300000.0);
var eciMat = [1,  0,  0,  0,
           0,  0, -1,  0,
           0,  1,  0,  0,
           0,  0,  0,  1
           ];
mat4.mul(pMatrix, pMatrix, eciMat );

1 个解决方案

#1


0  

Matrix classes are pretty sophisticated in Three.js, look at the docs here: http://threejs.org/docs/#Reference/Math/Matrix4

矩阵类在Three.js中非常复杂,请查看这里的文档:http://threejs.org/docs/#Reference/Math/Matrix4

Here's how I would write it in Three.js

以下是我将如何在Three.js中编写它

// Arguments are fov, aspect, near, far
var perspectiveMatrix = new THREE.Matrix4().makePerspective(30, 1, 0.01, 20);

var eciMatrix = new THREE.Matrix4();
eciMatrix.set(1,  0,  0,  0,
              0,  0, -1,  0,
              0,  1,  0,  0,
              0,  0,  0,  1);

var resultMatrix = new THREE.Matrix4();
resultMatrix.multiply(eciMatrix);
resultMatrix.multiply(perspectiveMatrix);
resultMatrix.multiply(perspectiveMatrix);

console.log(resultMatrix);

#1


0  

Matrix classes are pretty sophisticated in Three.js, look at the docs here: http://threejs.org/docs/#Reference/Math/Matrix4

矩阵类在Three.js中非常复杂,请查看这里的文档:http://threejs.org/docs/#Reference/Math/Matrix4

Here's how I would write it in Three.js

以下是我将如何在Three.js中编写它

// Arguments are fov, aspect, near, far
var perspectiveMatrix = new THREE.Matrix4().makePerspective(30, 1, 0.01, 20);

var eciMatrix = new THREE.Matrix4();
eciMatrix.set(1,  0,  0,  0,
              0,  0, -1,  0,
              0,  1,  0,  0,
              0,  0,  0,  1);

var resultMatrix = new THREE.Matrix4();
resultMatrix.multiply(eciMatrix);
resultMatrix.multiply(perspectiveMatrix);
resultMatrix.multiply(perspectiveMatrix);

console.log(resultMatrix);