From 39225b2a48bbe80bce6c85026ea4ca00344898a6 Mon Sep 17 00:00:00 2001 From: hpinkos Date: Thu, 16 Aug 2018 11:06:28 -0400 Subject: [PATCH 1/3] Fixes #6925 --- .../StaticGroundPolylinePerMaterialBatch.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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) { From 37feafad7daaaa7b0dbe6168580225099eec0c0d Mon Sep 17 00:00:00 2001 From: hpinkos Date: Thu, 16 Aug 2018 11:08:41 -0400 Subject: [PATCH 2/3] CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 1cec70b4d301..5149a5d21c23 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -27,6 +27,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 From 31728965542e90344db5d5c7cfe14416b3d71658 Mon Sep 17 00:00:00 2001 From: hpinkos Date: Mon, 20 Aug 2018 09:27:20 -0400 Subject: [PATCH 3/3] specs --- ...taticGroundPolylinePerMaterialBatchSpec.js | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) 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