diff --git a/CHANGES.md b/CHANGES.md index d368c71aae2e..d74e0a772ab0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -34,6 +34,7 @@ Change Log * Fixed a crash when setting show to `false` on a polyline clamped to the ground. [#6912](https://github.com/AnalyticalGraphicsInc/cesium/issues/6912) * Fixed crash that happened when calling `scene.pick` after setting a new terrain provider [#6918](https://github.com/AnalyticalGraphicsInc/cesium/pull/6918) * Fixed an issue that caused the browser to hang when using `drillPick` on a polyline clamped to the ground. [6907](https://github.com/AnalyticalGraphicsInc/cesium/issues/6907) +* Fixed an issue where color wasn't updated propertly for polylines clamped to ground [#6927](https://github.com/AnalyticalGraphicsInc/cesium/pull/6927) ### 1.48 - 2018-08-01 diff --git a/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js b/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js index c3da5fdcae14..f5df9d4d540e 100644 --- a/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js +++ b/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js @@ -1,5 +1,7 @@ define([ '../Core/AssociativeArray', + '../Core/Color', + '../Core/ColorGeometryInstanceAttribute', '../Core/defined', '../Core/DistanceDisplayCondition', '../Core/DistanceDisplayConditionGeometryInstanceAttribute', @@ -13,6 +15,8 @@ define([ './Property' ], function( AssociativeArray, + Color, + ColorGeometryInstanceAttribute, defined, DistanceDisplayCondition, DistanceDisplayConditionGeometryInstanceAttribute, @@ -26,6 +30,7 @@ define([ Property) { 'use strict'; + var scratchColor = new Color(); var distanceDisplayConditionScratch = new DistanceDisplayCondition(); var defaultDistanceDisplayCondition = new DistanceDisplayCondition(); @@ -195,6 +200,15 @@ define([ this.attributes.set(instance.id.id, attributes); } + if (!updater.fillMaterialProperty.isConstant) { + var colorProperty = updater.fillMaterialProperty.color; + var resultColor = Property.getValueOrDefault(colorProperty, time, Color.WHITE, scratchColor); + if (!Color.equals(attributes._lastColor, resultColor)) { + attributes._lastColor = Color.clone(resultColor, attributes._lastColor); + attributes.color = ColorGeometryInstanceAttribute.toValue(resultColor, attributes.color); + } + } + var show = entity.isShowing && (updater.hasConstantFill || updater.isFilled(time)); var currentShow = attributes.show[0] === 1; if (show !== currentShow) { diff --git a/Specs/DataSources/StaticGroundPolylinePerMaterialBatchSpec.js b/Specs/DataSources/StaticGroundPolylinePerMaterialBatchSpec.js index 8dfed1d1f9b8..a8270facff08 100644 --- a/Specs/DataSources/StaticGroundPolylinePerMaterialBatchSpec.js +++ b/Specs/DataSources/StaticGroundPolylinePerMaterialBatchSpec.js @@ -10,6 +10,7 @@ defineSuite([ 'Core/TimeInterval', 'Core/TimeIntervalCollection', 'DataSources/BoundingSphereState', + 'DataSources/ColorMaterialProperty', 'DataSources/ConstantProperty', 'DataSources/Entity', 'DataSources/PolylineOutlineMaterialProperty', @@ -32,6 +33,7 @@ defineSuite([ TimeInterval, TimeIntervalCollection, BoundingSphereState, + ColorMaterialProperty, ConstantProperty, Entity, PolylineOutlineMaterialProperty, @@ -122,6 +124,52 @@ 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 color = new TimeIntervalCollectionProperty(); + color.intervals.addInterval(TimeInterval.fromIso8601({ + iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', + data: Color.RED + })); + var polyline = createGroundPolyline(); + polyline.material = new ColorMaterialProperty(color); + var entity = new Entity({ + availability: new TimeIntervalCollection([TimeInterval.fromIso8601({iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100'})]), + polyline: polyline + }); + + var batch = new StaticGroundPolylinePerMaterialBatch(scene.groundPrimitives); + + 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.color).toEqual([255, 0, 0, 255]); + + batch.update(time); + scene.render(time); + + primitive = scene.groundPrimitives.get(0); + attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes.color).toEqual([255, 255, 255, 255]); + + batch.removeAllPrimitives(); + }); + }); + it('updates with sampled distance display condition out of range', function() { if (!GroundPolylinePrimitive.isSupported(scene)) { // Don't fail if GroundPolylinePrimitive is not supported