Vector3D

new Vector3D(x, y, z)

A 3D Vector.

Parameters:
Name Type Description
x float The X component of the vector.
y float The Y component of the vector.
z float The Z component of the vector.

Methods

add(other) → {Vector3D}

Add this vector to another.

Parameters:
Name Type Description
other Vector3D The other vector to use in the calculation.
Returns:
Vector3D A new vector representing the sum of the two vectors.

asArray() → {Array.<int>}

Get the vector values as an array.

Returns:
Array.<int> An array in the form of [x,y,z].

cross(other) → {Vector3D}

Calculate the vector cross product.

Parameters:
Name Type Description
other Vector3D The other vector to use in the calculation.
Returns:
Vector3D A new vector representing the cross product.

dot(other) → {float}

Calculate the vector dot product.

Parameters:
Name Type Description
other Vector3D The other vector to use in the calculation.
Returns:
float The dot product.

length() → {float}

Get the length of the vector.

Returns:
float The vector length.

normalize()

Normalizes the existing vector.

scaleInPlace(factor)

Scales the vector.

Parameters:
Name Type Description
factor float The scale factor.

set(other)

Set the vector to the values of another vector.

Parameters:
Name Type Description
other Vector3D The other vector.

setFromArray(arr)

Set the vector values from an array.

Parameters:
Name Type Description
arr Array.<integer> An array in the form of [x,y,z].

subtract(other) → {Vector3D}

Subtract another vector from this vector.

Parameters:
Name Type Description
other Vector3D The other vector to use in the calculation.
Returns:
Vector3D A new vector representing the difference of the two vectors (this vector - other vector).