cesium已知两个点 写一个简单具有动画尾迹效果的抛物线

// 定义起点和终点的经纬度和高度
var start = {
longitude: 111.09683723811149,
latitude: 38.92112250636146,
elevation: 603.5831692856873
};

var end = {
longitude: 111.09769465526689,
latitude: 38.92815375977821,
elevation: 627.0132157062261
};
// 生成更多的中间点
function generateIntermediatePoints(start, end, numPoints) {
var positions = [];
for (var i = 0; i <= numPoints; i++) {
var t = i / numPoints;
var longitude = Cesium.Math.lerp(start.longitude, end.longitude, t);
var latitude = Cesium.Math.lerp(start.latitude, end.latitude, t);
// 使用二次方程来增加中间点的高度以形成抛物线
var elevation = Cesium.Math.lerp(start.elevation, end.elevation, t) + (1 - Math.pow(2 * t - 1, 2)) * 200;
positions.push(longitude, latitude, elevation);
}
return positions;
}

// 创建位置数组,包含更多的中间点
var positions = generateIntermediatePoints(start, end, 50); // 50个中间点

// 添加尾迹线
let poly = this.viewer.entities.add({
id: ‘trail-line’ + start.latitude,
description: ‘trail-line’,
polyline: {
width: 5,
positions: Cesium.Cartesian3.fromDegreesArrayHeights(positions),
material: new Cesium.PolylineTrailMaterialProperty({
color: Cesium.Color.fromCssColorString(“rgba(95, 241, 250, 1.0)”),
trailLength: 0.8,
period: 3.0
})
}
});
this.viewer.zoomTo(poly)

最近更新

  1. TCP协议是安全的吗?

    2024-06-10 11:26:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-10 11:26:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-10 11:26:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-10 11:26:02       18 阅读

热门阅读

  1. Git常用命令

    2024-06-10 11:26:02       9 阅读
  2. python-win10跑通chattts笔记(亲测可跑)0.8.010

    2024-06-10 11:26:02       9 阅读
  3. 列举常见的SQL语句

    2024-06-10 11:26:02       10 阅读
  4. 谈谈 Tomcat 连接器

    2024-06-10 11:26:02       7 阅读
  5. 2024年城市客运安全员考试题库及答案

    2024-06-10 11:26:02       9 阅读