Changing the color of a GLTF Model

Dear all,

I guess I do know how change the color of a loaded GLTF model (for highlighting purposes)

Currently I’m loading the GLTF models and via the ID of the GLTF entities I can find the the GLTF Models in the Cesium.Viewer.scene.primitives.

There I can browse through the nodes and meshes of a GLTF model. I see that the meshes have a material property however I 'm not sure how to set a color or even if this is the correct way to go? All help is appreciated.

cheers,

Hans

Hi Hans,

See Model.getMaterial and ModelMaterial.selValue. Also see issue #2387.

Patrick

Hi Patrick,

Thanks for that and looking forward to new releases!

cheers,

Hans

Hi,

I have a similar issue related to the changing of the model material value. I am using the glTF model having texture images (and not cartesian color values). I have attached the screenshot for your review. In order to provide highlighting effect, I am willing to either change the brightness of the model (e.g. make the model more or less bright) or provide a highlighting color on top of that. If the glTF model contains the color values, I can easily change its color using model.getMaterial and then modelMaterial.setValue. But I am not sure how would I change the material values in case of texture images. Any help would be appreciated.

Best regards,

Kanishk

We recently announced 3D building works being done in Cesium, here’s the forum thread about it: https://groups.google.com/d/msg/cesium-dev/IArj5ju4cI8/JjuND35APT8J As far as I know (I could be wrong) there’s no easy way to do what you want right now, but we will be exploring such capabilities in the near future.

Hi Kanishk,

I can easily change its color using model.getMaterial and then modelMaterial.setValue. But I am not sure how would I change the material values in case of texture images. Any help would be appreciated.

When textures are used, the glTF material might still have a diffuse property that is multiplied with each texel read from the texture. If so, just set it as before. If not, you could post-process the glTF to use a custom material and fragment shader so you can set any value you want.

Patrick

I’m taking a look at this today. I’ll get back you in a bit.

Can you change the image itself that is used on the building? (say if the building shape is the same, just want to put texture image)

change texture image* programatically

Hi,

Can you change the image itself that is used on the building? (say if the building shape is the same, just want to put texture image)

No. Cesium’s Texture object is not part of the public API, and we would have to add some interop for glTF/Cesium textures.

Cesium will support this at some point; in the meantime, you could use two different models.

Patrick

what is allProps method, what it will return?