diff --git a/CHANGES.md b/CHANGES.md index d9c35c8545c6..c045ab331eb7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,7 @@ Change Log * Added the ability to specify the width of the intersection volume for `Scene.sampleHeight`, `Scene.clampToHeight`, `Scene.sampleHeightMostDetailed`, and `Scene.clampToHeightMostDetailed`. [#7287](https://github.com/AnalyticalGraphicsInc/cesium/pull/7287) ##### Fixes :wrench: +* Fixed crash when entity geometry show value is an interval that only covered part of the entity availability range [#7458](https://github.com/AnalyticalGraphicsInc/cesium/pull/7458) * Fixed image size issue when using multiple particle systems [#7412](https://github.com/AnalyticalGraphicsInc/cesium/pull/7412) ### 1.53 - 2019-01-02 diff --git a/Source/DataSources/GeometryUpdater.js b/Source/DataSources/GeometryUpdater.js index 6783a2c650cf..1afd6808d271 100644 --- a/Source/DataSources/GeometryUpdater.js +++ b/Source/DataSources/GeometryUpdater.js @@ -306,7 +306,8 @@ define([ */ GeometryUpdater.prototype.isOutlineVisible = function(time) { var entity = this._entity; - return this._outlineEnabled && entity.isAvailable(time) && this._showProperty.getValue(time) && this._showOutlineProperty.getValue(time); + var visible = this._outlineEnabled && entity.isAvailable(time) && this._showProperty.getValue(time) && this._showOutlineProperty.getValue(time); + return defaultValue(visible, false); }; /** @@ -317,7 +318,8 @@ define([ */ GeometryUpdater.prototype.isFilled = function(time) { var entity = this._entity; - return this._fillEnabled && entity.isAvailable(time) && this._showProperty.getValue(time) && this._fillProperty.getValue(time); + var visible = this._fillEnabled && entity.isAvailable(time) && this._showProperty.getValue(time) && this._fillProperty.getValue(time); + return defaultValue(visible, false); }; /** diff --git a/Source/DataSources/PolylineGeometryUpdater.js b/Source/DataSources/PolylineGeometryUpdater.js index 530d49f94c6a..d807626da496 100644 --- a/Source/DataSources/PolylineGeometryUpdater.js +++ b/Source/DataSources/PolylineGeometryUpdater.js @@ -338,7 +338,8 @@ define([ */ PolylineGeometryUpdater.prototype.isFilled = function(time) { var entity = this._entity; - return this._fillEnabled && entity.isAvailable(time) && this._showProperty.getValue(time); + var visible = this._fillEnabled && entity.isAvailable(time) && this._showProperty.getValue(time); + return defaultValue(visible, false); }; /** diff --git a/Specs/DataSources/StaticGeometryColorBatchSpec.js b/Specs/DataSources/StaticGeometryColorBatchSpec.js index 62a499b64a4e..185eeab1cc4e 100644 --- a/Specs/DataSources/StaticGeometryColorBatchSpec.js +++ b/Specs/DataSources/StaticGeometryColorBatchSpec.js @@ -101,6 +101,7 @@ defineSuite([ it('updates with sampled color out of range', function() { var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100'); + var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100'); var color = new TimeIntervalCollectionProperty(); color.intervals.addInterval(TimeInterval.fromIso8601({ iso8601 : '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', @@ -133,8 +134,8 @@ defineSuite([ var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes.color).toEqual([255, 0, 0, 255]); - batch.update(time); - scene.render(time); + batch.update(outOfRangeTime); + scene.render(outOfRangeTime); primitive = scene.primitives.get(0); attributes = primitive.getGeometryInstanceAttributes(entity); @@ -146,6 +147,7 @@ defineSuite([ it('updates with sampled distance display condition out of range', function() { var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100'); + var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100'); var ddc = new TimeIntervalCollectionProperty(); ddc.intervals.addInterval(TimeInterval.fromIso8601({ iso8601 : '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', @@ -179,8 +181,8 @@ defineSuite([ var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes.distanceDisplayCondition).toEqualEpsilon([1.0, 2.0], CesiumMath.EPSILON6); - batch.update(time); - scene.render(time); + batch.update(outOfRangeTime); + scene.render(outOfRangeTime); primitive = scene.primitives.get(0); attributes = primitive.getGeometryInstanceAttributes(entity); @@ -190,6 +192,52 @@ defineSuite([ }); }); + it('updates with sampled show out of range', function() { + var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100'); + var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100'); + var show = new TimeIntervalCollectionProperty(); + show.intervals.addInterval(TimeInterval.fromIso8601({ + iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', + data: true + })); + var entity = new Entity({ + availability : new TimeIntervalCollection([TimeInterval.fromIso8601({iso8601 : '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100'})]), + position : new Cartesian3(1234, 5678, 9101112), + ellipse : { + semiMajorAxis : 2, + semiMinorAxis : 1, + extrudedHeight : 20, + show: show + } + }); + + var batch = new StaticGeometryColorBatch(scene.primitives, PerInstanceColorAppearance, undefined, false, ShadowMode.DISABLED); + + var updater = new EllipseGeometryUpdater(entity, scene); + batch.add(validTime, updater); + + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = batch.update(validTime); + scene.render(validTime); + return isUpdated; + }).then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes.show).toEqual([1]); + + batch.update(outOfRangeTime); + scene.render(outOfRangeTime); + + primitive = scene.primitives.get(0); + attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes.show).toEqual([0]); + + batch.removeAllPrimitives(); + }); + }); + it('updates color attribute after rebuilding polyline primitive', function() { var batch = new StaticGeometryColorBatch(scene.primitives, PolylineColorAppearance, undefined, false, ShadowMode.DISABLED); diff --git a/Specs/DataSources/StaticGeometryPerMaterialBatchSpec.js b/Specs/DataSources/StaticGeometryPerMaterialBatchSpec.js index d696c7c5edd5..b4609f070b0e 100644 --- a/Specs/DataSources/StaticGeometryPerMaterialBatchSpec.js +++ b/Specs/DataSources/StaticGeometryPerMaterialBatchSpec.js @@ -119,6 +119,7 @@ defineSuite([ it('updates with sampled distance display condition out of range', function() { var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100'); + var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100'); var ddc = new TimeIntervalCollectionProperty(); ddc.intervals.addInterval(TimeInterval.fromIso8601({ iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', @@ -152,8 +153,8 @@ defineSuite([ var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes.distanceDisplayCondition).toEqualEpsilon([1.0, 2.0], CesiumMath.EPSILON6); - batch.update(time); - scene.render(time); + batch.update(outOfRangeTime); + scene.render(outOfRangeTime); primitive = scene.primitives.get(0); attributes = primitive.getGeometryInstanceAttributes(entity); @@ -163,6 +164,53 @@ defineSuite([ }); }); + it('updates with sampled show out of range', function() { + var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100'); + var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100'); + var show = new TimeIntervalCollectionProperty(); + show.intervals.addInterval(TimeInterval.fromIso8601({ + iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', + data: true + })); + var entity = new Entity({ + availability: new TimeIntervalCollection([TimeInterval.fromIso8601({iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100'})]), + position : new Cartesian3(1234, 5678, 9101112), + ellipse: { + semiMajorAxis : 2, + semiMinorAxis : 1, + extrudedHeight: 20, + material : new GridMaterialProperty(), + show: show + } + }); + + var batch = new StaticGeometryPerMaterialBatch(scene.primitives, MaterialAppearance, undefined, false, ShadowMode.DISABLED); + + var updater = new EllipseGeometryUpdater(entity, scene); + batch.add(validTime, updater); + + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = batch.update(validTime); + scene.render(validTime); + return isUpdated; + }).then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes.show).toEqual([1]); + + batch.update(outOfRangeTime); + scene.render(outOfRangeTime); + + primitive = scene.primitives.get(0); + attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes.show).toEqual([0]); + + batch.removeAllPrimitives(); + }); + }); + it('handles shared material being invalidated for polyline', function() { var batch = new StaticGeometryPerMaterialBatch(scene.primitives, PolylineMaterialAppearance, undefined, false, ShadowMode.DISABLED); diff --git a/Specs/DataSources/StaticGroundGeometryColorBatchSpec.js b/Specs/DataSources/StaticGroundGeometryColorBatchSpec.js index b988502a18f9..c8fccc300362 100644 --- a/Specs/DataSources/StaticGroundGeometryColorBatchSpec.js +++ b/Specs/DataSources/StaticGroundGeometryColorBatchSpec.js @@ -133,6 +133,7 @@ defineSuite([ it('updates with sampled distance display condition out of range', function() { var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100'); + var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100'); var ddc = new TimeIntervalCollectionProperty(); ddc.intervals.addInterval(TimeInterval.fromIso8601({ iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', @@ -165,8 +166,8 @@ defineSuite([ var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes.distanceDisplayCondition).toEqualEpsilon([1.0, 2.0], CesiumMath.EPSILON6); - batch.update(time); - scene.render(time); + batch.update(outOfRangeTime); + scene.render(outOfRangeTime); primitive = scene.groundPrimitives.get(0); attributes = primitive.getGeometryInstanceAttributes(entity); @@ -176,6 +177,52 @@ defineSuite([ }); }); + it('updates with sampled show out of range', function() { + var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100'); + var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100'); + var show = new TimeIntervalCollectionProperty(); + show.intervals.addInterval(TimeInterval.fromIso8601({ + iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', + data: true + })); + var entity = new Entity({ + availability: new TimeIntervalCollection([TimeInterval.fromIso8601({iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100'})]), + position : new Cartesian3(1234, 5678, 9101112), + ellipse: { + semiMajorAxis : 2, + semiMinorAxis : 1, + material: Color.RED, + show: show + } + }); + + var batch = new StaticGroundGeometryColorBatch(scene.groundPrimitives, ClassificationType.BOTH); + + var updater = new EllipseGeometryUpdater(entity, scene); + batch.add(validTime, updater); + + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = batch.update(validTime); + scene.render(validTime); + return isUpdated; + }).then(function() { + expect(scene.groundPrimitives.length).toEqual(1); + var primitive = scene.groundPrimitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes.show).toEqual([1]); + + batch.update(outOfRangeTime); + scene.render(outOfRangeTime); + + primitive = scene.groundPrimitives.get(0); + attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes.show).toEqual([0]); + + batch.removeAllPrimitives(); + }); + }); + it('shows only one primitive while rebuilding primitive', function() { if (!GroundPrimitive.isSupported(scene)) { return; diff --git a/Specs/DataSources/StaticGroundGeometryPerMaterialBatchSpec.js b/Specs/DataSources/StaticGroundGeometryPerMaterialBatchSpec.js index e90c7393f5b9..2250692be2d0 100644 --- a/Specs/DataSources/StaticGroundGeometryPerMaterialBatchSpec.js +++ b/Specs/DataSources/StaticGroundGeometryPerMaterialBatchSpec.js @@ -135,6 +135,7 @@ defineSuite([ } var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100'); + var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100'); var ddc = new TimeIntervalCollectionProperty(); ddc.intervals.addInterval(TimeInterval.fromIso8601({ iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', @@ -167,8 +168,8 @@ defineSuite([ var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes.distanceDisplayCondition).toEqualEpsilon([1.0, 2.0], CesiumMath.EPSILON6); - batch.update(time); - scene.render(time); + batch.update(outOfRangeTime); + scene.render(outOfRangeTime); primitive = scene.primitives.get(0); attributes = primitive.getGeometryInstanceAttributes(entity); @@ -178,6 +179,57 @@ defineSuite([ }); }); + it('updates with sampled show out of range', function() { + if (!GroundPrimitive.isSupported(scene) || !GroundPrimitive.supportsMaterials(scene)) { + // Don't fail if materials on GroundPrimitive not supported + return; + } + + var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100'); + var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100'); + var show = new TimeIntervalCollectionProperty(); + show.intervals.addInterval(TimeInterval.fromIso8601({ + iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', + data: true + })); + var entity = new Entity({ + availability: new TimeIntervalCollection([TimeInterval.fromIso8601({iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100'})]), + position : new Cartesian3(1234, 5678, 9101112), + ellipse: { + semiMajorAxis : 2, + semiMinorAxis : 1, + material : new GridMaterialProperty(), + show: show + } + }); + + var batch = new StaticGroundGeometryPerMaterialBatch(scene.primitives, MaterialAppearance); + + var updater = new EllipseGeometryUpdater(entity, scene); + batch.add(validTime, updater); + + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = batch.update(validTime); + scene.render(validTime); + return isUpdated; + }).then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes.show).toEqual([1]); + + batch.update(outOfRangeTime); + scene.render(outOfRangeTime); + + primitive = scene.primitives.get(0); + attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes.show).toEqual([0]); + + batch.removeAllPrimitives(); + }); + }); + it('shows only one primitive while rebuilding primitive', function() { if (!GroundPrimitive.isSupported(scene) || !GroundPrimitive.supportsMaterials(scene)) { // Don't fail if materials on GroundPrimitive not supported diff --git a/Specs/DataSources/StaticGroundPolylinePerMaterialBatchSpec.js b/Specs/DataSources/StaticGroundPolylinePerMaterialBatchSpec.js index 6fbd74d96407..4056a2d7a26a 100644 --- a/Specs/DataSources/StaticGroundPolylinePerMaterialBatchSpec.js +++ b/Specs/DataSources/StaticGroundPolylinePerMaterialBatchSpec.js @@ -184,6 +184,7 @@ defineSuite([ return; } var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100'); + var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100'); var ddc = new TimeIntervalCollectionProperty(); ddc.intervals.addInterval(TimeInterval.fromIso8601({ iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', @@ -213,8 +214,8 @@ defineSuite([ var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes.distanceDisplayCondition).toEqualEpsilon([1.0, 2.0], CesiumMath.EPSILON6); - batch.update(time); - scene.render(time); + batch.update(outOfRangeTime); + scene.render(outOfRangeTime); primitive = scene.groundPrimitives.get(0); attributes = primitive.getGeometryInstanceAttributes(entity); @@ -224,6 +225,53 @@ defineSuite([ }); }); + it('updates with sampled color out of range', function() { + if (!GroundPolylinePrimitive.isSupported(scene)) { + // Don't fail if GroundPolylinePrimitive is not supported + return; + } + + var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100'); + var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100'); + var show = new TimeIntervalCollectionProperty(); + show.intervals.addInterval(TimeInterval.fromIso8601({ + iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', + data: true + })); + var polyline = createGroundPolyline(); + polyline.show = show; + var entity = new Entity({ + availability: new TimeIntervalCollection([TimeInterval.fromIso8601({iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100'})]), + polyline: polyline + }); + + batch = new StaticGroundPolylinePerMaterialBatch(scene.groundPrimitives, false); + + var updater = new PolylineGeometryUpdater(entity, scene); + batch.add(validTime, updater); + + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = batch.update(validTime); + scene.render(validTime); + return isUpdated; + }).then(function() { + expect(scene.groundPrimitives.length).toEqual(1); + var primitive = scene.groundPrimitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes.show).toEqual([1]); + + batch.update(outOfRangeTime); + scene.render(outOfRangeTime); + + primitive = scene.groundPrimitives.get(0); + attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes.show).toEqual([0]); + + batch.removeAllPrimitives(); + }); + }); + it('shows only one primitive while rebuilding primitive', function() { if (!GroundPolylinePrimitive.isSupported(scene)) { // Don't fail if GroundPolylinePrimitive is not supported diff --git a/Specs/DataSources/StaticOutlineGeometryBatchSpec.js b/Specs/DataSources/StaticOutlineGeometryBatchSpec.js index a5317e0e6896..cca4ddc3f878 100644 --- a/Specs/DataSources/StaticOutlineGeometryBatchSpec.js +++ b/Specs/DataSources/StaticOutlineGeometryBatchSpec.js @@ -94,6 +94,7 @@ defineSuite([ it('updates with sampled color out of range', function() { var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100'); + var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100'); var color = new TimeIntervalCollectionProperty(); color.intervals.addInterval(TimeInterval.fromIso8601({ iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', @@ -127,8 +128,8 @@ defineSuite([ var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes.color).toEqual([255, 0, 0, 255]); - batch.update(time); - scene.render(time); + batch.update(outOfRangeTime); + scene.render(outOfRangeTime); primitive = scene.primitives.get(0); attributes = primitive.getGeometryInstanceAttributes(entity); @@ -140,6 +141,7 @@ defineSuite([ it('updates with sampled distance display condition out of range', function() { var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100'); + var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100'); var ddc = new TimeIntervalCollectionProperty(); ddc.intervals.addInterval(TimeInterval.fromIso8601({ iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', @@ -174,8 +176,8 @@ defineSuite([ var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes.distanceDisplayCondition).toEqualEpsilon([1.0, 2.0], CesiumMath.EPSILON6); - batch.update(time); - scene.render(time); + batch.update(outOfRangeTime); + scene.render(outOfRangeTime); primitive = scene.primitives.get(0); attributes = primitive.getGeometryInstanceAttributes(entity); @@ -185,6 +187,53 @@ defineSuite([ }); }); + it('updates with sampled show out of range', function() { + var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100'); + var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100'); + var show = new TimeIntervalCollectionProperty(); + show.intervals.addInterval(TimeInterval.fromIso8601({ + iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', + data: true + })); + var entity = new Entity({ + availability: new TimeIntervalCollection([TimeInterval.fromIso8601({iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100'})]), + position : new Cartesian3(1234, 5678, 9101112), + ellipse: { + semiMajorAxis : 2, + semiMinorAxis : 1, + extrudedHeight: 20, + outline : true, + show: show + } + }); + + var batch = new StaticOutlineGeometryBatch(scene.primitives, scene, false, ShadowMode.DISABLED); + + var updater = new EllipseGeometryUpdater(entity, scene); + batch.add(validTime, updater); + + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = batch.update(validTime); + scene.render(validTime); + return isUpdated; + }).then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes.show).toEqual([1]); + + batch.update(outOfRangeTime); + scene.render(outOfRangeTime); + + primitive = scene.primitives.get(0); + attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes.show).toEqual([0]); + + batch.removeAllPrimitives(); + }); + }); + it('shows only one primitive while rebuilding primitive', function() { var batch = new StaticOutlineGeometryBatch(scene.primitives, scene, false, ShadowMode.DISABLED);