Represents a vector with three components. Vectors created with
Vector.xy have z = 0. All magnitude and interpolation operations
(length, dot, distance, normalized, lerp, …) use all three
components; with z = 0 they behave exactly as 2D math.
Fields
The x component of the vector (read-only).
The y component of the vector (read-only).
The z component of the vector (read-only). Zero for vectors created
with Vector.xy; populated by 3D APIs that return a Vector .
Constructors
Creates a vector with the specified x and y components.
xyz
Creates a vector with the specified x, y and z components.
origin
Returns the zero vector (0, 0).
cross3
Returns the 3D cross product of two vectors.
scaleAndAdd
Returns a + b * scale.
scaleAndSub
Returns a - b * scale.
lerp
Returns the linear interpolation from one vector to another, using t
where 0 returns from and 1 returns to.
normalized
Returns a normalized copy of the given vector.
Static Functions
distance
Returns the distance between the two vectors.
distanceSquared
Returns the squared distance between the two vectors.
dot
Returns the dot product of the two vectors.
cross
Returns the cross product of two vectors (z-component of the 3D cross product).
length
Returns the length of the given vector.
lengthSquared
Returns the squared length of the given vector.
Methods
length
Deprecated - Use Vector.length instead.
Returns the length of the vector.
lengthSquared
Deprecated - Use Vector.lengthSquared instead.
Returns the squared length of the vector.
normalized
Deprecated - Use Vector.normalized instead.
Returns a normalized copy of the vector. If the length is zero,
the result is the zero vector.
__eq
Returns true if the two vectors have equal components.
__unm
Returns the negated vector.
__add
Returns the sum of two vectors.
__sub
Returns the difference between two vectors.
__mul
Returns the vector scaled by the given number.
__div
Returns the vector divided by the given number.
distance
Deprecated - Use Vector.distance instead.
Returns the distance to the other vector.
distanceSquared
Deprecated - Use Vector.distanceSquared instead.
Returns the squared distance to the other vector.
dot
Deprecated - Use Vector.dot instead.
Returns the dot product of the vector and the other vector.
lerp
Deprecated - Use Vector.lerp instead.
Returns the linear interpolation between the vector and the other
vector, using t where 0 returns the vector and 1 returns the other.
writeToBuffer
Writes x, y, z as 12 bytes (three float32) into the buffer at
byteOffset.
writeVec4
Writes x, y, z, w as 16 bytes (four float32) into the buffer at
byteOffset, matching a vec4 uniform-buffer slot.