Skip to content

Commit

Permalink
Merge pull request #6890 from janeyx99/fix-6874
Browse files Browse the repository at this point in the history
Removes frameState parameter from evaluate and evaluateColor
  • Loading branch information
lilleyse authored Aug 14, 2018
2 parents d22e21c + f9c2886 commit 7e459c8
Show file tree
Hide file tree
Showing 29 changed files with 883 additions and 903 deletions.
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/3D Tiles Interactivity.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
}

// Evaluate feature description
console.log('Description : ' + tileset.style.meta.description.evaluate(scene.frameState, feature));
console.log('Description : ' + tileset.style.meta.description.evaluate(feature));
}

function zoom(movement, feature) {
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Change Log
##### Breaking Changes :mega:
* Removed `ClippingPlaneCollection.clone` [#6872](https://github.com/AnalyticalGraphicsInc/cesium/pull/6872)
* Changed `Globe.pick` to return a position in ECEF coordinates regardless of the current scene mode. This will only effect you if you were working around a bug to make `Globe.pick` work in 2D and Columbus View. Use `Globe.pickWorldCoordinates` to get the position in world coordinates that correlate to the current scene mode. [#6859](https://github.com/AnalyticalGraphicsInc/cesium/pull/6859)
* Removed the unused `frameState` parameter in `evaluate` and `evaluateColor` functions in `Expression`, `StyleExpression`, `ConditionsExpression` and all other places that call the functions. [#6890](https://github.com/AnalyticalGraphicsInc/cesium/pull/6890).

##### Additions :tada:
* Added `ClippingPlaneCollection.planeAdded` and `ClippingPlaneCollection.planeRemoved` events. `planeAdded` is raised when a new plane is added to the collection and `planeRemoved` is raised when a plane is removed. [#6875](https://github.com/AnalyticalGraphicsInc/cesium/pull/6875)
Expand Down
4 changes: 2 additions & 2 deletions Source/Scene/Batched3DModel3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ define([
}
};

Batched3DModel3DTileContent.prototype.applyStyle = function(frameState, style) {
this._batchTable.applyStyle(frameState, style);
Batched3DModel3DTileContent.prototype.applyStyle = function(style) {
this._batchTable.applyStyle(style);
};

Batched3DModel3DTileContent.prototype.update = function(tileset, frameState) {
Expand Down
6 changes: 3 additions & 3 deletions Source/Scene/Cesium3DTileBatchTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ define([

var scratchColor = new Color();

Cesium3DTileBatchTable.prototype.applyStyle = function(frameState, style) {
Cesium3DTileBatchTable.prototype.applyStyle = function(style) {
if (!defined(style)) {
this.setAllColor(DEFAULT_COLOR_VALUE);
this.setAllShow(true);
Expand All @@ -555,8 +555,8 @@ define([
var length = this.featuresLength;
for (var i = 0; i < length; ++i) {
var feature = content.getFeature(i);
var color = defined(style.color) ? style.color.evaluateColor(frameState, feature, scratchColor) : DEFAULT_COLOR_VALUE;
var show = defined(style.show) ? style.show.evaluate(frameState, feature) : DEFAULT_SHOW_VALUE;
var color = defined(style.color) ? style.color.evaluateColor(feature, scratchColor) : DEFAULT_COLOR_VALUE;
var show = defined(style.show) ? style.show.evaluate(feature) : DEFAULT_SHOW_VALUE;
this.setColor(i, color);
this.setShow(i, show);
}
Expand Down
3 changes: 1 addition & 2 deletions Source/Scene/Cesium3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,11 @@ define([
* not part of the public Cesium API.
* </p>
*
* @param {FrameSate} frameState The frame state.
* @param {Cesium3DTileStyle} style The style.
*
* @private
*/
Cesium3DTileContent.prototype.applyStyle = function(frameState, style) {
Cesium3DTileContent.prototype.applyStyle = function(style) {
DeveloperError.throwInstantiationError();
};

Expand Down
56 changes: 28 additions & 28 deletions Source/Scene/Cesium3DTileStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,13 @@ define([
* var style = new Cesium3DTileStyle({
* show : '(regExp("^Chest").test(${County})) && (${YearBuilt} >= 1970)'
* });
* style.show.evaluate(frameState, feature); // returns true or false depending on the feature's properties
* style.show.evaluate(feature); // returns true or false depending on the feature's properties
*
* @example
* var style = new Cesium.Cesium3DTileStyle();
* // Override show expression with a custom function
* style.show = {
* evaluate : function(frameState, feature) {
* evaluate : function(feature) {
* return true;
* }
* };
Expand Down Expand Up @@ -319,13 +319,13 @@ define([
* var style = new Cesium3DTileStyle({
* color : '(${Temperature} > 90) ? color("red") : color("white")'
* });
* style.color.evaluateColor(frameState, feature, result); // returns a Cesium.Color object
* style.color.evaluateColor(feature, result); // returns a Cesium.Color object
*
* @example
* var style = new Cesium.Cesium3DTileStyle();
* // Override color expression with a custom function
* style.color = {
* evaluateColor : function(frameState, feature, result) {
* evaluateColor : function(feature, result) {
* return Cesium.Color.clone(Cesium.Color.WHITE, result);
* }
* };
Expand Down Expand Up @@ -381,13 +381,13 @@ define([
* var style = new Cesium3DTileStyle({
* pointSize : '(${Temperature} > 90) ? 2.0 : 1.0'
* });
* style.pointSize.evaluate(frameState, feature); // returns a Number
* style.pointSize.evaluate(feature); // returns a Number
*
* @example
* var style = new Cesium.Cesium3DTileStyle();
* // Override pointSize expression with a custom function
* style.pointSize = {
* evaluate : function(frameState, feature) {
* evaluate : function(feature) {
* return 1.0;
* }
* };
Expand Down Expand Up @@ -690,13 +690,13 @@ define([
* var style = new Cesium3DTileStyle({
* font : '(${Temperature} > 90) ? "30px Helvetica" : "24px Helvetica"'
* });
* style.font.evaluate(frameState, feature); // returns a String
* style.font.evaluate(feature); // returns a String
*
* @example
* var style = new Cesium.Cesium3DTileStyle();
* // Override font expression with a custom function
* style.font = {
* evaluate : function(frameState, feature) {
* evaluate : function(feature) {
* return '24px Helvetica';
* }
* };
Expand Down Expand Up @@ -738,13 +738,13 @@ define([
* var style = new Cesium3DTileStyle({
* labelStyle : '(${Temperature} > 90) ? ' + LabelStyle.FILL_AND_OUTLINE + ' : ' + LabelStyle.FILL
* });
* style.labelStyle.evaluate(frameState, feature); // returns a LabelStyle
* style.labelStyle.evaluate(feature); // returns a LabelStyle
*
* @example
* var style = new Cesium.Cesium3DTileStyle();
* // Override labelStyle expression with a custom function
* style.labelStyle = {
* evaluate : function(frameState, feature) {
* evaluate : function(feature) {
* return LabelStyle.FILL;
* }
* };
Expand Down Expand Up @@ -786,13 +786,13 @@ define([
* var style = new Cesium3DTileStyle({
* labelText : '(${Temperature} > 90) ? ">90" : "<=90"'
* });
* style.labelText.evaluate(frameState, feature); // returns a String
* style.labelText.evaluate(feature); // returns a String
*
* @example
* var style = new Cesium.Cesium3DTileStyle();
* // Override labelText expression with a custom function
* style.labelText = {
* evaluate : function(frameState, feature) {
* evaluate : function(feature) {
* return 'Example label text';
* }
* };
Expand Down Expand Up @@ -882,7 +882,7 @@ define([
* var style = new Cesium.Cesium3DTileStyle();
* // Override backgroundPadding expression with a string
* style.backgroundPadding = 'vec2(5.0, 7.0)';
* style.backgroundPadding.evaluate(frameState, feature); // returns a Cartesian2
* style.backgroundPadding.evaluate(feature); // returns a Cartesian2
*/
backgroundPadding : {
get : function() {
Expand Down Expand Up @@ -969,7 +969,7 @@ define([
* var style = new Cesium.Cesium3DTileStyle();
* // Override scaleByDistance expression with a string
* style.scaleByDistance = 'vec4(1.5e2, 2.0, 1.5e7, 0.5)';
* style.scaleByDistance.evaluate(frameState, feature); // returns a Cartesian4
* style.scaleByDistance.evaluate(feature); // returns a Cartesian4
*/
scaleByDistance : {
get : function() {
Expand Down Expand Up @@ -1008,7 +1008,7 @@ define([
* var style = new Cesium.Cesium3DTileStyle();
* // Override translucencyByDistance expression with a string
* style.translucencyByDistance = 'vec4(1.5e2, 1.0, 1.5e7, 0.2)';
* style.translucencyByDistance.evaluate(frameState, feature); // returns a Cartesian4
* style.translucencyByDistance.evaluate(feature); // returns a Cartesian4
*/
translucencyByDistance : {
get : function() {
Expand Down Expand Up @@ -1047,7 +1047,7 @@ define([
* var style = new Cesium.Cesium3DTileStyle();
* // Override distanceDisplayCondition expression with a string
* style.distanceDisplayCondition = 'vec2(0.0, 5.5e6)';
* style.distanceDisplayCondition.evaluate(frameState, feature); // returns a Cartesian2
* style.distanceDisplayCondition.evaluate(feature); // returns a Cartesian2
*/
distanceDisplayCondition : {
get : function() {
Expand Down Expand Up @@ -1230,13 +1230,13 @@ define([
* var style = new Cesium3DTileStyle({
* image : '(${Temperature} > 90) ? "/url/to/image1" : "/url/to/image2"'
* });
* style.image.evaluate(frameState, feature); // returns a String
* style.image.evaluate(feature); // returns a String
*
* @example
* var style = new Cesium.Cesium3DTileStyle();
* // Override image expression with a custom function
* style.image = {
* evaluate : function(frameState, feature) {
* evaluate : function(feature) {
* return '/url/to/image';
* }
* };
Expand Down Expand Up @@ -1278,7 +1278,7 @@ define([
* var style = new Cesium.Cesium3DTileStyle();
* // Override disableDepthTestDistance expression with a string
* style.disableDepthTestDistance = '1000.0';
* style.disableDepthTestDistance.evaluate(frameState, feature); // returns a Number
* style.disableDepthTestDistance.evaluate(feature); // returns a Number
*/
disableDepthTestDistance : {
get : function() {
Expand Down Expand Up @@ -1317,13 +1317,13 @@ define([
* var style = new Cesium3DTileStyle({
* horizontalOrigin : HorizontalOrigin.LEFT
* });
* style.horizontalOrigin.evaluate(frameState, feature); // returns a HorizontalOrigin
* style.horizontalOrigin.evaluate(feature); // returns a HorizontalOrigin
*
* @example
* var style = new Cesium.Cesium3DTileStyle();
* // Override horizontalOrigin expression with a custom function
* style.horizontalOrigin = {
* evaluate : function(frameState, feature) {
* evaluate : function(feature) {
* return HorizontalOrigin.CENTER;
* }
* };
Expand Down Expand Up @@ -1365,13 +1365,13 @@ define([
* var style = new Cesium3DTileStyle({
* verticalOrigin : VerticalOrigin.TOP
* });
* style.verticalOrigin.evaluate(frameState, feature); // returns a VerticalOrigin
* style.verticalOrigin.evaluate(feature); // returns a VerticalOrigin
*
* @example
* var style = new Cesium.Cesium3DTileStyle();
* // Override verticalOrigin expression with a custom function
* style.verticalOrigin = {
* evaluate : function(frameState, feature) {
* evaluate : function(feature) {
* return VerticalOrigin.CENTER;
* }
* };
Expand Down Expand Up @@ -1413,13 +1413,13 @@ define([
* var style = new Cesium3DTileStyle({
* labelHorizontalOrigin : HorizontalOrigin.LEFT
* });
* style.labelHorizontalOrigin.evaluate(frameState, feature); // returns a HorizontalOrigin
* style.labelHorizontalOrigin.evaluate(feature); // returns a HorizontalOrigin
*
* @example
* var style = new Cesium.Cesium3DTileStyle();
* // Override labelHorizontalOrigin expression with a custom function
* style.labelHorizontalOrigin = {
* evaluate : function(frameState, feature) {
* evaluate : function(feature) {
* return HorizontalOrigin.CENTER;
* }
* };
Expand Down Expand Up @@ -1461,13 +1461,13 @@ define([
* var style = new Cesium3DTileStyle({
* labelVerticalOrigin : VerticalOrigin.TOP
* });
* style.labelVerticalOrigin.evaluate(frameState, feature); // returns a VerticalOrigin
* style.labelVerticalOrigin.evaluate(feature); // returns a VerticalOrigin
*
* @example
* var style = new Cesium.Cesium3DTileStyle();
* // Override labelVerticalOrigin expression with a custom function
* style.labelVerticalOrigin = {
* evaluate : function(frameState, feature) {
* evaluate : function(feature) {
* return VerticalOrigin.CENTER;
* }
* };
Expand Down Expand Up @@ -1503,7 +1503,7 @@ define([
* description : '"Building id ${id} has height ${Height}."'
* }
* });
* style.meta.description.evaluate(frameState, feature); // returns a String with the substituted variables
* style.meta.description.evaluate(feature); // returns a String with the substituted variables
*/
meta : {
get : function() {
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/Cesium3DTileStyleEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ define([
// 2) this tile is now visible, but it wasn't visible when the style was first assigned
var content = tile.content;
tile.lastStyleTime = lastStyleTime;
content.applyStyle(frameState, this._style);
content.applyStyle(this._style);
statistics.numberOfFeaturesStyled += content.featuresLength;
++statistics.numberOfTilesStyled;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Scene/Composite3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,11 @@ define([
}
};

Composite3DTileContent.prototype.applyStyle = function(frameState, style) {
Composite3DTileContent.prototype.applyStyle = function(style) {
var contents = this._contents;
var length = contents.length;
for (var i = 0; i < length; ++i) {
contents[i].applyStyle(frameState, style);
contents[i].applyStyle(style);
}
};

Expand Down
16 changes: 7 additions & 9 deletions Source/Scene/ConditionsExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ define([
* ['true', 'color("#FFFFFF")']
* ]
* });
* expression.evaluateColor(frameState, feature, result); // returns a Cesium.Color object
* expression.evaluateColor(feature, result); // returns a Cesium.Color object
*/
function ConditionsExpression(conditionsExpression, defines) {
this._conditionsExpression = clone(conditionsExpression, true);
Expand Down Expand Up @@ -96,21 +96,20 @@ define([
* a {@link Cartesian2}, {@link Cartesian3}, or {@link Cartesian4} object will be returned. If the <code>result</code> argument is
* a {@link Color}, the {@link Cartesian4} value is converted to a {@link Color} and then returned.
*
* @param {FrameState} frameState The frame state.
* @param {Cesium3DTileFeature} feature The feature whose properties may be used as variables in the expression.
* @param {Object} [result] The object onto which to store the result.
* @returns {Boolean|Number|String|RegExp|Cartesian2|Cartesian3|Cartesian4|Color} The result of evaluating the expression.
*/
ConditionsExpression.prototype.evaluate = function(frameState, feature, result) {
ConditionsExpression.prototype.evaluate = function(feature, result) {
var conditions = this._runtimeConditions;
if (!defined(conditions)) {
return undefined;
}
var length = conditions.length;
for (var i = 0; i < length; ++i) {
var statement = conditions[i];
if (statement.condition.evaluate(frameState, feature)) {
return statement.expression.evaluate(frameState, feature, result);
if (statement.condition.evaluate(feature)) {
return statement.expression.evaluate(feature, result);
}
}
};
Expand All @@ -120,21 +119,20 @@ define([
* <p>
* This is equivalent to {@link ConditionsExpression#evaluate} but always returns a {@link Color} object.
* </p>
* @param {FrameState} frameState The frame state.
* @param {Cesium3DTileFeature} feature The feature whose properties may be used as variables in the expression.
* @param {Color} [result] The object in which to store the result
* @returns {Color} The modified result parameter or a new Color instance if one was not provided.
*/
ConditionsExpression.prototype.evaluateColor = function(frameState, feature, result) {
ConditionsExpression.prototype.evaluateColor = function(feature, result) {
var conditions = this._runtimeConditions;
if (!defined(conditions)) {
return undefined;
}
var length = conditions.length;
for (var i = 0; i < length; ++i) {
var statement = conditions[i];
if (statement.condition.evaluate(frameState, feature)) {
return statement.expression.evaluateColor(frameState, feature, result);
if (statement.condition.evaluate(feature)) {
return statement.expression.evaluateColor(feature, result);
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/Empty3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ define([
Empty3DTileContent.prototype.applyDebugSettings = function(enabled, color) {
};

Empty3DTileContent.prototype.applyStyle = function(frameState, style) {
Empty3DTileContent.prototype.applyStyle = function(style) {
};

Empty3DTileContent.prototype.update = function(tileset, frameState) {
Expand Down
Loading

0 comments on commit 7e459c8

Please sign in to comment.