Hi,
I have some simple entities that I’m trying to display in Cesium.js. Here’s my setup:
- Using Cesium.js 1.123
- Using terrain - Cesium World Terrain for this example
- Using imagery - Bing Maps Aerial for this example
- 1 Polygon - in an area with significant terrain, should “follow” terrain
- 1 Label - should “follow” terrain
viewer.scene.globe.depthTestAgainstTerrain = true
This scenario can be seen in this Sandcastle link.
I’m having issues with the terrain obscuring my entities and trying to get the entity options/properties correct to fix it.
First some details about the displayed polygon:
- If I set
heightReference
toNONE
and don’t specify aheight
, it seems to follow the terrain but the polygon’s outline doesn’t display (supported by the message in the Console stating that outlines are not supported on terrain). Ok, I can live with that. - If I set
heightReference
toCLAMP_TO_GROUND
and keep theheight
unspecified, it follows the terrain like before, but the Console shows a message stating thatEntity corridor, ellipse, polygon or rectangle with a heightReference must also have a height defined. heightReference will be ignored
. Seems odd but ok? - If I keep
heightReference
set toCLAMP_TO_GROUND
and set aheight
(0) on the polygon as hinted by the Console message, a couple of things happen:- The outline is displayed
- The polygon no longer follows the terrain but rather is shown as a plane at some non-zero height, clearly visible in the scene as being above ground level
- The peaks of the mountains in the area stick out the top of the polygon.
- Increasing the height value causes the polygon to move further away from the ground
Is there a combination of options (these or others) that would allow me to clamp the polygon to the ground without visual artifacts or Console warnings?
Now on to the label:
- If I set
heightReference
toNONE
and don’t specify aheight
, the label is not visible. It’s there (under the terrain) and can be seen ifdepthTestAgainstTerrain
is disabled but that is not the behavior I desire. - If I set
heightReference
toCLAMP_TO_GROUND
and keep theheight
unspecified, it becomes visible but is obscured by the terrain in various ways depending on the camera position. - If I keep
heightReference
toCLAMP_TO_GROUND
and set aheight
(any value) I see the same behavior as the previous combination - If I set
heightReference
toNONE
and set aheight
(something large enough to get it to be above the terrain) the label is displayed unobscured but not where I want it.
Is there a combination of options (these or others) that would allow me to have the label clamped to the ground but not obscured by the terrain?
Thank you in advance for your time and consideration.
-Jeff