Skip to content
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

3D Tiles Styling - treat colors as vec4 #4849

Merged
merged 3 commits into from
Jan 12, 2017
Merged

3D Tiles Styling - treat colors as vec4 #4849

merged 3 commits into from
Jan 12, 2017

Conversation

lilleyse
Copy link
Contributor

Based on discussion here: CesiumGS/3d-tiles#166 (comment).

@@ -212,7 +202,7 @@ define([
Expression.prototype.evaluateColor = function(frameState, feature, result) {
ScratchStorage.reset();
var color = this._runtimeAst.evaluate(frameState, feature);
return Color.clone(color, result);
return Color.fromCartesian4(color, result);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured evaluateColor should return a Color object. evaluate will just return a Cartesian4.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, agreed. It is fine for the Cesium implementation to map vec4 to Cesium's Color when we know it is the color property. This is an implementation detail and does not affect the spec.

} else if (member === 'w') {
return property.alpha;
if ((property instanceof Cartesian2) || (property instanceof Cartesian3) || (property instanceof Cartesian4)) {
// Vector components may be accessed with .red, .green, .blue, .alpha and implicitly with .x, .y, .z, .w
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like how glsl can access components of a vector with .r, .g, .b, .a, I kept in the .red, .green, .blue, .alpha. Should they be shortened to .r, etc instead, or should this be removed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it, but go with r, g, b, a. I went with the full words to start because I was copying the Cesium Color type, but we should stay consistent with GLSL so the styling language isn't too much of a hybrid.

Also, given that styles are often very concise and look like equations, this will fit well.

@pmconne this will be a small breaking change for your styles.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 11, 2017

Code looks good. Don't forget to update the Sandcastle examples when you make the property renames.

@lilleyse
Copy link
Contributor Author

Updated. I couldn't find any uses in the examples.

@pjcozzi pjcozzi merged commit 70e841b into 3d-tiles Jan 12, 2017
@pjcozzi pjcozzi deleted the color-vec4 branch January 12, 2017 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants