import { mat4, vec3 } from 'gl-matrix'; import { GLsizei2 } from './tuples'; /** * Virtual 3D camera specified by eye, center, up, fovy, near, far, and a viewport size. It provides access to cached * view, projection, and view projection matrices. Cached by means of whenever one of the attributes change, all * matrices are invalidated and recalculated only once and only when requested. Please note that eye denotes the * position in a virtual 3D scene and center denotes the position which is being looked at. */ export declare class Camera { private static readonly DEFAULT_EYE; private static readonly DEFAULT_CENTER; private static readonly DEFAULT_UP; private static readonly DEFAULT_FOVY; private static readonly DEFAULT_NEAR; private static readonly DEFAULT_FAR; /** @see {@link eye} */ protected _eye: vec3; /** @see {@link center} */ protected _center: vec3; /** @see {@link up} */ protected _up: vec3; /** @see {@link fovy} */ protected _fovy: number; /** @see {@link near} */ protected _near: number; /** @see {@link far} */ protected _far: number; /** @see {@link viewport} */ protected _viewport: GLsizei2; /** @see {@link aspect} */ protected _aspect: GLfloat; /** @see {@link view} */ protected _view: mat4 | undefined; /** @see {@link viewInverse} */ protected _viewInverse: mat4 | undefined; /** @see {@link projection} */ protected _projection: mat4 | undefined; /** @see {@link projectionInverse} */ protected _projectionInverse: mat4 | undefined; /** @see {@link viewProjection} */ protected _viewProjection: mat4 | undefined; /** @see {@link viewProjectionInverse} */ protected _viewProjectionInverse: mat4 | undefined; /** @see {@link postViewProjection} */ protected _postViewProjection: mat4 | undefined; /** @see {@link altered} */ protected _altered: boolean; /** * Computes a vertical field of view angle based on the display height and distance to eye. Since both parameters * are highly dependent of the device, this function can only be used to derive a rough estimate for a reasonable * field of view. Note that both parameters should be passed using the same unit, e.g., inch or centimeters. * @param elementDisplayHeight - Height of an element on the display. * @param eyeToDisplayDistance - Distance from the users eye to that element. * @returns - Vertical field of view angle in radian. */ static calculateFovY(elementDisplayHeight: number, eyeToDisplayDistance: number): number; /** * Constructor setting up the camera's eye, center and up vectors. * @param eye - The viewpoint of the virtual camera * @param center - The look-at point in the scene * @param up - The up-vector of the virtual camera */ constructor(eye?: vec3, center?: vec3, up?: vec3); /** * Invalidates derived matrices, i.e., view, projection, and view-projection. The view should be invalidated on * eye, center, and up changes. The projection should be invalidated on fovy, viewport, near, and far changes. * The view projection invalidates whenever either one or both view and projection are to be invalidated. */ protected invalidate(invalidateView: boolean, invalidateProjection: boolean, invalidateOnlyViewProjection?: boolean): void; /** * Position of the virtual camera in a virtual 3D scene, the point of view. */ get eye(): vec3; /** * Sets the eye. Invalidates the view. */ set eye(eye: vec3); /** * Look-at point into a virtual 3D scene. */ get center(): vec3; /** * Sets the center. Invalidates the view. */ set center(center: vec3); /** * Up-vector of the virtual camera. */ get up(): vec3; /** * Sets the up vector. Invalidates the view. */ set up(up: vec3); /** * Vertical field of view in degree. */ get fovy(): GLfloat; /** * Sets the vertical field-of-view in degrees. Invalidates the projection. */ set fovy(fovy: GLfloat); /** * Sets the horizontal field-of-view in degrees. Invalidates the projection. * Note that internally, this will be translated to the corresponding the vertical field. */ set fovx(fovx: GLfloat); /** * With this function the view of a physical camera can be emulated. The width and focal length of * a lens are used to generate the correct field of view. * Blender camera presets can be imported by using the camera setting 'HorizontalFit' and using the * width and focal length values in this function. * See: https://www.scantips.com/lights/fieldofviewmath.html * @param sensorWidth - Width of the sensor in mm * @param focalLength - Focal length of the lens in mm */ fovFromLens(sensorWidth: number, focalLength: number): void; /** * Distance of near-plane in view coordinates. */ get near(): GLfloat; /** * Sets the distance to the near clipping plane. Invalidates the projection. */ set near(near: GLfloat); /** * Distance of far-plane in view coordinates. */ get far(): GLfloat; /** * Sets the distance to the far clipping plane. Invalidates the projection. */ set far(far: GLfloat); /** * Sets the viewport size. Invalidates the projection. */ set viewport(size: GLsizei2); /** * The size of the target viewport used to determine the aspect ratio for subsequent perspective matrix projection * computation. */ get viewport(): GLsizei2; /** * Access to the viewport width. */ get width(): GLsizei; /** * Access to the viewport height. */ get height(): GLsizei; /** * Sets the aspect ratio (width over height). However, this is not derived from viewport to allow for * differentiation between viewport size and scale. */ set aspect(aspect: GLfloat); /** * Computes the ratio of width over height (set explicitly for differentiation between viewport size and scale). */ get aspect(): GLfloat; /** * Either returns the cached view matrix or derives the current one after invalidation and caches it. */ get view(): mat4; /** * Either returns the inverse cached view matrix or derives the current one after invalidation and caches it. */ get viewInverse(): mat4 | undefined; /** * Either returns the cached projection matrix or derives the current one after invalidation and caches it. */ get projection(): mat4; /** * Either returns the cached inverse projection matrix or derives the current one after invalidation and caches it. */ get projectionInverse(): mat4 | undefined; /** * Returns the view projection matrix based on view and projection. This is also cached (since matrix * multiplication is involved). */ get viewProjection(): mat4; /** * Returns the inverse view projection matrix based on view and projection. This is also cached (since matrix * multiplication is involved). */ get viewProjectionInverse(): mat4 | undefined; /** * Returns the matrix which contains the operations that are applied to the viewProjection matrix. * For now this is only used by the TiledRenderer to adjust the NDC-coordinates to the tile. */ get postViewProjection(): mat4; /** * Sets the matrix which contains the operations that are applied to the viewProjection matrix. * For now this is only used by the TiledRenderer to adjust the NDC-coordinates to the tile. */ set postViewProjection(matrix: mat4); /** * Whether or not any other public property has changed. Please note that the alteration status is detached from * caching state of lazily computed properties. */ get altered(): boolean; /** * Intended for resetting alteration status. */ set altered(status: boolean); }