AdvancedCreate a new Buffer Resource.
The options for the buffer resource
The underlying buffer that this resource is using
Optionaloffset?: numberThe byte offset into the buffer this resource starts at, defaulting to 0.
Must be a multiple of renderer.limits.minUniformBufferOffsetAlignment.
Optionalsize?: numberThe number of bytes this resource covers.
If not provided, it covers the rest of the buffer after offset.
Optionalwatch?: booleanListen to the buffer, defaulting to true. A watched resource changes its id and
emits change when the buffer resizes, unloads or is destroyed, so the bind groups holding it rebuild.
Pass false when many resources share one buffer and every bind group holds them with
BindGroup.setResourceUnwatched, as thousands of listeners on one buffer cost memory and time to add and
remove. An unwatched resource keeps its id through those changes, so whoever owns it must
replace it with a new resource once the buffer changes, or bind groups keep using the old GPU buffer.
the underlying buffer that this resource is using
ReadonlydestroyedHas the Buffer resource been destroyed?
Readonlyoffsetthe byte offset into the buffer this resource starts at, defaulting to 0.
Must be a multiple of renderer.limits.minUniformBufferOffsetAlignment.
Readonlysizethe number of bytes this resource covers. If not provided, it covers the rest of the buffer after offset.
Readonlyuida unique id for this uniform group used through the renderer
ReadonlywatchWhether this resource listens to its buffer. See the watch constructor option.
A resource that can be bound to a bind group and used in a shader. Whilst a buffer can be used as a resource, this class allows you to specify an offset and size of the buffer to use. This is useful if you have a large buffer and only part of it is used in a shader.
This resource listens for changes on the underlying buffer and emits a change itself if the buffer changes shape, unless it is created with
watch: false.Example