Updating Model Color and Texture/Skin

Model Color…

I see that color has been added as a property for models. This is a great new feature! However, I’m having trouble getting it to work in my scenario.

I am using Cesium 1.29, and we are creating models using Cesium.Model.fromGltf and adding the result to the primitives collection. So far I have not been able to change the color property by setting model.color. Does this new color property only work for entities? I only see examples for entities, but the documentation makes it seem like this should work for primitives.

Model Texture/Skin…

We have the need to display multiple instances of the same model with different textures/skins. Is there a way to change/update/assign the texture/skin on a model programmatically (during runtime)?

Hello,

Yes, you can set model.color if you’re using Model.fromGltf. You can see an example of this in the 3D models development sandcastle example: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Apps/Sandcastle/gallery/development/3D%20Models.html

If that’s not working, could you paste a code sample to reproduce the problem?

Best,

Hannah

Thank you, Hannah, for the response. It turns out since I use Google’s closure compiler I needed to include extern references for the other color related properties. Once I did this the models get colored great!

I have another color question: How do I remove the color?

I have models that have a texture “baked” on. I want to toggle the color of the model based on a switch the user selects and then return the model to no color with the original texture appearance when the user turns off the switch. How do I go about removing the color from a model once it has been applied?

The Sandcastle color example has a property called colorBlendAmountEnabled, but I don’t see that in the API. I’ve tried setting that flag to true and setting the colorBlendAmount to 0. I’ve also tried setting the color to white with an alpha of 0. But none of these approaches remove the color from the model once the color has been applied.

I figured it out. To remove the applied color from the model you set the colorBlendMode to ColorBlendMode.MIX and set the colorBlendAmount to 0.

It works great! Thanks for the new feature!

Any input on the ability to apply or bind a different texture to a model during runtime?

Alternatively to remove the color set colorBlendMode to ColorBlendMode.HIGHLIGHT and color to Color.WHITE, this is the default state at least. Your way works too though.

Right now there’s no ability to apply different textures on the fly.

what about dynamically changing the texture of a model? – how would you do that?

I definitely want this feature as well! My understanding is that the answer has been you cannot do that (apply texture to a model during run time) so far. However, I’m hopeful that the new support for compressed textures (KTX) may also introduce some method for applying those textures dynamically. I don’t see anything about this in the change log, however, so I’m not holding my breath. It seems that when support is added to apply textures dynamically it will be advertised significantly since it will definitely be a big deal!

I actually don’t think this would be too hard to do, in fact I remember someone posting a hacked up solution for this not too long ago (I can’t find the thread though). This sounds like a good code sprint idea…

I actually don't think this would be too hard to do, in fact I remember someone posting a hacked up solution for this not too long ago (I can't find the thread though). This sounds like a good code sprint idea..

:+1:

Hey Sean,

It would be GREAT if this could be addressed in a code sprint! Is there anything I can do to make a formal request for this?

Rob

I opened up an issue so we can at least track progress on github. This one is open to anyone, not just the core team.

Link: https://github.com/AnalyticalGraphicsInc/cesium/issues/5094

Thanks, Sean!

This would be a great feature
that we would definitely put to use immediately. We display aircraft around airports, and the
ability to apply the textures during run time would be great (we do this in a
Java application). I assume this would
also reduce memory consumption. Since Cesium caches the models I would think applying a texture to different instances of the same model would be less expensive than loading a unique aircraft model with “baked on”
airline texture for each aircraft displayed.

Thanks again,

Rob

Rob - sounds like you are developing a cool app, let me know if we can showcase your work on the Cesium website: http://cesiumjs.org/demos.html

Patrick

Hi Patrick,

Thanks for the offer! Unfortunately almost all of the airports and entities we work with use data that has use restrictions. Maybe at some point in the future we’ll have a data source that would make a demo site feasible.

Rob