Sharing scene data between multiple viewers

I need to share all scene data (primitives, data sources etc) with multiple cesium viewers/canvas.
The only difference between them would be the cameras (they would show the same content but using different view points).

Does Cesium currently supports this?
I checked the Viewer constructor and methods, but it noes not allow to change the ‘scene’.

Cesium doesn’t currently support it. A big part of the problem is that WebGL does not currently have the ability to share data across contexts, which would be needed to share primitive and texture information. I believe WebGL 2, which is in development, will address many of these issues and open the door for us to support it (but even then is going to take a lot of work on our side).

For now, the only way to do what you want is to load the same data in both Viewers, which will work, but is obviously not optimal. You might be able to re-use the same DataSource and Entity instances, but I haven’t tried it.

I’ll try sharing the data sources, but does this means I’ll have to careful manage the primitives?

For example, when I create a primitive, then I’ll have to add it manually to all viewers, and same thing when deleting it, basically keeping my own list outside Cesium?

It’s more than that. You can’t share primitives at all, you will need to create two copies of each primitive, one for each viewer and mange them that way.

I’m not event 100% sure you can share data sources either, but I think it will work.

Yes, that was what I meant, I just worded it wrong, I mean adding duplicates of primitives, one duplicate per viewer.

I’ll look better into changing our code base to support this.

Since this was a while ago, has any of this changed? Is it now possible to share data across viewers? Specifically, it would be nice to create an entity and add it to multiple viewers and do the same for 3D Tiles tilesets. Currently, I’m trying to do this with an entity and it doesn’t seem to be working but I may not be doing it correctly; I’m doing
var some_entity = {

};
viewer1.entities.add(some_entity);
viewer2.entities.add(some_entity);

``

Hi there,

Creating an entity then adding it to multiple viewers works for me. See this code example: http://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=a12af66ed545a12d1bb83c02a4dad197

Hope that helps,

  • Rachel
1 Like