A three dimensional vector. Vectors can only store finite numbers in the range Number.MIN_VALUE to Number.MAX_VALUE.

// Check the distance between two objects
//@input SceneObject objectA
//@input SceneObject objectB
//@input float distCheck

var pointA = script.objectA.getTransform().getWorldPosition();
var pointB = script.objectB.getTransform().getWorldPosition();
var distance = pointA.distance(pointB);
if(distance > script.distCheck)
{
print("Too Far.");
}

Constructors

  • Creates a new instance of a vec3.

    Parameters

    • x: number
    • y: number
    • z: number

    Returns vec3

Properties

b: number

Alternate name for the z component.

g: number

Alternate name for the y component.

length: number

Returns the length of the vector.

lengthSquared: number

Returns the squared length of the vector.

r: number

Alternate name for the x component.

x: number

x component of the vec3.

y: number

y component of the vec3.

z: number

z component of the vec3.

Methods

  • Returns the vector plus vec.

    Parameters

    Returns vec3

  • Returns the angle in radians between the vector and vec.

    Parameters

    Returns number

  • Returns a copy of the vector with its length clamped to length.

    Parameters

    • length: number

    Returns vec3

  • Returns the cross product of the vector and vec

    Parameters

    Returns vec3

  • Returns the distance between the vector and the vector vec.

    Parameters

    Returns number

  • Like distance(), but returns the squared distance between vectors.

    Parameters

    Returns number

  • Returns the division of the vector by the vector vec.

    Parameters

    Returns vec3

  • Returns the dot product of the vector and vec.

    Parameters

    Returns number

  • Returns whether this is equal to vec.

    Parameters

    Returns boolean

  • Returns a copy of the vector moved towards the point point by the amount magnitude.

    Parameters

    • point: vec3
    • magnitude: number

    Returns vec3

  • Returns the component-wise multiplication product of the vector and vec.

    Parameters

    Returns vec3

  • Returns a copy of the vector with its length scaled to 1.

    Returns vec3

  • Returns a copy of the vector projected onto the vector vec.

    Parameters

    Returns vec3

  • Projects the vector onto the plane represented by the normal normal.

    Parameters

    Returns vec3

  • Returns a copy of the vector reflected across the plane defined by the normal vec.

    Parameters

    Returns vec3

  • Returns a copy of the vector rotated towards the target vector by step radians.

    The vectors may be non-normalized. The function always returns a vector with the source vector's magnitude. This prevents overshoot. If step exceeds the angle between vectors, it stops at the target direction. If step is negative, this rotates the source vector away from target. It stops when the direction is precisely opposite to target. If the vectors are in opposite directions, the result is rotated along an arbitrary (but consistent) axis. If either vector is zero magnitude, it returns the source vector.

    Parameters

    • target: vec3
    • step: number

    Returns vec3

  • Returns the component-wise multiplication product of the vector and vec.

    Parameters

    Returns vec3

  • Returns the vector minus vec.

    Parameters

    Returns vec3

  • Returns a string representation of the vector.

    Returns string

  • Multiplies the components by the number scale.

    Parameters

    • scale: number

    Returns vec3