diff --git a/Web/WebAssembly/vtkWasmSceneManager.cxx b/Web/WebAssembly/vtkWasmSceneManager.cxx index b7d0c5ccc416cb90698c4b282b841c64bc8da884..5dbd326586632860c9c5536e074cb263c4c9bd89 100644 --- a/Web/WebAssembly/vtkWasmSceneManager.cxx +++ b/Web/WebAssembly/vtkWasmSceneManager.cxx @@ -8,6 +8,7 @@ #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" +#include "vtkRenderer.h" VTK_ABI_NAMESPACE_BEGIN //------------------------------------------------------------------------------- @@ -52,6 +53,18 @@ bool vtkWasmSceneManager::Render(vtkTypeUInt32 identifier) return false; } +//------------------------------------------------------------------------------- +bool vtkWasmSceneManager::ResetCamera(vtkTypeUInt32 identifier) +{ + auto object = this->GetObjectAtId(identifier); + if (auto renderer = vtkRenderer::SafeDownCast(object)) + { + renderer->ResetCamera(); + return true; + } + return false; +} + //------------------------------------------------------------------------------- bool vtkWasmSceneManager::StartEventLoop(vtkTypeUInt32 identifier) { diff --git a/Web/WebAssembly/vtkWasmSceneManager.h b/Web/WebAssembly/vtkWasmSceneManager.h index 493fa82a25b4f3922cb0f7810fd468bf59e7f076..d386a267f7f3dbbe430053a9b61b5da503fcab40 100644 --- a/Web/WebAssembly/vtkWasmSceneManager.h +++ b/Web/WebAssembly/vtkWasmSceneManager.h @@ -33,7 +33,7 @@ public: * Set the size of the `vtkRenderWindow` object at `identifier` to * the supplied dimesions. * - * Returns `true` if the obejct at `identifier` is a `vtkRenderWindow` + * Returns `true` if the object at `identifier` is a `vtkRenderWindow` * with a `vtkRenderWindowInteractor` attached to it, * `false` otherwise. */ @@ -42,15 +42,23 @@ public: /** * Render the `vtkRenderWindow` object at `identifier`. * - * Returns `true` if the obejct at `identifier` is a `vtkRenderWindow` + * Returns `true` if the object at `identifier` is a `vtkRenderWindow` * `false` otherwise. */ bool Render(vtkTypeUInt32 identifier); + /** + * Reset the active camera of the `vtkRenderer` object at `identifier`. + * + * Returns `true` if the object at `identifier` is a `vtkRenderer` + * `false` otherwise. + */ + bool ResetCamera(vtkTypeUInt32 identifier); + /** * Start event loop of the `vtkRenderWindowInteractor` object at `identifier`. * - * Returns `true` if the obejct at `identifier` is a `vtkRenderWindowInteractor` + * Returns `true` if the object at `identifier` is a `vtkRenderWindowInteractor` * `false` otherwise. */ bool StartEventLoop(vtkTypeUInt32 identifier); @@ -58,7 +66,7 @@ public: /** * Stop event loop of the `vtkRenderWindowInteractor` object at `identifier`. * - * Returns `true` if the obejct at `identifier` is a `vtkRenderWindowInteractor` + * Returns `true` if the object at `identifier` is a `vtkRenderWindowInteractor` * `false` otherwise. */ bool StopEventLoop(vtkTypeUInt32 identifier); diff --git a/Web/WebAssembly/vtkWasmSceneManagerEmBinding.cxx b/Web/WebAssembly/vtkWasmSceneManagerEmBinding.cxx index dcd19e40564c2af43491fb417326263049b5cefb..39be3f6788bee7dfb1bac1c55885d4d08348e454 100644 --- a/Web/WebAssembly/vtkWasmSceneManagerEmBinding.cxx +++ b/Web/WebAssembly/vtkWasmSceneManagerEmBinding.cxx @@ -177,6 +177,13 @@ bool render(vtkTypeUInt32 identifier) return Manager->Render(identifier); } +//------------------------------------------------------------------------------- +bool resetCamera(vtkTypeUInt32 identifier) +{ + CHECK_INIT; + return Manager->ResetCamera(identifier); +} + //------------------------------------------------------------------------------- bool startEventLoop(vtkTypeUInt32 identifier) { @@ -249,6 +256,7 @@ EMSCRIPTEN_BINDINGS(vtkWasmSceneManager) function("setSize", ::setSize); function("render", ::render); + function("resetCamera", ::resetCamera); function("startEventLoop", ::startEventLoop); function("stopEventLoop", ::stopEventLoop);