2 viewers and same globe event (rotation and mouseclick)

Hello,
I have 2 viewers with different layers (viewer1 and viewer2)
How can i have the same action in my viewers.
- if i move the globe in viewer1 i want the same move in viewer2
- if i have a mouseclick Event on the first globe i want to show the same Event on the 2nd.
- ...

var viewer1 = new Cesium.Viewer('cesiumContainer');
//Add 2. viewer
var viewer2 = new Cesium.Viewer('cesiumContainer');

Is it possible?

*(remove "fullSize" in Sandcastle (css))

Thanks

Hello,

You can handle events for one viewer and use the handler to replicate the action in a second viewer.

Take a look at the answer to this forum question for an example: https://groups.google.com/forum/?hl=en#!searchin/cesium-dev/slave/cesium-dev/GNK7GYNfWNI/V_UbRAuxBAAJ

Best,

Hannah

Hello Hannah
thank you for your help but the 2nd view doesn't move. I tried this before and it just works by replicating the scene posiion but not with the camera position. I tried also with lat/lon position and globe coordinates in a specific scene and camera position, with setView and lookAt,... but it doesn't. May be i do something wrong. Did you or someone try to run it?

Ah yes, there have been some code changes to Camera.setView since that example was posted.
Here is the updated code:

var masterViewer = new Cesium.Viewer(‘cesiumContainer1’);
var slaveViewer = new Cesium.Viewer(‘cesiumContainer2’);

var masterCamera = masterViewer.scene.camera;
var slaveCamera = slaveViewer.scene.camera;

slaveViewer.scene.preRender.addEventListener(function(){
if(slaveViewer.scene.mode !== Cesium.SceneMode.MORPHING){
slaveCamera.setView({
destination : masterCamera.position,
orientation: {
heading : masterCamera.heading,
pitch : masterCamera.pitch,
roll : masterCamera.roll
}
});
}
});

``

Best,

Hannah

Thank you.

Best,
Lia

Hello,
i used this updated code to copy the globe movement (rotation and zoom). I want to add also the ClickEvents (ScreenSpaceEvent). How can i show the masterview-clik to the slaveview? Can someone help me?

var masterViewer = new Cesium.Viewer('cesiumContainer1');
var slaveViewer = new Cesium.Viewer('cesiumContainer2');

var masterCamera = masterViewer.scene.camera;
var slaveCamera = slaveViewer.scene.camera;

slaveViewer.scene.preRender.addEventListener(function(){
    if(slaveViewer.scene.mode !== Cesium.SceneMode.MORPHING){
      slaveCamera.setView({
          destination : masterCamera.position,
          orientation: {
              heading : masterCamera.heading,
              pitch : masterCamera.pitch,
              roll : masterCamera.roll
          }
      });
    }
});

Regards,
Lia

Hello Lia,

Could you please explain a little more what you are trying to do? What are you using the click event for?

Thanks,

Hannah

Hello Hannah,
i have an old globe A and the modern globe B. i want to compare the 2 globes (2 views), bind rotation with your code above and show a clicked point A in B and the other way round. The maps are different.
--> i want to replicate actions and clicks that happen from A to B and B to A depending on the view in action.
--> I want that B moves if a moves but i don't know how to reverse the action with your code.
--> if right click show the coordinates in A, i want to see the same point (position) in B at the same time.

Thanks,
Lia

Hello Hannah,
do you understand what i want to do? Maybe any idea?

Thanks
Lia

Hi Lia,

Sorry I missed following up on this. I actually don’t have any good ideas for how to accomplish this. Hopefully someone else will have some input.

Best,

Hannah