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.
StaticbackReturns the vector (0, 0, -1).
Returns a copy of the vector with its length clamped to length.
Clamps this vector's length to length in place.
Returns a copy of this vector.
Sets this vector to the cross product of this vector and vec in place.
Like distance(), but returns the squared distance between vectors.
StaticdownReturns the vector (0, -1, 0).
Sets the x, y, and z components of this vector to scalar.
StaticforwardReturns the vector (0, 0, 1).
StaticleftReturns the vector (-1, 0, 0).
StaticlerpLinearly interpolates this vector towards target by factor t in place.
StaticmaxStaticminMoves this vector towards point by magnitude in place.
Returns a copy of the vector with its length scaled to 1.
Scales this vector's length to 1 in place.
StaticoneReturns the vector (1, 1, 1).
StaticorthonormalizeProjects this vector onto the plane defined by planeNormal in place.
StaticrandomGenerates a random 3D unit vector. Equivalent to a random point on a unit-radius sphere.
StaticrandomGenerates a random 3D unit vector. Equivalent to a random point on a unit-radius sphere.
Reflects this vector across the plane defined by planeNormal in place.
StaticrightReturns 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.
Rotates this vector towards the target vector by step radians in place.
The vectors may be non-normalized. The function preserves this 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 this vector away from target. It stops when the direction is precisely opposite to target.
If the vectors are in opposite directions, this vector is rotated along an arbitrary (but consistent) axis.
If either vector is zero magnitude, this vector is not modified.
Sets this vector to a random unit vector in place. Equivalent to a random point on a unit-radius sphere.
Alternative to setXYZ. Sets the x, y, and z components of this vector. Omit parameters or pass null or undefined to leave a component unchanged.
Optionalr: numberOptionalg: numberOptionalb: numberSets the x, y, and z components of this vector. Omit parameters or pass null or undefined to leave a component unchanged.
Optionalx: numberOptionaly: numberOptionalz: numberStaticslerpSpherically interpolates this vector towards target by factor t in place. Preserves vector magnitude by interpolating both direction and length.
Returns a string representation of the vector.
Multiplies the components of this vector by scale in place.
StaticupReturns the vector (0, 1, 0).
StaticzeroReturns 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