Bootstrap

cesium 删除primitive

记录项目中使用了primitive添加实体,移除所有实体removeAll无效。

删除primitive:

viewer.scene.primitives.removeAll()没有任何效果,删除失败。

primitive可能需要一个个的删除,具体代码实现如下:

if(this.billboardsPrimitive) {
   for (const keyId in this.billboardsPrimitive) {
      this.viewer.scene.primitives.remove(this.billboardsPrimitive[keyId])
      this.billboardsPrimitive[keyId] = this.billboardsPrimitive[keyId] && this.billboardsPrimitive[keyId].destroy()
   }
}

;