I'm trying to delete a primitive (Polygon or Polyline) previously added like this:
primitive.destroy();
or
scene.getPrimitives().remove(primitive);
but both methods give me this error:
DeveloperError: This object was destroyed, i.e., destroy() was called.
Error
at new t (http://cesiumjs.org/Cesium/Build/Cesium/Cesium.js:405:3035)
at o (http://cesiumjs.org/Cesium/Build/Cesium/Cesium.js:414:9476)
at o.update (http://cesiumjs.org/Cesium/Build/Cesium/Cesium.js:433:11535)
at tt (http://cesiumjs.org/Cesium/Build/Cesium/Cesium.js:435:26010)
at at.render (http://cesiumjs.org/Cesium/Build/Cesium/Cesium.js:435:29699)
at P.render (http://cesiumjs.org/Cesium/Build/Cesium/Cesium.js:440:25610)
at t (http://cesiumjs.org/Cesium/Build/Cesium/Cesium.js:440:9605)