Vec3

A three dimensional vector.

Properties

  • x - double

  • y - double

  • z - double

Methods

Vec3:new(x, y, z)

  • x - What to set x to

  • y - What to set y to

  • z - What to set z to

Constructs a new Vec3 with the provided x, y and z.

Example:

length()

Returns the length of the Vec3

Example:

distanceTo(otherVec3)

  • otherVec3 - A different Vec3

Returns the distance from this vector to the otherVec3

Example:

distanceTo2D(otherVec3)

  • otherVec3 - A different Vec3

Returns the 2D distance from this vector to the otherVec3

Example:

getXYAngle()

Returns the angle which this vector is pointing at in the XY-Plane.

Example:

normalize360()

Returns a new Vec3 where all components are normalized between 0 and 360. Useful when working with viewangles.

Example:

normalized()

Returns this vector but normalized (that is with length 1)

Example:

scale(scalar)

  • scalar - By how much you want to scale the vector

Returns a scaled version of this vector

Example:

screenPosition()

Returns a Vec2 of where this Vec3 would be drawn on screen if it was a world position.

Example:

toVec2()

Returns the first 2 components of this vector as a Vec2

Example:

toString()

Returns a string representation of the Vec3

Example:

Last updated