Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix entity visibility for non-dynamic show #7156

Merged
merged 6 commits into from
Oct 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions Source/DataSources/StaticGeometryColorBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions Source/DataSources/StaticGeometryPerMaterialBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions Source/DataSources/StaticGroundGeometryColorBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions Source/DataSources/StaticGroundGeometryPerMaterialBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions Source/DataSources/StaticGroundPolylinePerMaterialBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions Source/DataSources/StaticOutlineGeometryBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
232 changes: 147 additions & 85 deletions Specs/DataSources/StaticGeometryColorBatchSpec.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down Expand Up @@ -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)
}
});

Expand Down Expand Up @@ -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
}
});

Expand Down Expand Up @@ -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)
}
});

Expand Down Expand Up @@ -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();
});
});
});
Loading