VTK WebAssembly JavaScript#
The vtkWebAssembly.mjs
module provides JavaScript bindings to VTK WebAssembly using Emscripten. It includes two key classes:
vtkStandaloneSession
: For standalone VTK WebAssembly apps capable of creating and manipulating VTK objects.vtkRemoteSession
: For remote VTK WebAssembly apps meant to sync with a VTK application on a remote server.
Global Functions#
Function |
Description |
---|---|
|
Returns the short VTK version string (e.g., |
|
Returns the full VTK version string (e.g., |
vtkStandaloneSession
#
Provides methods to directly create, manage, and manipulate VTK objects.
Constructor#
new vtkStandaloneSession()
Methods#
Signature |
Description |
---|---|
|
Creates a new VTK object. |
|
Destroys a previously created VTK object. |
|
Apply properties from JSON object to the VTK object. |
|
Retrieves the state of the given object. |
|
Invokes a method on the object with JSON arguments. |
|
Registers a JavaScript callback for a VTK event. |
|
Unregisters an observer using its tag. |
vtkRemoteSession
#
Wraps around VTK session C API for client-server WebAssembly rendering. This is more suitable when the rendering state is controlled remotely.
Constructor#
new vtkRemoteSession()
Methods#
Signature |
Description |
---|---|
|
Registers a VTK object state. |
|
Unregisters an object’s state. |
|
[Deprecated] Retrieves the object’s current state. |
|
Apply properties from JSON object to the VTK object. |
|
Retrieves the state of the given object. |
|
Prevents a property from being (de)serialized. |
|
Re-enables serialization for a property. |
|
Registers a binary blob. |
|
Unregisters a blob using its hash. |
|
Retrieves a registered blob. |
|
Calls a method on a VTK object. |
|
Returns object dependency handles. |
|
Applies a JSON state to an object. |
|
Updates the state JSON from the object. |
|
Sets the size of a render window. |
|
Triggers a render operation. |
|
Resets the camera for the given scene. |
|
Begins the VTK interactor event loop. |
|
Stops the VTK interactor event loop. |
|
Binds a VTK render window to an HTML canvas element. |
|
Observes events on an object. |
|
Removes an observer by tag. |
|
Exports the state and blobs. |
|
Imports a scene and associated data. |
|
Applies all registered states to their respective objects. |
|
Refreshes all states based on their current object data. |
|
Deletes unused blobs. |
|
Deletes unused objects. |
|
Deletes unused states. |
|
Clears all objects, blobs, and state. |
|
Returns memory usage of all blobs. |
|
Returns memory usage of all VTK data objects. |
|
Prints internal scene manager details. |
|
Sets verbosity for deserialization. |
|
Sets verbosity for method invocations. |
|
Sets verbosity for the object manager. |
|
Sets verbosity for serialization. |
Notes#
All
objectId
are an unsigned integer.All states must be passed as JSON and will be returned as JSON. Do not pass stringified JSON.
Blob support is useful for caching binary data such as images or meshes to ease network traffic in the remote session use case.