From ca62ae43d7614216e5d43dd905fde1fd4a260158 Mon Sep 17 00:00:00 2001
From: jihongshun <1151753686@qq.com>
Date: 星期一, 28 七月 2025 17:25:33 +0800
Subject: [PATCH] 视锥体支持变倍

---
 src/utils/components/init-map.vue                            |  152 ++++++++++++++++++++++++++++++++++++++++++++------
 src/views/system/shootPoint/components/chooseModelDialog.vue |    4 
 2 files changed, 135 insertions(+), 21 deletions(-)

diff --git a/src/utils/components/init-map.vue b/src/utils/components/init-map.vue
index 2184ae1..6cb1d61 100644
--- a/src/utils/components/init-map.vue
+++ b/src/utils/components/init-map.vue
@@ -4,15 +4,42 @@
     <div ref="cesiumContainer" id="cesiumContainer"></div>
     <!-- 鐩告満瑙嗚瀹瑰櫒 -->
     <div ref="cesiumCamera" id="cesiumCamera"></div>
+    <div class="zoom-ui-container" @wheel="handleWheel">
+       <!-- 涓棿榛勮壊鍑嗘槦妗� -->
+    <div
+      class="reticle"
+      :style="{ width: boxWidth + 'px', height: boxHeight + 'px' }"
+    ></div>
+
+    <!-- 浣跨敤 ElementUI 鐨� Slider 鏇夸唬鍙樺�嶈酱 -->
+    <div class="zoom-bar-slider">
+      <el-slider
+        v-model="zoomRatio"
+        vertical
+        height="200px"
+        :min="minZoom"
+        :max="maxZoom"
+        :step="0.1"
+        :format-tooltip="formatTooltip"
+        :marks="marks"
+        @input="onSliderInput"
+      />
+    </div>
+
+      <!-- 宸︿笅瑙掑�嶇巼淇℃伅 -->
+      <div class="zoom-info">
+        <el-tag type="success">鍊嶇巼: {{ zoomRatio.toFixed(1) }}X</el-tag>
+      </div>
+    </div>
+
+    
+    
     <!-- botton -->
     <div class="cesiumBotton">
       <div class="cesiumButtonGroup">
         <el-button id="groundPoi" @click="addGroundPoi()" type="primary">鍦伴潰鐐�</el-button>
-        <!-- <el-button id="groundPoi" @click="addGroundPoi()" type="primary">鍋滅暀鏃堕棿</el-button> -->
         <el-input v-model="mergeNumber" placeholder="璇疯緭鍏ュ悎骞惰寖鍥�" type="number" style="width: 150px;"></el-input>
         <el-button  @click="mergePoint()" type="success">鍚堝苟</el-button>
-        <el-button  @click="renderData()" type="success">鏁版嵁娓叉煋</el-button>
-
       </div>
       <!-- <div class="key-container">
         <div class="arrow-row">
@@ -132,10 +159,29 @@
         mergeNumber:null,
         activeKey: null,
         timer: null,
+        zoomRatio: 1,
+        minZoom: 1,
+        maxZoom: 56,
+        baseBoxSize: 400,
+        marks: {
+          1: '1X',
+          7: '7X',
+          14: '14X',
+          28: '28X',
+          56: '56X'
+        }
     }
   },
   mounted(){
      this.initCesium();
+  },
+  computed: {
+    boxWidth() {
+      return this.baseBoxSize / this.zoomRatio;
+    },
+    boxHeight() {
+      return (this.baseBoxSize * 0.75) / this.zoomRatio; // 楂樺害淇濇寔 4:3 姣斾緥
+    }
   },
   beforeDestroy() {
     counter = 0
@@ -365,6 +411,7 @@
                 const distance1 = Cesium.Cartesian3.distance(point1, point2)
                 console.log(distance1)
                 data.distance = distance1
+                _this.zoomRatio = 1
                 _this.createVideoScope(data)
                 setTimeout(() => {
                   viewerC.camera.changed.addEventListener(_this.onCameraChange)
@@ -677,9 +724,6 @@
     cammove_measure_point(){
       CesiumSurvey.cammeasureMovePoint(viewerC,'cammoveResultCon');
     },
-    renderData(){
-        this.$emit('renderData',viewerM)
-    },
     mergePoint(){
       let allEntities = viewerM.entities.values; // 鎵�鏈夊疄浣撳璞$粍鎴愮殑鏁扮粍
       const grouped = {};
@@ -789,7 +833,7 @@
           roll: Cesium.Math.toRadians(0),
         });
         let frustum = new Cesium.PerspectiveFrustum({
-          fov: Cesium.Math.toRadians(6),
+          fov: Cesium.Math.toRadians(1),
           aspectRatio: Number(1.77778), // 瀹介珮姣�
           near: Number(0.05), // 璁惧鐒﹁窛
           far: Number(data.distance), // 鎷嶆憚璺濈
@@ -902,7 +946,7 @@
       console.log(chooseId)
       preVideoScopePrimitiveArrTie.map((item)=>{
         if(item.id == chooseId){
-          let obj = this.updateSZScope(Cesium.Math.toDegrees(position.longitude),Cesium.Math.toDegrees(position.latitude),position.height,heading,pitch,roll,1,distanceBetween)
+          let obj = this.updateSZScope(Cesium.Math.toDegrees(position.longitude),Cesium.Math.toDegrees(position.latitude),position.height,heading,pitch,roll,this.zoomRatio,distanceBetween)
           item.primitive.inverseViewMatrix = obj.M
           item.primitive.frustum = obj.F
         }
@@ -933,6 +977,24 @@
       console.log(inverseViewMatrixNew)
       return {M: inverseViewMatrixNew, F: frustum};
     },
+    handleWheel(event) {
+      const delta = event.deltaY;
+      const step = 0.5;
+      if (delta > 0) {
+        this.zoomRatio = Math.min(this.zoomRatio + step, this.maxZoom);
+      } else {
+        this.zoomRatio = Math.max(this.zoomRatio - step, this.minZoom);
+      }
+      this.onCameraChange()
+    },
+    formatTooltip(val) {
+      if(val){
+        return `${val.toFixed(1)}X`;
+      }
+    },
+    onSliderInput(val) {
+      this.zoomRatio = val;
+    }
   }
 }
 </script>
@@ -945,20 +1007,23 @@
 #cesiumContainer {
     margin: 0;
     padding: 0;
-    width: 60%;
+    width: 73%;
     height: calc(100vh - 205px);
 }
 #cesiumCamera {
     position: absolute;
     z-index: 2;
     background-color: rgba(47, 53, 60, 1);
-    padding: 0 5px;
-    right: 0px;
-    top: 0px;
+    /* padding: 0 5px; */
+    right: 10px;
+    /* top: 0px; */
+    bottom: 80px;
     margin: 0;
-    width: 33%;
-    height:  calc(100vh - 400px);
-    border: 1px solid #000;
+    width: 400px;
+    height: 300px;
+    z-index: 6;
+    /* height:  calc(100vh - 400px); */
+    /* border: 1px solid #000; */
 }
 .cesiumBotton {
     position: absolute;
@@ -967,14 +1032,16 @@
     /* padding: 0 5px; */
     margin-top: 10px;
     right: 0px;
+    width: 420px;
+    height: calc(100vh - 210px);
     bottom: 30px;
     margin: 0;
-    width: 33%;
-    height: calc(30% - 30px);
 }
 .cesiumButtonGroup{
-  margin-top: 10px;
-  margin-left: 10px;
+  position: absolute;
+  bottom: 0;
+  /* margin-top: 10px;
+  margin-left: 10px; */
 }
 .moveResult{position:absolute;z-index:2;background-color:rgba(47,53,60,1);padding:0 5px;right:50%;bottom:30px;
     border:1px solid rgba(255,255,255,.1);box-sizing:content-box;width:220px;height:30px;font-size:14px;text-align:center}
@@ -1029,4 +1096,51 @@
 .key.active {
   background-color: #00aaff;
 }
+</style>
+<style scoped>
+.zoom-ui-container {
+  /* width: 100%;
+  height: 100%;
+  position: relative;
+  background: #1e1e1e; /* 浣犲彲浠ユ浛鎹㈡垚鍥惧儚鎴栬棰戣儗鏅� */
+  /* overflow: hidden; */
+  width: 400px;
+  height: 300px;
+  position: absolute;
+  right: 10px;
+  bottom:80px;
+  /* background-color: red; */
+  z-index: 9;
+
+}
+/* 榛勮壊鍑嗘槦妗� */
+.reticle {
+  position: absolute;
+  left: 50%;
+  top: 50%;
+  border: 2px dashed orange;
+  transform: translate(-50%, -50%);
+  pointer-events: none;
+}
+
+/* ElementUI 婊戝潡鏍峰紡鍖哄煙 */
+.zoom-bar-slider {
+  position: absolute;
+  right: 20px;
+  top: 50px;
+  height: 200px;
+}
+
+/* 宸︿笅瑙掑�嶇巼鏍囩 */
+.zoom-info {
+  position: absolute;
+  bottom: 20px;
+  left: 20px;
+}
+
+</style>
+<style>
+.el-slider.is-vertical .el-slider__marks-text{
+  width: 30px!important;
+}
 </style>
\ No newline at end of file
diff --git a/src/views/system/shootPoint/components/chooseModelDialog.vue b/src/views/system/shootPoint/components/chooseModelDialog.vue
index 320911b..eff4d2b 100644
--- a/src/views/system/shootPoint/components/chooseModelDialog.vue
+++ b/src/views/system/shootPoint/components/chooseModelDialog.vue
@@ -20,10 +20,10 @@
           <CesiumMap ></CesiumMap>
        </el-col>
      </el-row>
-    <span slot="footer" class="dialog-footer">
+    <!-- <span slot="footer" class="dialog-footer">
       <el-button @click="cancel">鍙� 娑�</el-button>
       <el-button type="primary" @click="dialogVisible = false">纭� 瀹�</el-button>
-    </span>
+    </span> -->
   </el-dialog>
 </template>
 <script>

--
Gitblit v1.9.3