-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Set color conditional #3655
Set color conditional #3655
Conversation
I think we need both. We should probably position this as a general "conditional", not specific to colors even if that is where the original use case came from. |
OK, that should be pretty easy, Should I do that in this PR? |
Yes, let me know if you run into any ideas. I will also do the spec/schema for this tomorrow or Friday. |
What exactly is the problem? Can't we just generate strings? |
I set up the conditional like this:
Then set up the conditional and color expression strings and use
but this outputs |
setRuntimeDefault(this); | ||
} | ||
|
||
defineProperties(ColorConditional.prototype, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would actually remove this for now until we expose the AST (probably not for the first pull request into 3d-tiles
).
Otherwise, this looks like a fast get/set, but it is just as bad as assigning a new style since it forces a recompile.
Looks good, just those comments. |
I still don't understand; is this with |
I didn't use JSON.stringify- I will try it with that. |
The default |
Let's remove |
In the case that someone doesn't provide a |
Yes. |
OK, I updated the name of the file to |
Looks great, just one rename request: throughout, rename |
Updated. |
👍 |
Added support for color conditionals. They are in the form:
We check each condition in order, and, if true, evaluate the corresponding color expression.
I added the file
ColorConditional.js
for the conditionals. It has both anevaluate(feature)
and evaluate(feature, result)` function. I think we may only need the latter?I deleted
ColorMapExpression
andColorRampExpression
.I added tests for
ColorConditional
and forCesium3DTileStyle
andCesium3DTileset
to check if the style is properly applied.I also updated the Sandcastle example.
I'm having trouble with the
Change Style Using ID
andChange Style Using Height
buttons, because they generate the conditionals depending on the number of colors, and I was having trouble making the conditional JSON expression, because the Boolean expressions have to be strings: (ex.'${height} < 1' : 'color("red")'
not${height < 1 : 'color("red")'
). So that part of the Sandcastle example has not yet been updated.