Material difference in 2D scene

I have some questions


If comment code : height: 0.
you will find that you get a polygon of different colors, which only changes a height, and the default value of height is 0( At least that’s what the API documentation describes)

2:The polygon in the example will appear or disappear randomly with the distance of the camera. I know the way to prevent this is to set a height attribute to the polygon, but this will lead to material changes.


Welcome to the community! :grinning: :fireworks: Thank you for sharing your sandcastle demos.

Regarding your first question, I suggest you check out the following community forum thread. I had a great conversation with @11179 where we discussed color accuracy in 2D. In particular, be sure to look at the second half of the thread.

Regarding your second question, what material changes do you notice when you set the height attribute of your polygon? I have not encountered this issue in the past and was not able to reproduce the bug on my machine. Does anyone from the rest of the community have any suggestions?

Please let me know if you have any other questions or concerns. I am looking forward to learning more about your application.


Thank you for your reply on your second question. Firstly, not only the material changes, but also the examples provided. By default, polygon will disappear according to the specific changes of the camera. Secondly, in order to avoid the disappearance caused by the camera distance, I can set a height attribute for polygon graphic with a value of 0, although the API document explains that the default value of height attribute is 0, However, after this setting, the polygon will not disappear, but the material will change. You can see that the color I set is color.cyan. After setting the height, you will get a darker color. The following is a screenshot


Thank you for providing some more information as well as some screenshots. Regarding your second screenshot, it seems like setting the height attribute ensures that the polygon will be visible. There seems to be a consensus among community members that this is the correct way to ensure that the polygon is visible. As for the color accuracy when viewing the polygon in 2D, @11179 came up with a great solution that he outlined in the following post.

The key is that both the height and extrudedHeight affect the color of the asset. @11179 feel free to interject here with more suggestions for @zhouhai1. Let me know if there are any lingering questions or concerns!


I’m very sorry, so the visibility and color can’t be guaranteed to be correct at the same time, right? Let me see the example you mentioned above, which is also true. If I have misunderstood something, please let me know. thank you


While color accuracy and visibility in 2D is a recurring issue in our community, I believe that we have found a workaround. The following sandcastle demos showcase this workaround.

The key is that height and extrudedHeight both impact the color of the object. Let me know if you have any other questions or concerns. Give my suggestions a try and let me know how everything goes!



In this example, I didn't find that the color and visible are correct at the same time


I would recommend only adding the polygon that you need. Here is an example of adding one color accurate polygon to the Cesium Viewer.


You can also modify the demo that I sent in my last response to add polygons around the entire world.


Indeed, as you said, from the example you provided, this polygon can maintain the correct color and visibility in 2D.
However, when I raised this question, I did not explain one point. Visibility problems do not occur absolutely. On the premise of correct 2D and color, not all polygons will have visibility errors (possibly due to the position of the polygon or the shape of the polygon, which is just my guess).
In my application scenario, I added some face data of administrative areas, but only one polygon will have visibility problems. So in my last reply, the screenshot showed that some polygons were not displayed correctly.
In the following example, I just modified the position and shape of the polygon you provided, and added a button to ensure that you can successfully locate it after switching to 2D mode. You will find that it does ensure the correctness of color, but the visibility is incorrect. It will appear randomly with the zoom of the camera.

Hi Sam,

I also encountered the problem of polygons’ visibility and material appearance recently in my project.
Glad to see your discussion with @zhouhai1 here.
However, in this Sandcastle demo you provided in the post:

all polygons look good in 3d and 2.5d mode but when I change to 2d mode, the second line of polygons (without setting “height: 0”) seem to have some visibility issue when I drag the map.

Here is the screen record of what it looks like on my computer. (3.5 MB)

I wonder if the visibility issue is related to the hight/extrudehight or timeline properties.

Thank you!