scene.primitives.removeAll() crashes

Hi all,

If a rendered object is selected, the infobox displays its name. (as usual)

1) Executing the following command:
,to remove all objects (including the currently selected one), results in an error:
         ->"This object was destroyed, i.e., destroy() was called"

2) Closing the the infobox manually, and thus unselecting the current primitive seems to work.

3) Closing the infobox using this command doesn't seem to work:
         -> "viewer.infoBox.destroy()"

How do I remove all primitives, including the currently selected one?

Thanks again!

OK, if anyone wants to remove all primitives (including the one that might be selected by the user) without any errors, this is how you do it:

1) document.getElementsByClassName('cesium-infoBox-close')[0].click();
2) scene.primitives.removeAll();

In general, you shouldn’t remove primitives you yourself haven’t created and your code will still cause problems in many situations. Since it looks like you are using entities, you are better off calling viewer.entities.removeAll() or view.dataSoures.removeAll() (if you are using data sources). This thread should have lots of details on the problem: There’s actually a bug in Cesium that I’ve been meaning to look into.