diff --git a/CHANGES.md b/CHANGES.md index ae01a76b078d..d7a799acbfd4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,6 +17,7 @@ Change Log * Fixed an issue where `pickPosition` would return incorrect results when called after `sampleHeight` or `clampToHeight`. [#7113](https://github.com/AnalyticalGraphicsInc/cesium/pull/7113) * Fixed crash when updating polyline attributes twice in one frame [#7155](https://github.com/AnalyticalGraphicsInc/cesium/pull/7155) * Fixed a crash when using `BingMapsGeocoderService` [#7143](https://github.com/AnalyticalGraphicsInc/cesium/issues/7143) +* Fixed entity visibility issue related to setting an entity show property and altering or adding entity geometry [#7156](https://github.com/AnalyticalGraphicsInc/cesium/pull/7156) ### 1.50 - 2018-10-01 diff --git a/Source/DataSources/StaticGeometryColorBatch.js b/Source/DataSources/StaticGeometryColorBatch.js index 8fb868d1a8af..338e14e5e609 100644 --- a/Source/DataSources/StaticGeometryColorBatch.js +++ b/Source/DataSources/StaticGeometryColorBatch.js @@ -271,6 +271,7 @@ define([ var currentShow = attributes.show[0] === 1; if (show !== currentShow) { attributes.show = ShowGeometryInstanceAttribute.toValue(show, attributes.show); + instance.attributes.show.value[0] = attributes.show[0]; } } this.showsUpdated.removeAll(); diff --git a/Source/DataSources/StaticGeometryPerMaterialBatch.js b/Source/DataSources/StaticGeometryPerMaterialBatch.js index 0b409e1e7fd6..af659d2843fe 100644 --- a/Source/DataSources/StaticGeometryPerMaterialBatch.js +++ b/Source/DataSources/StaticGeometryPerMaterialBatch.js @@ -258,6 +258,7 @@ define([ var currentShow = attributes.show[0] === 1; if (show !== currentShow) { attributes.show = ShowGeometryInstanceAttribute.toValue(show, attributes.show); + instance.attributes.show.value[0] = attributes.show[0]; } } this.showsUpdated.removeAll(); diff --git a/Source/DataSources/StaticGroundGeometryColorBatch.js b/Source/DataSources/StaticGroundGeometryColorBatch.js index a64f22868263..f75563d36f40 100644 --- a/Source/DataSources/StaticGroundGeometryColorBatch.js +++ b/Source/DataSources/StaticGroundGeometryColorBatch.js @@ -198,6 +198,7 @@ define([ var currentShow = attributes.show[0] === 1; if (show !== currentShow) { attributes.show = ShowGeometryInstanceAttribute.toValue(show, attributes.show); + instance.attributes.show.value[0] = attributes.show[0]; } } this.showsUpdated.removeAll(); diff --git a/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js b/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js index 5b4efae2150f..c4fe25feea59 100644 --- a/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js +++ b/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js @@ -226,6 +226,7 @@ define([ var currentShow = attributes.show[0] === 1; if (show !== currentShow) { attributes.show = ShowGeometryInstanceAttribute.toValue(show, attributes.show); + instance.attributes.show.value[0] = attributes.show[0]; } } this.showsUpdated.removeAll(); diff --git a/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js b/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js index b99b0e8b3493..809c0f235d17 100644 --- a/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js +++ b/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js @@ -234,6 +234,7 @@ define([ var currentShow = attributes.show[0] === 1; if (show !== currentShow) { attributes.show = ShowGeometryInstanceAttribute.toValue(show, attributes.show); + instance.attributes.show.value[0] = attributes.show[0]; } } this.showsUpdated.removeAll(); diff --git a/Source/DataSources/StaticOutlineGeometryBatch.js b/Source/DataSources/StaticOutlineGeometryBatch.js index 3cfc3a3da71f..fb6519ff7998 100644 --- a/Source/DataSources/StaticOutlineGeometryBatch.js +++ b/Source/DataSources/StaticOutlineGeometryBatch.js @@ -219,6 +219,7 @@ define([ var currentShow = attributes.show[0] === 1; if (show !== currentShow) { attributes.show = ShowGeometryInstanceAttribute.toValue(show, attributes.show); + instance.attributes.show.value[0] = attributes.show[0]; } } this.showsUpdated.removeAll(); diff --git a/Specs/DataSources/StaticGeometryColorBatchSpec.js b/Specs/DataSources/StaticGeometryColorBatchSpec.js index 3586a6d036f2..62a499b64a4e 100644 --- a/Specs/DataSources/StaticGeometryColorBatchSpec.js +++ b/Specs/DataSources/StaticGeometryColorBatchSpec.js @@ -1,43 +1,43 @@ defineSuite([ - 'DataSources/StaticGeometryColorBatch', - 'Core/Cartesian3', - 'Core/Color', - 'Core/DistanceDisplayCondition', - 'Core/JulianDate', - 'Core/Math', - 'Core/TimeInterval', - 'Core/TimeIntervalCollection', - 'DataSources/CallbackProperty', - 'DataSources/ColorMaterialProperty', - 'DataSources/EllipseGeometryUpdater', - 'DataSources/Entity', - 'DataSources/PolylineGeometryUpdater', - 'DataSources/TimeIntervalCollectionProperty', - 'Scene/PerInstanceColorAppearance', - 'Scene/PolylineColorAppearance', - 'Scene/ShadowMode', - 'Specs/createScene', - 'Specs/pollToPromise' - ], function( - StaticGeometryColorBatch, - Cartesian3, - Color, - DistanceDisplayCondition, - JulianDate, - CesiumMath, - TimeInterval, - TimeIntervalCollection, - CallbackProperty, - ColorMaterialProperty, - EllipseGeometryUpdater, - Entity, - PolylineGeometryUpdater, - TimeIntervalCollectionProperty, - PerInstanceColorAppearance, - PolylineColorAppearance, - ShadowMode, - createScene, - pollToPromise) { + 'DataSources/StaticGeometryColorBatch', + 'Core/Cartesian3', + 'Core/Color', + 'Core/DistanceDisplayCondition', + 'Core/JulianDate', + 'Core/Math', + 'Core/TimeInterval', + 'Core/TimeIntervalCollection', + 'DataSources/CallbackProperty', + 'DataSources/ColorMaterialProperty', + 'DataSources/EllipseGeometryUpdater', + 'DataSources/Entity', + 'DataSources/PolylineGeometryUpdater', + 'DataSources/TimeIntervalCollectionProperty', + 'Scene/PerInstanceColorAppearance', + 'Scene/PolylineColorAppearance', + 'Scene/ShadowMode', + 'Specs/createScene', + 'Specs/pollToPromise' +], function( + StaticGeometryColorBatch, + Cartesian3, + Color, + DistanceDisplayCondition, + JulianDate, + CesiumMath, + TimeInterval, + TimeIntervalCollection, + CallbackProperty, + ColorMaterialProperty, + EllipseGeometryUpdater, + Entity, + PolylineGeometryUpdater, + TimeIntervalCollectionProperty, + PerInstanceColorAppearance, + PolylineColorAppearance, + ShadowMode, + createScene, + pollToPromise) { 'use strict'; var time = JulianDate.now(); @@ -103,17 +103,17 @@ defineSuite([ 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 + iso8601 : '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', + data : Color.RED })); var entity = new Entity({ - availability: new TimeIntervalCollection([TimeInterval.fromIso8601({iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100'})]), + 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: { + ellipse : { semiMajorAxis : 2, semiMinorAxis : 1, - extrudedHeight: 20, - material: new ColorMaterialProperty(color) + extrudedHeight : 20, + material : new ColorMaterialProperty(color) } }); @@ -148,18 +148,18 @@ defineSuite([ var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100'); var ddc = new TimeIntervalCollectionProperty(); ddc.intervals.addInterval(TimeInterval.fromIso8601({ - iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', - data: new DistanceDisplayCondition(1.0, 2.0) + iso8601 : '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', + data : new DistanceDisplayCondition(1.0, 2.0) })); var entity = new Entity({ - availability: new TimeIntervalCollection([TimeInterval.fromIso8601({iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100'})]), + 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: { + ellipse : { semiMajorAxis : 2, semiMinorAxis : 1, - extrudedHeight: 20, - material: Color.RED, - distanceDisplayCondition: ddc + extrudedHeight : 20, + material : Color.RED, + distanceDisplayCondition : ddc } }); @@ -236,15 +236,15 @@ defineSuite([ 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 + iso8601 : '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100', + data : Color.RED })); var entity = new Entity({ - availability: new TimeIntervalCollection([TimeInterval.fromIso8601({iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100'})]), + availability : new TimeIntervalCollection([TimeInterval.fromIso8601({iso8601 : '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100'})]), polyline : { positions : [Cartesian3.fromDegrees(0.0, 0.0), Cartesian3.fromDegrees(0.0, 1.0)], material : Color.BLUE, - depthFailMaterial: new ColorMaterialProperty(color) + depthFailMaterial : new ColorMaterialProperty(color) } }); @@ -305,35 +305,97 @@ defineSuite([ batch.add(time, updater1); return pollToPromise(renderScene) - .then(function() { - expect(scene.primitives.length).toEqual(1); - var primitive = scene.primitives.get(0); - expect(primitive.show).toBeTruthy(); - }) - .then(function() { - batch.add(time, updater2); - }) - .then(function() { - return pollToPromise(function() { - renderScene(); - return scene.primitives.length === 2; + .then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + expect(primitive.show).toBeTruthy(); + }) + .then(function() { + batch.add(time, updater2); + }) + .then(function() { + return pollToPromise(function() { + renderScene(); + return scene.primitives.length === 2; + }); + }) + .then(function() { + var showCount = 0; + expect(scene.primitives.length).toEqual(2); + showCount += !!scene.primitives.get(0).show; + showCount += !!scene.primitives.get(1).show; + expect(showCount).toEqual(1); + }) + .then(function() { + return pollToPromise(renderScene); + }) + .then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + expect(primitive.show).toBeTruthy(); + batch.removeAllPrimitives(); + }); + }); + + it('has correct show attribute after rebuilding primitive', function() { + var batch = new StaticGeometryColorBatch(scene.primitives, PerInstanceColorAppearance, undefined, false, ShadowMode.DISABLED); + + function buildEntity() { + return new Entity({ + position : new Cartesian3(1234, 5678, 9101112), + ellipse : { + semiMajorAxis : 2, + semiMinorAxis : 1, + material : Color.RED.withAlpha(0.5), + height : 0 + } + }); + } + + function renderScene() { + scene.initializeFrame(); + var isUpdated = batch.update(time); + scene.render(time); + return isUpdated; + } + + var entity1 = buildEntity(); + var updater1 = new EllipseGeometryUpdater(entity1, scene); + batch.add(time, updater1); + + var entity2 = buildEntity(); + var updater2 = new EllipseGeometryUpdater(entity2, scene); + + return pollToPromise(renderScene) + .then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([1]); + + entity1.show = false; + updater1._onEntityPropertyChanged(entity1, 'isShowing'); + return pollToPromise(renderScene); + }) + .then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([0]); + + batch.add(time, updater2); + return pollToPromise(renderScene); + }) + .then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([0]); + + attributes = primitive.getGeometryInstanceAttributes(entity2); + expect(attributes.show).toEqual([1]); + + batch.removeAllPrimitives(); }); - }) - .then(function() { - var showCount = 0; - expect(scene.primitives.length).toEqual(2); - showCount += !!scene.primitives.get(0).show; - showCount += !!scene.primitives.get(1).show; - expect(showCount).toEqual(1); - }) - .then(function() { - return pollToPromise(renderScene); - }) - .then(function() { - expect(scene.primitives.length).toEqual(1); - var primitive = scene.primitives.get(0); - expect(primitive.show).toBeTruthy(); - batch.removeAllPrimitives(); - }); }); }); diff --git a/Specs/DataSources/StaticGeometryPerMaterialBatchSpec.js b/Specs/DataSources/StaticGeometryPerMaterialBatchSpec.js index 84199148095f..d696c7c5edd5 100644 --- a/Specs/DataSources/StaticGeometryPerMaterialBatchSpec.js +++ b/Specs/DataSources/StaticGeometryPerMaterialBatchSpec.js @@ -378,4 +378,73 @@ defineSuite([ batch.removeAllPrimitives(); }); }); + + it('has correct show attribute after rebuilding primitive', function() { + var batch = new StaticGeometryPerMaterialBatch(scene.primitives, MaterialAppearance, undefined, false, ShadowMode.DISABLED); + + function buildEntity() { + var material = new GridMaterialProperty({ + color : Color.YELLOW, + cellAlpha : 0.3, + lineCount : new Cartesian2(8, 8), + lineThickness : new Cartesian2(2.0, 2.0) + }); + + return new Entity({ + position : new Cartesian3(1234, 5678, 9101112), + ellipse : { + semiMajorAxis : 2, + semiMinorAxis : 1, + height : 0, + material: material + } + }); + } + + function renderScene() { + scene.initializeFrame(); + var isUpdated = batch.update(time); + scene.render(time); + return isUpdated; + } + + var entity1 = buildEntity(); + var updater1 = new EllipseGeometryUpdater(entity1, scene); + batch.add(time, updater1); + + var entity2 = buildEntity(); + var updater2 = new EllipseGeometryUpdater(entity2, scene); + + return pollToPromise(renderScene) + .then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([1]); + + entity1.show = false; + updater1._onEntityPropertyChanged(entity1, 'isShowing'); + return pollToPromise(renderScene); + }) + .then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([0]); + + batch.add(time, updater2); + return pollToPromise(renderScene); + }) + .then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([0]); + + attributes = primitive.getGeometryInstanceAttributes(entity2); + expect(attributes.show).toEqual([1]); + + batch.removeAllPrimitives(); + }); + }); }); diff --git a/Specs/DataSources/StaticGroundGeometryColorBatchSpec.js b/Specs/DataSources/StaticGroundGeometryColorBatchSpec.js index 24c2293e02b8..b988502a18f9 100644 --- a/Specs/DataSources/StaticGroundGeometryColorBatchSpec.js +++ b/Specs/DataSources/StaticGroundGeometryColorBatchSpec.js @@ -242,4 +242,70 @@ defineSuite([ batch.removeAllPrimitives(); }); }); + + it('has correct show attribute after rebuilding primitive', function() { + if (!GroundPrimitive.isSupported(scene)) { + return; + } + + var batch = new StaticGroundGeometryColorBatch(scene.groundPrimitives, ClassificationType.BOTH); + function buildEntity() { + return new Entity({ + position : new Cartesian3(1234, 5678, 9101112), + ellipse : { + semiMajorAxis : 2, + semiMinorAxis : 1, + height : 0, + outline : true, + outlineColor : Color.RED.withAlpha(0.5) + } + }); + } + + function renderScene() { + scene.initializeFrame(); + var isUpdated = batch.update(time); + scene.render(time); + return isUpdated; + } + + var entity1 = buildEntity(); + var updater1 = new EllipseGeometryUpdater(entity1, scene); + batch.add(time, updater1); + + var entity2 = buildEntity(); + var updater2 = new EllipseGeometryUpdater(entity2, scene); + + return pollToPromise(renderScene) + .then(function() { + expect(scene.groundPrimitives.length).toEqual(1); + var primitive = scene.groundPrimitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([1]); + + entity1.show = false; + updater1._onEntityPropertyChanged(entity1, 'isShowing'); + return pollToPromise(renderScene); + }) + .then(function() { + expect(scene.groundPrimitives.length).toEqual(1); + var primitive = scene.groundPrimitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([0]); + + batch.add(time, updater2); + return pollToPromise(renderScene); + }) + .then(function() { + expect(scene.groundPrimitives.length).toEqual(1); + var primitive = scene.groundPrimitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([0]); + + attributes = primitive.getGeometryInstanceAttributes(entity2); + expect(attributes.show).toEqual([1]); + + batch.removeAllPrimitives(); + }); + }); }); diff --git a/Specs/DataSources/StaticGroundGeometryPerMaterialBatchSpec.js b/Specs/DataSources/StaticGroundGeometryPerMaterialBatchSpec.js index 6b2f59dbf40e..e90c7393f5b9 100644 --- a/Specs/DataSources/StaticGroundGeometryPerMaterialBatchSpec.js +++ b/Specs/DataSources/StaticGroundGeometryPerMaterialBatchSpec.js @@ -338,4 +338,81 @@ defineSuite([ batch.removeAllPrimitives(); }); }); + + it('has correct show attribute after rebuilding primitive', function() { + if (!GroundPrimitive.isSupported(scene)) { + return; + } + + if (!GroundPrimitive.isSupported(scene) || !GroundPrimitive.supportsMaterials(scene)) { + // Don't fail if materials on GroundPrimitive not supported + return; + } + + var batch = new StaticGroundGeometryPerMaterialBatch(scene.primitives, MaterialAppearance); + + function buildEntity(x, y, z) { + var material = new GridMaterialProperty({ + color : Color.YELLOW, + cellAlpha : 0.3, + lineCount : new Cartesian2(8, 8), + lineThickness : new Cartesian2(2.0, 2.0) + }); + + return new Entity({ + position : new Cartesian3(x, y, z), + ellipse : { + semiMajorAxis : 2, + semiMinorAxis : 1, + material: material + } + }); + } + + function renderScene() { + scene.initializeFrame(); + var isUpdated = batch.update(time); + scene.render(time); + return isUpdated; + } + + var entity1 = buildEntity(1234, 5678, 9101112); + var updater1 = new EllipseGeometryUpdater(entity1, scene); + batch.add(time, updater1); + + var entity2 = buildEntity(123, 456, 789); + var updater2 = new EllipseGeometryUpdater(entity2, scene); + + return pollToPromise(renderScene) + .then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([1]); + + entity1.show = false; + updater1._onEntityPropertyChanged(entity1, 'isShowing'); + return pollToPromise(renderScene); + }) + .then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([0]); + + batch.add(time, updater2); + return pollToPromise(renderScene); + }) + .then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([0]); + + attributes = primitive.getGeometryInstanceAttributes(entity2); + expect(attributes.show).toEqual([1]); + + batch.removeAllPrimitives(); + }); + }); }); diff --git a/Specs/DataSources/StaticGroundPolylinePerMaterialBatchSpec.js b/Specs/DataSources/StaticGroundPolylinePerMaterialBatchSpec.js index a8270facff08..2a2d15529dca 100644 --- a/Specs/DataSources/StaticGroundPolylinePerMaterialBatchSpec.js +++ b/Specs/DataSources/StaticGroundPolylinePerMaterialBatchSpec.js @@ -443,4 +443,71 @@ defineSuite([ batch.removeAllPrimitives(); }); }); + + it('has correct show attribute after rebuilding primitive', function() { + if (!GroundPolylinePrimitive.isSupported(scene)) { + // Don't fail if GroundPolylinePrimitive is not supported + return; + } + var batch = new StaticGroundPolylinePerMaterialBatch(scene.groundPrimitives); + + function buildEntity() { + var polyline = createGroundPolyline(); + polyline.material = new PolylineOutlineMaterialProperty({ + color : Color.ORANGE, + outlineWidth : 2, + outlineColor : Color.BLACK + }); + + return new Entity({ + polyline : polyline + }); + } + + function renderScene() { + scene.initializeFrame(); + var isUpdated = batch.update(time); + scene.render(time); + return isUpdated; + } + + var entity1 = buildEntity(); + var updater1 = new PolylineGeometryUpdater(entity1, scene); + batch.add(time, updater1); + + var entity2 = buildEntity(); + var updater2 = new PolylineGeometryUpdater(entity2, scene); + + return pollToPromise(renderScene) + .then(function() { + expect(scene.groundPrimitives.length).toEqual(1); + var primitive = scene.groundPrimitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([1]); + + entity1.show = false; + updater1._onEntityPropertyChanged(entity1, 'isShowing'); + return pollToPromise(renderScene); + }) + .then(function() { + expect(scene.groundPrimitives.length).toEqual(1); + var primitive = scene.groundPrimitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([0]); + + batch.add(time, updater2); + return pollToPromise(renderScene); + }) + .then(function() { + expect(scene.groundPrimitives.length).toEqual(1); + var primitive = scene.groundPrimitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([0]); + + attributes = primitive.getGeometryInstanceAttributes(entity2); + expect(attributes.show).toEqual([1]); + + batch.removeAllPrimitives(); + }); + }); }); diff --git a/Specs/DataSources/StaticOutlineGeometryBatchSpec.js b/Specs/DataSources/StaticOutlineGeometryBatchSpec.js index ba79994bc5bf..a5317e0e6896 100644 --- a/Specs/DataSources/StaticOutlineGeometryBatchSpec.js +++ b/Specs/DataSources/StaticOutlineGeometryBatchSpec.js @@ -248,4 +248,67 @@ defineSuite([ batch.removeAllPrimitives(); }); }); + + it('has correct show attribute after rebuilding primitive', function() { + var batch = new StaticOutlineGeometryBatch(scene.primitives, scene, false, ShadowMode.DISABLED); + + function buildEntity() { + return new Entity({ + position : new Cartesian3(1234, 5678, 9101112), + ellipse : { + semiMajorAxis : 2, + semiMinorAxis : 1, + height : 0, + outline : true, + outlineColor : Color.RED.withAlpha(0.5) + } + }); + } + + function renderScene() { + scene.initializeFrame(); + var isUpdated = batch.update(time); + scene.render(time); + return isUpdated; + } + + var entity1 = buildEntity(); + var updater1 = new EllipseGeometryUpdater(entity1, scene); + batch.add(time, updater1); + + var entity2 = buildEntity(); + var updater2 = new EllipseGeometryUpdater(entity2, scene); + + return pollToPromise(renderScene) + .then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([1]); + + entity1.show = false; + updater1._onEntityPropertyChanged(entity1, 'isShowing'); + return pollToPromise(renderScene); + }) + .then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([0]); + + batch.add(time, updater2); + return pollToPromise(renderScene); + }) + .then(function() { + expect(scene.primitives.length).toEqual(1); + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity1); + expect(attributes.show).toEqual([0]); + + attributes = primitive.getGeometryInstanceAttributes(entity2); + expect(attributes.show).toEqual([1]); + + batch.removeAllPrimitives(); + }); + }); });