Skip to content

types.vector3

A 3D vector

Properties

NameDescription
xtype: number The x component
ytype: number The y component
ztype: number The z component

Functions

new(opt_x : number, opt_y : number, opt_z : number): types.vector3

Creates a new 3D vector

  • opt_x (number) (optional) The x component
  • opt_y (number) (optional) The y component
  • opt_z (number) (optional) The z component
  • returns (types.vector3) A new vector instance

add(other : types.vector3): types.vector3

Adds another vector to this one and returns a new vector

sub(other : types.vector3): types.vector3

Subtracts another vector from this one and returns a new vector

mul(other : types.vector3 | number): types.vector3

Multiplies this vector by another vector or a number and returns a new vector

div(other : types.vector3 | number): types.vector3

Divides this vector by another vector or a number and returns a new vector

dist(other : types.vector3): number

Returns the distance between this vector and another

  • other (types.vector3) The other vector
  • returns (number) The distance

length(): number

Returns the length of this vector

  • returns (number) The length

dot(other : types.vector3): number

Returns the dot product of this vector and another

  • other (types.vector3) The other vector
  • returns (number) The dot product

normalize(): types.vector3

Returns a normalized (unit length) version of this vector