Vector3d
An immutable direction and length. Destructures as const [x, y, z] = vector.
Implements
Section titled “Implements”Iterable<number>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Vector3d(
x?,y?,z?):Vector3d
Creates a vector from components, which default to 0.
Parameters
Section titled “Parameters”number
number
number
Returns
Section titled “Returns”Vector3d
Properties
Section titled “Properties”length
Section titled “length”
readonlylength:number
Length of the vector.
readonlyx:number
X component.
readonlyy:number
Y component.
readonlyz:number
Z component.
Methods
Section titled “Methods”[iterator]()
Section titled “[iterator]()”[iterator]():
Iterator<number>
Returns
Section titled “Returns”Iterator<number>
Implementation of
Section titled “Implementation of”Iterable.[iterator]
add(
other):Vector3d
Component-wise sum.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Vector3d
angleBetween()
Section titled “angleBetween()”angleBetween(
other):number
Angle to another vector, in radians.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”number
cross()
Section titled “cross()”cross(
other):Vector3d
Cross product.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Vector3d
dot(
other):number
Dot product.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”number
equals()
Section titled “equals()”equals(
other):boolean
Exact component equality.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”boolean
negate()
Section titled “negate()”negate():
Vector3d
The vector pointing the opposite way.
Returns
Section titled “Returns”Vector3d
normalize()
Section titled “normalize()”normalize():
Vector3d
A vector with the same direction and length 1. Throws RangeError for a zero vector.
Returns
Section titled “Returns”Vector3d
scale()
Section titled “scale()”scale(
factor):Vector3d
Multiplies every component by factor.
Parameters
Section titled “Parameters”factor
Section titled “factor”number
Returns
Section titled “Returns”Vector3d
subtract()
Section titled “subtract()”subtract(
other):Vector3d
Component-wise difference.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Vector3d
toArray()
Section titled “toArray()”toArray(): [
number,number,number]
The components as an [x, y, z] array.
Returns
Section titled “Returns”[number, number, number]
transform()
Section titled “transform()”transform(
transformation):Vector3d
Applies a transformation without its translation.
Parameters
Section titled “Parameters”transformation
Section titled “transformation”Returns
Section titled “Returns”Vector3d
from()
Section titled “from()”
staticfrom(value):Vector3d
Converts a tuple, or returns an existing vector unchanged.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Vector3d