# glTF settings for setting color

**URL:** <https://community.cesium.com/t/gltf-settings-for-setting-color/7996>\
**Category:** CesiumJS\
**Created:** [February 13, 2019, 3:01pm UTC](https://community.cesium.com/t/gltf-settings-for-setting-color/7996 "2019-02-13T15:01:33Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mholthausen](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/mholthausen/32/2615_2.png) [@mholthausen](https://community.cesium.com/u/mholthausen)\
**Post date:** [February 13, 2019, 3:01pm UTC](https://community.cesium.com/t/gltf-settings-for-setting-color/7996/1 "2019-02-13T15:01:33Z")

</div>

Which settings for a glTF-Object created from Blender are needed to assign the object loaded within a 3D Tileset with another color in Cesium.  
Is any special material assignment in Blender required for this?

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [February 13, 2019, 3:46pm UTC](https://community.cesium.com/t/gltf-settings-for-setting-color/7996/2 "2019-02-13T15:46:32Z")

</div>

How are you converting the glTF to 3D Tiles? The material you set in Blender should come out on the other end.

Does the glTF have the material you set it to when loading it with something like the gltf viewer here?

[https://gltf-viewer.donmccurdy.com/](https://gltf-viewer.donmccurdy.com/)

---

<div class="post-metadata">

**Author:** ![mholthausen](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/mholthausen/32/2615_2.png) [@mholthausen](https://community.cesium.com/u/mholthausen)\
**Post date:** [February 14, 2019, 7:26am UTC](https://community.cesium.com/t/gltf-settings-for-setting-color/7996/3 "2019-02-14T07:26:10Z")

</div>

Yes, the Material (and color) assigned in Blender is visible in the glTF-Viewer and in my CesiumJS-Application. But when I set the color property in the 3DTileset object (e.g ```JavaScript Cesium.Color.BLUE```), I can see it is set in the console, but the appearance in the viewer doesn't change.

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [February 14, 2019, 2:40pm UTC](https://community.cesium.com/t/gltf-settings-for-setting-color/7996/4 "2019-02-14T14:40:41Z")

</div>

Oh, I see what you mean now. Can you show the CesiumJS code you’re using to set the color? A Sandcastle example would be great but even just seeing the code helps.

We recently fixed a bug with applying colors to tilesets with no features:

> <https://github.com/CesiumGS/cesium/pull/7255>

I wonder if this is related.

---

<div class="post-metadata">

**Author:** ![mholthausen](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/mholthausen/32/2615_2.png) [@mholthausen](https://community.cesium.com/u/mholthausen)\
**Post date:** [February 14, 2019, 3:25pm UTC](https://community.cesium.com/t/gltf-settings-for-setting-color/7996/5 "2019-02-14T15:25:03Z")

</div>

Hmm.. if i try it here in the sandcastel. it works just fine (don't mind the shape of the tileset)..

> **[Cesium Sandcastle](https://sandcastle.cesium.com/index.html?)**
>
> The Cesium Sandcastle provides an interactive environment for testing Cesium code.

But in the applcation on my desktop the tiles don't change color.  
Maybe there is something else wrong with it.

---

<div class="post-metadata">

**Author:** ![mholthausen](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/mholthausen/32/2615_2.png) [@mholthausen](https://community.cesium.com/u/mholthausen)\
**Post date:** [February 15, 2019, 7:11am UTC](https://community.cesium.com/t/gltf-settings-for-setting-color/7996/6 "2019-02-15T07:11:53Z")

</div>

I am calling it in nearly the same way in my application:

tileset[0].readyPromise.then(function (tileset) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tileset.root.children[0].color = Cesium.Color.BLUE;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tileset.root.transform = Cesium.Matrix4.setScale(tileset.root.transform, new Cesium.Cartesian3(1, 1, scale), tileset.root.transform);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log(tileset.root.children[0]);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});

The transform and the print out works fine, even the color properties are alle set to alpha 1 and blue 1. But the object won't change the color (using Cesium 1.54)

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [February 18, 2019, 2:14am UTC](https://community.cesium.com/t/gltf-settings-for-setting-color/7996/7 "2019-02-18T02:14:11Z")

</div>

That does sound very strange.I’m not sure why it would work in Sandcastle and not in your app. I would keep trying to put more of your application on Sandcastle until you see if there’s a specific piece that breaks it.

Glitch ([https://glitch.com/](https://glitch.com/)) might also be another way to try and test this. It might be easier to put your full application there since that’s more of a complete developer environment. If you can recreate the issue there I can try to take a look.

Does setting debugColorizeTiles work for you?

[https://cesiumjs.org/Cesium/Build/Documentation/Cesium3DTileset.html?classFilter=Cesium3dT#debugColorizeTiles](https://cesiumjs.org/Cesium/Build/Documentation/Cesium3DTileset.html?classFilter=Cesium3dT#debugColorizeTiles)

---

<div class="post-metadata">

**Author:** ![mholthausen](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/mholthausen/32/2615_2.png) [@mholthausen](https://community.cesium.com/u/mholthausen)\
**Post date:** [February 18, 2019, 12:20pm UTC](https://community.cesium.com/t/gltf-settings-for-setting-color/7996/8 "2019-02-18T12:20:16Z")

</div>

It works, when I set the color on the deepest child of tileset.root.children[this.state.node\_index].children[0].  
DebugColor works fine. But still I get differences in the color displayed on the 3D object if it has a color assigned by blender.

The only way I figured out today is to assign the Material there to double sided without adding a color to it.

---

<div class="post-metadata">

**Author:** ![mholthausen](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/mholthausen/32/2615_2.png) [@mholthausen](https://community.cesium.com/u/mholthausen)\
**Post date:** [February 20, 2019, 8:36am UTC](https://community.cesium.com/t/gltf-settings-for-setting-color/7996/9 "2019-02-20T08:36:04Z")

</div>

I get strange behavior from Cesium processing 3D object colors in a tileset. The object was generated in Blender with the color rgb(102,51,153), a hue in purple ([https://drive.google.com/file/d/1tBMoTi3h3oJERb76G4Q7vVMc85n7WWHM/view?usp=sharing](https://drive.google.com/file/d/1tBMoTi3h3oJERb76G4Q7vVMc85n7WWHM/view?usp=sharing)). When loaded into the Asset Controller, the color in the display here is still very close to the original color ([https://drive.google.com/open?id=12I-prD4AikgaUNnZN5UHsDgNbnJJzpv9](https://drive.google.com/open?id=12I-prD4AikgaUNnZN5UHsDgNbnJJzpv9)). But as soon as the Tileset is loaded in the Cesium Viewer (on my local application or in the Sandcastle), the hue changes, it somehow brightens, as if the object's color in CesiumJS is mixed with another (possibly white) color ([https://drive.google.com/open?id=1bvxoEcntjMTHQf2DL7MwHnncCraK9qds](https://drive.google.com/open?id=1bvxoEcntjMTHQf2DL7MwHnncCraK9qds)).  
I know that the color may change due to lighting, but these changes seem too strong to me from the original color.  
All images were shot on my desktop and I have created a sandcastel for it here: [https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/index.html#c=lVPRbtowFP0Vi5cGCTkERre2tFoXVhZE6NqmbI3yEhxDDI5NbScUqv77bhLa0e5pliL72ufee86xY9toqGJhkEs1y7PRHYoJoVojI9FW5goxKVCsNTU6EjUGe1LghM7jnJvLChzIFRXoHB3R7SidDQm7ZiPvfuc5E+ZpT9z2iOsde6v176k7OsEAekyGKwB5G/9XuPKXCQ+Zkz7sUj4Obp78gWcelrfp5K7dC4PJMhzedMIBfMGKjd3ROoRik4G/8d0NI51JQYbTnbdcz7zsakfKhlmy9HgbZp4mgPWD+7Y/uHH85X3H/9HG3W7sp1N3dXIchr3YdTqT0VL6+bVgj+6nE+NfET3tyCe3Z74cnUUiEkWsUMHohirQKOhm7xWeVnvWEalCVwoTM0HVUQs9RwLBMFQp2PqpZMESyD49zK6n4D3E2meWI1f8FP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nze0GFGTNtQIGy5rkgBt6xVUKa6BlBO9suA1yXPn8TU4YVv29bQ7XltDutntNyet3mGaocRpVdtUE7KbNAWnsCexFYAmW1YZq+9UUWOC5VEx14Q6TQEghwudifnr2aAItGq9HXZsvpRb35lWVrqUzpqIWxbWi25jEQtGc5WYF2onWZ1rdfk/oJKxBLzqPGh8cZNRDh8D/DyTzn/I7taNS46NuAf5fGwUkmFtcFVTzeAqQm0k+di3F9hDHu2xCWbT9mGyn5LFYHlf8A)

When line 19 is commented out, I add the original color to the tile. However, I would have hoped that the color generated in Blender will be taken over.

Just as background info: 3DTile Style does not work, because the object does not have any features and in my end application and I am merging several tiles in a tileset to which all one clippingPlane should be applied. With 3D Style, alle Tiles in the Tileset would be colored in th same color.

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [February 20, 2019, 1:12pm UTC](https://community.cesium.com/t/gltf-settings-for-setting-color/7996/10 "2019-02-20T13:12:21Z")

</div>

I do think it is still the lighting. If I move the timeline slider to control the sun position, I can see the the color changing into the very bright color and then back to the original. Are you seeing this too?

---

<div class="post-metadata">

**Author:** ![mholthausen](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/mholthausen/32/2615_2.png) [@mholthausen](https://community.cesium.com/u/mholthausen)\
**Post date:** [February 20, 2019, 2:41pm UTC](https://community.cesium.com/t/gltf-settings-for-setting-color/7996/11 "2019-02-20T14:41:34Z")

</div>

Yes, I see it, too. Isn't the lighting turned off if the timeline is set to false?  
But are there other settings to make in order to deactivate the lighing to see the real color of the object except:  
viewer.scene.globe.enableLighting = false;  
viewer.scene.globe.showGroundAtmosphere = false;

> **[Cesium Sandcastle](https://sandcastle.cesium.com/index.html?)**
>
> The Cesium Sandcastle provides an interactive environment for testing Cesium code.

---

<div class="post-metadata">

**Author:** ![mholthausen](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/mholthausen/32/2615_2.png) [@mholthausen](https://community.cesium.com/u/mholthausen)\
**Post date:** [February 21, 2019, 8:40am UTC](https://community.cesium.com/t/gltf-settings-for-setting-color/7996/12 "2019-02-21T08:40:55Z")

</div>

I tried a bit with the timeline feature, and yes, there are some changes in lighting while movinge the time slider. But the color mixing I've experienced on my desktop can't assigned to this functionality.  
The initial color of the gltf object here ([https://drive.google.com/open?id=1e34mVtUZT-yehIGzistMyxPhEHXuDzz-](https://drive.google.com/open?id=1e34mVtUZT-yehIGzistMyxPhEHXuDzz-)) is set by Blender to #663399 or rgb(102,51,153). This color can be achieved by adjusting the lighting, yes. But when I change the color by picking e.g. this color ([https://drive.google.com/open?id=1wwCW7RjupDpyTc9MlM6Ro9XzAyUry7yD](https://drive.google.com/open?id=1wwCW7RjupDpyTc9MlM6Ro9XzAyUry7yD)) the resulting color of the object looks like this: [https://drive.google.com/open?id=10jYYyKwIAXvJyf3M-bd3hHu7cV8vr2al](https://drive.google.com/open?id=10jYYyKwIAXvJyf3M-bd3hHu7cV8vr2al) .  
The console says the selected color is set ([https://drive.google.com/open?id=1PZwQ2WFNhlhR8sSs6xeoFArsRQhcLVEt](https://drive.google.com/open?id=1PZwQ2WFNhlhR8sSs6xeoFArsRQhcLVEt)) and assigned to the 3D Tile ([https://drive.google.com/open?id=1o496hQ8\_bythAAIJjpy3QL5W2xOP45Os](https://drive.google.com/open?id=1o496hQ8_bythAAIJjpy3QL5W2xOP45Os)). But the displayed color is definitely not the selected color, even though the values in the console are set.

You can see this behaviour in the modified sandcastle, if you uncomment or commend line 34 there:

> **[Cesium Sandcastle](https://sandcastle.cesium.com/index.html?)**
>
> The Cesium Sandcastle provides an interactive environment for testing Cesium code.

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [March 4, 2019, 3:22pm UTC](https://community.cesium.com/t/gltf-settings-for-setting-color/7996/13 "2019-03-04T15:22:27Z")

</div>

One thing I just thought of, I think giving the glTF an unlit material should fix this. There’s some discussion and examples here:

[https://groups.google.com/d/msg/cesium-dev/GMZkSjUUSAo/GFq47cadBwAJ](https://groups.google.com/d/msg/cesium-dev/GMZkSjUUSAo/GFq47cadBwAJ)

This is the glTF extension for unlit:

> **[KhronosGroup/glTF](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)**
>
> glTF – Runtime 3D Asset Delivery. Contribute to KhronosGroup/glTF development by creating an account on GitHub.

Which CesiumJS does support, but I think the tool you’re using to convert glTF -\> 3D Tiles would need to add it in, or at least leave it in if you can generate a glTF with that extension.
