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 tileset style recompilation edge cases #9223

Merged
merged 2 commits into from
Nov 3, 2020
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
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

### 1.76 - 2020-12-01

##### Fixes :wrench:

- Fixed an issue where tileset styles would be reapplied every frame when a tileset has a style and `tileset.preloadWhenHidden` is true and `tileset.show` is false. Also fixed a related issue where styles would be reapplied if the style being set is the same as the active style. [#9223](https://github.com/CesiumGS/cesium/pull/9223)

### 1.75 - 2020-11-02

##### Fixes :wrench:
Expand Down
14 changes: 8 additions & 6 deletions Source/Scene/Cesium3DTileStyleEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Object.defineProperties(Cesium3DTileStyleEngine.prototype, {
return this._style;
},
set: function (value) {
if (value === this._style) {
return;
}
this._style = value;
this._styleDirty = true;
},
Expand All @@ -25,7 +28,11 @@ Cesium3DTileStyleEngine.prototype.makeDirty = function () {
this._styleDirty = true;
};

Cesium3DTileStyleEngine.prototype.applyStyle = function (tileset, passOptions) {
Cesium3DTileStyleEngine.prototype.resetDirty = function () {
this._styleDirty = false;
};

Cesium3DTileStyleEngine.prototype.applyStyle = function (tileset) {
if (!tileset.ready) {
return;
}
Expand All @@ -36,11 +43,6 @@ Cesium3DTileStyleEngine.prototype.applyStyle = function (tileset, passOptions) {

var styleDirty = this._styleDirty;

if (passOptions.isRender) {
// Don't reset until the render pass
this._styleDirty = false;
}

if (styleDirty) {
// Increase "time", so the style is applied to all visible tiles
++this._lastStyleTime;
Expand Down
3 changes: 2 additions & 1 deletion Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -1892,6 +1892,7 @@ Cesium3DTileset.prototype.postPassesUpdate = function (frameState) {
cancelOutOfViewRequests(this, frameState);
raiseLoadProgressEvent(this, frameState);
this._cache.unloadTiles(this, unloadTile);
this._styleEngine.resetDirty();
};

/**
Expand Down Expand Up @@ -2173,7 +2174,7 @@ function updateTileDebugLabels(tileset, frameState) {
}

function updateTiles(tileset, frameState, passOptions) {
tileset._styleEngine.applyStyle(tileset, passOptions);
tileset._styleEngine.applyStyle(tileset);

var isRender = passOptions.isRender;
var statistics = tileset._statistics;
Expand Down
34 changes: 34 additions & 0 deletions Specs/Scene/Cesium3DTilesetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2866,6 +2866,40 @@ describe(
);
});

it("doesn't re-evaluate style during the next update", function () {
return Cesium3DTilesTester.loadTileset(scene, withBatchTableUrl).then(
function (tileset) {
tileset.show = false;
tileset.preloadWhenHidden = true;
tileset.style = new Cesium3DTileStyle({ color: 'color("red")' });
scene.renderForSpecs();

var statistics = tileset._statisticsPerPass[Cesium3DTilePass.PRELOAD];
expect(statistics.numberOfTilesStyled).toBe(1);

scene.renderForSpecs();
expect(statistics.numberOfTilesStyled).toBe(0);
}
);
});

it("doesn't re-evaluate style if the style being set is the same as the active style", function () {
return Cesium3DTilesTester.loadTileset(scene, withBatchTableUrl).then(
function (tileset) {
var style = new Cesium3DTileStyle({ color: 'color("red")' });
tileset.style = style;
scene.renderForSpecs();

var statistics = tileset._statisticsPerPass[Cesium3DTilePass.RENDER];
expect(statistics.numberOfTilesStyled).toBe(1);

tileset.style = style;
scene.renderForSpecs();
expect(statistics.numberOfTilesStyled).toBe(0);
}
);
});

function testColorBlendMode(url) {
return Cesium3DTilesTester.loadTileset(scene, url).then(function (
tileset
Expand Down