From 5c09a75fda9530cbc36a99585a2054569ce16e90 Mon Sep 17 00:00:00 2001 From: Scott Hunter Date: Tue, 28 Jan 2020 10:05:15 -0500 Subject: [PATCH 1/3] Primitive takes a single geometry instance, so we don't need a single-element array. --- Apps/Sandcastle/gallery/development/Circle Outline.html | 4 ++-- Apps/Sandcastle/gallery/development/Circle.html | 4 ++-- Apps/Sandcastle/gallery/development/Corridor.html | 4 ++-- Apps/Sandcastle/gallery/development/Cylinder Outline.html | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Apps/Sandcastle/gallery/development/Circle Outline.html b/Apps/Sandcastle/gallery/development/Circle Outline.html index 1b4b8197bf2c..1a86927228f6 100644 --- a/Apps/Sandcastle/gallery/development/Circle Outline.html +++ b/Apps/Sandcastle/gallery/development/Circle Outline.html @@ -42,7 +42,7 @@ }); // Add the geometry instance to primitives. scene.primitives.add(new Cesium.Primitive({ - geometryInstances : [circleOutlineInstance], + geometryInstances : circleOutlineInstance, appearance : new Cesium.PerInstanceColorAppearance({ flat : true, renderState : { @@ -72,7 +72,7 @@ }); // Add the geometry instance to primitives. scene.primitives.add(new Cesium.Primitive({ - geometryInstances : [circleOutlineInstance], + geometryInstances : circleOutlineInstance, appearance : new Cesium.PerInstanceColorAppearance({ flat : true, renderState : { diff --git a/Apps/Sandcastle/gallery/development/Circle.html b/Apps/Sandcastle/gallery/development/Circle.html index 90ce6451ddbd..8249668fcada 100644 --- a/Apps/Sandcastle/gallery/development/Circle.html +++ b/Apps/Sandcastle/gallery/development/Circle.html @@ -45,7 +45,7 @@ }); // Add the geometry instance to primitives. scene.primitives.add(new Cesium.Primitive({ - geometryInstances: [redCircleInstance], + geometryInstances: redCircleInstance, appearance: new Cesium.PerInstanceColorAppearance({ closed: true }) @@ -71,7 +71,7 @@ }); // Add the geometry instance to primitives. scene.primitives.add(new Cesium.Primitive({ - geometryInstances: [greenCircleInstance], + geometryInstances: greenCircleInstance, appearance: new Cesium.PerInstanceColorAppearance({ closed: true }) diff --git a/Apps/Sandcastle/gallery/development/Corridor.html b/Apps/Sandcastle/gallery/development/Corridor.html index ab28a0500387..7866eb4b355a 100644 --- a/Apps/Sandcastle/gallery/development/Corridor.html +++ b/Apps/Sandcastle/gallery/development/Corridor.html @@ -49,7 +49,7 @@ }); // Add the geometry instance to primitives. scene.primitives.add(new Cesium.Primitive({ - geometryInstances : [redCorridorInstance], + geometryInstances : redCorridorInstance, appearance : new Cesium.PerInstanceColorAppearance({ closed : true }) @@ -118,7 +118,7 @@ }); // Add the geometry instance to primitives. scene.primitives.add(new Cesium.Primitive({ - geometryInstances : [blueCorridorInstance], + geometryInstances : blueCorridorInstance, appearance : new Cesium.PerInstanceColorAppearance({ closed : true }) diff --git a/Apps/Sandcastle/gallery/development/Cylinder Outline.html b/Apps/Sandcastle/gallery/development/Cylinder Outline.html index bdee996bacf6..98bb094eb184 100644 --- a/Apps/Sandcastle/gallery/development/Cylinder Outline.html +++ b/Apps/Sandcastle/gallery/development/Cylinder Outline.html @@ -55,7 +55,7 @@ }); // Add the instance to primitives. scene.primitives.add(new Cesium.Primitive({ - geometryInstances : [cylinderOutline], + geometryInstances : cylinderOutline, appearance : new Cesium.PerInstanceColorAppearance({ flat : true, renderState : { From f006faec2b345f1167432f0d1386a6f1bb544781 Mon Sep 17 00:00:00 2001 From: Scott Hunter Date: Tue, 28 Jan 2020 10:05:51 -0500 Subject: [PATCH 2/3] Make a copy of the array of geometry instances before passing to the Primitive constructor. In the batches, the `geometries` is a live reference to the array inside the AssociativeArray owned by the batch. We need to make a copy of the array so that subsequent changes to the batch don't affect the Primitive's view of the instances, which could happen during async creation or combining. --- Source/DataSources/StaticGeometryColorBatch.js | 2 +- Source/DataSources/StaticGeometryPerMaterialBatch.js | 2 +- Source/DataSources/StaticGroundGeometryColorBatch.js | 2 +- Source/DataSources/StaticGroundGeometryPerMaterialBatch.js | 2 +- Source/DataSources/StaticGroundPolylinePerMaterialBatch.js | 2 +- Source/DataSources/StaticOutlineGeometryBatch.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/DataSources/StaticGeometryColorBatch.js b/Source/DataSources/StaticGeometryColorBatch.js index b8e3f8572411..c91067d16421 100644 --- a/Source/DataSources/StaticGeometryColorBatch.js +++ b/Source/DataSources/StaticGeometryColorBatch.js @@ -131,7 +131,7 @@ import Property from './Property.js'; primitive = new Primitive({ show : false, asynchronous : true, - geometryInstances : geometries, + geometryInstances : geometries.slice(), appearance : new this.appearanceType({ translucent : this.translucent, closed : this.closed diff --git a/Source/DataSources/StaticGeometryPerMaterialBatch.js b/Source/DataSources/StaticGeometryPerMaterialBatch.js index 850209590347..59bd5ffb57ac 100644 --- a/Source/DataSources/StaticGeometryPerMaterialBatch.js +++ b/Source/DataSources/StaticGeometryPerMaterialBatch.js @@ -127,7 +127,7 @@ import Property from './Property.js'; primitive = new Primitive({ show : false, asynchronous : true, - geometryInstances : geometries, + geometryInstances : geometries.slice(), appearance : new this.appearanceType({ material : this.material, translucent : this.material.isTranslucent(), diff --git a/Source/DataSources/StaticGroundGeometryColorBatch.js b/Source/DataSources/StaticGroundGeometryColorBatch.js index c565a3a092fc..79859d83b861 100644 --- a/Source/DataSources/StaticGroundGeometryColorBatch.js +++ b/Source/DataSources/StaticGroundGeometryColorBatch.js @@ -89,7 +89,7 @@ import Property from './Property.js'; primitive = new GroundPrimitive({ show : false, asynchronous : true, - geometryInstances : geometries, + geometryInstances : geometries.slice(), classificationType : this.classificationType }); primitives.add(primitive, this.zIndex); diff --git a/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js b/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js index 7ddb610f66a7..e34e513f636f 100644 --- a/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js +++ b/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js @@ -119,7 +119,7 @@ import Property from './Property.js'; primitive = new GroundPrimitive({ show : false, asynchronous : true, - geometryInstances : geometries, + geometryInstances : geometries.slice(), appearance : new this.appearanceType({ material : this.material // translucent and closed properties overridden diff --git a/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js b/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js index 4794d6702715..317cc0c1732b 100644 --- a/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js +++ b/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js @@ -121,7 +121,7 @@ import Property from './Property.js'; primitive = new GroundPolylinePrimitive({ show : false, asynchronous : this._asynchronous, - geometryInstances : geometries, + geometryInstances : geometries.slice(), appearance : new this.appearanceType(), classificationType : this.classificationType }); diff --git a/Source/DataSources/StaticOutlineGeometryBatch.js b/Source/DataSources/StaticOutlineGeometryBatch.js index f37ed8bee20a..03feea0bcd5f 100644 --- a/Source/DataSources/StaticOutlineGeometryBatch.js +++ b/Source/DataSources/StaticOutlineGeometryBatch.js @@ -90,7 +90,7 @@ import Property from './Property.js'; primitive = new Primitive({ show : false, asynchronous : true, - geometryInstances : geometries, + geometryInstances : geometries.slice(), appearance : new PerInstanceColorAppearance({ flat : true, translucent : this.translucent, From 680fcbe4480f7d6d10149e5c91646819199695e6 Mon Sep 17 00:00:00 2001 From: Scott Hunter Date: Tue, 28 Jan 2020 15:02:19 -0500 Subject: [PATCH 3/3] Update CHANGES. --- CHANGES.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index c83cacff0d0b..888bf37ee814 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -42,7 +42,8 @@ Change Log * Fixed a bug where toggling point cloud classification visibility would result in a grey screen on Linux / Nvidia [#8538](https://github.com/AnalyticalGraphicsInc/cesium/pull/8538) * Fixed a bug where a point in a `PointPrimitiveCollection` is rendered in the middle of the screen instead of being clipped. [#8542](https://github.com/AnalyticalGraphicsInc/cesium/pull/8542) * Fixed a crash when deleting and re-creating polylines from CZML. `ReferenceProperty` now returns undefined when the target entity or property does not exist, instead of throwing. [#8544](https://github.com/AnalyticalGraphicsInc/cesium/pull/8544) -* Fixed a bug where rapidly updating a PolylineCollection could result in an instanceIndex is out of range error [#8546](https://github.com/AnalyticalGraphicsInc/cesium/pull/8546) +* Fixed a bug where rapidly updating a `PolylineCollection` could result in an instanceIndex is out of range error. [#8546](https://github.com/AnalyticalGraphicsInc/cesium/pull/8546) +* Fixed a crash that could occur when an entity was deleted while the corresponding `Primitive` was being created asynchronously. [#8569](https://github.com/AnalyticalGraphicsInc/cesium/pull/8569) ### 1.65.0 - 2020-01-06