import { Matrix } from './babylonjs-import';
import { ProjectionMatrix } from '../math/ProjectionMatrix';
export class ShortFrustumProjectionMatrixState {
    _invertedShortFrustumProjectionMatrix = Matrix.Identity();
    _shortFrustumProjectionMatrix = Matrix.Identity();
    _originalProjectionMatrix = Matrix.Identity();
    depthRenderCameraMinZ = 0.25;
    depthRenderCameraMaxZ = 600.0;
    _camera;
    calculateShortFrustumProjectionMatrix(camera) {
        this._originalProjectionMatrix.copyFrom(camera.getProjectionMatrix());
        ProjectionMatrix.getToRef(camera, { minZ: this.depthRenderCameraMinZ, maxZ: this.depthRenderCameraMaxZ }, this._shortFrustumProjectionMatrix);
        this._shortFrustumProjectionMatrix.invertToRef(this._invertedShortFrustumProjectionMatrix);
    }
    updateMatricesIfNeeded() {
        const currentProjectionMatrix = this._camera.getProjectionMatrix();
        const savedProjectionMatrix = this._originalProjectionMatrix;
        if (currentProjectionMatrix.updateFlag !== savedProjectionMatrix.updateFlag) {
            this.calculateShortFrustumProjectionMatrix(this._camera);
        }
    }
    getProjectionMatrix() {
        this.updateMatricesIfNeeded();
        return this._shortFrustumProjectionMatrix;
    }
    getInvertedProjectionMatrix() {
        this.updateMatricesIfNeeded();
        return this._invertedShortFrustumProjectionMatrix;
    }
    constructor(camera) {
        this._camera = camera;
        this.calculateShortFrustumProjectionMatrix(camera);
    }
}
//# sourceMappingURL=ShortFrustumProjectionMatrixState.js.map