Represents a 3-dimensional vector.
Signature:
export default class Vector3 extends Float32Array implements Vector3Like Extends: Float32Array
Implements: Vector3Like
All vector methods result in mutation of the vector instance. This class extends Float32Array to provide an efficient way to create and manipulate a 3-dimensional vector. Various convenience methods are provided for common vector operations.
|
Constructor |
Modifiers |
Description |
|---|---|---|
|
Constructs a new instance of the |
|
Property |
Modifiers |
Type |
Description |
|---|---|---|---|
|
|
number |
The length of the vector. | |
|
|
number |
The magnitude of the vector. Alias for | |
|
|
number |
The squared length of the vector. | |
|
|
number |
The squared magnitude of the vector. Alias for | |
|
number |
The x-component of the vector. | ||
|
number |
The y-component of the vector. | ||
|
number |
The z-component of the vector. |
|
Method |
Modifiers |
Description |
|---|---|---|
|
Adds a vector to the current vector. | ||
|
Rounds each component of the vector up to the nearest integer. | ||
|
Returns a new vector with the same components as the current vector. | ||
|
Copies the components of a vector to the current vector. | ||
|
|
Creates a new | |
|
Calculates the cross product of the current vector and another vector. | ||
|
Calculates the distance between the current vector and another vector. | ||
|
Divides each component of the current vector by the corresponding component of another vector. | ||
|
Returns the dot product of this vector and another vector. | ||
|
Checks if the current vector is approximately equal to another vector. | ||
|
Checks if the current vector is exactly equal to another vector. | ||
|
Rounds each component of the vector down to the nearest integer. | ||
|
|
Creates a new | |
|
Inverts each component of the vector. | ||
|
Linearly interpolates between the current vector and another vector. | ||
|
Sets each component of the vector to the maximum of the current vector and another vector. | ||
|
Sets each component of the vector to the minimum of the current vector and another vector. | ||
|
Multiplies each component of the current vector by the corresponding component of another vector. | ||
|
Negates each component of the vector. | ||
|
Normalizes the vector. | ||
|
Randomizes the vector. | ||
|
Rotates the vector around the x-axis. | ||
|
Rotates the vector around the y-axis. | ||
|
Rotates the vector around the z-axis. | ||
|
Rounds each component of the vector to the nearest integer. | ||
|
Scales each component of the vector by a scalar value. | ||
|
Adds 2 vectors together after scaling the provided vector by a scalar value. | ||
|
Subtracts a vector from the current vector. | ||
|
Returns a string representation of the vector in x,y,z format. | ||
|
Transforms the vector by a matrix3. | ||
|
Transforms the vector by a matrix4. | ||
|
Transforms the vector by a quaternion. | ||
|
Sets each component of the vector to zero. |