Polyline with two points. Achieve one point follow the terrain surface, and the other has elevation?

132 views
Skip to first unread message

Hongyi Sun

unread,
Aug 31, 2018, 3:46:26 AM8/31/18
to cesium-dev
1. A concise explanation of the problem you're experiencing.
hi. This is my first time to ask questions at this group. Thank you for your contribution to the Cesium project.
i want to draw polyline with two points. How to draw it with one point  follow the terrain surface(without elevation), and the other point has elevation. 


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

var fieldPath = viewer.entities.add({
name : uav.uavNum + ' view field path',
polyline : {
positions : new Cesium.CallbackProperty(function() {
return [uavUpdateInfo[uav.uavNum]['pos'], viewFieldGlobalPositions[uav.uavNum]]
}, false),
material : Cesium.Color.BLUE.withAlpha(0.5),
outline : false,
width: 2,
outlineColor : Cesium.Color.BLACK,
granularity: Cesium.Math.toRadians(0.5),
}
});

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
uav emits the laser at about 2km above the terrain, i want to draw a line from uav to the emit center(terrain surface)


4. The Cesium version you're using, your operating system and browser.
cesium 1.48.  win7.  Chrome


Scott Reynolds

unread,
Sep 2, 2018, 11:40:01 AM9/2/18
to cesium-dev
The responses to this should help if I understand your question.

Scott

Omar Shehata

unread,
Sep 2, 2018, 12:33:24 PM9/2/18
to cesium-dev
Thanks for the link Scott! I was already looking at this so I'll add my thoughts as well:

If your ground position does not move, I think the easiest way would be to use sampleTerrainMostDetailed to get the terrain height at that location and use that as the second point in your polyline like in this Sandcastle example.

If your ground location is changing however, my approach was to use a point that's clamped to ground, and take its position as the polyline's second point (and then make that point invisible). Unfortunately, there's no way to do that with the public API. I opened an issue here to discuss it:


I also included an example of what it would look like.

Hongyi Sun

unread,
Sep 3, 2018, 9:55:26 PM9/3/18
to cesium-dev
i will try. Thank you

在 2018年9月2日星期日 UTC+8下午11:40:01,Scott Reynolds写道:

Hongyi Sun

unread,
Sep 3, 2018, 10:06:49 PM9/3/18
to cesium-dev
Thanks for the Sandcastle demo. Awesome. There should be a high level api to do this.
Reply all
Reply to author
Forward
0 new messages