Vector3
A vector with three components.
Constructor Summary
Public Constructor | ||
public |
constructor(x: Number, y: Number, z: Number) Constructs a new vector. |
Member Summary
Public Members | ||
public |
The X component. |
|
public |
The Y component. |
|
public |
The Z component. |
Method Summary
Public Methods | ||
public |
Adds a vector to this one. |
|
public |
Adds a scalar to this vector. |
|
public |
addScaledVector(v: Vector3, s: Number): Vector3 Adds a scaled vector to this one. |
|
public |
addVectors(a: Vector3, b: Vector3): Vector3 Sets this vector to the sum of two given vectors. |
|
public |
Computes the angle to the given vector. |
|
public |
applyMatrix3(m: Matrix3): Vector3 Applies a matrix to this vector. |
|
public |
applyMatrix4(m: Matrix4): Vector3 Applies a matrix to this vector. |
|
public |
Applies a normal matrix to this vector and normalizes it. |
|
public |
Applies a quaternion to this vector. |
|
public |
Ceils this vector. |
|
public |
Clamps this vector. |
|
public |
Clones this vector. |
|
public |
Copies the values of another vector. |
|
public |
Calculates the cross product of this vector and the given one. |
|
public |
crossVectors(a: Vector3, b: Vector3): Vector3 Sets this vector to the cross product of the given vectors. |
|
public |
distanceTo(v: Vector3): Number Calculates the distance to a given vector. |
|
public |
Calculates the squared distance to a given vector. |
|
public |
Divides this vector by another vector. |
|
public |
divideScalar(s: Number): Vector3 Divides this vector by a given scalar. |
|
public |
Calculates the dot product with another vector. |
|
public |
Checks if this vector equals the given one. |
|
public |
Floors this vector. |
|
public |
Copies values from an array. |
|
public |
Calculates the length of this vector. |
|
public |
Calculates the squared length of this vector. |
|
public |
Lerps towards the given vector. |
|
public |
lerpVectors(v1: Vector3, v2: Vector3, alpha: Number): Vector3 Sets this vector to the lerp result of the given vectors. |
|
public |
Calculates the Manhattan distance to a given vector. |
|
public |
Calculates the Manhattan length of this vector. |
|
public |
Adopts the max value for each component of this vector and the given one. |
|
public |
Adopts the min value for each component of this vector and the given one. |
|
public |
Multiplies this vector with another vector. |
|
public |
multiplyScalar(s: Number): Vector3 Multiplies this vector with a given scalar. |
|
public |
multiplyVectors(a: Vector3, b: Vector3): Vector3 Sets this vector to the product of two given vectors. |
|
public |
Negates this vector. |
|
public |
Normalizes this vector. |
|
public |
Randomizes the values of this vector |
|
public |
Reflects this vector. |
|
public |
Rounds this vector. |
|
public |
Sets the values of this vector |
|
public |
Sets the values of this vector based on a cylindrical description. |
|
public |
setFromCylindricalCoords(radius: Number, theta: Number, y: Number): Vector3 Sets the values of this vector based on cylindrical coordinates. |
|
public |
setFromMatrix3Column(m: Matrix4, index: Number): Vector3 Copies the values of a matrix column. |
|
public |
setFromMatrixColumn(m: Matrix4, index: Number): Vector3 Copies the values of a matrix column. |
|
public |
Extracts the position from a matrix. |
|
public |
Extracts the scale from a matrix. |
|
public |
Sets the values of this vector based on a spherical description. |
|
public |
setFromSphericalCoords(radius: Number, phi: Number, theta: Number): Vector3 Sets the values of this vector based on spherical coordinates. |
|
public |
Sets the length of this vector. |
|
public |
Subtracts a vector from this vector. |
|
public |
Subtracts a scalar from this vector. |
|
public |
subVectors(a: Vector3, b: Vector3): Vector3 Sets this vector to the difference between two given vectors. |
|
public |
Stores this vector in an array. |
|
public |
Applies a matrix to this direction vector. |
Public Constructors
Public Members
Public Methods
public add(v: Vector3): Vector3 source
Adds a vector to this one.
Params:
Name | Type | Attribute | Description |
v | Vector3 | The vector to add. |
public addScalar(s: Number): Vector3 source
Adds a scalar to this vector.
Params:
Name | Type | Attribute | Description |
s | Number | The scalar to add. |
public addVectors(a: Vector3, b: Vector3): Vector3 source
Sets this vector to the sum of two given vectors.
public angleTo(v: Vector3): Number source
Computes the angle to the given vector.
Params:
Name | Type | Attribute | Description |
v | Vector3 | A vector. |
public applyMatrix3(m: Matrix3): Vector3 source
Applies a matrix to this vector.
Params:
Name | Type | Attribute | Description |
m | Matrix3 | A matrix. |
public applyMatrix4(m: Matrix4): Vector3 source
Applies a matrix to this vector.
Params:
Name | Type | Attribute | Description |
m | Matrix4 | A matrix. |
public applyNormalMatrix(m: Matrix3): Vector3 source
Applies a normal matrix to this vector and normalizes it.
Params:
Name | Type | Attribute | Description |
m | Matrix3 | A normal matrix. |
public applyQuaternion(q: Quaternion): Vector3 source
Applies a quaternion to this vector.
Params:
Name | Type | Attribute | Description |
q | Quaternion | A quaternion. |
public copy(v: Vector3): Vector3 source
Copies the values of another vector.
Params:
Name | Type | Attribute | Description |
v | Vector3 | A vector. |
public cross(v: Vector3): Vector3 source
Calculates the cross product of this vector and the given one.
Params:
Name | Type | Attribute | Description |
v | Vector3 | A vector. |
public crossVectors(a: Vector3, b: Vector3): Vector3 source
Sets this vector to the cross product of the given vectors.
public distanceTo(v: Vector3): Number source
Calculates the distance to a given vector.
Params:
Name | Type | Attribute | Description |
v | Vector3 | A vector. |
public distanceToSquared(v: Vector3): Number source
Calculates the squared distance to a given vector.
Params:
Name | Type | Attribute | Description |
v | Vector3 | A vector. |
public divide(v: Vector3): Vector3 source
Divides this vector by another vector.
Params:
Name | Type | Attribute | Description |
v | Vector3 | A vector. |
public divideScalar(s: Number): Vector3 source
Divides this vector by a given scalar.
Params:
Name | Type | Attribute | Description |
s | Number | A scalar. |
public dot(v: Vector3): Number source
Calculates the dot product with another vector.
Params:
Name | Type | Attribute | Description |
v | Vector3 | A vector. |
public equals(v: Vector3): Boolean source
Checks if this vector equals the given one.
Params:
Name | Type | Attribute | Description |
v | Vector3 | A vector. |
public lerpVectors(v1: Vector3, v2: Vector3, alpha: Number): Vector3 source
Sets this vector to the lerp result of the given vectors.
public manhattanDistanceTo(v: Vector3): Number source
Calculates the Manhattan distance to a given vector.
Params:
Name | Type | Attribute | Description |
v | Vector3 | A vector. |
public max(v: Vector3): Vector3 source
Adopts the max value for each component of this vector and the given one.
Params:
Name | Type | Attribute | Description |
v | Vector3 | A vector. |
public min(v: Vector3): Vector3 source
Adopts the min value for each component of this vector and the given one.
Params:
Name | Type | Attribute | Description |
v | Vector3 | A vector. |
public multiply(v: Vector3): Vector3 source
Multiplies this vector with another vector.
Params:
Name | Type | Attribute | Description |
v | Vector3 | A vector. |
public multiplyScalar(s: Number): Vector3 source
Multiplies this vector with a given scalar.
Params:
Name | Type | Attribute | Description |
s | Number | A scalar. |
public multiplyVectors(a: Vector3, b: Vector3): Vector3 source
Sets this vector to the product of two given vectors.
public reflect(n: Vector3): Vector3 source
Reflects this vector. The given plane normal is assumed to be normalized.
Params:
Name | Type | Attribute | Description |
n | Vector3 | A normal. |
public setFromCylindrical(c: Cylindrical): Vector3 source
Sets the values of this vector based on a cylindrical description.
Params:
Name | Type | Attribute | Description |
c | Cylindrical | A cylindrical description. |
public setFromCylindricalCoords(radius: Number, theta: Number, y: Number): Vector3 source
Sets the values of this vector based on cylindrical coordinates.
public setFromMatrix3Column(m: Matrix4, index: Number): Vector3 source
Copies the values of a matrix column.
public setFromMatrixColumn(m: Matrix4, index: Number): Vector3 source
Copies the values of a matrix column.
public setFromMatrixPosition(m: Matrix4): Vector3 source
Extracts the position from a matrix.
Params:
Name | Type | Attribute | Description |
m | Matrix4 | A 4x4 matrix. |
public setFromMatrixScale(m: Matrix4): Vector3 source
Extracts the scale from a matrix.
Params:
Name | Type | Attribute | Description |
m | Matrix4 | A 4x4 matrix. |
public setFromSpherical(s: Spherical): Vector3 source
Sets the values of this vector based on a spherical description.
Params:
Name | Type | Attribute | Description |
s | Spherical | A spherical description. |
public setFromSphericalCoords(radius: Number, phi: Number, theta: Number): Vector3 source
Sets the values of this vector based on spherical coordinates.
public setLength(length: Number): Vector3 source
Sets the length of this vector.
Params:
Name | Type | Attribute | Description |
length | Number | The new length. |
public sub(v: Vector3): Vector3 source
Subtracts a vector from this vector.
Params:
Name | Type | Attribute | Description |
v | Vector3 | The vector to subtract. |
public subScalar(s: Number): Vector3 source
Subtracts a scalar from this vector.
Params:
Name | Type | Attribute | Description |
s | Number | The scalar to subtract. |
public subVectors(a: Vector3, b: Vector3): Vector3 source
Sets this vector to the difference between two given vectors.