1, 通过选择地球上的点,生成平滑且贴地的路径,但是发现polyline可以通过clampToGround: true属性贴地,path没有贴地属性,path可以通过
entity.position.setInterpolationOptions({
interpolationDegree : 5,
interpolationAlgorithm : GeoVis.LagrangePolynomialApproximation
});
设置插值算法,形成平滑曲线,polyline不可以。
2,解决办法: 可以先利用path获取插值后的position,然后把这个position赋值给polyline,再设置贴地:
这个是利用path获取插值后的position代码:
cumputePosition(){
var paths = viewer.entities.add({
position: positionProperty,
path: {
resolution: 1,
material: new GeoVis.PolylineGlowMaterialProperty({
glowPower: 0.1,
color: GeoVis.Color.YELLOW
}),
width: 10
}
});
paths.position.setInterpolationOptions({
interpolationDegree: 5,
interpolationAlgorithm: this.interpolation()
});
var newPosition = [];
for (var now = startTime; now < endTime; ) { // 这个startTime和endTIme都是你自己规定的JulianDate
var posi = paths.position.getValue(now);
var pos = new GeoVis.Cartesian3(posi.x, posi.y, posi.z);
newPosition.push(pos); // 把所有的坐标放到newPosition数组中
now = GeoVis.JulianDate.addSeconds(now, 1, new GeoVis.JulianDate());
}
viewer.entities.remove(paths);
return newPosition
}
这个是将绘制polyline贴地的代码:
var lastPosition = this.cumputePosition();
polyline = earth.entities.add({
position: lastPosition,
polyline: {
clampToGround: true,
positions: lastPosition,
material: new GeoVis.PolylineGlowMaterialProperty({
glowPower: 0.1,
color: GeoVis.Color.YELLOW
}),
width: 10
},
});