设置three.js投影矩阵方向

时间:2015-11-21 09:44:33

标签: javascript three.js webgl

我读了下面为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 个答案:

答案 0 :(得分:0)

在Three.js中,Matrix类非常复杂,请查看文档:{​​{3}}

以下是我将如何在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);