# In VTK+WASM, how do I make the camera zoom on right click?

**URL:** https://discourse.vtk.org/t/in-vtk-wasm-how-do-i-make-the-camera-zoom-on-right-click/15338
**Category:** Support
**Tags:** vtkwasm
**Created:** [March 4, 2025, 10:44pm UTC](https://discourse.vtk.org/t/in-vtk-wasm-how-do-i-make-the-camera-zoom-on-right-click/15338 "2025-03-04T22:44:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![uv382](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/u/c89c15/32.png) [@uv382](https://discourse.vtk.org/u/uv382)
#### Post date: [March 4, 2025, 10:44pm UTC](https://discourse.vtk.org/t/in-vtk-wasm-how-do-i-make-the-camera-zoom-on-right-click/15338/1 "2025-03-04T22:44:24Z")

</div>

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:

```python
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?

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [March 5, 2025, 1:46am UTC](https://discourse.vtk.org/t/in-vtk-wasm-how-do-i-make-the-camera-zoom-on-right-click/15338/2 "2025-03-05T01:46:09Z")

</div>

> [@uv382](#):
>
> Creating the custom interactor style like the example above does not do anything in VTK/WASM.  
> Will I need to compile custom bindings into a VTK+WASM binary for access to the camera object?

Yes.

1. The implementation needs to be in C++ for it to work in the browser.
2. There is still one more missing link. The object manager should be capable of (de)serializing the custom class. We are working on infrastructure to allow classes from extension modules to (de)serialize over the network. We will need to flesh out how this all ties together. This work would also address [ParaView serialization · Issue #2 · Kitware/trame-vtklocal · GitHub](https://github.com/Kitware/trame-vtklocal/issues/2) because ParaView has subclasses of VTK classes.

In the end, it would mean you implement custom overrides of the interactor style methods in C++, compile that project for desktop and wasm together.

@Sebastien_Jourdain
