Preparing search index...

    Class vec3

    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.");
    }
    Index

    Constructors

    • 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

    • Adds vec to this vector in place.

      Parameters

      Returns void

    • Returns the angle between the vector and vec.

      Parameters

      Returns number

    • Returns the vector (0, 0, -1).

      Returns vec3

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

      Parameters

      • length: number

      Returns vec3

    • Clamps this vector's length to length in place.

      Parameters

      • length: number

      Returns void

    • Returns a copy of this vector.

      Returns vec3

    • Copies matching components from the source vector, leaving other destination components untouched and ignoring extra source components. For example, copying a vec2 leaves z unchanged, while copying a vec4 ignores w.

      Parameters

      Returns void

    • Returns the cross product of the vector and vec

      Parameters

      Returns vec3

    • Sets this vector to the cross product of this vector and vec in place.

      Parameters

      Returns void

    • 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

    • Divides this vector by vec component-wise in place.

      Parameters

      Returns void

    • Returns the dot product of the vector and vec.

      Parameters

      Returns number

    • Returns the vector (0, -1, 0).

      Returns vec3

    • Returns whether this is equal to vec.

      Parameters

      Returns boolean

    • Sets the x, y, and z components of this vector to scalar.

      Parameters

      • scalar: number

      Returns void

    • Returns the vector (0, 0, 1).

      Returns vec3

    • Returns the vector (-1, 0, 0).

      Returns vec3

    • Linearly interpolates between the two vectors from and to by the factor t.

      Parameters

      Returns vec3

    • Linearly interpolates this vector towards target by factor t in place.

      Parameters

      • target: vec3
      • t: number

      Returns void

    • Returns a new vector containing the largest value of each component in the two vectors.

      Parameters

      Returns vec3

    • Returns a new vector containing the smallest value of each component in the two vectors.

      Parameters

      Returns vec3

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

      Parameters

      • target: vec3
      • step: number

      Returns vec3

    • Moves this vector towards point by magnitude in place.

      Parameters

      • point: vec3
      • magnitude: number

      Returns void

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

      Parameters

      Returns vec3

    • Multiplies this vector by vec component-wise in place.

      Parameters

      Returns void

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

      Returns vec3

    • Scales this vector's length to 1 in place.

      Returns void

    • Returns the vector (1, 1, 1).

      Returns vec3

    • Makes the vectors vecA and vecB normalized and orthogonal to each other.

      Parameters

      Returns void

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

      Parameters

      Returns vec3

    • Projects this vector onto the vector onto in place.

      Parameters

      Returns void

    • Projects the vector onto the plane defined by planeNormal.

      Parameters

      Returns vec3

    • Projects this vector onto the plane defined by planeNormal in place.

      Parameters

      Returns void

    • Generates a random 3D unit vector. Equivalent to a random point on a unit-radius sphere.

      Returns vec3

      Use Math.randomUnitVector or Math.setRandomUnitVector instead.

    • Generates a random 3D unit vector. Equivalent to a random point on a unit-radius sphere.

      Returns vec3

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

      Parameters

      Returns vec3

    • Reflects this vector across the plane defined by planeNormal in place.

      Parameters

      Returns void

    • Returns the vector (1, 0, 0).

      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

    • Rotates this vector towards the target vector by step radians in place.

      • The vectors may be non-normalized. The function preserves this 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 this vector away from target. It stops when the direction is precisely opposite to target.
      • If the vectors are in opposite directions, this vector is rotated along an arbitrary (but consistent) axis.
      • If either vector is zero magnitude, this vector is not modified.

      Parameters

      • target: vec3
      • step: number

      Returns void

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

      Parameters

      Returns vec3

    • Multiplies this vector by vec component-wise in place.

      Parameters

      Returns void

    • Sets this vector to a random unit vector in place. Equivalent to a random point on a unit-radius sphere.

      Returns void

    • Alternative to setXYZ. Sets the x, y, and z components of this vector. Omit parameters or pass null or undefined to leave a component unchanged.

      Parameters

      • Optionalr: number
      • Optionalg: number
      • Optionalb: number

      Returns void

    • Sets the x, y, and z components of this vector. Omit parameters or pass null or undefined to leave a component unchanged.

      Parameters

      • Optionalx: number
      • Optionaly: number
      • Optionalz: number

      Returns void

    • Spherically interpolates between the two vectors from and to by the factor t.

      Parameters

      Returns vec3

    • Spherically interpolates this vector towards target by factor t in place. Preserves vector magnitude by interpolating both direction and length.

      Parameters

      • target: vec3
      • t: number

      Returns void

    • Returns the vector minus vec.

      Parameters

      Returns vec3

    • Subtracts vec from this vector in place.

      Parameters

      Returns void

    • Returns a string representation of the vector.

      Returns string

    • Multiplies the components of this vector by scale.

      Parameters

      • scale: number

      Returns vec3

    • Multiplies the components of this vector by scale in place.

      Parameters

      • scale: number

      Returns void

    • Returns the vector (0, 1, 0).

      Returns vec3

    • Returns the vector (0, 0, 0).

      Returns vec3