Create a new Buffer Resource.
Name | Type | Description |
---|---|---|
options |
{ buffer: Buffer, offset?: number, size?: number } |
The options for the buffer resource |
options.buffer |
Buffer |
The underlying buffer that this resource is using |
options.offset |
number |
The offset of the buffer this resource is using. If not provided, then it will use the offset of the buffer. |
options.size |
number |
The size of the buffer this resource is using. If not provided, then it will use the size of the buffer. |
Example
const buffer = new Buffer({
data: new Float32Array(1000),
usage: BufferUsage.UNIFORM,
});
// Create a buffer resource that uses the first 100 bytes of a buffer
const bufferResource = new BufferResource({
buffer,
offset: 0,
size: 100,
});
Extends
- EventEmitter
Implements
Members
buffer Buffer
the underlying buffer that this resource is using
Has the Buffer resource been destroyed?
- Default Value:
- false
the offset of the buffer this resource is using. If not provided, then it will use the offset of the buffer.
the size of the buffer this resource is using. If not provided, then it will use the size of the buffer.
Methods
Destroys this resource. Make sure the underlying buffer is not used anywhere else if you want to destroy it as well, or code will explode
Name | Type | Default | Description |
---|---|---|---|
destroyBuffer |
boolean | false |
Should the underlying buffer be destroyed as well? |
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