Creates a new Buffer with the given options
Name | Type | Description |
---|---|---|
options |
BufferOptions |
the options for the buffer |
Example
const buffer = new Buffer({
data: new Float32Array([1, 2, 3, 4]),
usage: BufferUsage.VERTEX,
});
Extends
- EventEmitter
Implements
Members
the data in the buffer
Has the buffer been destroyed?
- Default Value:
- false
should the GPU buffer be shrunk when the data becomes smaller? changing this will cause the buffer to be destroyed and a new one created on the GPU this can be expensive, especially if the buffer is already big enough! setting this to false will prevent the buffer from being shrunk. This will yield better performance if you are constantly setting data that is changing size often.
- Default Value:
- true
whether the buffer is static or not
a unique id for this uniform group used through the renderer
Methods
Destroys the buffer
Sets the data in the buffer to the given value. This will immediately update the buffer on the GPU. If you only want to update a subset of the buffer, you can pass in the size of the data.
Name | Type | Description |
---|---|---|
value |
TypedArray |
the data to set |
size |
number |
the size of the data in bytes |
syncGPU |
boolean |
should the buffer be updated on the GPU immediately? |
updates the buffer on the GPU to reflect the data in the buffer. By default it will update the entire buffer. If you only want to update a subset of the buffer, you can pass in the size of the buffer to update.
Name | Type | Attributes | Description |
---|---|---|---|
sizeInBytes |
number |
<optional> |
the new size of the buffer in bytes |
Events
emits when the underlying buffer has changed shape (i.e. resized) letting the renderer know that it needs to discard the old buffer on the GPU and create a new one
emits when the buffer is destroyed. letting the renderer know that it needs to destroy the buffer on the GPU
emits when the underlying buffer data has been updated. letting the renderer know that it needs to update the buffer on the GPU