Normally in VTK, if you wanted to modify what each mouse button does, you would create a subclass of vtkInteractorStyle
with all your custom events described.
For example, in Python, if you wanted the camera to zoom every time you right-clicked:
class CustomInteractorStyle(vtkInteractorStyleTrackballCamera):
def __init__(self, renderer: vtkRenderer): super().__init__()
self.__Renderer = renderer
def OnRightButtonDown(self):
self.__Renderer.GetActiveCamera().Zoom(1.1)
However, I am working with VTK/WASM at the moment, and I do not know how to go about doing this in the VTK/WASM framework. Creating the custom interactor style like the example above does not do anything in VTK/WASM.
How would I implement this example above in VTK/WASM? I would like to make the camera zoom in a little bit every time I clicked the right mouse button.
Technically I could create a @trigger
endpoint on the TrameApp
server that receives a right-click event from the frontend, update the camera zoom on the server, and then forward the camera update back to the frontend. However this would be overkill and I know there has to be a better way.
Will I need to compile custom bindings into a VTK+WASM binary for access to the camera object?