arcade-physics
Version:
Use Arcade Physics without Phaser.
526 lines • 17.4 kB
TypeScript
export default Matrix4;
/**
* @classdesc
* A four-dimensional matrix.
*
* Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji
* and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl
*
* @class Matrix4
* @memberof Phaser.Math
* @constructor
* @since 3.0.0
*
* @param {Phaser.Math.Matrix4} [m] - Optional Matrix4 to copy values from.
*/
declare class Matrix4 {
constructor(m: any);
/**
* The matrix values.
*
* @name Phaser.Math.Matrix4#val
* @type {Float32Array}
* @since 3.0.0
*/
val: Float32Array;
/**
* Make a clone of this Matrix4.
*
* @method Phaser.Math.Matrix4#clone
* @since 3.0.0
*
* @return {Phaser.Math.Matrix4} A clone of this Matrix4.
*/
clone(): Phaser.Math.Matrix4;
/**
* This method is an alias for `Matrix4.copy`.
*
* @method Phaser.Math.Matrix4#set
* @since 3.0.0
*
* @param {Phaser.Math.Matrix4} src - The Matrix to set the values of this Matrix's from.
*
* @return {this} This Matrix4.
*/
set(src: Phaser.Math.Matrix4): this;
/**
* Sets all values of this Matrix4.
*
* @method Phaser.Math.Matrix4#setValues
* @since 3.50.0
*
* @param {number} m00 - The m00 value.
* @param {number} m01 - The m01 value.
* @param {number} m02 - The m02 value.
* @param {number} m03 - The m03 value.
* @param {number} m10 - The m10 value.
* @param {number} m11 - The m11 value.
* @param {number} m12 - The m12 value.
* @param {number} m13 - The m13 value.
* @param {number} m20 - The m20 value.
* @param {number} m21 - The m21 value.
* @param {number} m22 - The m22 value.
* @param {number} m23 - The m23 value.
* @param {number} m30 - The m30 value.
* @param {number} m31 - The m31 value.
* @param {number} m32 - The m32 value.
* @param {number} m33 - The m33 value.
*
* @return {this} This Matrix4 instance.
*/
setValues(m00: number, m01: number, m02: number, m03: number, m10: number, m11: number, m12: number, m13: number, m20: number, m21: number, m22: number, m23: number, m30: number, m31: number, m32: number, m33: number): this;
/**
* Copy the values of a given Matrix into this Matrix.
*
* @method Phaser.Math.Matrix4#copy
* @since 3.0.0
*
* @param {Phaser.Math.Matrix4} src - The Matrix to copy the values from.
*
* @return {this} This Matrix4.
*/
copy(src: Phaser.Math.Matrix4): this;
/**
* Set the values of this Matrix from the given array.
*
* @method Phaser.Math.Matrix4#fromArray
* @since 3.0.0
*
* @param {number[]} a - The array to copy the values from. Must have at least 16 elements.
*
* @return {this} This Matrix4.
*/
fromArray(a: number[]): this;
/**
* Reset this Matrix.
*
* Sets all values to `0`.
*
* @method Phaser.Math.Matrix4#zero
* @since 3.0.0
*
* @return {Phaser.Math.Matrix4} This Matrix4.
*/
zero(): Phaser.Math.Matrix4;
/**
* Generates a transform matrix based on the given position, scale and rotation.
*
* @method Phaser.Math.Matrix4#transform
* @since 3.50.0
*
* @param {Phaser.Math.Vector3} position - The position vector.
* @param {Phaser.Math.Vector3} scale - The scale vector.
* @param {Phaser.Math.Quaternion} rotation - The rotation quaternion.
*
* @return {this} This Matrix4.
*/
transform(position: Phaser.Math.Vector3, scale: Phaser.Math.Vector3, rotation: Phaser.Math.Quaternion): this;
/**
* Set the `x`, `y` and `z` values of this Matrix.
*
* @method Phaser.Math.Matrix4#xyz
* @since 3.0.0
*
* @param {number} x - The x value.
* @param {number} y - The y value.
* @param {number} z - The z value.
*
* @return {this} This Matrix4.
*/
xyz(x: number, y: number, z: number): this;
/**
* Set the scaling values of this Matrix.
*
* @method Phaser.Math.Matrix4#scaling
* @since 3.0.0
*
* @param {number} x - The x scaling value.
* @param {number} y - The y scaling value.
* @param {number} z - The z scaling value.
*
* @return {this} This Matrix4.
*/
scaling(x: number, y: number, z: number): this;
/**
* Reset this Matrix to an identity (default) matrix.
*
* @method Phaser.Math.Matrix4#identity
* @since 3.0.0
*
* @return {this} This Matrix4.
*/
identity(): this;
/**
* Transpose this Matrix.
*
* @method Phaser.Math.Matrix4#transpose
* @since 3.0.0
*
* @return {this} This Matrix4.
*/
transpose(): this;
/**
* Copies the given Matrix4 into this Matrix and then inverses it.
*
* @method Phaser.Math.Matrix4#getInverse
* @since 3.50.0
*
* @param {Phaser.Math.Matrix4} m - The Matrix4 to invert into this Matrix4.
*
* @return {this} This Matrix4.
*/
getInverse(m: Phaser.Math.Matrix4): this;
/**
* Invert this Matrix.
*
* @method Phaser.Math.Matrix4#invert
* @since 3.0.0
*
* @return {this} This Matrix4.
*/
invert(): this;
/**
* Calculate the adjoint, or adjugate, of this Matrix.
*
* @method Phaser.Math.Matrix4#adjoint
* @since 3.0.0
*
* @return {this} This Matrix4.
*/
adjoint(): this;
/**
* Calculate the determinant of this Matrix.
*
* @method Phaser.Math.Matrix4#determinant
* @since 3.0.0
*
* @return {number} The determinant of this Matrix.
*/
determinant(): number;
/**
* Multiply this Matrix by the given Matrix.
*
* @method Phaser.Math.Matrix4#multiply
* @since 3.0.0
*
* @param {Phaser.Math.Matrix4} src - The Matrix to multiply this Matrix by.
*
* @return {this} This Matrix4.
*/
multiply(src: Phaser.Math.Matrix4): this;
/**
* Multiply the values of this Matrix4 by those given in the `src` argument.
*
* @method Phaser.Math.Matrix4#multiplyLocal
* @since 3.0.0
*
* @param {Phaser.Math.Matrix4} src - The source Matrix4 that this Matrix4 is multiplied by.
*
* @return {this} This Matrix4.
*/
multiplyLocal(src: Phaser.Math.Matrix4): this;
/**
* Multiplies the given Matrix4 object with this Matrix.
*
* This is the same as calling `multiplyMatrices(m, this)`.
*
* @method Phaser.Math.Matrix4#premultiply
* @since 3.50.0
*
* @param {Phaser.Math.Matrix4} m - The Matrix4 to multiply with this one.
*
* @return {this} This Matrix4.
*/
premultiply(m: Phaser.Math.Matrix4): this;
/**
* Multiplies the two given Matrix4 objects and stores the results in this Matrix.
*
* @method Phaser.Math.Matrix4#multiplyMatrices
* @since 3.50.0
*
* @param {Phaser.Math.Matrix4} a - The first Matrix4 to multiply.
* @param {Phaser.Math.Matrix4} b - The second Matrix4 to multiply.
*
* @return {this} This Matrix4.
*/
multiplyMatrices(a: Phaser.Math.Matrix4, b: Phaser.Math.Matrix4): this;
/**
* Translate this Matrix using the given Vector.
*
* @method Phaser.Math.Matrix4#translate
* @since 3.0.0
*
* @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to translate this Matrix with.
*
* @return {this} This Matrix4.
*/
translate(v: (Phaser.Math.Vector3 | Phaser.Math.Vector4)): this;
/**
* Translate this Matrix using the given values.
*
* @method Phaser.Math.Matrix4#translateXYZ
* @since 3.16.0
*
* @param {number} x - The x component.
* @param {number} y - The y component.
* @param {number} z - The z component.
*
* @return {this} This Matrix4.
*/
translateXYZ(x: number, y: number, z: number): this;
/**
* Apply a scale transformation to this Matrix.
*
* Uses the `x`, `y` and `z` components of the given Vector to scale the Matrix.
*
* @method Phaser.Math.Matrix4#scale
* @since 3.0.0
*
* @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to scale this Matrix with.
*
* @return {this} This Matrix4.
*/
scale(v: (Phaser.Math.Vector3 | Phaser.Math.Vector4)): this;
/**
* Apply a scale transformation to this Matrix.
*
* @method Phaser.Math.Matrix4#scaleXYZ
* @since 3.16.0
*
* @param {number} x - The x component.
* @param {number} y - The y component.
* @param {number} z - The z component.
*
* @return {this} This Matrix4.
*/
scaleXYZ(x: number, y: number, z: number): this;
/**
* Derive a rotation matrix around the given axis.
*
* @method Phaser.Math.Matrix4#makeRotationAxis
* @since 3.0.0
*
* @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} axis - The rotation axis.
* @param {number} angle - The rotation angle in radians.
*
* @return {this} This Matrix4.
*/
makeRotationAxis(axis: (Phaser.Math.Vector3 | Phaser.Math.Vector4), angle: number): this;
/**
* Apply a rotation transformation to this Matrix.
*
* @method Phaser.Math.Matrix4#rotate
* @since 3.0.0
*
* @param {number} rad - The angle in radians to rotate by.
* @param {Phaser.Math.Vector3} axis - The axis to rotate upon.
*
* @return {this} This Matrix4.
*/
rotate(rad: number, axis: Phaser.Math.Vector3): this;
/**
* Rotate this matrix on its X axis.
*
* @method Phaser.Math.Matrix4#rotateX
* @since 3.0.0
*
* @param {number} rad - The angle in radians to rotate by.
*
* @return {this} This Matrix4.
*/
rotateX(rad: number): this;
/**
* Rotate this matrix on its Y axis.
*
* @method Phaser.Math.Matrix4#rotateY
* @since 3.0.0
*
* @param {number} rad - The angle to rotate by, in radians.
*
* @return {this} This Matrix4.
*/
rotateY(rad: number): this;
/**
* Rotate this matrix on its Z axis.
*
* @method Phaser.Math.Matrix4#rotateZ
* @since 3.0.0
*
* @param {number} rad - The angle to rotate by, in radians.
*
* @return {this} This Matrix4.
*/
rotateZ(rad: number): this;
/**
* Set the values of this Matrix from the given rotation Quaternion and translation Vector.
*
* @method Phaser.Math.Matrix4#fromRotationTranslation
* @since 3.0.0
*
* @param {Phaser.Math.Quaternion} q - The Quaternion to set rotation from.
* @param {Phaser.Math.Vector3} v - The Vector to set translation from.
*
* @return {this} This Matrix4.
*/
fromRotationTranslation(q: Phaser.Math.Quaternion, v: Phaser.Math.Vector3): this;
/**
* Set the values of this Matrix from the given Quaternion.
*
* @method Phaser.Math.Matrix4#fromQuat
* @since 3.0.0
*
* @param {Phaser.Math.Quaternion} q - The Quaternion to set the values of this Matrix from.
*
* @return {this} This Matrix4.
*/
fromQuat(q: Phaser.Math.Quaternion): this;
/**
* Generate a frustum matrix with the given bounds.
*
* @method Phaser.Math.Matrix4#frustum
* @since 3.0.0
*
* @param {number} left - The left bound of the frustum.
* @param {number} right - The right bound of the frustum.
* @param {number} bottom - The bottom bound of the frustum.
* @param {number} top - The top bound of the frustum.
* @param {number} near - The near bound of the frustum.
* @param {number} far - The far bound of the frustum.
*
* @return {this} This Matrix4.
*/
frustum(left: number, right: number, bottom: number, top: number, near: number, far: number): this;
/**
* Generate a perspective projection matrix with the given bounds.
*
* @method Phaser.Math.Matrix4#perspective
* @since 3.0.0
*
* @param {number} fovy - Vertical field of view in radians
* @param {number} aspect - Aspect ratio. Typically viewport width /height.
* @param {number} near - Near bound of the frustum.
* @param {number} far - Far bound of the frustum.
*
* @return {this} This Matrix4.
*/
perspective(fovy: number, aspect: number, near: number, far: number): this;
/**
* Generate a perspective projection matrix with the given bounds.
*
* @method Phaser.Math.Matrix4#perspectiveLH
* @since 3.0.0
*
* @param {number} width - The width of the frustum.
* @param {number} height - The height of the frustum.
* @param {number} near - Near bound of the frustum.
* @param {number} far - Far bound of the frustum.
*
* @return {this} This Matrix4.
*/
perspectiveLH(width: number, height: number, near: number, far: number): this;
/**
* Generate an orthogonal projection matrix with the given bounds.
*
* @method Phaser.Math.Matrix4#ortho
* @since 3.0.0
*
* @param {number} left - The left bound of the frustum.
* @param {number} right - The right bound of the frustum.
* @param {number} bottom - The bottom bound of the frustum.
* @param {number} top - The top bound of the frustum.
* @param {number} near - The near bound of the frustum.
* @param {number} far - The far bound of the frustum.
*
* @return {this} This Matrix4.
*/
ortho(left: number, right: number, bottom: number, top: number, near: number, far: number): this;
/**
* Generate a right-handed look-at matrix with the given eye position, target and up axis.
*
* @method Phaser.Math.Matrix4#lookAtRH
* @since 3.50.0
*
* @param {Phaser.Math.Vector3} eye - Position of the viewer.
* @param {Phaser.Math.Vector3} target - Point the viewer is looking at.
* @param {Phaser.Math.Vector3} up - vec3 pointing up.
*
* @return {this} This Matrix4.
*/
lookAtRH(eye: Phaser.Math.Vector3, target: Phaser.Math.Vector3, up: Phaser.Math.Vector3): this;
/**
* Generate a look-at matrix with the given eye position, focal point, and up axis.
*
* @method Phaser.Math.Matrix4#lookAt
* @since 3.0.0
*
* @param {Phaser.Math.Vector3} eye - Position of the viewer
* @param {Phaser.Math.Vector3} center - Point the viewer is looking at
* @param {Phaser.Math.Vector3} up - vec3 pointing up.
*
* @return {this} This Matrix4.
*/
lookAt(eye: Phaser.Math.Vector3, center: Phaser.Math.Vector3, up: Phaser.Math.Vector3): this;
/**
* Set the values of this matrix from the given `yaw`, `pitch` and `roll` values.
*
* @method Phaser.Math.Matrix4#yawPitchRoll
* @since 3.0.0
*
* @param {number} yaw - The yaw value.
* @param {number} pitch - The pitch value.
* @param {number} roll - The roll value.
*
* @return {this} This Matrix4.
*/
yawPitchRoll(yaw: number, pitch: number, roll: number): this;
/**
* Generate a world matrix from the given rotation, position, scale, view matrix and projection matrix.
*
* @method Phaser.Math.Matrix4#setWorldMatrix
* @since 3.0.0
*
* @param {Phaser.Math.Vector3} rotation - The rotation of the world matrix.
* @param {Phaser.Math.Vector3} position - The position of the world matrix.
* @param {Phaser.Math.Vector3} scale - The scale of the world matrix.
* @param {Phaser.Math.Matrix4} [viewMatrix] - The view matrix.
* @param {Phaser.Math.Matrix4} [projectionMatrix] - The projection matrix.
*
* @return {this} This Matrix4.
*/
setWorldMatrix(rotation: Phaser.Math.Vector3, position: Phaser.Math.Vector3, scale: Phaser.Math.Vector3, viewMatrix?: any, projectionMatrix?: any): this;
/**
* Multiplies this Matrix4 by the given `src` Matrix4 and stores the results in the `out` Matrix4.
*
* @method Phaser.Math.Matrix4#multiplyToMat4
* @since 3.50.0
*
* @param {Phaser.Math.Matrix4} src - The Matrix4 to multiply with this one.
* @param {Phaser.Math.Matrix4} out - The receiving Matrix.
*
* @return {Phaser.Math.Matrix4} This `out` Matrix4.
*/
multiplyToMat4(src: Phaser.Math.Matrix4, out: Phaser.Math.Matrix4): Phaser.Math.Matrix4;
/**
* Takes the rotation and position vectors and builds this Matrix4 from them.
*
* @method Phaser.Math.Matrix4#fromRotationXYTranslation
* @since 3.50.0
*
* @param {Phaser.Math.Vector3} rotation - The rotation vector.
* @param {Phaser.Math.Vector3} position - The position vector.
* @param {boolean} translateFirst - Should the operation translate then rotate (`true`), or rotate then translate? (`false`)
*
* @return {this} This Matrix4.
*/
fromRotationXYTranslation(rotation: Phaser.Math.Vector3, position: Phaser.Math.Vector3, translateFirst: boolean): this;
/**
* Returns the maximum axis scale from this Matrix4.
*
* @method Phaser.Math.Matrix4#getMaxScaleOnAxis
* @since 3.50.0
*
* @return {number} The maximum axis scale.
*/
getMaxScaleOnAxis(): number;
}
//# sourceMappingURL=Matrix4.d.ts.map