pronotron-tech-art-suite
    Preparing search index...

    Class representing a 2D vector. A 2D vector is an ordered pair of numbers (labeled x and y), which can be used to represent a number of things, such as:

    • A point in 2D space (i.e. a position on a plane).
    • A direction and length across a plane. In three.js the length will always be the Euclidean distance(straight-line distance) from (0, 0) to (x, y) and the direction is also measured from (0, 0) towards (x, y).
    • Any arbitrary ordered pair of numbers. Iterating through a vector instance will yield its components (x, y) in the corresponding order.
    const vector = new Vector2( 0, 1 );
    
    Index

    Constructors

    Properties

    x y

    Methods

    Constructors

    Properties

    x: number
    y: number

    Methods

    • Returns Generator<number, void, unknown>

    • If this vector's x or y value is greater than the max vector's x or y value, it is replaced by the corresponding value. If this vector's x or y value is less than the min vector's x or y value, it is replaced by the corresponding value.

      Parameters

      • min: Vector2

        The minimum x and y values.

      • max: Vector2

        The maximum x and y values in the desired range.

      Returns Vector2

      A reference to this vector.

    • Computes the square of the Euclidean length (straight-line length) from (0, 0) to (x, y). If you are comparing the lengths of vectors, you should compare the length squared instead as it is slightly more efficient to calculate.

      Returns number

      The square length of this vector.

    • Sets the vector components.

      Parameters

      • x: number

        The value of the x component.

      • y: number

        The value of the y component.

      Returns Vector2

      A reference to this vector.