Creates a new Vector3
The x component
The y component
The z component
The x component
The y component
The z component
StaticsharedA static Vector3 reset to (0, 0, 0) on every access, for a result used straight away
This vector is shared and temporary. Do not store references to it.
Adds v to this vector
The point to add
The target to write the result into, defaults to this vector
The point the result was written into
Adds v * s to this vector, such as a velocity times the frame time
The point to scale and add
The scalar to multiply v by
The target to write the result into, defaults to this vector
The point the result was written into
Computes the angle between this vector and v
Returns π/2 when either vector has zero length.
The other vector
The angle in radians, from 0 to π
Transforms this point by m, translation included, without the divide
Vector3#applyMatrix4 does
Cheaper, and correct for any transform that doesn't project, such as a node's world transform.
The matrix to apply
The target to write the result into, defaults to this vector
The point the result was written into
Multiplies this vector by the 3x3 matrix m, such as a normal matrix
The matrix to apply
The target to write the result into, defaults to this vector
The point the result was written into
Transforms this point by m, translation included, then divides by the resulting w
The divide is what a projection matrix needs: with a camera's viewProjection, x and y come out from -1 to 1 across the visible area, and z from -1 at the near plane to 1 at the far plane. A point behind the camera can land inside that x and y range too, so check z as well. Use Vector3#applyAffineMatrix4 for transforms that don't project, and Vector3#transformDirection for directions.
The matrix to apply
The target to write the result into, defaults to this vector
The point the result was written into
Rotates this vector by the unit Quaternion q
The unit quaternion to rotate by
The target to write the result into, defaults to this vector
The point the result was written into
Clamps each component of this vector between the matching components of min and max
Assumes min <= max componentwise.
The lower bound per component
The upper bound per component
The target to write the result into, defaults to this vector
The point the result was written into
Copies x, y, z from the given point into this vector
The point to copy from
Copies this vector's x, y, z into the given point
The point to copy into
The given point with values updated
Computes the cross product this × v, a vector at right angles to both
The other vector
The target to write the result into, defaults to this vector
The point the result was written into
Computes the distance from this point to v
The point to measure to
Computes the squared distance from this point to v
Cheaper than Vector3#distanceTo and enough to compare distances.
The point to measure to
Divides each component of this vector by the matching component of v
The point to divide by
The target to write the result into, defaults to this vector
The point the result was written into
Divides each component of this vector by the scalar s
The scalar to divide by
The target to write the result into, defaults to this vector
The point the result was written into
Computes the dot product of this vector and v
For unit vectors it's the cosine of the angle between them: 1 when they point the same way, 0 at right angles and -1 when opposite.
The other vector
Checks whether x, y and z all match p exactly, with no tolerance
The point to compare against
Reads x, y, z from array starting at offset
The array to read from
The index of the first component
Computes the squared length of this vector
Cheaper than Vector3#magnitude, since it skips the square root, and enough to compare lengths.
Sets each component to the larger of this vector's and v's
The point to compare with
The target to write the result into, defaults to this vector
The point the result was written into
Sets each component to the smaller of this vector's and v's
The point to compare with
The target to write the result into, defaults to this vector
The point the result was written into
Multiplies each component of this vector by the matching component of v
The point to multiply by
The target to write the result into, defaults to this vector
The point the result was written into
Multiplies each component of this vector by the scalar s
The scalar to multiply by
The target to write the result into, defaults to this vector
The point the result was written into
Negates each component of this vector, reversing its direction
The target to write the result into, defaults to this vector
The point the result was written into
Scales this vector to unit length, keeping its direction
A zero vector stays zero.
The target to write the result into, defaults to this vector
The point the result was written into
Sets this point to the position the Cylindrical coordinate c describes
theta is the angle around Y, starting at +Z and turning toward +X, and y is the height above the
XZ plane.
The cylindrical coordinate to convert
Reads the first three values of column index of m into this vector
In a transform, column 3 is the translation and columns 0 to 2 are the X, Y and Z axes, scaled.
The matrix to read from
The column index, 0 to 3
Scales this vector so its length equals length, keeping its direction
A zero vector stays zero.
The target length
The target to write the result into, defaults to this vector
The point the result was written into
Subtracts v from this vector
The point to subtract
The target to write the result into, defaults to this vector
The point the result was written into
Writes this vector's values into array starting at offset
Allocates a new array when one is not supplied.
The array to write into
The index to write the first component at
The array the values were written into
Turns this direction by the rotation and scale in m, ignoring its translation, then normalizes it
The matrix whose rotation to apply
The target to write the result into, defaults to this vector
The point the result was written into
A point or direction in 3D, such as a position, a velocity or an offset
Math methods change the vector they're called on and return it, so calls chain. Pass an
outvector as the last argument to write the result there instead and leave this one as it is. In code that runs every frame, createoutvectors once and reuse them: anew Vector3()per frame is garbage the collector has to clean up.Where a method takes a point, any PointData3D works, such as a node's
positionor a plain{ x, y, z }object.Example