|
|
@@ -14,6 +14,32 @@
|
|
|
<span>{{ Resource.flyRoute }}</span>
|
|
|
<input type="file" accept=".fpf" id="flyFile" style="width: 100%" />
|
|
|
</div>
|
|
|
+ <div class="sm-function-module-sub-section">
|
|
|
+ <label class="label-container">{{ Resource.flySpeed }}</label>
|
|
|
+ <div class="sm-solider-input-box">
|
|
|
+ <input
|
|
|
+ class="min-solider"
|
|
|
+ min="1"
|
|
|
+ max="1000"
|
|
|
+ step="1"
|
|
|
+ style="width: 63%"
|
|
|
+ type="range"
|
|
|
+ v-model="flySpeed"
|
|
|
+ @change="updateFlySpeed"
|
|
|
+ />
|
|
|
+ <input
|
|
|
+ class="min-solider"
|
|
|
+ min="1"
|
|
|
+ max="1000"
|
|
|
+ step="1"
|
|
|
+ style="width: 34%"
|
|
|
+ type="number"
|
|
|
+ v-model="flySpeed"
|
|
|
+ @change="updateFlySpeed"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
<div class="flybox">
|
|
|
<i
|
|
|
class="el-icon-video-play flyBtn"
|
|
|
@@ -291,7 +317,7 @@
|
|
|
</TabPane>
|
|
|
</Tabs>
|
|
|
</div>
|
|
|
-</template>
|
|
|
+</template>
|
|
|
|
|
|
<script>
|
|
|
let flyManager,
|
|
|
@@ -321,6 +347,14 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ // 新增飞行速度变量,默认200
|
|
|
+ flySpeed: 200,
|
|
|
+ // 记录当前飞行状态用于速度调整
|
|
|
+ currentFlightState: {
|
|
|
+ isPaused: false,
|
|
|
+ currentStopIndex: 0,
|
|
|
+ progress: 0, // 记录在当前段的飞行进度(0-1)
|
|
|
+ },
|
|
|
sharedState: store.state,
|
|
|
stopSelected: [],
|
|
|
stopFlyCircle: false,
|
|
|
@@ -467,9 +501,9 @@ export default {
|
|
|
});
|
|
|
if (flyManager.readyPromise) {
|
|
|
Cesium.when(flyManager.readyPromise, function () {
|
|
|
- let currentRoute = flyManager.currentRoute;
|
|
|
- currentRoute.isLineVisible = true;
|
|
|
- currentRoute.isStopVisible = true;
|
|
|
+ // let currentRoute = flyManager.currentRoute;
|
|
|
+ // currentRoute.isLineVisible = false;
|
|
|
+ // currentRoute.isStopVisible = true;
|
|
|
|
|
|
let allStops = flyManager.getAllRouteStops();
|
|
|
let menu = document.getElementById("stopList");
|
|
|
@@ -497,55 +531,126 @@ export default {
|
|
|
camera.flyCircleLoop = true;
|
|
|
},
|
|
|
flyStart() {
|
|
|
- if (flyManager && this.routeSpeed !=0) {
|
|
|
+ if (flyManager) {
|
|
|
+ // 如果是从暂停状态恢复,保持当前速度
|
|
|
flyManager.play();
|
|
|
- } else {
|
|
|
- let routes = new Cesium.RouteCollection(viewer.entities);
|
|
|
- let fileInput = document.getElementById("flyFile");
|
|
|
- let file = fileInput.files[0];
|
|
|
- if (!file) {
|
|
|
- return; // 没有选择fpf文件无法开始执行
|
|
|
- }
|
|
|
- let reader = new FileReader();
|
|
|
- reader.onload = function (e) {
|
|
|
- // 读取操作完成时出发
|
|
|
- let XMLContent = e.target.result;
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- routes.fromXML(XMLContent);
|
|
|
- };
|
|
|
- reader.readAsBinaryString(file);
|
|
|
- //创建飞行管理对象
|
|
|
+ // 新创建飞行管理器时设置初始速度
|
|
|
+ let routes = new Cesium.RouteCollection(viewer.entities);
|
|
|
+ let fileInput = document.getElementById("flyFile");
|
|
|
+ let file = fileInput.files[0];
|
|
|
+ if (!file) return;
|
|
|
+
|
|
|
+ let reader = new FileReader();
|
|
|
+ reader.onload = (e) => {
|
|
|
+ let XMLContent = e.target.result;
|
|
|
+ routes.fromXML(XMLContent);
|
|
|
+
|
|
|
+ // 创建飞行管理对象时设置速度
|
|
|
flyManager = new Cesium.FlyManager({
|
|
|
scene: scene,
|
|
|
routes: routes,
|
|
|
+ speed: this.flySpeed, // 设置初始速度
|
|
|
+ });
|
|
|
+
|
|
|
+ // 监听站点到达事件,更新当前状态
|
|
|
+ flyManager.stopArrived.addEventListener((routeStop) => {
|
|
|
+ this.currentFlightState.currentStopIndex = routeStop.index;
|
|
|
+ this.currentFlightState.progress = 0;
|
|
|
});
|
|
|
- flyManager.stopArrived.addEventListener(function (routeStop) {
|
|
|
- routeStop.waitTime = 1;
|
|
|
+
|
|
|
+ // 监听飞行进度事件,更新当前进度
|
|
|
+ flyManager.update.addEventListener((progress) => {
|
|
|
+ this.currentFlightState.progress = progress;
|
|
|
});
|
|
|
+
|
|
|
+ // 原有就绪逻辑
|
|
|
if (flyManager.readyPromise) {
|
|
|
- Cesium.when(flyManager.readyPromise, function () {
|
|
|
- let currentRoute = flyManager.currentRoute;
|
|
|
- currentRoute.isLineVisible = true;
|
|
|
- currentRoute.isStopVisible = true;
|
|
|
-
|
|
|
- let allStops = flyManager.getAllRouteStops();
|
|
|
- let menu = document.getElementById("stopList");
|
|
|
- for (let i = 0, j = allStops.length; i < j; i++) {
|
|
|
- let option = document.createElement("option");
|
|
|
- option.textContent = Resource.stop + (i + 1);
|
|
|
- option.value = allStops[i].index;
|
|
|
- menu.appendChild(option);
|
|
|
- }
|
|
|
+ Cesium.when(flyManager.readyPromise, () => {
|
|
|
+ // 原有站点列表逻辑...
|
|
|
flyManager.play();
|
|
|
});
|
|
|
}
|
|
|
+ };
|
|
|
+ reader.readAsBinaryString(file);
|
|
|
+ },
|
|
|
+
|
|
|
+ // 新增速度更新方法
|
|
|
+ updateFlySpeed() {
|
|
|
+ if (!flyManager) return;
|
|
|
+
|
|
|
+ // 保存当前飞行状态(关键改进:更精确的状态保存)
|
|
|
+ const currentStopIndex = flyManager.currentStopIndex || 0;
|
|
|
+ const nextStopIndex = currentStopIndex + 1;
|
|
|
+ let progressInSegment = 0;
|
|
|
+
|
|
|
+ // 获取当前段的飞行进度(如果支持)
|
|
|
+ if (flyManager.getSegmentProgress) {
|
|
|
+ progressInSegment = flyManager.getSegmentProgress() || 0;
|
|
|
+ }
|
|
|
+ const isPlaying =
|
|
|
+ flyManager.isPaused !== undefined ? !flyManager.isPaused : false;
|
|
|
+
|
|
|
+ // 1. 更新当前路线速度(不重建路线,直接修改现有实例)
|
|
|
+ const currentRoute = flyManager.currentRoute;
|
|
|
+ if (currentRoute) {
|
|
|
+ currentRoute.speed = this.flySpeed;
|
|
|
+
|
|
|
+ // 2. 更新所有站点速度
|
|
|
+ let allStops = [];
|
|
|
+ if (
|
|
|
+ flyManager.getAllRouteStops &&
|
|
|
+ typeof flyManager.getAllRouteStops === "function"
|
|
|
+ ) {
|
|
|
+ allStops = flyManager.getAllRouteStops() || [];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修复length错误:确保是数组才遍历
|
|
|
+ if (Array.isArray(allStops)) {
|
|
|
+ allStops.forEach((stop) => {
|
|
|
+ if (stop && typeof stop.speed !== "undefined") {
|
|
|
+ stop.speed = this.flySpeed;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 不重建路线,而是调整当前飞行参数(关键改进)
|
|
|
+ if (isPlaying) {
|
|
|
+ flyManager.pause();
|
|
|
+
|
|
|
+ // 仅在有下一个站点时调整进度,避免从头开始
|
|
|
+ if (nextStopIndex < allStops.length) {
|
|
|
+ flyManager.goToStop(currentStopIndex);
|
|
|
+ // 如果支持设置段内进度,精确恢复位置
|
|
|
+ if (flyManager.setSegmentProgress) {
|
|
|
+ flyManager.setSegmentProgress(progressInSegment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ flyManager.play();
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
flyPause() {
|
|
|
- flyManager && flyManager.pause();
|
|
|
+ if (flyManager) {
|
|
|
+ flyManager.pause();
|
|
|
+ this.currentFlightState.isPaused = true;
|
|
|
+ }
|
|
|
},
|
|
|
+
|
|
|
+ // 停止方法
|
|
|
flyStop() {
|
|
|
- flyManager && flyManager.stop();
|
|
|
+ if (flyManager) {
|
|
|
+ flyManager.stop();
|
|
|
+ // 重置飞行状态
|
|
|
+ this.currentFlightState = {
|
|
|
+ isPaused: false,
|
|
|
+ currentStopIndex: 0,
|
|
|
+ progress: 0,
|
|
|
+ };
|
|
|
+ }
|
|
|
},
|
|
|
onSpinClk(evt) {
|
|
|
this.isDestroyFlag = false;
|
|
|
@@ -734,11 +839,7 @@ export default {
|
|
|
saveStop() {
|
|
|
if (this.state.routeStops.length < 2) {
|
|
|
if (this.state.customRouteNames.length == 0) {
|
|
|
- // notification.create({
|
|
|
- // content: () => ("至少两个节点才能保存"),
|
|
|
- // duration: 3500,
|
|
|
- // });
|
|
|
- this.$message.waring("至少两个节点才能保存");
|
|
|
+ this.$message.warning("至少两个节点才能保存");
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
@@ -810,6 +911,7 @@ export default {
|
|
|
routes: routeCollection,
|
|
|
});
|
|
|
createXml = new createFlyLine_xml();
|
|
|
+ this.flySpeed = 200; // 设置初始速度
|
|
|
},
|
|
|
|
|
|
// 操作切换
|
|
|
@@ -944,7 +1046,7 @@ export default {
|
|
|
if (newValue != oldValue && newValue != 0) {
|
|
|
this.saveStop();
|
|
|
this.flyStart(); //开始
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this.flyStop();
|
|
|
}
|
|
|
},
|