The following is my TypeScript code:
````typescript
export class VtkWasmRenderComponent extends EmscriptenWasmComponent 
implements AfterViewInit, OnDestroy {
 .....
 .....
 .....

  vtkCameraChanged(cameraChangeEvent: CameraChangeEvent) {
    if (cameraChangeEvent === this.lastCameraChangeEvent) return;
    this.lastCameraChangeEvent = cameraChangeEvent;
    this.cameraChange.next(cameraChangeEvent);
  }
}
````
In my C++ file, I have the following:
````cpp 
using namespace emscripten;
/*
extern "C" {
  extern void vtkCameraChanged(CameraChangeEvent positionChange);
}
*/

void vtkCallbackFunc(vtkObject* caller, long unsigned int evId,
                     void* clientData, void* /*callData*/)
{
  // Note the use of reinterpret_cast to cast the caller and callData to the
  // expected types.
  auto interactor = reinterpret_cast<vtkRenderWindowInteractor*>(caller);
  std::cout << "  Event Id: " << std::endl;
  auto renderer = reinterpret_cast<vtkRenderer*>(clientData);
   CameraChangeEvent positionChange;
    positionChange.position = renderer->GetActiveCamera()->GetPosition();
    positionChange.viewAngle = renderer->GetActiveCamera()->GetViewAngle();
    positionChange.clippingRange = 
renderer->GetActiveCamera()->GetClippingRange();
    positionChange.focalPoint = 
renderer->GetActiveCamera()->GetFocalPoint();
    positionChange.parallelProjection = 
renderer->GetActiveCamera()->GetParallelProjection();
    positionChange.parallelProjection = 
renderer->GetActiveCamera()->GetParallelProjection();
    positionChange.viewUp = renderer->GetActiveCamera()->GetViewUp();
    positionChange.parallelScale = 
renderer->GetActiveCamera()->GetParallelScale();
    val vtkWasm = val::global("VtkWasmRenderComponent").new_();
    vtkWasm.call<void>("vtkCameraChanged", positionChange); // calling the 
vtkCameraChange function
    
};

````

What is the correct way to call the the `vtkCameraChange` method in the 
TypeScript file from the C++ file using emscripten? I have used val as 
stated in the 
[documentation](https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#interacting-with-code-call-javascript-from-native),
 
however, it does not seem to work.

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/4b66d647-d08d-4555-a1b6-3478591e7dcdn%40googlegroups.com.

Reply via email to