Is it possible to make CorridorGraphics follow the terrain?


Is it possible to make a corridor following the actual terrain of a map?

I would like to get the green corridor following the terrain, but as you can see in the image above, it only touches the terrain at its highest point.
I currently use the following configuration:

        name: 'Z1',
        corridor: {
          positions: points,
          width: zones.z1.width,
          cornerType: CornerType.MITERED,
          extrudedHeight: zones.z1.height,
          height: 0,
          extrudedHeightReference: HeightReference.RELATIVE_TO_GROUND,
          heightReference: HeightReference.CLAMP_TO_GROUND,
          material: Color.GREEN.withAlpha(0.8),

I appreciate every input on this topic.

Hi @Simon_Prosen,

It’s currently not possible yet. Corridors, polygons and rectangles with extruded height does not clamp to the terrain at the moment. It doesn’t look like there is a feature request for this in CesiumJS yet. Please feel free to open one!

I’m confused, what does HeightReference.RELATIVE_TO_GROUND do if not what Simon is asking? For example, if the heightReference is RELATIVE_TO_GROUND and the height is 100, each point of the corridor should sit 100m off the ground, right? That’s what it looks like in the Sandcastle example for HeightReference, though that uses Polygon instead of Corridor.

1 Like

Hi James,

thanks for the input and the example!

I´ve tried to adjust my code, but I cannot reproduce the behaviour of the sandcastle. Although I set the extrudedHeightReference to CLAMP_TO_GROUND the polygon seems to be drawn under the base layer of the globe.

new Entity({
                      description: polygonChild.description,
                      show: false,
                      polygon: {
                        hierarchy: polygonChild.polygon.hierarchy,
                        heightReference: HeightReference.RELATIVE_TO_GROUND,
                        extrudedHeight: 0.0,
                        perPositionHeight: true,
                        outline: polygonChild.polygon.outline,
                        outlineColor: polygonChild.polygon.outlineColor,
                        material: polygonChild.polygon.material,

I got it!

The solution was to activate the depthTestAgainstTerrain…

viewer.scene.globe.depthTestAgainstTerrain = true;

Million thanks to @James_B!