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

Fix for model coloring #4798

Merged
merged 8 commits into from
Jan 6, 2017
Merged

Fix for model coloring #4798

merged 8 commits into from
Jan 6, 2017

Conversation

szsolt
Copy link
Contributor

@szsolt szsolt commented Jan 3, 2017

#1 Opened issue

@szsolt
Copy link
Contributor Author

szsolt commented Jan 3, 2017

For some reason the CI system fails to run:

npm run makeZipFile

Running locally the command succeed without any issue.

@lilleyse
Copy link
Contributor

lilleyse commented Jan 3, 2017

Thanks for catching this @szsolt. This is a good initial solution, with the downside being if there is no result parameter then a new Color will be allocated every time, which actually seems to be a problem with silhouetteColor too currently...

I think the proper solution may be to turn Model.color and Model.silhouetteColor into a getter/setter and mark that the colors as dirty in a different way. I am happy to add that work to this PR, unless you wish to look into it.

@szsolt
Copy link
Contributor Author

szsolt commented Jan 3, 2017

@lilleyse What if we follow how modelMatrix is set a few lines above?

model.silhouetteColor = Property.getValueOrClonedDefault(modelGraphics.silhouetteColor, time, defaultSilhouetteColor, model.silhouetteColor);
model.color = Property.getValueOrClonedDefault(modelGraphics._color, time, defaultColor, model.color);

@szsolt
Copy link
Contributor Author

szsolt commented Jan 3, 2017

Updated pull request to avoid creating a new Color each update.

Is this good enough or you still prefer the getter/setter option?

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 3, 2017

@szsolt can you please send in a Contributor License Agreement (CLA) so we'll be able to merge this?

@lilleyse
Copy link
Contributor

lilleyse commented Jan 3, 2017

I think the getter/setter is still preferable. If the model's color is not set the default color will be cloned every update.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 5, 2017

@szsolt do you have any update here? We would like to get this fix into master since other users have also noticed it. Do you prefer that @lilleyse or I finish this or are you able to? Thanks!

@szsolt
Copy link
Contributor Author

szsolt commented Jan 5, 2017

Updated the pull request. Now if the model color is not set, it will not be cloned for every update.
Also removed the unnecessary clone from updateSilhouette() as it was cloning the full Color() object and all it needed was the alpha value of it.

I was wondering if it would worth changing the behavior of getValueOrDefault() or introducing a new method which will allocate a new object when the result is frozen, something like:

Property.getValueOrDefaultSafe = function(property, time, valueDefault, result) {
    return defined(property) ? defaultValue(property.getValue(time, Object.isFrozen(result) ? undefined : result), valueDefault) : valueDefault;
};

Of course we could implement isFrozen() method like you did for the freeze() method for older browser compatibility.

@szsolt
Copy link
Contributor Author

szsolt commented Jan 5, 2017

Please feel free to modify / replace my implementation as you guys have more expertise on the implementation detail.

@lilleyse
Copy link
Contributor

lilleyse commented Jan 6, 2017

Cool nice idea with only storing the alphas to avoid the clone, and using the underscored colors as scratch variables. I think this is good to go for now, if we decide to use getters/setters for Color later that can be in a different PR.

@pjcozzi can you do the final review?

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 6, 2017

Looks great, thanks again @szsolt! Great job with this.

If you have the time to more involved with Cesium, there's lots of ideas here.

@pjcozzi pjcozzi merged commit 443855f into CesiumGS:master Jan 6, 2017
@pikvic
Copy link

pikvic commented Aug 26, 2022

This bug still appears in 1.96. Link to Sandcastle

@j9liu
Copy link
Contributor

j9liu commented Aug 26, 2022

Hi @pikvic,

This bug has already been fixed in main, and the fix will be included in the CesiumJS 1.97 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants