two viewer primitives synchronize

1. A concise explanation of the problem you’re experiencing.

i create two cesium viewer in one page, i get the primitiveA use viewerA.scene.primitives.get(id) function,

but when i call viewerB.scene.primitives.add(primitiveA) there is no primitive display on viewerB

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

for (var i = 0; i < viewerA.scene.primitives.length; ++i) {

var p = viewerA.scene.primitives.get(i);

if § {

viewB.scene.primitives.add§

}

}

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

i create two cesium viewer in one page, and i want to synchronize two viewer’s primitives

— after i draw rectangle on viewer A use the scene.primitives , display the same rectangle on viewer B

i don’t want to call the viewerB.scene.primitives.add function , because there will be much more oparation to synchronize .

4. The Cesium version you’re using, your operating system and browser.

Cesium:1.43

OS:win10

browser: Chrome 70

I don’t think you can take one primitive and add it to two viewers like that. There’s a lot of assumptions about the state of the primitive that won’t be compatible with this setup.

You might need to keep track of the global state yourself and synchronize the two primitives.

I think a better approach is if CesiumJS could somehow support a multi-camera view mode, that would be in the same viewer, kind of like how the imagery split works:

Can you describe more about your use case? That’ll help us collect information for figuring out if this is a feature that’ll be useful to users/the community.

There is a common need for monitoring system:
Users want to see more then one screen at the same time and each screen show a map in 3D or 2D and display diffrent images.

For example,the first shows satellite images in 3D ,the second shows road map in 2D, …

They expect the multiple screens show the same data and synchronized.

The data maybe come from server or mouse ploting.

If there is a easy way to get full property of whole primitives on one viewer and draw them directly to another viewer the synchronizing will be workable.

Omar Shehata omar.sameh.shehata@gmail.com 于2019年1月28日周一 下午8:56写道:

Thanks Feldon!

I found an issue for this on GitHub, and I shared your thoughts there: https://github.com/AnalyticalGraphicsInc/cesium/issues/5214

Supporting multiple viewports would be the right way to do this because then there would be no need to duplicate any data, and it would just be a matter of defining a second camera.

Perhaps the OVR_multiview2 WebGL extension would make implementing multiple viewports easier and/or more efficient?
www.khronos.org/registry/webgl/extensions/OVR_multiview2/
developer.mozilla.org/en-US/docs/Web/API/OVR_multiview2

Multiple viewports would be very useful. For example, when trying to see exactly where something is underground, such as tunnels, you can only get so much info from one vantage point, you don’t know the depth. If you had a camera view from up above and from the side simultaneously you can get a sense of where exactly it is very quickly rather than moving one camera around.

One could link multiple cameras, so when you move one the other one moves along with it, so their viewpoints are always say 90degrees apart.

That’s a good point @Hyper_Sonic - adding multiple cameras to a CesiumJS scene, where each camera can take an optional “canvas” parameter, would be a much easier way to set up these multiple views rather than creating two separate CesiumJS instances and syncing them.

I’m not sure how deep of a refactor this would require - @sean_lilley is this something we’ve considered? I don’t see anything in the CesiumJS GitHub issues on it.