Kitware / trame-vtklocal

VTK Local Rendering using VTK/WASM to match server side rendering pipeline on the client side.
Other
17 stars 0 forks source link

Add-on WASM API #4

Closed jourdain closed 5 months ago

jourdain commented 6 months ago

vtkObjectManager

GetCameraState(??) # ?? is the RenderWindow instance all we need?
SetCameraState(??) # Does the id captured in the state or do we need to provide (RenderWindow+state)?

vtkWASMSceneObjectManager

bool resetCamera(vtkTypeUInt32 identifier) # <= ID from RenderWindow
val getCameraState(vtkTypeUInt32 identifier) # <= ID from RenderWindow
bool setCameraState(??) # Does the state contain the id or do we need the RW_id?
jourdain commented 6 months ago

Side note, how do we do a screenshot from the WASM rendering?

If something can be done, we may want to add a captureImage(format="image/png", opts={}) method at some point too.

jourdain commented 6 months ago

Also I'm not sure what it would mean if we want to swap to a different view? Should we clear the state and remap the listening to a different instance of vtkRenderWindow. But in the vtk.js version of the widget, we have some mechanism to show a different view.

It might be possible to do with the current API, but I don't know what is required. Ideally, I should add a test and implement the correct flow on the WASM side...

jspanchu commented 6 months ago

The fact that the vue component only has a handle on the render window object limits the possibilities.

Here are some questions that need answers,

  1. do you want GetCameraState to return the states of all cameras in each renderer of the render window? Or is it just the first renderer?
  2. similarly, should resetCamera(renderWindowId) reset the camera of all renderers inside the window or just the first renderer?

It seems like you'd want to have a handle on the renderer as well. I wish there was a way to trigger a named method on a wasm instance. Could the C++ -> JS wrapping help? It was completed 10 months ago - https://gitlab.kitware.com/vtk/vtk/-/merge_requests/10282

jourdain commented 6 months ago

What if bool resetCamera(vtkTypeUInt32 identifier) could accept the following set of ids:

Then getCameraState() could take either a RenderWindow id or a Renderer id but the exported state should contain the ids info as well. So the when called with a RenderWindow id, you actually capture all the renderers camera state. While when you provide a renderer id, you get only one state in it.

And then on the server side, when we call SetCameraState(..), the msg/state should contains all the info with the corresponding ids. So that is self contained. For the GetCameraState(renderWindow/renderer) it should do the same as the client side and gather all that camera states with their ids so it is self contained again.

jspanchu commented 6 months ago

What if bool resetCamera(vtkTypeUInt32 identifier) could accept the following set of ids: RenderWindow => resetCamera on FirstRenderer() Renderer => resetCamera on that renderer

That is fine.

the exported state should contain the ids

exported state always contains the IDs, so it's okay to assume this.

Let's chat a little more about the camera state API and on which class it goes. The vtkObjectManager cannot have camera stuff.

jourdain commented 6 months ago

bool resetCamera(vtkTypeUInt32 identifier) # <= ID from Renderer

jspanchu commented 6 months ago

This function is now implemented in https://gitlab.kitware.com/vtk/vtk/-/merge_requests/11110

vue component needs updating.

jourdain commented 5 months ago

Available in 0.3.3