Alternate name for the z component.
Alternate name for the y component.
Returns the length of the vector.
Returns the squared length of the vector.
Alternate name for the x component.
x component of the vec3.
y component of the vec3.
z component of the vec3.
Static
backReturns the vector (0, 0, -1).
Returns a copy of the vector with its length clamped to length
.
Like distance()
, but returns the squared distance between vectors.
Static
downReturns the vector (0, -1, 0).
Static
forwardReturns the vector (0, 0, 1).
Static
leftReturns the vector (-1, 0, 0).
Static
lerpStatic
maxStatic
minReturns a copy of the vector with its length scaled to 1.
Static
oneReturns the vector (1, 1, 1).
Static
orthonormalizeStatic
randomGenerate random 3D direction vector. This is equivalent to a random point on a unit-radius sphere.
Static
rightReturns the vector (1, 0, 0).
Returns a copy of the vector rotated towards the target
vector by step
radians.
The vectors may be non-normalized. The function always returns a vector with the source vector's magnitude.
This prevents overshoot. If step
exceeds the angle between vectors, it stops at the target
direction.
If step
is negative, this rotates the source vector away from target
. It stops when the direction is precisely opposite to target
.
If the vectors are in opposite directions, the result is rotated along an arbitrary (but consistent) axis.
If either vector is zero magnitude, it returns the source vector.
Static
slerpReturns a string representation of the vector.
Static
upReturns the vector (0, 1, 0).
Static
zeroReturns the vector (0, 0, 0).
A three dimensional vector. Vectors can only store finite numbers in the range Number.MIN_VALUE to Number.MAX_VALUE.
Example