Vec3
A point in 3d space.
Constructors
Constructor
new Vec3(
x,y,z):Vec3
Creates a new Vec3 instance with the given coordinates
Parameters
x
number
y
number
z
number
Returns
Vec3
Methods
add()
add(
vec3):Vec3
Adds another vector to this one
Parameters
vec3
Vec3
The vector to add
Returns
Vec3
A new vector representing the sum
distanceTo()
distanceTo(
vec3):number
Calculates the distance to another vector
Parameters
vec3
Vec3
The vector to calculate distance to
Returns
number
The distance between the two vectors
getLength()
getLength():
number
Gets the length/magnitude of this vector
Returns
number
The vector length
getX()
getX():
number
Gets the X coordinate
Returns
number
The X coordinate
getY()
getY():
number
Gets the Y coordinate
Returns
number
The Y coordinate
getZ()
getZ():
number
Gets the Z coordinate
Returns
number
The Z coordinate
normalize()
normalize():
Vec3
Normalizes this vector to have a length of 1
Returns
Vec3
A new normalized vector
subtract()
subtract(
vec3):Vec3
Subtracts another vector from this one
Parameters
vec3
Vec3
The vector to subtract
Returns
Vec3
A new vector representing the difference
Last updated