Cluster Creator Kit Script Reference
    Preparing search index...

    Class Vector2

    A 2-dimensional vector.

    Methods that manipulate values are generally destructive. To preserve the original values, explicitly call clone() to create a duplicate instance.

    Index

    Constructors

    Properties

    x: number
    y: number

    Methods

    • Adds v to the vector's value.

      Parameters

      Returns this

    • Adds the scalar value s to the vector's x and y components.

      Parameters

      • s: number

      Returns this

    • Returns the size of the 2-dimensional cross product of the vector and v.

      Parameters

      Returns number

    • Divides the vector by v.

      Parameters

      Returns this

    • Divides the vector by the scalar value s.

      Parameters

      • s: number

      Returns this

    • Returns the dot product of the vector and v.

      Parameters

      Returns number

    • Compares the vector to v, and returns true if they are approximately equal.

      Parameters

      Returns boolean

    • Returns the vector's length.

      Returns number

    • Returns the vector's squared length.

      Returns number

    • Calculates the linear interpolation (lerp) between the current value and v, using a as the interpolation factor, then updates the vector's value to the result.

      Parameters

      • v: Vector2
      • a: number

        The interpolation factor, specified as a number between [0, 1].

      Returns this

    • Multiplies the vector by v.

      Parameters

      Returns this

    • Multiplies the vector by the scalar value s.

      Parameters

      • s: number

      Returns this

    • Negates the vector's value.

      Returns this

    • Normalizes the vector's value.

      Returns this

    • Sets the vector's component values to those specified in x and y.

      Parameters

      • x: number
      • y: number

      Returns this

    • Subtracts v from the vector's value.

      Parameters

      Returns this

    • Subtracts the scalar value s from the vector's x and y components.

      Parameters

      • s: number

      Returns this