in src/cameras/CameraData.ts [24:60]
constructor() {
this._updateProjectionMatrix = () => {
// prettier-ignore
this._projectionMatrix = new Matrix4(
2 * this.fx / this.width, 0, 0, 0,
0, -2 * this.fy / this.height, 0, 0,
0, 0, this.far / (this.far - this.near), 1,
0, 0, -(this.far * this.near) / (this.far - this.near), 0
);
this._viewProj = this.projectionMatrix.multiply(this.viewMatrix);
};
this.update = (position: Vector3, rotation: Quaternion) => {
const R = Matrix3.RotationFromQuaternion(rotation).buffer;
const t = position.flat();
// prettier-ignore
this._viewMatrix = new Matrix4(
R[0], R[1], R[2], 0,
R[3], R[4], R[5], 0,
R[6], R[7], R[8], 0,
-t[0] * R[0] - t[1] * R[3] - t[2] * R[6],
-t[0] * R[1] - t[1] * R[4] - t[2] * R[7],
-t[0] * R[2] - t[1] * R[5] - t[2] * R[8],
1,
);
this._viewProj = this.projectionMatrix.multiply(this.viewMatrix);
};
this.setSize = (width: number, height: number) => {
this._width = width;
this._height = height;
this._updateProjectionMatrix();
};
}