Poyline through mountain / under terrain?

Hi,

i have a line which goes through a mountain - is it possible to draw the whole line, i.e. the part in the mountain with a different color ?

Rüdiger

Hi @Ruediger_Brand.

One simple workaround would be to use three lines rather than one. The middle line segment would go through the mountain and could be colored differently than the other two segments. I think this would likely be the easiest solution.

Best,
Sam

@sam.rothstein

But in which way do I get the line-segments ?

I would like to achieve something like in the screenshot:

Rüdiger

Hi @Ruediger_Brand,

you could use the depthFailMaterial for that. It just dont work with dynamic polylines.

Look at this code snippet. You can use a simple color or, as I did, some other stuff like a dashed line.

let entity = viewer.entities.add({
  polyline: {
    positions: [Cesium.Cartesian3.fromDegrees(point1.lon, point1.lat, point1.height), Cesium.Cartesian3.fromDegrees(point2.lon, point2.lat, point2.height)],
    width: 2.0,
    material: color,
    depthFailMaterial: new Cesium.PolylineDashMaterialProperty({
      color: color
    })
  }
});

Best, Lennart

2 Likes

Hi @lennart.imberg! Thank you for the suggestions. This seems like a much more elegant approach.

I would do something like this;

material: new Cesium.PolylineOutlineMaterialProperty({
   color: color,
   outlineColor: Cesium.Color.LIGHTGREY.withAlpha(0.4)
}),
depthFailMaterial: new Cesium.PolylineOutlineMaterialProperty({
   color: Cesium.Color.LIGHTGREY.withAlpha(0.4),
   outlineColor: Cesium.Color.LIGHTGREY.withAlpha(0.4)
}),

Adjust as you like.

Cheers,

Alex

@sam.rothstein @Alexander_Johannesen @lennart.imberg

This is a great idea, I have to try, first experiences are super

former solution:

new

Great

Rüdiger

1 Like

Hi @Ruediger_Brand, this looks amazing! Thanks for sharing :grin: