1. A concise explanation of the problem you’re experiencing.
The background turns black in this case with Explicit Rendering. After removing and adding Datasources again, I would like to redraw the whole thing so that the data is up to date again.
This event actually only happens when the zoom level is very high.
2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
My application contains a lot of external data (ImageryLayer, Datasources) that are often removed and inserted. When fetching a new list with any number of layers (ImageryLayer, Datasources), this should be redrawn at the end. Only at the end in order not to render again permanently.
4. The Cesium version you’re using, your operating system and browser.
cesium: 1.65.0
OS: macOs High Sierra v 10.13.6
Google Chrome: Version 80.0.3987.163
Each data source you add should have a readyPromise to tell you when it’s successfully been added to the scene. Have you tried listening for that, and only after that returns true, re-rendering the scene?
var dataSourcePromise = viewer.dataSources.add(customDataSource2);
dataSourcePromise.then(function(){
viewer.scene.requestRender();
});
Although I’m starting to think this may be an issue specific to the custom data source you’re creating. Here’s a simpler example that calls request render each time this billboard changes.
Have you tried recreating your example without using CustomDataSource to determine if that’s what’s causing the issue?
What I’ve done in the past is simply keep my own set of arrays in my application. So you might have:
var labelEntities = [];
var buildingEntities = [];
// etc
And then when you add an entity you’d do:
var newEntity = viewer.entities.add({ ... })
labelEntities.push(newEntity);//Or add it to whatever the correct collection is
And if you want to add/remove/show/hide you can iterate over any of these arrays and apply these changes. It’s a little more code but I think it’s just as efficient.