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. Initializes the configuration, which supplies the 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 vtkWebGPUDevice that holds resource caches for this render window, or null before initialization.

One instance of this wrapper exists for each native device. Thus, render windows that share a configuration also share this object. Use getWebGPUConfiguration().getDevice() to get the native GPUDevice.

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.

getWebGPUConfiguration ​

Get the configuration that supplies the adapter and the device.

A render window always has a configuration. Unless the application gives one, the render window creates and owns it, and deletes it with itself.

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.

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.

setWebGPUConfiguration ​

Set the configuration that supplies the adapter and the device.

Set this before initialization. Render windows that share a configuration share one device, and thus one set of vtk.js resource caches. Set null to go back to a configuration that this render window creates and owns.

ArgumentTypeRequiredDescription
configurationYesthe configuration to use, or null

Returns ​

TypeDescription
true if the value changed

traverseAllPasses ​

Traverse all registered render passes.