Lens Scripting API

    Class vec2

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

    // Set the scale of a sprite using vec2 methods
    //@input Component.SpriteAligner spriteAligner
    //@input float spriteScale

    script.spriteAligner.size = vec2.one().uniformScale(script.spriteScale);
    Index

    Constructors

    • Creates a new instance of a vec2.

      Parameters

      • x: number
      • y: number

      Returns vec2

    Properties

    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 vec2.

    y: number

    y component of the vec2.

    Methods

    • Returns the vector plus vec.

      Parameters

      Returns vec2

    • Returns the angle between the vector and vec.

      Parameters

      Returns number

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

      Parameters

      • length: number

      Returns vec2

    • 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 vec2

    • Returns the dot product of the vector and vec.

      Parameters

      Returns number

    • Returns the vector (0, -1).

      Returns vec2

    • Returns whether this is equal to vec.

      Parameters

      Returns boolean

    • Returns the vector (-1, 0).

      Returns vec2

    • Linearly interpolates between the two vectors vecA and vecB by the factor t.

      Parameters

      Returns vec2

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

      Parameters

      Returns vec2

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

      Parameters

      Returns vec2

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

      Parameters

      • point: vec2
      • magnitude: number

      Returns vec2

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

      Parameters

      Returns vec2

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

      Returns vec2

    • Returns the vector (1, 1).

      Returns vec2

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

      Parameters

      Returns vec2

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

      Parameters

      Returns vec2

    • Generate a random 2D direction vector. This is equivalent to a random point on a unit-radius circle.

      Returns vec2

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

      Parameters

      Returns vec2

    • Returns the vector (1, 0).

      Returns vec2

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

      Parameters

      Returns vec2

    • Returns the vector minus vec.

      Parameters

      Returns vec2

    • Returns a string representation of the vector.

      Returns string

    • Multiplies the components by the number scale.

      Parameters

      • scale: number

      Returns vec2

    • Returns the vector (0, 1).

      Returns vec2

    • Returns the vector (0, 0).

      Returns vec2

    MMNEPVFCICPMFPCPTTAAATR