Matrix4.makePerspective()
是 three.js
库中 Matrix4
类的方法之一。它用于根据摄像机的视锥体参数构建透视投影矩阵。
Matrix4.makePerspective(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix4
left
(number
) :视锥体左侧面距离摄像机的距离。right
(number
) :视锥体右侧面距离摄像机的距离。bottom
(number
) :视锥体下方面距离摄像机的距离。top
(number
) :视锥体上方面距离摄像机的距离。near
(number
) :视锥体近处面距离摄像机的距离。far
(number
) :视锥体远处面距离摄像机的距离。Matrix4
:透视投影矩阵。
const fov = 45;
const aspect = window.innerWidth / window.innerHeight;
const near = 0.1;
const far = 1000;
const cameraMatrix = new THREE.Matrix4().makePerspective(
(fov / 2) * (Math.PI / 180),
aspect,
near,
far
);