I was working on a development project with react and typescript bundled with vite using vtk js for visualisation. However I had issues with it and since moved to handle the same with vtk-wasm instead.
I have set up the renderer following the guide here at Bundler Integration | VTK.wasm and below is the code I have with me right now.
While we are actively working on enabling more classes of VTK inside our VTK.wasm bundle. The current bundle only focus on the Rendering part of VTK. This currently solve the local rendering capabilities of trame while giving us time to setup infrastructure and testing around that new capability.
As you’ve noticed, we are exposing a plain JavaScript API for controlling those VTK objects. This aim to offer a fully feature VTK in the browser, but to be truly complete, we need to enable all/more vtk modules within WASM. But to make it practical (not a single humungous file), we are looking into a “shared” build of VTK where each module will be its own wasm file that will then be loaded/downloaded based on the need.
To make that possible we are fixing things in CMake and working with the Emscripten community to enable shared build. If everything goes as according to plan (not always the case) we are hoping to make that available in the next major version of VTK (+6 months).
On top of that, to have a vtk module to work with our wasm infrastructure, you need that module to be serializable with all its public classes in it properly tagged. As far as I know, we haven’t look at the IO modules yet to enable such serialization.
So to summarize as of today, in order to achieve what you want to do, you will need:
enable serialization on the vtk module you need to use on the JS side
build a custom wasm bundle with all the modules you’ve added
@Sebastien_Jourdain aptly descibed why this does not work. We hope to enable it (reader, and more classes in the “shared” WASM bundle) by end of March.