Skip to content

Vector3

Summary

Properties Properties of a `Vector3`.

Constants Constants of a `Vector3`.

Constructors Constructors of a `Vector3`.

Methods Methods of a `Vector3`.

Properties

X

Number

The X-axis component of the vector.


Y

Number

The Y-axis component of the vector.


Z

Number

The Z-axis component of the vector.


Magnitude

Number

The magnitude (aka. length) of the vector.


Unit

Vector3

The normalized vector.


Constants

zero

Vector3

Vector3.zero

The vector (0, 0, 0).


one

Vector3

Vector3.one

The vector (1, 1, 1).


xAxis

Vector3

Vector3.xAxis

The unit vector along the X axis, (1, 0, 0).


yAxis

Vector3

Vector3.yAxis

The unit vector along the Y axis, (0, 1, 0).


zAxis

Vector3

Vector3.zAxis

The unit vector along the Z axis, (0, 0, 1).


Constructors

new(X: Number, Y: Number, Z: Number)

Vector3

Returns a new Vector3 from the given components.


Methods

Dot(other: Vector3)

Vector3

Returns the dot product of two vectors.


Cross(other: Vector3)

Vector3

Returns the cross product of two vectors.

Lerp(other: Vector3, alpha: Number)

Vector3

Returns an interpolated vector between self and other.

When alpha is 0.0 it returns self; when alpha is 0.5 it returns the vector directly between self and other; when alpha is 1.0 it returns other.

Operators

Vector3 + Vector3

Vector3

Adds the components of two vectors.


Vector3 - Vector3

Vector3

Subtracts the components of two vectors.


Vector3 * Vector3 | Number

Vector3

Multiplies component-wise if both operands are Vector3, or scales every component if one operand is a Number.


Vector3 / Vector3 | Number

Vector3

Divides component-wise if both operands are Vector3, or scales every component if the denominator is a Number.


-Vector3

Vector3

Returns the negation of the vector.


Vector3 == Vector3

Boolean

Returns whether two vectors have equal X, Y, and Z components.


tostring(Vector3)

string

Formats the vector as "X, Y, Z" with 3 decimal places, e.g. "1.000, 2.000, 3.000".