Class Vector2Array<Buffer>

A typed array of three.js Vector2s.

Type Parameters

Hierarchy (view full)

Constructors

Properties

_array: Buffer
dimension: 2 = ...

Accessors

  • get byteLength(): number
  • The length in bytes of the array.

    Returns number

  • get length(): number
  • Returns the number of vectors in this array.

    Returns number

  • set length(v): void
  • Parameters

    • v: number

    Returns void

Methods

  • Clones this array.

    Returns Vector2Array<
        | Int8Array
        | Uint8Array
        | Uint8ClampedArray
        | Int16Array
        | Uint16Array
        | Int32Array
        | Uint32Array
        | Float32Array
        | Float64Array>

  • Allocates a new underlying array to match the new size, then copy the content of the previous array at the beginning of the new array.

    Parameters

    • newSize: number

      The new size, in number of vectors.

    Returns this

  • Performs the specified action for each element in an array.

    Note that mutating the callback value will not mutate the underlying array. To mutate the underlying array, use the index provided as second argument, then mutate the array with a mutating method, such as setVector:

    const array = new Vector3Array(...);

    // Add one to each Y value of the array
    array.forEach((v, index) => {
    // This has no effect on the Vector3Array:
    v.setY(v.y + 1);

    // Use this pattern instead:
    array.setVector(index, new Vector3(v.x, v.y + 1, v.z));

    // Or this one
    array.setY(index, v.y + 1);
    })

    Parameters

    • callbackfn: ((value: Readonly<Vector2>, index: number, array: this) => void)

      A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.

        • (value, index, array): void
        • Parameters

          • value: Readonly<Vector2>
          • index: number
          • array: this

          Returns void

    Returns void

  • Gets the fourth component of the vector at the specified index, or null if the dimension of this array is less than 4.

    Parameters

    • index: number

    Returns null | number

  • Gets the third component of the vector at the specified index, or null if the dimension of this array is less than 3.

    Parameters

    • index: number

    Returns null | number

  • Pushes a vector at the end of the array, allocating memory if necessary.

    Parameters

    • x: number
    • y: number
    • Optionalz: number
    • Optionalw: number

    Returns void

  • Sets the component of the array at the specified index.

    Parameters

    • index: number
    • x: number
    • y: number
    • Optionalz: number
    • Optionalw: number

    Returns void

  • Returns the Float32Array equivalent of this vector array. Note: if the underlying array is already a Float32Array, this array is returned. Otherwise, a new array is constructed.

    Returns Float32Array