import { RegisterComponent } from '@feng3d/ecs'; import { OrthographicCamera } from '../../thirdparty/three/imports'; import { Camera3D } from './Camera3D'; declare module '@feng3d/ecs' { interface ComponentMap { OrthographicCamera3D: OrthographicCamera3D; } } export interface OrthographicCamera3D { get _camera(): OrthographicCamera; set _camera(v); } /** * 3D透视摄像机,包装`three`中`PerspectiveCamera`。 */ @RegisterComponent({ name: 'OrthographicCamera3D' }) export class OrthographicCamera3D extends Camera3D { get left() { if (this._camera) { this._left = this._camera.left; } return this._left; } set left(v) { this._left = v; if (this._camera) { this._camera.left = this._left; } } private _left: number; get right() { if (this._camera) { this._right = this._camera.right; } return this._right; } set right(v) { this._right = v; if (this._camera) { this._camera.right = this._right; } } private _right: number; get top() { if (this._camera) { this._top = this._camera.top; } return this._top; } set top(v) { this._top = v; if (this._camera) { this._camera.top = this._top; } } private _top: number; get bottom() { if (this._camera) { this._bottom = this._camera.bottom; } return this._bottom; } set bottom(v) { this._bottom = v; if (this._camera) { this._camera.bottom = this._bottom; } } private _bottom: number; get near() { if (this._camera) { this._near = this._camera.near; } return this._near; } set near(v) { this._near = v; if (this._camera) { this._camera.near = v; } } private _near: number; get far() { if (this._camera) { this._far = this._camera.far; } return this._far; } set far(v) { this._far = v; if (this._camera) { this._camera.far = v; } } private _far: number; get zoom() { if (this._camera) { this._zoom = this._camera.zoom; } return this._zoom; } set zoom(v) { this._zoom = v; if (this._camera) { this._camera.zoom = v; } } private _zoom: number; init() { this._camera = new OrthographicCamera(this.left, this.right, this.top, this.bottom, this.near, this.far); this._entity.isOrthographicCamera = true; super.init(); } destroy(): void { super.destroy(); this._entity.isOrthographicCamera = false; } updateProjectionMatrix() { this._camera.updateProjectionMatrix(); } }