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 6f1331b
Show file tree
Hide file tree
Showing 3 changed files with 44 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
42 changes: 42 additions & 0 deletions Specs/Scene/Cesium3DTilesetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,48 @@ defineSuite([
});
});

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

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

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

viewAllTiles();
scene.renderForSpecs();
expect(feature.color).toEqual(Color.LIME);

// Feature's show property is preserved if the style hasn't changed and the feature is newly selected
feature.show = false;
scene.renderForSpecs();
expect(feature.show).toBe(false);
viewNothing();
scene.renderForSpecs();
expect(feature.show).toBe(false);
viewAllTiles();
expect(feature.show).toBe(false);
});
});

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 6f1331b

Please sign in to comment.