# Polygon rendering a minefield with terrain

**URL:** https://community.cesium.com/t/polygon-rendering-a-minefield-with-terrain/5983
**Category:** CesiumJS
**Created:** [August 25, 2017, 2:12am UTC](https://community.cesium.com/t/polygon-rendering-a-minefield-with-terrain/5983 "2017-08-25T02:12:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Scott\_Haynes](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_haynes/32/2063_2.png) [@Scott\_Haynes](https://community.cesium.com/u/Scott_Haynes)
#### Post date: [August 25, 2017, 2:12am UTC](https://community.cesium.com/t/polygon-rendering-a-minefield-with-terrain/5983/1 "2017-08-25T02:12:25Z")

</div>

**1. A concise explanation of the problem you’re experiencing.**

I’m trying to get a polygonGraphic(2D plane mapped to the terrain) to clamp to the terrain. I’m not setting height or extrudedHeight, but I am using an ImageMaterialProperty with a CallbackProperty for the repeat property. Image attached. Is this just a limitation of PolygonGraphic? The original set of points I was using for the hierarchy property didn’t have elevation values, but I did try to get the elevation values from the Cesium.sampleTerrainMostDetailed function.

**2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.**

The code is quite involved, but I can probably create a sandtable example if this does sound like a bug.

**3. Context. Why do you need to do this? We might know a better way to accomplish your goal.**

This feature is a standard military(2525) way of representing a minefield on a map. See the attached photo. Basically the polygon’s material should scale based upon the screen space. The larger the area on the view the higher the repeat value should be set for the ImageMaterialProperty.

**4. The Cesium version you’re using, your operating system and browser.**

v1.36, windows 7, chrome

Thanks,

Scott

 ![polygon.png](https://global.discourse-cdn.com/cesium/original/1X/85ba95b598dd1e9840653bcfd68c0de72e22afc5.png)

---

<div class="post-metadata">

### Author: ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)
#### Post date: [August 25, 2017, 7:01pm UTC](https://community.cesium.com/t/polygon-rendering-a-minefield-with-terrain/5983/2 "2017-08-25T19:01:08Z")

</div>

Hi Scott,

Polygons are able to clamp to ground, see this sandcastle example, and select “Draw Polygon” from the dropdown: [https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Ground%20Clamping.html&label=Showcases](https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Ground%20Clamping.html&label=Showcases)

If you provide a snippet of the relevant code in a sandcastle example, it will be easier to deduce what the problem is and track down a bug if there is one.

Thanks,

Gabby

---

<div class="post-metadata">

### Author: ![Scott\_Haynes](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_haynes/32/2063_2.png) [@Scott\_Haynes](https://community.cesium.com/u/Scott_Haynes)
#### Post date: [August 27, 2017, 6:39pm UTC](https://community.cesium.com/t/polygon-rendering-a-minefield-with-terrain/5983/3 "2017-08-27T18:39:43Z")

</div>

I think I remember that only solid colors or predefined materials clamp to the ground correctly? Am I wrong? This material is mostly transparent and is dynamically being set with the callbackProperty. I could see why this is causing an issue computationally.

Scott

---

<div class="post-metadata">

### Author: ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)
#### Post date: [August 28, 2017, 9:21pm UTC](https://community.cesium.com/t/polygon-rendering-a-minefield-with-terrain/5983/4 "2017-08-28T21:21:39Z")

</div>

Yes, I see. GroundPrimitives only work with color materials, see [this GitHub issue](https://github.com/AnalyticalGraphicsInc/cesium/issues/5025). Their materials can have an alpha value and can be swapped out in a callback function, but I can see how that wouldn’t serve your needs here.

There’s been some work done in [this branch](https://github.com/AnalyticalGraphicsInc/cesium/compare/ground-primitive-tex-coords) on getting other materials working, and I’ll add a comment in the GitHub issue that this feature was requested again.

Thanks,

Gabby
