gpu-curtains
    Preparing search index...

    Class Vec2

    Really basic 2D vector class used for vector calculations

    Index

    Constructors

    • Vec2 constructor

      Parameters

      • x: number = 0

        X component of our Vec2

      • y: number = x

        Y component of our Vec2

      Returns Vec2

    Properties

    type: string

    The type of the Vec2

    Accessors

    Methods

    • Called when at least one component of the Vec2 has changed

      Parameters

      • callback: () => void

        callback to run when at least one component of the Vec2 has changed

      Returns Vec2

    • Set the Vec2 from values

      Parameters

      • x: number = 0

        new X component to set

      • y: number = x

        new Y component to set

      Returns Vec2

      • this Vec2 after being set
    • Add a scalar to all the components of this Vec2

      Parameters

      • value: number = 0

        number to add

      Returns Vec2

      • this Vec2 after addition
    • Subtract a scalar to all the components of this Vec2

      Parameters

      • value: number = 0

        number to subtract

      Returns Vec2

      • this Vec2 after subtraction
    • Multiply all components of this Vec2 with a scalar

      Parameters

      • value: number = 1

        number to multiply with

      Returns Vec2

      • this Vec2 after multiplication
    • Divide all components of this Vec2 with a scalar

      Parameters

      • value: number = 1

        number to divide with

      Returns Vec2

      • this Vec2 after division
    • Calculate the linear interpolation of this Vec2 by given Vec2 and alpha, where alpha is the percent distance along the line

      Parameters

      • vector: Vec2 = ...

        Vec2 to interpolate towards

      • Optionalalpha: number = 1

        interpolation factor in the [0, 1] interval

      Returns Vec2

      • this Vec2 after linear interpolation