Vector3
A point or direction in the world, as { x, y, z } in metres, where z is height. Arithmetic methods modify the vector and return it, so they chain, and you should call clone() first if you still need the original. Any object with x, y and z works where the API expects a Vector3.
vector3.zero()
Vector3.zero()(0, 0, 0).
vector3.one()
Vector3.one()(1, 1, 1).
vector3.up()
Vector3.up()(0, 1, 0). Note that up in the game world is +Z, so this helper does not point up there.
vector3.forward()
Vector3.forward()(0, 0, 1). Note that characters in the game world face +Y, so this helper does not match them.
vector3.right()
Vector3.right()(1, 0, 0).
vector3.cross()
cross(other)Makes this the cross product of itself and another vector.
vector3.set()
set(...values)Sets the components: set(x, y, z).
vector3.add()
add(other)Adds another vector to this one.
vector3.sub()
sub(other)Subtracts another vector from this one.
vector3.mul()
mul(scalar)Multiplies every component by a number.
vector3.div()
div(scalar)Divides every component by a number (not 0).
vector3.dot()
dot(other)The dot product with another vector.
vector3.lengthSquared
lengthSquaredThe length squared (cheaper when comparing distances).
vector3.length
lengthThe vector's length.
vector3.normalize()
normalize()Scales this vector to length 1 (a zero vector stays zero).
vector3.lerp()
lerp(target, t)Moves this vector towards a target: t = 0 stays, 1 reaches it.
vector3.distance()
distance(other)The distance to another point.
vector3.clone()
clone()A copy.
vector3.x
x: numberAlong the world's x axis.
vector3.y
y: numberAlong the world's y axis.
vector3.z
z: numberHeight.