Skip to content

RenderWindow

Introduction

vtkWebGPURenderWindow is designed to view/render a vtkRenderWindow using the WebGPU API.

Methods

buildPass

Build pass callback invoked by the scene-graph traversal.

ArgumentTypeRequiredDescription
prepassYesWhether this is the pre-pass (true) or post-pass (false).

captureNextImage

Capture the next rendered frame as an image.

ArgumentTypeRequiredDescription
formatYesThe image format (default: 'image/png').
optsYesOptions for capture.
opts.resetCameraYesWhether to reset the camera before capture.
opts.sizeYesOverride the render size as [width, height].
opts.scaleYesScale factor for the render size.

create3DContextAsync

Create the WebGPU 3D context asynchronously. Requests the GPU adapter and device, then configures the canvas context.

createSelector

Create a hardware selector bound to this render window.

extend

Method used to decorate a given object (publicAPI+model) with vtkWebGPURenderWindow characteristics.

ArgumentTypeRequiredDescription
publicAPIYesobject on which methods will be bound (public)
modelYesobject on which data structure will be bound (protected)
initialValuesYes(default: {})

getCanvas

Get the current canvas element.

getCommandEncoder

Get the WebGPU command encoder for the current frame.

getContainer

Get the current container element.

getContainerSize

Get the size of the container element in pixels.

Returns

TypeDescription
[width, height]

getContext

Get the WebGPU canvas context.

getCurrentTexture

Get the current swap-chain texture from the canvas context.

getCursor

Get the current cursor style.

getDevice

Get the WebGPU device wrapper.

getFramebufferSize

Get the framebuffer size.

Returns

TypeDescription
[width, height]

getInitialized

Get whether the render window has been initialized.

getMultiSample

Get the current MSAA sample count.

getNotifyStartCaptureImage

Get whether image capture notification is enabled.

getPixelsAsync

Read pixels from the current framebuffer asynchronously. Returns an object with colorValues (Uint8ClampedArray), width, and height.

getPresentationFormat

Get the presentation texture format used by the swap chain.

getPropFromID

Get a prop (actor) by its hardware-selection ID.

ArgumentTypeRequiredDescription
idYesThe prop ID.

Returns

TypeDescription
The matching prop, or null if not found.

getRenderPasses

Get the render passes.

getSize

Get the current render window size.

Returns

TypeDescription
[width, height]

getUniquePropID

Get a unique prop ID for hardware selection.

getUseBackgroundImage

Get whether a background image is being used.

getUseOffScreen

Get whether off-screen rendering is enabled.

getViewNodeFactory

Get the view-node factory used to create WebGPU scene-graph nodes.

getXrSupported

Get whether XR (WebXR) is supported.

initialize

Initialize the render window. Triggers async GPU adapter/device creation; fires the initialized event on completion.

invokeImageReady

Programmatically fire the imageReady event.

ArgumentTypeRequiredDescription
imageURLYesThe image data URL.

invokeInitialized

Programmatically fire the initialized event.

invokeWindowResizeEvent

Programmatically fire the windowResizeEvent.

ArgumentTypeRequiredDescription
eventYesThe resize event payload.

newInstance

Method used to create a new instance of vtkWebGPURenderWindow.

ArgumentTypeRequiredDescription
initialValuesYesInitial property values.

onImageReady

Register a callback for when a captured image is ready.

ArgumentTypeRequiredDescription
callbackYesCalled with the image data URL string.

onInitialized

Register a callback for when the render window has finished initializing.

ArgumentTypeRequiredDescription
callbackYesCalled once GPU context creation is complete.

onWindowResizeEvent

Register a callback for window resize events.

ArgumentTypeRequiredDescription
callbackYesCalled with { width, height } when the window is resized.

recreateSwapChain

Unconfigure and reconfigure the swap chain. Called automatically when the canvas size changes.

releaseGraphicsResources

Release all GPU resources and clean up the rendering context.

setBackgroundImage

Set the background image element.

ArgumentTypeRequiredDescription
imgYesThe image element.

setCanvas

Set the canvas element.

ArgumentTypeRequiredDescription
canvasYesThe canvas element.

setContainer

Set the container element for the render window.

ArgumentTypeRequiredDescription
elYesThe HTML element to use as the container, or null to detach.

setContext

Set the WebGPU canvas context.

ArgumentTypeRequiredDescription
contextYesThe GPU canvas context.

setCursor

Set the cursor style.

ArgumentTypeRequiredDescription
cursorYesCSS cursor value.

setDevice

Set the WebGPU device wrapper.

ArgumentTypeRequiredDescription
deviceYesThe device wrapper instance.

setInitialized

Set the initialized state.

ArgumentTypeRequiredDescription
initializedYesWhether initialized.

setMultiSample

Controls the number of MSAA samples per pixel.

  • Default: 1 (no anti-aliasing)
ArgumentTypeRequiredDescription
countYesThe sample count (1 or 4).

Returns

TypeDescription
true if the value changed, false otherwise.

setNotifyStartCaptureImage

Set whether image capture notification is enabled.

ArgumentTypeRequiredDescription
notifyYesWhether to notify on capture start.

setRenderPasses

Set the render passes.

ArgumentTypeRequiredDescription
passesYesArray of render passes.

setSize

Set the size of the render window.

ArgumentTypeRequiredDescription
widthYesWidth in pixels.
heightYesHeight in pixels.

setUseBackgroundImage

Enable or disable rendering of a background image behind the scene.

ArgumentTypeRequiredDescription
valueYesWhether to use the background image.

setUseOffScreen

Set whether to use off-screen rendering.

ArgumentTypeRequiredDescription
useOffScreenYesWhether to render off-screen.

setViewStream

Set a view stream for remote rendering.

ArgumentTypeRequiredDescription
streamYesThe view stream instance.

traverseAllPasses

Traverse all registered render passes.