From 6f1331bcf1e764d0e7981af32702b4901b929e92 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 3 Sep 2018 11:29:33 -0400 Subject: [PATCH] Don't apply style if pick/render pass are together --- Source/Scene/Cesium3DTile.js | 1 + Source/Scene/Cesium3DTilesetTraversal.js | 3 +- Specs/Scene/Cesium3DTilesetSpec.js | 42 ++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/Source/Scene/Cesium3DTile.js b/Source/Scene/Cesium3DTile.js index eac37ba51e41..2e24ba16c617 100644 --- a/Source/Scene/Cesium3DTile.js +++ b/Source/Scene/Cesium3DTile.js @@ -739,6 +739,7 @@ define([ // Refresh style for expired content that._selectedFrame = 0; + that.lastStyleTime = 0; that._contentState = Cesium3DTileContentState.READY; that._contentReadyPromise.resolve(content); diff --git a/Source/Scene/Cesium3DTilesetTraversal.js b/Source/Scene/Cesium3DTilesetTraversal.js index b3b6e72394ba..ef5eaff01521 100644 --- a/Source/Scene/Cesium3DTilesetTraversal.js +++ b/Source/Scene/Cesium3DTilesetTraversal.js @@ -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; diff --git a/Specs/Scene/Cesium3DTilesetSpec.js b/Specs/Scene/Cesium3DTilesetSpec.js index 1e101a2b158f..4fde0ab601c6 100644 --- a/Specs/Scene/Cesium3DTilesetSpec.js +++ b/Specs/Scene/Cesium3DTilesetSpec.js @@ -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