Vector4

Four numbers, { x, y, z, w }. Arithmetic methods modify the vector and return it, so call clone() first if you still need the original.

vector4.zero()

Vector4.zero()

(0, 0, 0, 0).

vector4.one()

Vector4.one()

(1, 1, 1, 1).

vector4.set()

set(...values)

Sets the components: set(x, y, z, w).

vector4.add()

add(other)

Adds another vector to this one.

vector4.sub()

sub(other)

Subtracts another vector from this one.

vector4.mul()

mul(scalar)

Multiplies every component by a number.

vector4.div()

div(scalar)

Divides every component by a number (not 0).

vector4.dot()

dot(other)

The dot product with another vector.

vector4.lengthSquared

lengthSquared

The length squared.

vector4.length

length

The vector's length.

vector4.normalize()

normalize()

Scales this vector to length 1 (a zero vector stays zero).

vector4.lerp()

lerp(target, t)

Moves this vector towards a target: t = 0 stays, 1 reaches it.

vector4.distance()

distance(other)

The distance to another point.

vector4.clone()

clone()

A copy.

vector4.x

x: number

The first component.

vector4.y

y: number

The second component.

vector4.z

z: number

The third component.

vector4.w

w: number

The fourth component.