# Is it possible to make CorridorGraphics follow the terrain?

**URL:** <https://community.cesium.com/t/is-it-possible-to-make-corridorgraphics-follow-the-terrain/13378>\
**Category:** CesiumJS\
**Created:** [April 27, 2021, 10:19am UTC](https://community.cesium.com/t/is-it-possible-to-make-corridorgraphics-follow-the-terrain/13378 "2021-04-27T10:19:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simon\_Prosen](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/simon_prosen/32/4410_2.png) [@Simon\_Prosen](https://community.cesium.com/u/Simon_Prosen)\
**Post date:** [April 27, 2021, 10:19am UTC](https://community.cesium.com/t/is-it-possible-to-make-corridorgraphics-follow-the-terrain/13378/1 "2021-04-27T10:19:59Z")

</div>

Hello,

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

 ![image](https://global.discourse-cdn.com/cesium/original/2X/7/7de6749ef9555794a73f600dd5588a5bff0a8322.jpeg)

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:

```auto
this.viewer.entities.add({
        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.

---

<div class="post-metadata">

**Author:** ![dzung](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/dzung/32/2996_2.png) [@dzung](https://community.cesium.com/u/dzung)\
**Post date:** [May 10, 2021, 3:14pm UTC](https://community.cesium.com/t/is-it-possible-to-make-corridorgraphics-follow-the-terrain/13378/2 "2021-05-10T15:14:01Z")

</div>

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! [https://github.com/CesiumGS/cesium/issues/new/choose](https://github.com/CesiumGS/cesium/issues/new/choose)

---

<div class="post-metadata">

**Author:** ![James\_B](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/james_b/32/2424_2.png) [@James\_B](https://community.cesium.com/u/James_B)\
**Post date:** [May 12, 2021, 3:41pm UTC](https://community.cesium.com/t/is-it-possible-to-make-corridorgraphics-follow-the-terrain/13378/3 "2021-05-12T15:41:08Z")

</div>

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](https://sandcastle.cesium.com/?src=Geometry%20Height%20Reference.html), though that uses Polygon instead of Corridor.

---

<div class="post-metadata">

**Author:** ![Simon\_Prosen](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/simon_prosen/32/4410_2.png) [@Simon\_Prosen](https://community.cesium.com/u/Simon_Prosen)\
**Post date:** [May 17, 2021, 7:39am UTC](https://community.cesium.com/t/is-it-possible-to-make-corridorgraphics-follow-the-terrain/13378/4 "2021-05-17T07:39:08Z")

</div>

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.

 ![Screen Recording 2021-05-17 at 09.31.35](https://global.discourse-cdn.com/cesium/original/2X/a/a7965b17c7a63db55dc617d6a8a2151b4949919e.gif)

```auto
new Entity({
                      name: polygonChild.name,
                      description: polygonChild.description,
                      show: false,
                      polygon: {
                        hierarchy: polygonChild.polygon.hierarchy,
                        heightReference: HeightReference.RELATIVE_TO_GROUND,
                        extrudedHeight: 0.0,
                        extrudedHeightReference:
                          HeightReference.CLAMP_TO_GROUND,
                        perPositionHeight: true,
                        outline: polygonChild.polygon.outline,
                        outlineColor: polygonChild.polygon.outlineColor,
                        material: polygonChild.polygon.material,
                      },
                    })

```

---

<div class="post-metadata">

**Author:** ![Simon\_Prosen](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/simon_prosen/32/4410_2.png) [@Simon\_Prosen](https://community.cesium.com/u/Simon_Prosen)\
**Post date:** [May 21, 2021, 8:24am UTC](https://community.cesium.com/t/is-it-possible-to-make-corridorgraphics-follow-the-terrain/13378/5 "2021-05-21T08:24:31Z")

</div>

I got it!

The solution was to activate the depthTestAgainstTerrain…

```auto
viewer.scene.globe.depthTestAgainstTerrain = true;

```

Million thanks to @James_B!
