cione-comp-lib
Version:
`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`
34 lines (33 loc) • 905 B
JavaScript
import Camera from "../Camera.mjs";
var Perspective = Camera.extend(
{
fov: 50,
aspect: 1,
near: 0.1,
far: 2e3
},
{
updateProjectionMatrix: function() {
var rad = this.fov / 180 * Math.PI;
this.projectionMatrix.perspective(rad, this.aspect, this.near, this.far);
},
decomposeProjectionMatrix: function() {
var m = this.projectionMatrix.array;
var rad = Math.atan(1 / m[5]) * 2;
this.fov = rad / Math.PI * 180;
this.aspect = m[5] / m[0];
this.near = m[14] / (m[10] - 1);
this.far = m[14] / (m[10] + 1);
},
clone: function() {
var camera = Camera.prototype.clone.call(this);
camera.fov = this.fov;
camera.aspect = this.aspect;
camera.near = this.near;
camera.far = this.far;
return camera;
}
}
);
var PerspectiveCamera = Perspective;
export { PerspectiveCamera as default };