arcade-physics
Version:
Use Arcade Physics without Phaser.
486 lines • 15.4 kB
TypeScript
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* @classdesc
* A representation of a vector in 3D space.
*
* A three-component vector.
*
* @class Vector3
* @memberof Phaser.Math
* @constructor
* @since 3.0.0
*
* @param {number} [x] - The x component.
* @param {number} [y] - The y component.
* @param {number} [z] - The z component.
*/
export declare class Vector3 {
x: number;
y: number;
z: number;
static ZERO: Vector3;
static RIGHT: Vector3;
static LEFT: Vector3;
static UP: Vector3;
static DOWN: Vector3;
static FORWARD: Vector3;
static BACK: Vector3;
static ONE: Vector3;
constructor(x?: any, y?: any, z?: any);
/**
* Set this Vector to point up.
*
* Sets the y component of the vector to 1, and the others to 0.
*
* @method Phaser.Math.Vector3#up
* @since 3.0.0
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
up(): this;
/**
* Sets the components of this Vector to be the `Math.min` result from the given vector.
*
* @method Phaser.Math.Vector3#min
* @since 3.50.0
*
* @param {Phaser.Math.Vector3} v - The Vector3 to check the minimum values against.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
min(v: any): this;
/**
* Sets the components of this Vector to be the `Math.max` result from the given vector.
*
* @method Phaser.Math.Vector3#max
* @since 3.50.0
*
* @param {Phaser.Math.Vector3} v - The Vector3 to check the maximum values against.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
max(v: any): this;
/**
* Make a clone of this Vector3.
*
* @method Phaser.Math.Vector3#clone
* @since 3.0.0
*
* @return {Phaser.Math.Vector3} A new Vector3 object containing this Vectors values.
*/
clone(): Vector3;
/**
* Adds the two given Vector3s and sets the results into this Vector3.
*
* @method Phaser.Math.Vector3#addVectors
* @since 3.50.0
*
* @param {Phaser.Math.Vector3} a - The first Vector to add.
* @param {Phaser.Math.Vector3} b - The second Vector to add.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
addVectors(a: any, b: any): this;
/**
* Calculate the cross (vector) product of two given Vectors.
*
* @method Phaser.Math.Vector3#crossVectors
* @since 3.0.0
*
* @param {Phaser.Math.Vector3} a - The first Vector to multiply.
* @param {Phaser.Math.Vector3} b - The second Vector to multiply.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
crossVectors(a: any, b: any): this;
/**
* Check whether this Vector is equal to a given Vector.
*
* Performs a strict equality check against each Vector's components.
*
* @method Phaser.Math.Vector3#equals
* @since 3.0.0
*
* @param {Phaser.Math.Vector3} v - The Vector3 to compare against.
*
* @return {boolean} True if the two vectors strictly match, otherwise false.
*/
equals(v: any): boolean;
/**
* Copy the components of a given Vector into this Vector.
*
* @method Phaser.Math.Vector3#copy
* @since 3.0.0
*
* @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} src - The Vector to copy the components from.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
copy(src: any): this;
/**
* Set the `x`, `y`, and `z` components of this Vector to the given `x`, `y`, and `z` values.
*
* @method Phaser.Math.Vector3#set
* @since 3.0.0
*
* @param {(number|object)} x - The x value to set for this Vector, or an object containing x, y and z components.
* @param {number} [y] - The y value to set for this Vector.
* @param {number} [z] - The z value to set for this Vector.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
set(x: any, y: any, z: any): this;
/**
* Sets the components of this Vector3 from the position of the given Matrix4.
*
* @method Phaser.Math.Vector3#setFromMatrixPosition
* @since 3.50.0
*
* @param {Phaser.Math.Matrix4} mat4 - The Matrix4 to get the position from.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
setFromMatrixPosition(m: any): this;
/**
* Sets the components of this Vector3 from the Matrix4 column specified.
*
* @method Phaser.Math.Vector3#setFromMatrixColumn
* @since 3.50.0
*
* @param {Phaser.Math.Matrix4} mat4 - The Matrix4 to get the column from.
* @param {number} index - The column index.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
setFromMatrixColumn(mat4: any, index: any): this;
/**
* Sets the components of this Vector3 from the given array, based on the offset.
*
* Vector3.x = array[offset]
* Vector3.y = array[offset + 1]
* Vector3.z = array[offset + 2]
*
* @method Phaser.Math.Vector3#fromArray
* @since 3.50.0
*
* @param {number[]} array - The array of values to get this Vector from.
* @param {number} [offset=0] - The offset index into the array.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
fromArray(array: any, offset: any): this;
/**
* Add a given Vector to this Vector. Addition is component-wise.
*
* @method Phaser.Math.Vector3#add
* @since 3.0.0
*
* @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to add to this Vector.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
add(v: any): this;
/**
* Add the given value to each component of this Vector.
*
* @method Phaser.Math.Vector3#addScalar
* @since 3.50.0
*
* @param {number} s - The amount to add to this Vector.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
addScalar(s: any): this;
/**
* Add and scale a given Vector to this Vector. Addition is component-wise.
*
* @method Phaser.Math.Vector3#addScale
* @since 3.50.0
*
* @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to add to this Vector.
* @param {number} scale - The amount to scale `v` by.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
addScale(v: any, scale: any): this;
/**
* Subtract the given Vector from this Vector. Subtraction is component-wise.
*
* @method Phaser.Math.Vector3#subtract
* @since 3.0.0
*
* @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to subtract from this Vector.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
subtract(v: any): this;
/**
* Perform a component-wise multiplication between this Vector and the given Vector.
*
* Multiplies this Vector by the given Vector.
*
* @method Phaser.Math.Vector3#multiply
* @since 3.0.0
*
* @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to multiply this Vector by.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
multiply(v: any): this;
/**
* Scale this Vector by the given value.
*
* @method Phaser.Math.Vector3#scale
* @since 3.0.0
*
* @param {number} scale - The value to scale this Vector by.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
scale(scale: any): this;
/**
* Perform a component-wise division between this Vector and the given Vector.
*
* Divides this Vector by the given Vector.
*
* @method Phaser.Math.Vector3#divide
* @since 3.0.0
*
* @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to divide this Vector by.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
divide(v: any): this;
/**
* Negate the `x`, `y` and `z` components of this Vector.
*
* @method Phaser.Math.Vector3#negate
* @since 3.0.0
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
negate(): this;
/**
* Calculate the distance between this Vector and the given Vector.
*
* @method Phaser.Math.Vector3#distance
* @since 3.0.0
*
* @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to calculate the distance to.
*
* @return {number} The distance from this Vector to the given Vector.
*/
distance(v: any): number;
/**
* Calculate the distance between this Vector and the given Vector, squared.
*
* @method Phaser.Math.Vector3#distanceSq
* @since 3.0.0
*
* @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to calculate the distance to.
*
* @return {number} The distance from this Vector to the given Vector, squared.
*/
distanceSq(v: any): number;
/**
* Calculate the length (or magnitude) of this Vector.
*
* @method Phaser.Math.Vector3#length
* @since 3.0.0
*
* @return {number} The length of this Vector.
*/
length(): number;
/**
* Calculate the length of this Vector squared.
*
* @method Phaser.Math.Vector3#lengthSq
* @since 3.0.0
*
* @return {number} The length of this Vector, squared.
*/
lengthSq(): number;
/**
* Normalize this Vector.
*
* Makes the vector a unit length vector (magnitude of 1) in the same direction.
*
* @method Phaser.Math.Vector3#normalize
* @since 3.0.0
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
normalize(): this;
/**
* Calculate the dot product of this Vector and the given Vector.
*
* @method Phaser.Math.Vector3#dot
* @since 3.0.0
*
* @param {Phaser.Math.Vector3} v - The Vector3 to dot product with this Vector3.
*
* @return {number} The dot product of this Vector and `v`.
*/
dot(v: any): number;
/**
* Calculate the cross (vector) product of this Vector (which will be modified) and the given Vector.
*
* @method Phaser.Math.Vector3#cross
* @since 3.0.0
*
* @param {Phaser.Math.Vector3} v - The Vector to cross product with.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
cross(v: any): this;
/**
* Linearly interpolate between this Vector and the given Vector.
*
* Interpolates this Vector towards the given Vector.
*
* @method Phaser.Math.Vector3#lerp
* @since 3.0.0
*
* @param {Phaser.Math.Vector3} v - The Vector3 to interpolate towards.
* @param {number} [t=0] - The interpolation percentage, between 0 and 1.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
lerp(v: any, t: any): this;
/**
* Takes a Matrix3 and applies it to this Vector3.
*
* @method Phaser.Math.Vector3#applyMatrix3
* @since 3.50.0
*
* @param {Phaser.Math.Matrix3} mat3 - The Matrix3 to apply to this Vector3.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
applyMatrix3(mat3: any): this;
/**
* Takes a Matrix4 and applies it to this Vector3.
*
* @method Phaser.Math.Vector3#applyMatrix4
* @since 3.50.0
*
* @param {Phaser.Math.Matrix4} mat4 - The Matrix4 to apply to this Vector3.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
applyMatrix4(mat4: any): this;
/**
* Transform this Vector with the given Matrix.
*
* @method Phaser.Math.Vector3#transformMat3
* @since 3.0.0
*
* @param {Phaser.Math.Matrix3} mat - The Matrix3 to transform this Vector3 with.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
transformMat3(mat: any): this;
/**
* Transform this Vector with the given Matrix4.
*
* @method Phaser.Math.Vector3#transformMat4
* @since 3.0.0
*
* @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector3 with.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
transformMat4(mat: any): this;
/**
* Transforms the coordinates of this Vector3 with the given Matrix4.
*
* @method Phaser.Math.Vector3#transformCoordinates
* @since 3.0.0
*
* @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector3 with.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
transformCoordinates(mat: any): this;
/**
* Transform this Vector with the given Quaternion.
*
* @method Phaser.Math.Vector3#transformQuat
* @since 3.0.0
*
* @param {Phaser.Math.Quaternion} q - The Quaternion to transform this Vector with.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
transformQuat(q: any): this;
/**
* Multiplies this Vector3 by the specified matrix, applying a W divide. This is useful for projection,
* e.g. unprojecting a 2D point into 3D space.
*
* @method Phaser.Math.Vector3#project
* @since 3.0.0
*
* @param {Phaser.Math.Matrix4} mat - The Matrix4 to multiply this Vector3 with.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
project(mat: any): this;
/**
* Multiplies this Vector3 by the given view and projection matrices.
*
* @method Phaser.Math.Vector3#projectViewMatrix
* @since 3.50.0
*
* @param {Phaser.Math.Matrix4} viewMatrix - A View Matrix.
* @param {Phaser.Math.Matrix4} projectionMatrix - A Projection Matrix.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
projectViewMatrix(viewMatrix: any, projectionMatrix: any): this;
/**
* Multiplies this Vector3 by the given inversed projection matrix and world matrix.
*
* @method Phaser.Math.Vector3#unprojectViewMatrix
* @since 3.50.0
*
* @param {Phaser.Math.Matrix4} projectionMatrix - An inversed Projection Matrix.
* @param {Phaser.Math.Matrix4} worldMatrix - A World View Matrix.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
unprojectViewMatrix(projectionMatrix: any, worldMatrix: any): this;
/**
* Unproject this point from 2D space to 3D space.
* The point should have its x and y properties set to
* 2D screen space, and the z either at 0 (near plane)
* or 1 (far plane). The provided matrix is assumed to already
* be combined, i.e. projection * view * model.
*
* After this operation, this vector's (x, y, z) components will
* represent the unprojected 3D coordinate.
*
* @method Phaser.Math.Vector3#unproject
* @since 3.0.0
*
* @param {Phaser.Math.Vector4} viewport - Screen x, y, width and height in pixels.
* @param {Phaser.Math.Matrix4} invProjectionView - Combined projection and view matrix.
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
unproject(viewport: any, invProjectionView: any): this;
/**
* Make this Vector the zero vector (0, 0, 0).
*
* @method Phaser.Math.Vector3#reset
* @since 3.0.0
*
* @return {Phaser.Math.Vector3} This Vector3.
*/
reset(): this;
}
export default Vector3;
//# sourceMappingURL=Vector3.d.ts.map