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

const nbMeshes = 100

// assuming 'renderer' is a valid renderer or curtains instance
const renderBundle = new RenderBundle(renderer, {
label: 'Custom render bundle',
size: nbMeshes,
useBuffer: true, // use a single buffer to handle all 100 meshes transformations
})

for (let i = 0; i < nbMeshes; i++) {
const mesh = new Mesh(renderer, {
label: 'Cube ' + i,
geometry: new BoxGeometry(),
renderBundle,
})

mesh.onBeforeRender(() => {
mesh.rotation.y += 0.02
})
}

Constructors

Properties

type: string

The type of the RenderBundle.

uuid: string

The universal unique id of this RenderBundle.

index: number

Index of this RenderBundle, i.e. creation order.

renderer: Renderer

The Renderer used to create this RenderBundle.

Options used to create this RenderBundle.

renderOrder: number

Controls the order in which this RenderBundle should be rendered by our Scene.

transparent: boolean

Whether this RenderBundle should be added to our Scene transparent stack (drawn after the opaque stack).

visible: boolean

Whether this RenderBundle content should be drawn.

binding: BufferBinding

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.

indirectBuffer: IndirectBuffer

Optional internal IndirectBuffer containing all meshes unique geometries to render them using indirect drawing.

descriptor: GPURenderBundleEncoderDescriptor

The GPURenderBundleEncoderDescriptor created by this RenderBundle, based on the RenderPass passed as parameters.

encoder: GPURenderBundleEncoder

The GPURenderBundleEncoder created by this RenderBundle.

bundle: GPURenderBundle

The GPURenderBundle created by this RenderBundle.

meshes: Map<string, RenderedMesh>

A Map of mesh drawn by this RenderBundle.

Accessors

Methods