Skip to content

Commit

Permalink
Distinct PolylineCollections for each CustomDataSource
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rropp5 authored Dec 16, 2023
1 parent 890ee0c commit b7928c9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/engine/Source/DataSources/PolylineGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit b7928c9

Please sign in to comment.