Skip to content

Commit

Permalink
Change conditions from an object to an array
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Sep 27, 2016
1 parent cc1c4e6 commit 5cb1088
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
24 changes: 12 additions & 12 deletions Apps/Sandcastle/gallery/3D Tiles.html
Expand Up @@ -87,15 +87,15 @@
// "color" : "rgb(100, 255, 190)",
// "color" : "hsla(0.9, 0.6, 0.7, 0.75)",
"color" : {
"conditions" : {
"${Height} >= 83" : "color('purple', 0.5)",
"${Height} >= 80" : "color('red')",
"${Height} >= 70" : "color('orange')",
"${Height} >= 12" : "color('yellow')",
"${Height} >= 7" : "color('lime')",
"${Height} >= 1" : "color('cyan')",
"true" : "color('blue')"
}
"conditions" : [
["${Height} >= 83", "color('purple', 0.5)"],
["${Height} >= 80", "color('red')"],
["${Height} >= 70", "color('orange')"],
["${Height} >= 12", "color('yellow')"],
["${Height} >= 7", "color('lime')"],
["${Height} >= 1", "color('cyan')"],
["true", "color('blue')"]
]
},
// "show": false,
// "show" : "${Height} >= 0",
Expand Down Expand Up @@ -410,13 +410,13 @@
}

function styleFunction(name) {
var conditions = {};
var conditions = [];
var intervalSize = Math.floor(100/numberofColors);
for (var i = numberofColors; i >= 0; --i) {
var cond = '${' + name + '} > ' + (i * intervalSize);
conditions[cond] = getRandomColor();
conditions.push([cond, getRandomColor()]);
}
conditions['true'] = getRandomColor();
conditions.push(['true', getRandomColor()]);

tileset.style = new Cesium.Cesium3DTileStyle({
color : {
Expand Down
30 changes: 15 additions & 15 deletions Source/Scene/ConditionsExpression.js
Expand Up @@ -79,22 +79,22 @@ define([
var runtimeConditions = [];
var conditions = expression._conditions;
var exp = expression._expression;
for (var cond in conditions) {
if (conditions.hasOwnProperty(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(condExpression)
));
var length = conditions.length;
for (var i = 0; i < length; ++i) {
var statement = conditions[i];
var cond = String(statement[0]);
var condExpression = String(statement[1]);
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(condExpression)
));
}

expression._runtimeConditions = runtimeConditions;
Expand Down

0 comments on commit 5cb1088

Please sign in to comment.