From 8e98836ae8166550284f121d2e2b4e94bb10c2f9 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 20 Sep 2016 12:13:58 -0400 Subject: [PATCH] Organization --- Source/Scene/Batched3DModel3DTileContent.js | 7 +++++++ Source/Scene/Cesium3DTileContent.js | 19 +++++++++++++++++++ Source/Scene/Cesium3DTileStyle.js | 2 ++ Source/Scene/Cesium3DTileStyleEngine.js | 5 ++--- Source/Scene/ConditionsExpression.js | 7 +++++-- Source/Scene/Empty3DTileContent.js | 7 +++++++ Source/Scene/Instanced3DModel3DTileContent.js | 7 +++++++ Source/Scene/PointCloud3DTileContent.js | 15 +++++++-------- Source/Scene/Tileset3DTileContent.js | 7 +++++++ 9 files changed, 63 insertions(+), 13 deletions(-) diff --git a/Source/Scene/Batched3DModel3DTileContent.js b/Source/Scene/Batched3DModel3DTileContent.js index 881326e54a6c..858693c35f4f 100644 --- a/Source/Scene/Batched3DModel3DTileContent.js +++ b/Source/Scene/Batched3DModel3DTileContent.js @@ -289,6 +289,13 @@ define([ this.batchTable.setAllColor(color); }; + /** + * Part of the {@link Cesium3DTileContent} interface. + */ + Batched3DModel3DTileContent.prototype.applyStyleWithShader = function(frameState, style) { + return false; + }; + /** * Part of the {@link Cesium3DTileContent} interface. */ diff --git a/Source/Scene/Cesium3DTileContent.js b/Source/Scene/Cesium3DTileContent.js index 2efcd57ccc49..1f8e82413628 100644 --- a/Source/Scene/Cesium3DTileContent.js +++ b/Source/Scene/Cesium3DTileContent.js @@ -198,6 +198,25 @@ define([ DeveloperError.throwInstantiationError(); }; + /** + * Apply a style to the content using a shader instead of a batch table. Currently this is only + * applicable for {@link PointCloud3DTileContent}. + *

+ * This is used to implement the Cesium3DTileContent interface, but is + * not part of the public Cesium API. + *

+ * + * @param {FrameSate} frameState The frame state. + * @param {Cesium3DTileStyle} style The style. + * + * @returns {Boolean} true if this content is styled with a shader; otherwise, false. + * + * @private + */ + Cesium3DTileContent.prototype.applyStyleWithShader = function(frameState, style) { + DeveloperError.throwInstantiationError(); + }; + /** * Called by the tile during tileset traversal to get the draw commands needed to render this content. * When the tile's content is in the PROCESSING state, this creates WebGL resources to ultimately diff --git a/Source/Scene/Cesium3DTileStyle.js b/Source/Scene/Cesium3DTileStyle.js index e70c3bc7aeca..09aaf90b6efc 100644 --- a/Source/Scene/Cesium3DTileStyle.js +++ b/Source/Scene/Cesium3DTileStyle.js @@ -113,6 +113,8 @@ define([ show = new Expression(String(showExpression)); } else if (typeof(showExpression) === 'string') { show = new Expression(showExpression); + } else if (defined(showExpression.conditions)) { + show = new ConditionsExpression(showExpression); } that._show = show; diff --git a/Source/Scene/Cesium3DTileStyleEngine.js b/Source/Scene/Cesium3DTileStyleEngine.js index a8606fd02274..88b23a01a8d1 100644 --- a/Source/Scene/Cesium3DTileStyleEngine.js +++ b/Source/Scene/Cesium3DTileStyleEngine.js @@ -106,9 +106,8 @@ define([ stats.numberOfFeaturesStyled += length; - // Apply style to point cloud. Only apply style if the point cloud is not backed by a batch table. - if ((content instanceof PointCloud3DTileContent) && (length === 0)) { - content.applyStyle(frameState, style); + if (content.applyStyleWithShader(frameState, style)) { + return; } if (!defined(style)) { diff --git a/Source/Scene/ConditionsExpression.js b/Source/Scene/ConditionsExpression.js index 5d23e1909d5b..b60ebaa78384 100644 --- a/Source/Scene/ConditionsExpression.js +++ b/Source/Scene/ConditionsExpression.js @@ -81,15 +81,18 @@ define([ var exp = expression._expression; for (var cond in conditions) { if (conditions.hasOwnProperty(cond)) { - var colorExpression = conditions[cond]; + cond = String(cond); + var condExpression = String(conditions[cond]); if (defined(exp)) { cond = cond.replace(expressionPlaceholder, exp); + condExpression = condExpression.replace(expressionPlaceholder, exp); } else { cond = cond.replace(expressionPlaceholder, 'undefined'); + condExpression = condExpression.replace(expressionPlaceholder, 'undefined'); } runtimeConditions.push(new Statement( new Expression(cond), - new Expression(colorExpression) + new Expression(condExpression) )); } } diff --git a/Source/Scene/Empty3DTileContent.js b/Source/Scene/Empty3DTileContent.js index 29b91f1bc346..421b524db86f 100644 --- a/Source/Scene/Empty3DTileContent.js +++ b/Source/Scene/Empty3DTileContent.js @@ -113,6 +113,13 @@ define([ Empty3DTileContent.prototype.applyDebugSettings = function(enabled, color) { }; + /** + * Part of the {@link Cesium3DTileContent} interface. + */ + Empty3DTileContent.prototype.applyStyleWithShader = function(frameState, style) { + return false; + }; + /** * Part of the {@link Cesium3DTileContent} interface. */ diff --git a/Source/Scene/Instanced3DModel3DTileContent.js b/Source/Scene/Instanced3DModel3DTileContent.js index 6df988d56792..9f9a3c583637 100644 --- a/Source/Scene/Instanced3DModel3DTileContent.js +++ b/Source/Scene/Instanced3DModel3DTileContent.js @@ -463,6 +463,13 @@ define([ this.batchTable.setAllColor(color); }; + /** + * Part of the {@link Cesium3DTileContent} interface. + */ + Instanced3DModel3DTileContent.prototype.applyStyleWithShader = function(frameState, style) { + return false; + }; + /** * Part of the {@link Cesium3DTileContent} interface. */ diff --git a/Source/Scene/PointCloud3DTileContent.js b/Source/Scene/PointCloud3DTileContent.js index ea5786feef38..8beb3e10a12c 100644 --- a/Source/Scene/PointCloud3DTileContent.js +++ b/Source/Scene/PointCloud3DTileContent.js @@ -1026,15 +1026,14 @@ define([ }; /** - * Apply a style to the point cloud. - * - * @param {FrameSate} frameState The frame state. - * @param {Cesium3DTileStyle} style The style. - * - * @private + * Part of the {@link Cesium3DTileContent} interface. */ - PointCloud3DTileContent.prototype.applyStyle = function(frameState, style) { - createShaders(this, frameState, style); + PointCloud3DTileContent.prototype.applyStyleWithShader = function(frameState, style) { + if (!defined(this.batchTable)) { + createShaders(this, frameState, style); + return true; + } + return false; }; /** diff --git a/Source/Scene/Tileset3DTileContent.js b/Source/Scene/Tileset3DTileContent.js index b303b8134ba7..9fd0d5c09296 100644 --- a/Source/Scene/Tileset3DTileContent.js +++ b/Source/Scene/Tileset3DTileContent.js @@ -124,6 +124,13 @@ define([ Tileset3DTileContent.prototype.applyDebugSettings = function(enabled, color) { }; + /** + * Part of the {@link Cesium3DTileContent} interface. + */ + Tileset3DTileContent.prototype.applyStyleWithShader = function(frameState, style) { + return false; + }; + /** * Part of the {@link Cesium3DTileContent} interface. */