Skip to content

Commit

Permalink
Don't apply style if pick/render pass are together
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Sep 3, 2018
1 parent ef946ca commit cb3f18e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions Source/Scene/Cesium3DTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ define([

// Refresh style for expired content
that._selectedFrame = 0;
that.lastStyleTime = 0;

that._contentState = Cesium3DTileContentState.READY;
that._contentReadyPromise.resolve(content);
Expand Down
3 changes: 1 addition & 2 deletions Source/Scene/Cesium3DTilesetTraversal.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,8 @@ define([
tileContent.featurePropertiesDirty = false;
tile.lastStyleTime = 0; // Force applying the style to this tile
tileset._selectedTilesToStyle.push(tile);
} else if ((tile._selectedFrame !== frameState.frameNumber - 1)) {
} else if ((tile._selectedFrame < frameState.frameNumber - 1)) {
// Tile is newly selected; it is selected this frame, but was not selected last frame.
tile.lastStyleTime = 0; // Force applying the style to this tile
tileset._selectedTilesToStyle.push(tile);
}
tile._selectedFrame = frameState.frameNumber;
Expand Down
32 changes: 32 additions & 0 deletions Specs/Scene/Cesium3DTilesetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,38 @@ defineSuite([
});
});

it('applies style when tile is selected after new style is applied', function() {
return Cesium3DTilesTester.loadTileset(scene, withBatchTableUrl).then(function(tileset) {
var tile = tileset.root;
tileset.style = new Cesium3DTileStyle({color: 'color("red")'});
scene.renderForSpecs();
expect(tile.content.getFeature(0).color).toEqual(Color.RED);

tileset.style = new Cesium3DTileStyle({color: 'color("blue")'});
scene.renderForSpecs();
expect(tile.content.getFeature(0).color).toEqual(Color.BLUE);

viewNothing();
tileset.style = new Cesium3DTileStyle({color: 'color("lime")'});
scene.renderForSpecs();
expect(tile.content.getFeature(0).color).toEqual(Color.BLUE); // Hasn't been selected yet

viewAllTiles();
scene.renderForSpecs();
expect(tile.content.getFeature(0).color).toEqual(Color.LIME);
});
});

it('does not reapply style during pick pass', function() {
return Cesium3DTilesTester.loadTileset(scene, withBatchTableUrl).then(function(tileset) {
tileset.style = new Cesium3DTileStyle({color: 'color("red")'});
scene.renderForSpecs();
expect(tileset.statistics.numberOfTilesStyled).toBe(1);
scene.pickForSpecs();
expect(tileset.statistics.numberOfTilesStyled).toBe(0);
});
});

it('applies style with complex color expression to a tileset', function() {
return Cesium3DTilesTester.loadTileset(scene, withBatchTableUrl).then(function(tileset) {
// Each feature in the b3dm file has an id property from 0 to 9
Expand Down

0 comments on commit cb3f18e

Please sign in to comment.