How to synchronize viewports rotation with cornerstone3d?

Hi. I am trying to synchronize transformation changes between two StackViewports.

viewport.setProperties({ rotation: rotation + 90 });

I see that setProperties for a StackViewport calls setRotation and there CAMERA_MODIFIED event is triggered. So I wrote this synchronizer (based on already existing createCameraPositionSynchronizer)

export default function createExtendedCameraPositionSynchronizer(
) {
  const synchronizer = cornerstoneTools.SynchronizerManager.createSynchronizer(
    ) => {
      const { rotation, camera } = cameraModifiedEvent.detail;

      const renderingEngine = getRenderingEngine(targetViewport.renderingEngineId);
      if (!renderingEngine) {
        throw new Error(
          `No RenderingEngine for Id: ${targetViewport.renderingEngineId}`
      const tViewport = renderingEngine.getViewport(targetViewport.viewportId);
      tViewport.setProperties({ rotation });

  return synchronizer;

It is very similar to a createCameraPositionSynchronizer. I just added that it would change properties alongside with camera.

Unfortunately it doesn’t work. After I change properties in a viewport this synchronization callback is triggered, but rotation is always equal to 0.

I investigated further. It turns out that this callback reacts not on a CAMERA_MODIFIED event from StackViewport.setRotation, as I would expected, but from Viewport.triggerCameraModifiedEventIfNecessary. Moreover, though I can see in a debugger that setRotation indeed triggers a CAMERA_MODIFIED event, it is not intercepted by a synchronizer and a callback is not called.

I don’t know if it is bug, or I am doing something wrong. I am confused. Could somebody please help me with writing a synchronizer that will synchronize rotation properties between two StackViewports? Thank you!

What steps can we follow to reproduce the bug?

  1. Create a synchronizer I described above
  2. Initialize two Stack viewports and add them to that synchronizer
  3. Add a button that will apply a rotation change in the first viewport on click
  4. Notice that after a click the synchronizer callback function is called but rotation is always equal to zero.

Hello @vnosikov and welcome to the forum.

That might indeed be a bug. However, instead of getting the rotation from the event detail, perhaps try the sourceViewport.getRotation() - I suspect that might be accurate.