How to make the polygon entity with 2d coordinates over terrain as transparent.

I have drawn a polygon entity with 2d coordinates to display on cesium globe with terrain. When i am flying to the entity, the edges are not transparent, It is covered by terrain. How to make it transparent. I am attaching sandcastle link.

Any Solution for my query???

I think your issue might be to do with the fact that you are placing an unfilled polygon and then setting height to 0 - my understanding is setting height to 0 disables the clamp to ground.

If you set a material that is not fully transparent then the polygon will clamp to the terrain, so setting:

material: Cesium.Color.WHITE.withAlpha(0.2)


And also removing:

height: 0


Will result in your polygon clamping to the ground.

If you want to have the effect of an unfilled polygon being clamped to the ground then you could use a polyline instead, something like:

polyline: {
positions: Cesium.Cartesian3.fromDegreesArray(Coordinates),
clampToGround: true,
width: 3,
material: new Cesium.PolylineOutlineMaterialProperty({
color : Cesium.Color.WHITE,
outlineWidth : 1,
outlineColor : Cesium.Color.BLACK


Something like that should give you the effect you need, you will need to remember to add some additional coordinates into your array in order to create the closing line of the rectangle.


Thanks for your reply,I am also using the same polyline concept idea till now in my application. But Actually what i want is that when i am drawing the polygon on the terrain the outline of the polygon should be like transparent like the concept of polyline outline material property and similarly the material also transparent(Screenshot attached with filename expected.jpg).

When i am using the material: Cesium.Color.WHITE.withAlpha(0.2) and height =0, the polygon i am drawing is tracing the buildings which is my area of interest and outline is completely missing. I am attaching screenshot with filename clamptoground.jpg.

when i am using perposition height concept, the outline and the material is going inside the terrain and buildings. I am attaching the screenshot with filename perpositionheight.jpg.

Any help to resolve this issue please.

Thanks and regards