[name]

This buffer attribute class does not construct a VBO. Instead, it uses whatever VBO is passed in constructor and can later be altered via the `buffer` property.

It is required to pass additional params alongside the VBO. Those are: the GL context, the GL data type, the number of components per vertex, the number of bytes per component, and the number of vertices.

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

Examples

[example:webgl_buffergeometry_glbufferattribute Points with custom buffers]

Constructor

[name]( [param:WebGLBuffer buffer], [param:GLenum type], [param:Integer itemSize], [param:Integer elementSize], [param:Integer count], [param:Boolean normalized] )

`buffer` — Must be a [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLBuffer WebGLBuffer].
`type` — One of [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants#Data_types WebGL Data Types].
`itemSize` — The number of values of the array that should be associated with a particular vertex. For instance, if this attribute is storing a 3-component vector (such as a position, normal, or color), then itemSize should be 3.
`elementSize` — 1, 2 or 4. The corresponding size (in bytes) for the given "type" param.

`count` — The expected number of vertices in VBO.
`normalized` — (optional) Applies to integer data only. Indicates how the underlying data in the buffer maps to the values in the GLSL code. For instance, if [page:WebGLBuffer buffer] contains data of `gl.UNSIGNED_SHORT`, and [page:Boolean normalized] is true, the values `0 - +65535` in the buffer data will be mapped to 0.0f - +1.0f in the GLSL attribute. A `gl.SHORT` (signed) would map from -32768 - +32767 to -1.0f - +1.0f. If [page:Boolean normalized] is false, the values will be converted to floats unmodified, i.e. 32767 becomes 32767.0f.

Properties

[property:WebGLBuffer buffer]

The current [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLBuffer WebGLBuffer] instance.

[property:Integer count]

The expected number of vertices in VBO.

[property:Integer elementSize]

Stores the corresponding size in bytes for the current `type` property value.

See above (constructor) for a list of known type sizes.

[property:Boolean isGLBufferAttribute]

Read-only. Always `true`.

[property:Integer itemSize]

How many values make up each item (vertex).

[property:String name]

Optional name for this attribute instance. Default is an empty string.

[property:Boolean needsUpdate]

Default is `false`. Setting this to true increments [page:GLBufferAttribute.version version].

[property:Boolean normalized]

Indicates how the underlying data in the buffer maps to the values in the GLSL shader code. See the constructor above for details.

[property:GLenum type]

A [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants#Data_types WebGL Data Type] describing the underlying VBO contents.

Set this property together with `elementSize`. The recommended way is using the `setType` method.

[property:Integer version]

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

Methods

[method:this setBuffer]( buffer )

Sets the `buffer` property.

[method:this setType]( type, elementSize )

Sets the both `type` and `elementSize` properties.

[method:this setItemSize]( itemSize )

Sets the `itemSize` property.

[method:this setCount]( count )

Sets the `count` property.

Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]