play(id) {
this.isplay = !this.isplay;
if (!this.isplay) {
//播放
let para = {
parentId: id,
};
this.axios({
method: "post",
url: "/fzgh/tdPathNavigation/list",
params: para,
}).then((res) => {
var viewList = [];
res.data.forEach((item) => {
viewList.push({
x: Number(item.x),
y: Number(item.y),
z: Number(item.z),
speed: Number(item.speed),
roll: Number(item.roll),
pitch: Number(item.pitch),
heading: Number(item.heading),
distance: Number(item.distance),
});
});
let arrivedStopNum = 0;
window.flyManager.stopArrived.addEventListener((routeStop) => {
routeStop.waitTime = 0.1; //修改站点的停留时间
arrivedStopNum += 1;
if (arrivedStopNum === viewList.length - 1) {
this.playEnd();
}
});
window.flyManager.readyPromise.then(() => {
var route = window.flyManager.currentRoute;
route.isLineVisible = false;
route.isStopVisible = false;
window.flyManager.currentIndex = 1; //飞行路线可以添加多个route,设置索引来加载不同的路线
for (var k = 0; k < viewList.length; k++) {
var position = Cesium.Cartesian3.fromDegrees(
viewList[k].x,
viewList[k].y,
viewList[k].z
);
var routeStop = new Cesium.RouteStop({
point: position,
heading: viewList[k].heading,
tilt: Cesium.Math.toRadians(viewList[k].pitch),
stopName: "站" + k,
speed: viewList[k].speed,
waitTime: 1,
});
route.addStop(routeStop);
}
window.flyManager && window.flyManager.play();
});
});
} else {
window.flyManager && window.flyManager.pause();
}
},