我在场景中添加了粒子ParticleSystem,在执行销毁动作时(fireSystem.destroy();)报如下错误,有大神知道什么原因吗?
Cesium.js:250174 An error occurred while rendering. Rendering has stopped.
undefined
DeveloperError: This object was destroyed, i.e., destroy() was called.
Error
at new DeveloperError (http://127.0.0.1:8080/libs/cesium/Build/CesiumUnminified/Cesium.js:82:23)
at ParticleSystem.throwOnDestroyed (http://127.0.0.1:8080/libs/cesium/Build/CesiumUnminified/Cesium.js:29012:23)
at PrimitiveCollection.update (http://127.0.0.1:8080/libs/cesium/Build/CesiumUnminified/Cesium.js:131007:31)
at updateAndRenderPrimitives (http://127.0.0.1:8080/libs/cesium/Build/CesiumUnminified/Cesium.js:237258:31)
at executeCommandsInViewport (http://127.0.0.1:8080/libs/cesium/Build/CesiumUnminified/Cesium.js:237092:17)
at Scene.updateAndExecuteCommands (http://127.0.0.1:8080/libs/cesium/Build/CesiumUnminified/Cesium.js:236900:17)
at render (http://127.0.0.1:8080/libs/cesium/Build/CesiumUnminified/Cesium.js:237563:19)
at tryAndCatchError (http://127.0.0.1:8080/libs/cesium/Build/CesiumUnminified/Cesium.js:237582:17)
at Scene.render (http://127.0.0.1:8080/libs/cesium/Build/CesiumUnminified/Cesium.js:237657:17)
at CesiumWidget.render (http://127.0.0.1:8080/libs/cesium/Build/CesiumUnminified/Cesium.js:250222:29)
不想使用自动销毁,因为我也不知这把火会烧多久,只有灭火的信号一到,才能去移除它,我目前使用 show=false;
不让他显示,但这并不是我想要的,想用事件去移除它,信号一到就删除它。
@admin [#1楼](#comment1)
感觉似乎不是,我销毁前还判断了.isDestroyed()
if (ps && ps instanceof Cesium.ParticleSystem && !ps.isDestroyed()) {
// ps.destroy();//DeveloperError: This object was destroyed, i.e., destroy() was called.
ps.show = false;
}
在官方示例上做销毁操作依然同样问题,不知道为什么。
目前找到一个办法:
_viewer.scene.primitives.remove(primitive) → Boolean
既然销毁不行就做移除操作。实测有效,对象被移除了。