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

3D Tiles style fixes #6998

Merged
merged 1 commit into from
Sep 4, 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 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)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This caused the second bug. It wasn't accounting for the fact that the pick and render pass are the same frame number.

// 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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was originally added so that expired tiles would get restyled but was responsible for the first bug. Now lastStyleTime is reset above in the // Refresh style for expired content area.

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