[name]

此缓冲区属性类不构造 VBO。相反,它使用在构造函数中传递的任何 VBO,以后可以通过 缓冲区属性进行更改。

它需要与 VBO 一起传递额外的参数。它们是:GL 上下文、GL 数据类型、每个顶点的组件数、每个组件的字节数和顶点数。

此类最常见的用例是当某种 GPGPU 计算干扰甚至产生有问题的 VBO 时。

构造方法(Constructor)

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

*buffer* — 必须是 [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLBuffer WebGLBuffer].
*type* — [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants#Data_types WebGL数据类型]之一.
*itemSize* — 应与特定顶点关联的数组值的数量。例如,如果此属性存储一个3分量向量(例如位置、法线或颜色),则itemSize应为 3。
*elementSize* — 1、2 或 4。给定的相应大小(以字节为单位)“类型”参数。

*count* — 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.

Examples

[example:webgl_buffergeometry_glbufferattribute Points with custom buffers]

特性(Properties)

[property:WebGLBuffer buffer]

当前[link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLBuffer WebGLBuffer]的实例.

[property:Integer count]

VBO 中的预期顶点数。

[property:Integer elementSize]

存储当前类型属性值的相应大小(以字节为单位)。

有关已知类型大小的列表,请参见上面的(构造函数)。

[property:Boolean isGLBufferAttribute]

只读。值永远为"true"。

[property:Integer itemSize]

每个项目(顶点)组成多少个值。

[property:String name]

该attribute实例的别名,默认值为空字符串。

[property:Boolean needsUpdate]

默认为假。将此设置为 true 增量[page:GLBufferAttribute.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]

描述底层 VBO 内容的[link:https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants#Data_types WebGL数据类型]

将此属性与elementSize一起设置。推荐的方法是使用setType方法。

[property:Integer version]

版本号,每次将needsUpdate属性设置为true时递增。

方法(Methods)

[method:this setBuffer]( buffer )

设置缓冲区属性。

[method:this setType]( type, elementSize )

设置type和elementSize属性。

[method:this setItemSize]( itemSize )

设置itemSize属性。

[method:this setCount]( count )

设置计数属性。

源代码(Source)

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