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

Fixes #3945: Flickering when adding a new polygon entity #6413

Merged
merged 5 commits into from
Apr 13, 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
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Change Log
* Fixed glTF support to handle meshes with and without tangent vectors, and with/without morph targets, sharing one material. [#6421](https://github.com/AnalyticalGraphicsInc/cesium/pull/6421)
* Fixed glTF support to handle skinned meshes when no skin is supplied. [#6061](https://github.com/AnalyticalGraphicsInc/cesium/issues/6061)
* Allow loadWithXhr to work with string URLs in a web worker.
* `GroundPrimitive`s and `ClassificationPrimitive`s will become ready when `show` is `false`. [#6428](https://github.com/AnalyticalGraphicsInc/cesium/pull/6428)
* `GroundPrimitive`s and `ClassificationPrimitive`s will become ready when `show` is `false`. [#6428](https://github.com/AnalyticalGraphicsInc/cesium/pull/6428)
* Fix Firefox WebGL console warnings. [#5912](https://github.com/AnalyticalGraphicsInc/cesium/issues/5912)
* Fix parsing Cesium.js in older browsers that do not support all TypedArray types. [#6396](https://github.com/AnalyticalGraphicsInc/cesium/pull/6396)

* Fix flicker when adding, removing, or modifiying entities. [#3945](https://github.com/AnalyticalGraphicsInc/cesium/issues/3945)
##### Additions :tada:
* Improved `MapboxImageryProvider` performance by 300% via `tiles.mapbox.com` subdomain switching. [#6426](https://github.com/AnalyticalGraphicsInc/cesium/issues/6426)

Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
* [Natanael Rivera](https://github.com/nrivera-Novetta/)
* [Justin Burr](https://github.com/jburr-nc/)
* [Jeremy Marzano](https://github.com/JeremyMarzano-ISPA/)
* [Orbit Logic](http://www.orbitlogic.com)
* [Roderick Green](https://github.com/roderickgreen/)

## [Individual CLA](Documentation/Contributors/CLAs/individual-cla-agi-v1.0.txt)
* [Victor Berchet](https://github.com/vicb)
Expand Down
2 changes: 2 additions & 0 deletions Source/DataSources/StaticGeometryColorBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ define([
}

primitive = new Primitive({
show : false,
asynchronous : true,
geometryInstances : geometries,
appearance : new this.appearanceType({
Expand Down Expand Up @@ -184,6 +185,7 @@ define([
this.createPrimitive = false;
this.waitingOnCreate = true;
} else if (defined(primitive) && primitive.ready) {
primitive.show = true;
if (defined(this.oldPrimitive)) {
primitives.remove(this.oldPrimitive);
this.oldPrimitive = undefined;
Expand Down
2 changes: 2 additions & 0 deletions Source/DataSources/StaticGeometryPerMaterialBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ define([
}

primitive = new Primitive({
show : false,
asynchronous : true,
geometryInstances : geometries,
appearance : new this.appearanceType({
Expand Down Expand Up @@ -182,6 +183,7 @@ define([
this.primitive = primitive;
this.createPrimitive = false;
} else if (defined(primitive) && primitive.ready) {
primitive.show = true;
if (defined(this.oldPrimitive)) {
primitives.remove(this.oldPrimitive);
this.oldPrimitive = undefined;
Expand Down
2 changes: 2 additions & 0 deletions Source/DataSources/StaticGroundGeometryColorBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ define([
}

primitive = new GroundPrimitive({
show : false,
asynchronous : true,
geometryInstances : geometries,
classificationType : this.classificationType
Expand All @@ -134,6 +135,7 @@ define([
this.createPrimitive = false;
this.waitingOnCreate = true;
} else if (defined(primitive) && primitive.ready) {
primitive.show = true;
if (defined(this.oldPrimitive)) {
primitives.remove(this.oldPrimitive);
this.oldPrimitive = undefined;
Expand Down
2 changes: 2 additions & 0 deletions Source/DataSources/StaticOutlineGeometryBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ define([
}

primitive = new Primitive({
show : false,
asynchronous : true,
geometryInstances : geometries,
appearance : new PerInstanceColorAppearance({
Expand Down Expand Up @@ -142,6 +143,7 @@ define([
this.createPrimitive = false;
this.waitingOnCreate = true;
} else if (defined(primitive) && primitive.ready) {
primitive.show = true;
if (defined(this.oldPrimitive)) {
primitives.remove(this.oldPrimitive);
this.oldPrimitive = undefined;
Expand Down
62 changes: 62 additions & 0 deletions Specs/DataSources/StaticGeometryColorBatchSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,66 @@ defineSuite([
batch.removeAllPrimitives();
});
});

it('shows only one primitive while 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 entity2 = buildEntity();

var updater1 = new EllipseGeometryUpdater(entity1, scene);
var updater2 = new EllipseGeometryUpdater(entity2, scene);

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() {
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();
});
});
});
72 changes: 72 additions & 0 deletions Specs/DataSources/StaticGeometryPerMaterialBatchSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defineSuite([
'DataSources/StaticGeometryPerMaterialBatch',
'Core/Cartesian2',
'Core/Cartesian3',
'Core/Color',
'Core/DistanceDisplayCondition',
Expand All @@ -26,6 +27,7 @@ defineSuite([
'Specs/pollToPromise'
], function(
StaticGeometryPerMaterialBatch,
Cartesian2,
Cartesian3,
Color,
DistanceDisplayCondition,
Expand Down Expand Up @@ -240,4 +242,74 @@ defineSuite([
batch.removeAllPrimitives();
});
});

it('shows only one primitive while 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 entity2 = buildEntity();

var updater1 = new EllipseGeometryUpdater(entity1, scene);
var updater2 = new EllipseGeometryUpdater(entity2, scene);

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() {
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();
});
});
});
67 changes: 67 additions & 0 deletions Specs/DataSources/StaticGroundGeometryColorBatchSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,71 @@ defineSuite([
batch.removeAllPrimitives();
});
});

it('shows only one primitive while 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 entity2 = buildEntity();

var updater1 = new EllipseGeometryUpdater(entity1, scene);
var updater2 = new EllipseGeometryUpdater(entity2, scene);

batch.add(time, updater1);
return pollToPromise(renderScene)
.then(function() {
expect(scene.groundPrimitives.length).toEqual(1);
var primitive = scene.groundPrimitives.get(0);
expect(primitive.show).toBeTruthy();
})
.then(function() {
batch.add(time, updater2);
})
.then(function() {
return pollToPromise(function() {
renderScene();
return scene.groundPrimitives.length === 2;
});
})
.then(function() {
var showCount = 0;
expect(scene.groundPrimitives.length).toEqual(2);
showCount += !!scene.groundPrimitives.get(0).show;
showCount += !!scene.groundPrimitives.get(1).show;
expect(showCount).toEqual(1);
})
.then(function() {
return pollToPromise(renderScene);
})
.then(function() {
expect(scene.groundPrimitives.length).toEqual(1);
var primitive = scene.groundPrimitives.get(0);
expect(primitive.show).toBeTruthy();

batch.removeAllPrimitives();
});
});
});
64 changes: 64 additions & 0 deletions Specs/DataSources/StaticOutlineGeometryBatchSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,68 @@ defineSuite([
batch.removeAllPrimitives();
});
});

it('shows only one primitive while 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 entity2 = buildEntity();

var updater1 = new EllipseGeometryUpdater(entity1, scene);
var updater2 = new EllipseGeometryUpdater(entity2, scene);

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() {
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();
});
});
});