UNPKG

@osbjs/osbjs

Version:

a minimalist osu! storyboarding framework

183 lines (182 loc) 8.28 kB
import { Quaternion, Vector3 } from '.'; import { Matrix3 } from './Matrix3'; export declare class Matrix4 { m11: number; m12: number; m13: number; m14: number; m21: number; m22: number; m23: number; m24: number; m31: number; m32: number; m33: number; m34: number; m41: number; m42: number; m43: number; m44: number; isIdentity: boolean; translation: Vector3; static readonly Identity: Matrix4; constructor(m11?: number, m12?: number, m13?: number, m14?: number, m21?: number, m22?: number, m23?: number, m24?: number, m31?: number, m32?: number, m33?: number, m34?: number, m41?: number, m42?: number, m43?: number, m44?: number); /** * Calculates the determinant for this matrix. */ determinant(): number; /** * Calculates the determinant for this matrix. */ det(): number; /** * Returns a value that indicates whether this instance and another 3x3 matrix are equal. */ equals(m: Matrix4): boolean; /** * Returns a new Matrix3 and with identical elements to this one. */ clone(): Matrix4; /** * Returns a new Matrix4 which its upper 3x3 elements is the values if the given Matrix3. */ static fromMat3(m: Matrix3): Matrix4; /** * Adds each element in one matrix with its corresponding element in a second matrix. */ static add(m1: Matrix4, m2: Matrix4): Matrix4; /** * Subtracts each element in a second matrix from its corresponding element in a first matrix. */ static sub(m1: Matrix4, m2: Matrix4): Matrix4; /** * Returns the matrix that results from multiplying two matrices together. */ static multiply(m1: Matrix4, m2: Matrix4): Matrix4; /** * Returns the matrix that results from scaling all the elements of a specified matrix by a scalar factor. */ static multiplyScalar(m: Matrix4, s: number): Matrix4; /** * Transposes the rows and columns of a matrix. */ static transpose(m: Matrix4): Matrix4; /** * Inverts the specified matrix. The return value indicates whether the operation succeeded. */ static invert(mat: Matrix4, result: Matrix4): boolean; /** * Negates the specified matrix by multiplying all its values by -1. */ static negate(m: Matrix4): Matrix4; /** * Decomposes this matrix into its position, quaternion and scale components. */ static decompose(m: Matrix4): { scale: Vector3; rotation: Quaternion; translation: Vector3; }; /** * Performs a linear interpolation from one matrix to a second matrix based on a value that specifies the weighting of the second matrix. */ static lerp(m1: Matrix4, m2: Matrix4, alpha: number): Matrix4; /** * Creates a matrix that rotates around an arbitrary vector. */ static createFromAxisAngle(axis: Vector3, angle: number): Matrix4; /** * Creates a rotation matrix from the given Quaternion rotation value. */ static createFromQuaternion(q: Quaternion): Matrix4; /** * Creates a rotation matrix from the specified yaw, pitch, and roll. * @param yaw Angle of rotation, in radians, around the Y-axis. * @param pitch Angle of rotation, in radians, around the X-axis. * @param roll Angle of rotation, in radians, around the Z-axis. */ static createFromYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix4; /** * Creates a view matrix. * @param cameraPosition The position of the camera. * @param cameraTarget The target towards which the camera is pointing. * @param cameraUpVector The direction that is "up" from the camera's point of view. */ static createLookAt(cameraPosition: Vector3, cameraTarget: Vector3, cameraUpVector: Vector3): Matrix4; /** * Creates an orthographic perspective matrix from the given view volume dimensions. * @param width Width of the view volume at the near view plane. * @param height Height of the view volume at the near view plane. * @param zNearPlane Minimum Z-value of the view volume. * @param zFarPlane Maximum Z-value of the view volume. * @returns */ static createOrthographic(width: number, height: number, zNearPlane: number, zFarPlane: number): Matrix4; /** * Builds a customized, orthographic projection matrix. * @param left Minimum X-value of the view volume. * @param right Maximum X-value of the view volume. * @param bottom Minimum Y-value of the view volume. * @param top Maximum Y-value of the view volume. * @param zNearPlane Minimum Z-value of the view volume. * @param zFarPlane Maximum Z-value of the view volume. */ static createOrthographicOffCenter(left: number, right: number, bottom: number, top: number, zNearPlane: number, zFarPlane: number): Matrix4; /** * Creates a perspective projection matrix from the given view volume dimensions. * @param width Width of the view volume at the near view plane. * @param height Height of the view volume at the near view plane. * @param nearPlaneDistance Distance to the near view plane. * @param farPlaneDistance Distance to of the far view plane. */ static createPerspective(width: number, height: number, nearPlaneDistance: number, farPlaneDistance: number): Matrix4; /** * Creates a perspective projection matrix based on a field of view, aspect ratio, and near and far view plane distances. * @param fieldOfView Field of view in the y direction, in radians. * @param aspectRatio Aspect ratio, defined as view space width divided by height. * @param nearPlaneDistance Distance to the near view plane. * @param farPlaneDistance Distance to of the far view plane. */ static createPerspectiveFieldOfView(fieldOfView: number, aspectRatio: number, nearPlaneDistance: number, farPlaneDistance: number): Matrix4; /** * Creates a customized perspective projection matrix. * @param left Minimum X-value of the view volume. * @param right Maximum X-value of the view volume. * @param bottom Minimum Y-value of the view volume. * @param top Maximum Y-value of the view volume. * @param nearPlaneDistance Distance to the near view plane. * @param farPlaneDistance Distance to of the far view plane. */ static createPerspectiveOffCenter(left: number, right: number, bottom: number, top: number, nearPlaneDistance: number, farPlaneDistance: number): Matrix4; /** * Creates a world matrix with the specified parameters * @param position The position of the object; used in translation operations. * @param forward Forward direction of the object. * @param up Upward direction of the object; usually [0, 1, 0]. */ static createWorld(position: Vector3, forward: Vector3, up: Vector3): Matrix4; /** * Creates a rotation matrix around the X axis using the given rotation in radians and a center point (if specified). */ static createRotationX(angle: number, center?: Vector3): Matrix4; /** * Creates a rotation matrix around the Y axis using the given rotation in radians and a center point (if specified). */ static createRotationY(angle: number, center?: Vector3): Matrix4; /** * Creates a rotation matrix around the Z axis using the given rotation in radians and a center point (if specified). */ static createRotationZ(angle: number, center?: Vector3): Matrix4; /** * Creates a scaling matrix from the specified vector scale and a center point (if specified). */ static createScaleVec(v: Vector3, center?: Vector3): Matrix4; /** * Creates a scaling matrix that scales uniformly with the given scale and a center point (if specified). */ static createScaleScalar(s: number, center?: Vector3): Matrix4; /** * Creates a translation matrix from the specified 2-dimensional vector. */ static createTranslation(v: Vector3): Matrix4; }