Capítulo 656 de 859

Chapter 656: GLBufferAttribute

Core Idea

An alternative version of a buffer attribute with more control over the VBO.

The renderer does not construct a VBO for this kind of attribute. Instead, it uses whatever VBO is passed in constructor and can later be altered via the buffer property.

The most common use case for this class is when some kind of GPGPU calculation interferes or even produces the VBOs in question.

Notice that this class can only be used with WebGLRenderer.

Key Concepts

  • buffer : WebGLBuffer: The native WebGL buffer.
  • count : number: The expected number of vertices in VBO.
  • elementSize : number: The corresponding size (in bytes) for the given type parameter.
  • isGLBufferAttribute : boolean (readonly): This flag can be used for type testing.
  • itemSize : number: The item size, see BufferAttribute#itemSize.
  • name : string: The name of the buffer attribute.
  • 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…
  • normalized : boolean: Applies to integer data only. Indicates how the underlying data in the buffer maps to the values in the GLSL code. For instance, if `buffer…
  • type : number: The native data type.
  • version : number: A version number, incremented every time the needsUpdate is set to true.

Reference Tables

Constructor

Signature
new GLBufferAttribute( buffer : WebGLBuffer, type : number, itemSize : number, elementSize : number, count : number, normalized : boolean )

Properties

PropertyDescription
.buffer : WebGLBufferThe native WebGL buffer.
.count : numberThe expected number of vertices in VBO.
.elementSize : numberThe corresponding size (in bytes) for the given type parameter.
.isGLBufferAttribute : boolean (readonly)This flag can be used for type testing.
.itemSize : numberThe item size, see BufferAttribute#itemSize.
.name : stringThe name of the buffer attribute.
.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.
.normalized : booleanApplies to integer data only. Indicates how the underlying data in the buffer maps to the values in the GLSL code. For instance, if buffer contains data of gl.UNSIGNED_SHORT, and normalized is …
.type : numberThe native data type.
.version : numberA version number, incremented every time the needsUpdate is set to true.

Methods

MethodDescription
.setBuffer( buffer : WebGLBuffer ) : BufferAttributeSets the given native WebGL buffer.
.setCount( count : number ) : BufferAttributeSets the count (the expected number of vertices in VBO).
.setItemSize( itemSize : number ) : BufferAttributeSets the item size.
.setType( type : number, elementSize : number ) : BufferAttributeSets the given native data type and element size.

Key Takeaways

  1. Most relevant properties: buffer, count, elementSize, isGLBufferAttribute.
  2. Key methods: setBuffer, setCount, setItemSize, setType.

Connects To