Create a new instance eof the Bind Group.
Name | Type | Attributes | Description |
---|---|---|---|
resources |
Record<string, BindResource> |
<optional> |
The resources that are bound together for use by a shader. |
Example
// Create a bind group with a single texture and sampler
const bindGroup = new BindGroup({
uTexture: texture.source,
uTexture: texture.style,
});
Bind groups resources must implement the BindResource interface.
The following resources are supported:
- TextureSource
- {@link TextureStyle}
- Buffer
- {@link BufferResource}
- UniformGroup
The keys in the bind group must correspond to the names of the resources in the GPU program.
This bind group class will also watch for changes in its resources ensuring that the changes
are reflected in the WebGPU BindGroup.
Members
resources Record<string, BindResource>
The resources that are bound together for use by a shader.
Methods
Destroys this bind group and removes all listeners.
getResource (index) BindResource
Returns the resource at the current specified index.
Name | Type | Description |
---|---|---|
index |
number |
The index of the resource to get. |
Returns:
Type | Description |
---|---|
BindResource |
|
Set a resource at a given index. this function will ensure that listeners will be removed from the current resource and added to the new resource.
Name | Type | Description |
---|---|---|
resource |
BindResource |
The resource to set. |
index |
number |
The index to set the resource at. |