Rectangle in 2D mode disappears

Hello, a rectangle entity that is visible in 3D mode disappears in 2D mode. This happens on Chrome on Ubuntu 18.04, but works on Firefox on the same operating system. I tried with both Cesium 1.50 and 1.59.

The following is how I add it:

selection = cesiumViewerLulc.entities.add({
rectangle: {
coordinates: getSelectionCoordinates,
material: Cesium.Color.WHITE.withAlpha(0.5)
}
});

``

Can anyone guess the reason or suggest a fix? Thanks.

Are you able to reproduce this issue in Sandcastle? (https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html) if so, can you share a complete code example I can run? You can do this by clicking “share” in the top and pasting the link you get here.

Hey did you ever figure this out? I have the same issue, i noticed that when i have it in 2D AND ellipsoid, they disappear, but when i change to 3D or use terrain, or both, they all work again.
The only work around i found was to use height at 0, but it alters the color of the rectangle and means they don’t work when using terrain.

Hello Mitchell, I am sorry I could not solve this issue in the past.

I had this issue with entities and resolved it by decreasing scene.nearToFarDistance2D. See the note on z-fighting (among primitives?) in docs.

I know it is late, but the way I solved it was by setting the height attribute to 0.5 when using ellipsoid, and setting height to undefined when using terrain.
I am unsure, but i am wondering if it has something to do with the imagery layers i have, and maybe it is putting the rectangle graphics under them?

1 Like

@Mitchell_Day

Thank you for posting this update! If other community members have similar questions, I will point them to this thread. I suspect that you are right - the rectangle graphics are most likely going under the imagery layers.

-Sam