返回介绍

手册

参考

示例

开发者参考

GLBufferAttribute

发布于 2021-07-10 14:14:15 字数 3892 浏览 1194 评论 0 收藏 0

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.

Constructor

GLBufferAttribute( buffer : WebGLBuffer, type : GLenum, itemSize : Integer, elementSize : Integer, count : Integer )

buffer — Must be a WebGLBuffer.
type — One of 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.

  • gl.FLOAT: 4
  • gl.UNSIGNED_SHORT: 2
  • gl.SHORT: 2
  • gl.UNSIGNED_INT: 4
  • gl.INT: 4
  • gl.BYTE: 1
  • gl.UNSIGNED_BYTE: 1
count — The expected number of vertices in VBO.

Properties

.buffer : WebGLBuffer

The current WebGLBuffer instance.

.count : Integer

The expected number of vertices in VBO.

.itemSize : Integer

How many values make up each item (vertex).

.elementSize : Integer

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

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

.type : GLenum

A WebGL Data Type describing the underlying VBO contents.

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

.isGLBufferAttribute : Boolean

Read-only. Always true.

Methods

.setBuffer ( buffer ) : null

Sets the buffer property.

.setType ( type, elementSize ) : null

Sets the both type and elementSize properties.

.setItemSize ( itemSize ) : null

Sets the itemSize property.

.setCount ( count ) : null

Sets the count property.

.version : Integer

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

.needsUpdate : Boolean

Default is false. Setting this to true increments version.

Source

src/core/GLBufferAttribute.js

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文