From b7928c9d101243df97d44e46d295d170a1335432 Mon Sep 17 00:00:00 2001 From: rropp5 <12055531+rropp5@users.noreply.github.com> Date: Fri, 15 Dec 2023 22:49:26 -0500 Subject: [PATCH] Distinct PolylineCollections for each CustomDataSource CustomDataSources were using the same PolylineCollection to store their Polyline primitives. When a CustomDataSource was destroyed, it was also destroying the PolylineCollection. Since that object was shared and other CustomDataSources remained in the system, this would cause Cesium to stop rendering when the destroyed PolylineCollection was accessed. Solution: use distinct PolylineCollections per CustomDataSource by keying PolylineCollections with the PrimitiveCollection's guid in addition to the Scene id. --- .../Source/DataSources/PolylineGeometryUpdater.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/engine/Source/DataSources/PolylineGeometryUpdater.js b/packages/engine/Source/DataSources/PolylineGeometryUpdater.js index 6c3a595a9aa5..131fdaef3595 100644 --- a/packages/engine/Source/DataSources/PolylineGeometryUpdater.js +++ b/packages/engine/Source/DataSources/PolylineGeometryUpdater.js @@ -661,12 +661,12 @@ function getLine(dynamicGeometryUpdater) { return dynamicGeometryUpdater._line; } - const sceneId = dynamicGeometryUpdater._geometryUpdater._scene.id; - let polylineCollection = polylineCollections[sceneId]; const primitives = dynamicGeometryUpdater._primitives; + const polylineCollectionId = dynamicGeometryUpdater._geometryUpdater._scene.id + primitives._guid; + let polylineCollection = polylineCollections[polylineCollectionId]; if (!defined(polylineCollection) || polylineCollection.isDestroyed()) { polylineCollection = new PolylineCollection(); - polylineCollections[sceneId] = polylineCollection; + polylineCollections[polylineCollectionId] = polylineCollection; primitives.add(polylineCollection); } else if (!primitives.contains(polylineCollection)) { primitives.add(polylineCollection); @@ -869,14 +869,14 @@ DynamicGeometryUpdater.prototype.isDestroyed = function () { DynamicGeometryUpdater.prototype.destroy = function () { const geometryUpdater = this._geometryUpdater; - const sceneId = geometryUpdater._scene.id; - const polylineCollection = polylineCollections[sceneId]; + const polylineCollectionId = geometryUpdater._scene.id + this._primitives._guid; + const polylineCollection = polylineCollections[polylineCollectionId]; if (defined(polylineCollection)) { polylineCollection.remove(this._line); if (polylineCollection.length === 0) { removePolylineCollection(geometryUpdater._scene.primitives, polylineCollection); this._primitives.removeAndDestroy(polylineCollection); - delete polylineCollections[sceneId]; + delete polylineCollections[polylineCollectionId]; } } if (defined(this._groundPolylinePrimitive)) {