Create a new IndexBuffer instance.
The graphics device used to manage this index buffer.
The type of each index to be stored in the index buffer. Can be:
The number of indices to be stored in the index buffer.
Optionalusage: number = BUFFER_STATIC
The usage type of the vertex buffer. Can be:
Defaults to BUFFER_STATIC.
OptionalinitialData: ArrayBuffer | ArrayBufferView<ArrayBufferLike>
Initial data. Can be an ArrayBuffer or a typed array (for example a Uint16Array). The data is stored by reference and is not copied, so a typed array that is a view into a larger buffer is kept as-is. If left unspecified, the index buffer will be initialized to zeros.
Optionaloptions: { storage?: boolean }
Object for passing optional arguments.
Optionalstorage?: booleanDefines if the index buffer can be used as a storage buffer by a compute shader. Defaults to false. Only supported on WebGPU.
Frees resources associated with this index buffer.
Returns the data format of the specified index buffer.
The data format of the specified index buffer. Can be:
Returns the number of indices stored in the specified index buffer.
The number of indices stored in the specified index buffer.
Gives access to the block of memory that stores the buffer's indices.
The memory that stores the buffer's indices. This matches whatever was supplied as the initial data: an ArrayBuffer when none was provided, otherwise the ArrayBuffer or typed array that was passed in. Use ArrayBufferConstructor.isView to distinguish the two before accessing it.
Uploads the client side copy of the index buffer to the GPU. When called without arguments, uploads the entire buffer. An explicit range uploads only those bytes at the same GPU offset. The first upload always initializes the entire GPU buffer, regardless of the requested range. A zero byte length does nothing, including before the first upload.
Partial uploads do not resize the buffer or change its CPU storage. The caller must upload every modified range before expecting those changes on the GPU. Context restoration uploads the entire CPU storage. Invalid ranges are ignored in all builds and report an assertion in debug builds.
OptionalbyteOffset: number
Offset in bytes from the start of the buffer's storage. Defaults to 0. Must be a non-negative integer and a multiple of 4 on all graphics backends.
OptionalbyteLength: number
Number of bytes to upload. Defaults to the remaining bytes after byteOffset. The length must be a non-negative integer and the range must fit within the buffer. Partial ranges require a length that is a multiple of 4. Full-buffer uploads support any byte length, whether the range is explicit or the arguments are omitted.
An index buffer stores index values into a VertexBuffer. Indexed graphical primitives can normally utilize less memory that unindexed primitives (if vertices are shared).
Typically, index buffers are set on Mesh objects.