|
|
@@ -482,6 +482,9 @@ export default {
|
|
|
// MVT点击处理器
|
|
|
mvtClickHandler: null, //MVT点击处理器实例
|
|
|
_hasMvtLayer: false, //是否有MVT图层加载
|
|
|
+ // 模型拆解图标相关
|
|
|
+ sceneModelIconEntity: null, //场景模型拆解图标实体
|
|
|
+ sceneModelIconHandler: null, //场景模型拆解图标点击处理器
|
|
|
};
|
|
|
},
|
|
|
|
|
|
@@ -1502,6 +1505,11 @@ export default {
|
|
|
this.gatePosition = scene.initialGatePosition || 0
|
|
|
console.log('📌 场景启用闸门控制,等待模型加载...')
|
|
|
}
|
|
|
+
|
|
|
+ // 加载模型拆解图标
|
|
|
+ if (scene.modelDisassemblyIcon) {
|
|
|
+ this.addSceneModelIcon(scene.modelDisassemblyIcon)
|
|
|
+ }
|
|
|
|
|
|
ElMessage.success(`已加载固定场景:${scene.sceneName}`)
|
|
|
} catch (error) {
|
|
|
@@ -1531,6 +1539,9 @@ export default {
|
|
|
this.showGateControl = false
|
|
|
this.gatePosition = 0
|
|
|
|
|
|
+ // 移除模型拆解图标
|
|
|
+ this.removeSceneModelIcon()
|
|
|
+
|
|
|
// 清除当前场景ID
|
|
|
this.currentSceneId = null
|
|
|
|
|
|
@@ -2325,9 +2336,6 @@ export default {
|
|
|
await this.restoreLoadedServices();
|
|
|
this.isRestoring = false; // 恢复完成,允许保存
|
|
|
|
|
|
- // 添加模型图标
|
|
|
- this.addModelIcon();
|
|
|
-
|
|
|
// 加载水面图层
|
|
|
this.loadWaterLayers();
|
|
|
}, 1500);
|
|
|
@@ -2347,35 +2355,60 @@ export default {
|
|
|
);
|
|
|
},
|
|
|
|
|
|
- // 添加模型图标到 Cesium 地图
|
|
|
- addModelIcon() {
|
|
|
- if (!window.viewer) return
|
|
|
+ // 添加场景模型拆解图标
|
|
|
+ addSceneModelIcon(config) {
|
|
|
+ if (!window.viewer || !config) return
|
|
|
|
|
|
- const longitude = 119.143770
|
|
|
- const latitude = 25.867679
|
|
|
- const height = 43.80
|
|
|
+ const Cesium = window.Cesium
|
|
|
+
|
|
|
+ // 如果已存在图标,先移除
|
|
|
+ this.removeSceneModelIcon()
|
|
|
|
|
|
// 创建图标实体
|
|
|
const modelIcon = window.viewer.entities.add({
|
|
|
name: '模型拆解',
|
|
|
- position: Cesium.Cartesian3.fromDegrees(longitude, latitude, height),
|
|
|
+ position: Cesium.Cartesian3.fromDegrees(config.longitude, config.latitude, config.height || 0),
|
|
|
billboard: {
|
|
|
- image: '/img/svg/logo.svg', // 使用现有的图标
|
|
|
- width: 32,
|
|
|
- height: 32,
|
|
|
+ image: config.image || '/img/svg/logo.svg',
|
|
|
+ width: config.width || 32,
|
|
|
+ height: config.height || 32,
|
|
|
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
|
|
pixelOffset: new Cesium.Cartesian2(0, -16)
|
|
|
},
|
|
|
description: '点击查看模型拆解'
|
|
|
})
|
|
|
|
|
|
- // 添加点击事件
|
|
|
- window.viewer.screenSpaceEventHandler.setInputAction((movement) => {
|
|
|
+ // 保存实体引用
|
|
|
+ this.sceneModelIconEntity = modelIcon
|
|
|
+
|
|
|
+ // 使用独立的点击处理器(避免覆盖全局点击事件)
|
|
|
+ const handler = new Cesium.ScreenSpaceEventHandler(window.viewer.canvas)
|
|
|
+ handler.setInputAction((movement) => {
|
|
|
const pickedObject = window.viewer.scene.pick(movement.position)
|
|
|
if (Cesium.defined(pickedObject) && pickedObject.id === modelIcon) {
|
|
|
this.showModelDialog = true
|
|
|
}
|
|
|
}, Cesium.ScreenSpaceEventType.LEFT_CLICK)
|
|
|
+
|
|
|
+ // 保存处理器引用
|
|
|
+ this.sceneModelIconHandler = handler
|
|
|
+ },
|
|
|
+
|
|
|
+ // 移除场景模型拆解图标
|
|
|
+ removeSceneModelIcon() {
|
|
|
+ // 移除实体
|
|
|
+ if (this.sceneModelIconEntity) {
|
|
|
+ if (window.viewer) {
|
|
|
+ window.viewer.entities.remove(this.sceneModelIconEntity)
|
|
|
+ }
|
|
|
+ this.sceneModelIconEntity = null
|
|
|
+ }
|
|
|
+
|
|
|
+ // 销毁点击处理器
|
|
|
+ if (this.sceneModelIconHandler) {
|
|
|
+ this.sceneModelIconHandler.destroy()
|
|
|
+ this.sceneModelIconHandler = null
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
// 删除场景公共服务
|