BufferAttribute

This class stores data for an attribute (such as vertex positions, face indices, normals, colors, UVs, and any custom attributes ) associated with a BufferGeometry, which allows for more efficient passing of data to the GPU. See that page for details and a usage example.<br /><br /> Data is stored as vectors of any length (defined by itemSize), and in general in the methods outlined below if passing in an index, this is automatically multiplied by the vector length.

Core Class

This class stores data for an attribute (such as vertex positions, face indices, normals, colors, UVs, and any custom attributes ) associated with a BufferGeometry, which allows for more efficient passing of data to the GPU. See that page for details and a usage example.

Data is stored as vectors of any length (defined by itemSize), and in general in the methods outlined below if passing in an index, this is automatically multiplied by the vector length.

Type Parameters

  • T extends TypedArray = TypedArray

Hierarchy

Constructors

  • Type Parameters

    • T extends TypedArray = TypedArray

    Parameters

    • array: T
    • itemSize: number

    Returns BufferAttribute<T>

Properties

_array: T

The geometry attribute data store as TypedArray.

itemSize: number

If the buffer is storing a 3-component vector (such as a position, normal, or color), then this will count the number of such vectors stored.

normalized: boolean

If attribute data is normalized.

count: number

Stores the array's length divided by the itemSize.

If the buffer is storing a 3-component vector (such as a position, normal, or color), then this will count the number of such vectors stored.

dynamic: boolean

The data of this buffer always need update.

will not take effect, update attribute.array if need to reupload

updateRange: { offset: number; count: number }

Object containing:
offset:Integer - Default is 0. Position at which to start update.
count:Integer - Default is -1, which means don't use update ranges.

This can be used to only update some components of stored vectors (for example, just the component related to color).

will not take effect, update attribute.array instead

isBufferAttribute: boolean

Used to check type of this or extended instance. This value should not be changed by user.

isDataDropped: boolean

When the data is cleared from memory, this mark will be set true.

never updated, always false.

removeDataAfterUpload: boolean

Remove the data after it is uploaded to GPU memory.

will not take effect

version: number

A version number, incremented every time the needsUpdate property is set to true.

onUpdateCallback: () => void

A callback function for updating. It will be called after needsUpdate.

onUploadCallback: () => void

A callback function for uploading. It will be called after the data uploaded to WebGL.

userData: Record<keyof any, any>
_uuid: any
uuid: string
_listeners: Map<Symbol, Listener<never>[]>

Accessors

  • get array(): T

    The geometry attribute data store as TypedArray.

    Returns T

  • set array(v: T): void

    Parameters

    Returns void

  • set needsUpdate(value: boolean): void

    When this attribute is set to true, the version will be change.

    Parameters

    • value: boolean

    Returns void

  • get businessTag(): string

    Returns string

  • set businessTag(v: string): void

    Parameters

    • v: string

    Returns void

Methods

  • Returns void

  • Change the data of array.

    Parameters

    • array: T

    Returns this

  • Change the state of dynamic.

    Parameters

    • value: boolean

    Returns this

  • Copy the data at specified position. The given index is items' index, do not need to multiply with item' size.

    Parameters

    • index1: number

      the start position of this array.

    • attribute: BufferAttribute

      the start position of this array.

    • index2: number

      the start position of source array.

    Returns this

  • Copy the data from given array to this array.

    Parameters

    • array: TypedArray | number[]

      the start position of this array.

    Returns this

  • Copy the data from given array to this array.

    Parameters

    • colors: Color[]

      the start position of this array.

    Returns this

  • Copy the data which is type of Vector2 from given array to this array.

    Parameters

    • vectors: Vector2[]

      the start position of this array.

    Returns this

  • Copy the data which is type of Vector3 from given array to this array.

    Parameters

    • vectors: Vector3[]

      the start position of this array.

    Returns this

  • Copy the data which is type of Vector4 from given array to this array.

    Parameters

    • vectors: Vector4[]

      the start position of this array.

    Returns this

  • Copy the data from given Array or typedArray.

    Parameters

    • value: ArrayLike<number>

      an Array or TypedArray from which to copy values.

    • offset: number

      (optional) index of the array at which to start copying.

    Returns this

  • Return the x component of all items.

    Parameters

    • index: number

    Returns number

  • Set the x component of the vector at the given index.

    Parameters

    • index: number
    • x: number

    Returns this

  • Return the y component of all vectors.

    Parameters

    • index: number

    Returns number

  • Set the y component of the vector at the given index.

    Parameters

    • index: number
    • y: number

    Returns this

  • Return the z component of all vectors.

    Parameters

    • index: number

    Returns number

  • Set the z component of the vector at the given index.

    Parameters

    • index: number
    • z: number

    Returns this

  • Return the w component of all vectors.

    Parameters

    • index: number

    Returns number

  • Set the w component of the vector at the given index.

    Parameters

    • index: number
    • w: number

    Returns this

  • Set the x and y component of the vector at the given index.

    Parameters

    • index: number
    • x: number
    • y: number

    Returns this

  • Set the x , y and z component of the vector at the given index.

    Parameters

    • index: number
    • x: number
    • y: number
    • z: number

    Returns this

  • Set all component of the vector at the given index.

    Parameters

    • index: number
    • x: number
    • y: number
    • z: number
    • w: number

    Returns this

  • Return the vector2 at specific position.

    Parameters

    Returns Vector2

  • Release the memory which is occupied by this instance from CPU and GPU.

    Returns void

  • Returns void

  • Parameters

    • v: string

    Returns this

  • Returns boolean

  • Returns void

  • Returns void

  • Returns void

  • Adds a listener to an event type.

    Type Parameters

    • T

    Parameters

    • _type: EventType<T>
    • _listener: Listener<T>

    Returns void

  • Only active the listener one times and then off it| it.

    Type Parameters

    • T

    Parameters

    • _type: EventType<T>
    • _listener: Listener<T>

    Returns void

  • Checks if listener is added to an event type.

    Type Parameters

    • T

    Parameters

    • _type: EventType<T>
    • _listener: Listener<T>

    Returns boolean

  • Removes a listener from listening list.

    Type Parameters

    • T

    Parameters

    • _type: EventType<T>
    • _listener: Listener<T>

    Returns void

  • Active the event and call the registered listener.

    Parameters

    • type: EventType<never>

    Returns void

  • Type Parameters

    • T

    Parameters

    • type: EventType<T>
    • payload: T

    Returns void

  • Removes all listeners from listening list.

    Returns void