Capítulo 669 de 859

Chapter 669: InterleavedBuffer

Core Idea

"Interleaved" means that multiple attributes, possibly of different types, (e.g., position, normal, uv, color) are packed into a single array buffer.

An introduction into interleaved arrays can be found here: Interleaved array basics

Key Concepts

  • array : TypedArray: A typed array with a shared buffer storing attribute data.
  • count : number (readonly): The total number of elements in the array
  • isInterleavedBuffer : boolean (readonly): This flag can be used for type testing.
  • needsUpdate : number: Flag to indicate that this attribute has changed and should be re-sent to the GPU. Set this to true when you modify the value of the arra…
  • stride : number: The number of typed-array elements per vertex.
  • updateRanges : Array.<Object>: This can be used to only update some components of stored vectors (for example, just the component related to color). Use the `addUpdateRan…
  • usage : StaticDrawUsage | DynamicDrawUsage | StreamDrawUsage | StaticReadUsage | DynamicReadUsage | StreamReadUsage | StaticCopyUsage | DynamicCopyUsage | StreamCopyUsage: Defines the intended usage pattern of the data store for optimization purposes.
  • uuid : string (readonly): The UUID of the interleaved buffer.
  • version : number: A version number, incremented every time the needsUpdate is set to true.

Reference Tables

Constructor

Signature
new InterleavedBuffer( array : TypedArray, stride : number )

Properties

PropertyDescription
.array : TypedArrayA typed array with a shared buffer storing attribute data.
.count : number (readonly)The total number of elements in the array
.isInterleavedBuffer : boolean (readonly)This flag can be used for type testing.
.needsUpdate : numberFlag to indicate that this attribute has changed and should be re-sent to the GPU. Set this to true when you modify the value of the array.
.stride : numberThe number of typed-array elements per vertex.
.updateRanges : Array.<Object>This can be used to only update some components of stored vectors (for example, just the component related to color). Use the addUpdateRange() function to add ranges to this array.
`.usage : StaticDrawUsageDynamicDrawUsage
.uuid : string (readonly)The UUID of the interleaved buffer.
.version : numberA version number, incremented every time the needsUpdate is set to true.

Methods

MethodDescription
.addUpdateRange( start : number, count : number )Adds a range of data in the data array to be updated on the GPU.
.clearUpdateRanges()Clears the update ranges.
.clone( data : Object ) : InterleavedBufferReturns a new interleaved buffer with copied values from this instance.
.copy( source : InterleavedBuffer ) : InterleavedBufferCopies the values of the given interleaved buffer to this instance.
.copyAt( index1 : number, interleavedBuffer : InterleavedBuffer, index2 : number ) : InterleavedBufferCopies a vector from the given interleaved buffer to this one. The start and destination position in the attribute buffers are represented by the given indices.
.onUpload( callback : function ) : InterleavedBufferSets the given callback function that is executed after the Renderer has transferred the array data to the GPU. Can be used to perform clean-up operations after the upload when data are not needed an…
.onUploadCallback()A callback function that is executed after the renderer has transferred the attribute array data to the GPU.
`.set( value : TypedArrayArray, offset : number ) : InterleavedBuffer`
`.setUsage( value : StaticDrawUsageDynamicDrawUsage
.toJSON( data : Object ) : ObjectSerializes the interleaved buffer into JSON.

Key Takeaways

  1. Most relevant properties: array, count, isInterleavedBuffer, needsUpdate.
  2. Key methods: addUpdateRange, clearUpdateRanges, clone, copy.

Connects To