"Reset" Cesium.Viewer to default state?

I’ve added imageryLayers and dataSources to an instance of a Viewer object, is there an easy way to restore it to its default state without resorting to .destroy() and creating a new one?

Hello,

You can use viewer.dataSources.removeAll() to remove all data sources from the scene.

For imagery layers, your base layer will usually be layer 0, so you can loop through layers 1 to imageryLayers.length and call viewer.imageryLayers.remove(viewer.imageryLayers.get(i))

Best,

Hannah