-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Feature reactive Cesium3DTileStyle.style object #7573
Feature reactive Cesium3DTileStyle.style object #7573
Conversation
Thanks for the pull request @bkuster!
Reviewers, don't forget to make sure that:
|
Thanks @bkuster, I'll look at this soon. |
Thanks again for your contribution @bkuster! No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy? I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with |
@lilleyse will you have time to review this soon? |
Source/Scene/Cesium3DTileStyle.js
Outdated
@@ -159,16 +159,29 @@ define([ | |||
that._ready = true; | |||
} | |||
|
|||
function getExpression(tileStyle, value) { | |||
function getExpression(tileStyle, value, key) { |
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.
Maybe it would be better to separate getting the expression from setting the json. One idea:
function getJsonFromExpression(expression) {
if (defined(value.expression)) {
return value.expression;
} else if (defined(value.conditionsExpression)) {
return clone(value.conditionsExpression, true);
}
return expression;
}
set : function(value) {
this._show = getExpression(this, value);
this._style.show = getJsonFromExpression(this._show);
}
A couple things to handle are:
this._style
would need to be initialized to an empty object- What happens if the expression is a custom expression? Should that be added to the json as is? Or should
getJsonFromExpression
return undefined in that case.
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.
Thanks for the feedback @lilleyse. True, abusing getExpression
in this fashion is not very intuitive, I like your proposal and will implement something along those lines.
this._style
initialization in the constructor makes sense to me, but this would change a non-experimental API, as the default value for.style
would not longer beundefined
butObject
, or would you still returnundefined
in the getter, if the Object is empty?- Haven't thought of custom expressions tbh. Both approaches (
undefined
or the expression instance) have their uses. You cant serialize the expression, but you could use it to clone the style at runtime. I would lean toward an implementation that is closest to the current behavior, I'll have to checkout what that is first, but would assume it to beundefined
?
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.
Changed my mind on 2.. Behavior as is now adds the custom expression passed in the options to style
, this should remain unchanged. Added some specs to outline the behavior.
This is ready for a second review. |
Thanks @bkuster, this all looks good to me. My simple test checks out: var viewer = new Cesium.Viewer('cesiumContainer');
var tileset = new Cesium.Cesium3DTileset({
url: '../../SampleData/Cesium3DTiles/PointCloud/PointCloudWithPerPointProperties/tileset.json'
});
viewer.scene.primitives.add(tileset);
viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.0, -1.0, 50.0));
var style = new Cesium.Cesium3DTileStyle({
color : "color('#ff0000')"
});
tileset.style = style;
console.log(style.style);
style.color = "color('#ffff00')";
console.log(style.style); And the breaking change is minimal enough to not worry about deprecating first. |
This closes #7567.
Recap
The
.style
property was set on creation ofCesium3DTileStyle
and no longer evaluated.New Implementation
The
.style
property now reacts to property changes on theCesium3DTileStyle
. This allows cloning or serializing of a style, even after it has been updated.