Capítulo 388 de 859

Chapter 388: BufferNode

Core Idea

A special type of uniform node which represents array-like data as uniform buffers. The access usually happens via element() which returns an instance of ArrayElementNode. For example:

In general, it is recommended to use the more managed UniformArrayNode since it handles more input types and automatically cares about buffer paddings.

Key Concepts

  • bufferCount : number: The uniform node that holds the value of the reference node.
  • bufferType : string: The data type of the buffer.
  • isBufferNode : boolean (readonly): This flag can be used for type testing.
  • updateRanges : Array.<{start: number, count: number}>: An array of update ranges.

Code Examples

const bufferNode = buffer( array, 'mat4', count );
const matrixNode = bufferNode.element( index ); // access a matrix from the buffer
  • What it demonstrates: Typical usage of BufferNode.

Reference Tables

Constructor

Signature
new BufferNode( value : Array.<number>, bufferType : string, bufferCount : number )

Properties

PropertyDescription
.bufferCount : numberThe uniform node that holds the value of the reference node.
.bufferType : stringThe data type of the buffer.
.isBufferNode : boolean (readonly)This flag can be used for type testing.
.updateRanges : Array.<{start: number, count: number}>An array of update ranges.

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.
.getElementType( builder : NodeBuilder ) : stringThe data type of the buffer elements.
.getInputType( builder : NodeBuilder ) : stringOverwrites the default implementation to return a fixed value 'buffer'.

Key Takeaways

  1. BufferNode extends: EventDispatcher → Node → InputNode → UniformNode
  2. Most relevant properties: bufferCount, bufferType, isBufferNode, updateRanges.
  3. Key methods: addUpdateRange, clearUpdateRanges, getElementType, getInputType.

Connects To