RenderBundle constructor
Renderer or GPUCurtains class object used to create this RenderBundle.
parameters use to create this RenderBundle.
The type of the RenderBundle.
Readonly
uuidThe universal unique id of this RenderBundle.
Readonly
indexIndex of this RenderBundle, i.e. creation order.
The Renderer used to create this RenderBundle.
Options used to create this RenderBundle.
Controls the order in which this RenderBundle should be rendered by our Scene.
Whether this RenderBundle should be added to our Scene transparent stack (drawn after the opaque stack).
Whether this RenderBundle content should be drawn.
Optional BufferBinding created if the useBuffer parameter has been set to true
and if the meshes drawn actually have transformation matrices. This BufferBinding will act as a parent buffer, and the meshes matrices
binding will use a BufferBinding with this binding as parent and the correct offset
.
Optional internal IndirectBuffer containing all meshes unique geometries to render them using indirect drawing.
The GPURenderBundleEncoderDescriptor created by this RenderBundle, based on the RenderPass passed as parameters.
The GPURenderBundleEncoder created by this RenderBundle.
The GPURenderBundle created by this RenderBundle.
A Map of mesh drawn by this RenderBundle.
Get whether our RenderBundle handles projected meshes or not (useful to know in which Scene stack it has been added.
Set the new RenderBundle size. Should be used before adding or removing meshes to the RenderBundle if the bundle has already been created (especially if it's using a binding).
New size to set.
Get whether our RenderBundle is ready.
Private
#setPrivate
Set the binding and patches its array and buffer size if needed.
Private
#patchPrivate
new binding size to use.
Private
#onPrivate
Called each time the RenderBundle size has actually changed.
new RenderBundle size to set.
Called by the Scene to eventually add a mesh to this RenderBundle. Can set the render pass if needed. If the render pass is already set and the mesh output RenderPass does not match, it won't be added.
Mesh to eventually add.
The mesh output RenderPass.
Remove any rendered mesh from this RenderBundle.
Mesh to remove.
Remove a scene stacked mesh from this RenderBundle.
Scene stacked mesh to remove.
Whether to preserve the mesh in order to render it normally again. Default to true
.
Private
#setPrivate
Set the descriptor based on the render pass.
Private
#encodePrivate
Create the descriptor, encoder and bundle used by this RenderBundle.
Update the binding buffer if needed.
Render the RenderBundle.
If it is ready, execute each RenderedMesh#onBeforeRenderPass | mesh onBeforeRenderPass method, update the binding if needed, execute the bundle and finally execute each mesh onAfterRenderPass method.
If not, just render its meshes as usual and check whether they are all ready and if we can therefore encode our RenderBundle.
GPURenderPassEncoder to use.
Called when the WebGPU device has been lost.
Just set the ready flag to false
to eventually invalidate the bundle.
Empty the RenderBundle. Can eventually re-add the scene stacked meshes to the Scene in order to render them normally again.
Whether to preserve the meshes in order to render them normally again. Default to true
.
Private
#cleanPrivate
Destroy the binding buffer if needed and remove the RenderBundle from the Renderer.
Remove the RenderBundle, i.e. destroy it while preserving the scene stacked meshes by re-adding them to the Scene.
Remove the RenderBundle from our Scene, remove the meshes, eventually destroy the binding and remove the RenderBundle from the Renderer.
Used to create a GPURenderBundle and its associated GPURenderBundleEncoder.
Render bundle are a powerful tool that can significantly reduce the amount of CPU time spent issuing repeated rendered commands. In other words, it can be used to draw given set of meshes that share the same output target faster (up to 1.5x in some cases) and with less CPU overhead.
The main drawback is that RenderBundle works best when the number of meshes drawn is known in advance and is not subject to change.
Example