Browse Source

去掉控制版

wandequan 2 years ago
parent
commit
3772210581
5 changed files with 250 additions and 59 deletions
  1. 67 0
      package-lock.json
  2. 1 0
      package.json
  3. 130 35
      src/components/MainMap.vue
  4. 51 23
      src/components/Tool.vue
  5. 1 1
      src/views/Home.vue

+ 67 - 0
package-lock.json

@@ -10,6 +10,7 @@
       "dependencies": {
         "amfe-flexible": "^2.2.1",
         "axios": "^0.27.2",
+        "clipboard": "^2.0.11",
         "core-js": "^3.8.3",
         "moment": "^2.29.4",
         "vant": "^3.6.2",
@@ -3795,6 +3796,16 @@
         "node": ">=6"
       }
     },
+    "node_modules/clipboard": {
+      "version": "2.0.11",
+      "resolved": "https://registry.npmmirror.com/clipboard/-/clipboard-2.0.11.tgz",
+      "integrity": "sha512-C+0bbOqkezLIsmWSvlsXS0Q0bmkugu7jcfMIACB+RDEntIzQIkdr148we28AfSloQLRdZlYL/QYyrq05j/3Faw==",
+      "dependencies": {
+        "good-listener": "^1.2.2",
+        "select": "^1.1.2",
+        "tiny-emitter": "^2.0.0"
+      }
+    },
     "node_modules/clipboardy": {
       "version": "2.3.0",
       "resolved": "https://registry.npmmirror.com/clipboardy/-/clipboardy-2.3.0.tgz",
@@ -4645,6 +4656,11 @@
         "node": ">=0.4.0"
       }
     },
+    "node_modules/delegate": {
+      "version": "3.2.0",
+      "resolved": "https://registry.npmmirror.com/delegate/-/delegate-3.2.0.tgz",
+      "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw=="
+    },
     "node_modules/depd": {
       "version": "2.0.0",
       "resolved": "https://registry.npmmirror.com/depd/-/depd-2.0.0.tgz",
@@ -5424,6 +5440,14 @@
         "node": ">=10"
       }
     },
+    "node_modules/good-listener": {
+      "version": "1.2.2",
+      "resolved": "https://registry.npmmirror.com/good-listener/-/good-listener-1.2.2.tgz",
+      "integrity": "sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==",
+      "dependencies": {
+        "delegate": "^3.1.2"
+      }
+    },
     "node_modules/graceful-fs": {
       "version": "4.2.10",
       "resolved": "https://registry.npmmirror.com/graceful-fs/-/graceful-fs-4.2.10.tgz",
@@ -8451,6 +8475,11 @@
         "node": ">= 8.9.0"
       }
     },
+    "node_modules/select": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmmirror.com/select/-/select-1.1.2.tgz",
+      "integrity": "sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA=="
+    },
     "node_modules/select-hose": {
       "version": "2.0.0",
       "resolved": "https://registry.npmmirror.com/select-hose/-/select-hose-2.0.0.tgz",
@@ -9169,6 +9198,11 @@
       "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==",
       "dev": true
     },
+    "node_modules/tiny-emitter": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmmirror.com/tiny-emitter/-/tiny-emitter-2.1.0.tgz",
+      "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q=="
+    },
     "node_modules/to-fast-properties": {
       "version": "2.0.0",
       "resolved": "https://registry.npmmirror.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
@@ -13065,6 +13099,16 @@
       "integrity": "sha512-qu3pN8Y3qHNgE2AFweciB1IfMnmZ/fsNTEE+NOFjmGB2F/7rLhnhzppvpCnN4FovtP26k8lHyy9ptEbNwWFLzw==",
       "dev": true
     },
+    "clipboard": {
+      "version": "2.0.11",
+      "resolved": "https://registry.npmmirror.com/clipboard/-/clipboard-2.0.11.tgz",
+      "integrity": "sha512-C+0bbOqkezLIsmWSvlsXS0Q0bmkugu7jcfMIACB+RDEntIzQIkdr148we28AfSloQLRdZlYL/QYyrq05j/3Faw==",
+      "requires": {
+        "good-listener": "^1.2.2",
+        "select": "^1.1.2",
+        "tiny-emitter": "^2.0.0"
+      }
+    },
     "clipboardy": {
       "version": "2.3.0",
       "resolved": "https://registry.npmmirror.com/clipboardy/-/clipboardy-2.3.0.tgz",
@@ -13735,6 +13779,11 @@
       "resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz",
       "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="
     },
+    "delegate": {
+      "version": "3.2.0",
+      "resolved": "https://registry.npmmirror.com/delegate/-/delegate-3.2.0.tgz",
+      "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw=="
+    },
     "depd": {
       "version": "2.0.0",
       "resolved": "https://registry.npmmirror.com/depd/-/depd-2.0.0.tgz",
@@ -14384,6 +14433,14 @@
         "slash": "^3.0.0"
       }
     },
+    "good-listener": {
+      "version": "1.2.2",
+      "resolved": "https://registry.npmmirror.com/good-listener/-/good-listener-1.2.2.tgz",
+      "integrity": "sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==",
+      "requires": {
+        "delegate": "^3.1.2"
+      }
+    },
     "graceful-fs": {
       "version": "4.2.10",
       "resolved": "https://registry.npmmirror.com/graceful-fs/-/graceful-fs-4.2.10.tgz",
@@ -16717,6 +16774,11 @@
         "ajv-keywords": "^3.5.2"
       }
     },
+    "select": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmmirror.com/select/-/select-1.1.2.tgz",
+      "integrity": "sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA=="
+    },
     "select-hose": {
       "version": "2.0.0",
       "resolved": "https://registry.npmmirror.com/select-hose/-/select-hose-2.0.0.tgz",
@@ -17312,6 +17374,11 @@
       "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==",
       "dev": true
     },
+    "tiny-emitter": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmmirror.com/tiny-emitter/-/tiny-emitter-2.1.0.tgz",
+      "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q=="
+    },
     "to-fast-properties": {
       "version": "2.0.0",
       "resolved": "https://registry.npmmirror.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz",

+ 1 - 0
package.json

@@ -9,6 +9,7 @@
   "dependencies": {
     "amfe-flexible": "^2.2.1",
     "axios": "^0.27.2",
+    "clipboard": "^2.0.11",
     "core-js": "^3.8.3",
     "moment": "^2.29.4",
     "vant": "^3.6.2",

+ 130 - 35
src/components/MainMap.vue

@@ -1,44 +1,30 @@
 <template>
   <div id="cesiumContainer">
     <!-- <div class="get_now_camera_view">
-      <van-button @click="getNowCameraPosition"> 当前视角 </van-button>
+      <van-button @click="consoleCameraPosition"> 当前视角 </van-button>
       <van-button @click="setViewDefaultlocation"> 复位 </van-button>
-    </div> -->
-    <!-- <el-dialog
-      title="提示"
-      :visible.sync="dialogVisible"
-      width="30%"
-      :before-close="hideInfoDailog"
-    >
-      <span>{{ dialogInfoStr }}</span>
-      <span slot="footer" class="dialog-footer">
-        <el-button @click="hideInfoDailog">关 闭</el-button>
-        <el-button :class="'copy_info_dialog'" type="primary">复 制</el-button>
-      </span>
-    </el-dialog> -->
-    <!-- get-container="body" -->
-    <Tool></Tool>
+    </div>
     <van-popup
-      v-model="dialogVisible"
-      round
+      v-model:show="dialogVisible"
       :style="{ height: '50%', width: '80%' }"
       :closed="hideInfoDailog"
     >
       <div>
-        <span>{{ dialogInfoStr }}</span>
+        <div style="font-size: 16px">{{ dialogInfoStr }}</div>
         <van-button @click="hideInfoDailog">关 闭</van-button>
         <van-button :class="'copy_info_dialog'" type="primary">
           复 制
         </van-button>
       </div>
-    </van-popup>
+    </van-popup> -->
+
+    <Tool></Tool>
   </div>
 </template>
 
 <script>
 // import Clipboard from "clipboard";
 import { defineAsyncComponent } from "vue";
-// import Tool from "@/components/Tool.vue";
 import Water from "@/utils/Water";
 
 export default {
@@ -135,6 +121,7 @@ export default {
   },
   created() {},
   mounted() {
+    let that = this;
     // this.clipboard = new Clipboard(".copy_info_dialog", {
     //   // 点击copy按钮,直接通过text直接返回复印的内容
     //   text: function () {
@@ -149,8 +136,12 @@ export default {
         this.mainFunc();
         // camera范围限制
         this.bindLimitCameraFunc();
+
         // 取消滑动事件
         this.controlCZ(false);
+
+        // 自定义滑动事件
+        this.wetherScroll(this.changeCamera);
       });
     });
 
@@ -163,6 +154,14 @@ export default {
   },
 
   methods: {
+    consoleCameraPosition() {
+      this.getNowCameraPosition().then((result) => {
+        this.showInfoDailog(
+          JSON.stringify(result.result).replaceAll("{", "").replaceAll("}", "")
+        );
+      });
+    },
+
     initViewer() {
       return new Promise((resolve, reject) => {
         globalVariable.viewer = new Cesium.Viewer("cesiumContainer", {
@@ -235,25 +234,118 @@ export default {
       this.addTree();
     },
 
-    bindCameraNo() {
-      globalVariable.viewer.scene.preUpdate.addEventListener(this.cameraddte);
-    },
-    unbindCamera() {
-      globalVariable.viewer.scene.preUpdate.removeEventListener(this.cameraddte);
+    // bindCameraNo() {
+    //   globalVariable.viewer.scene.preUpdate.addEventListener(this.cameraddte);
+    // },
+    // unbindCamera() {
+    //   globalVariable.viewer.scene.preUpdate.removeEventListener(
+    //     this.cameraddte
+    //   );
+    // },
+    // cameraddte() {
+    //   // 获取当前位置,当前方向,强制禁止X轴、Y轴
+    //   var heading = Cesium.Math.toDegrees(globalVariable.viewer.camera.heading);
+    //   var pitch = Cesium.Math.toDegrees(globalVariable.viewer.camera.pitch); //Cesium.Math.toDegrees作用是把弧度转换成度数
+    //   var roll = Cesium.Math.toDegrees(globalVariable.viewer.camera.roll);
+
+    //   var positionCartesian = globalVariable.viewer.camera.position;
+    //   // var position = Cesium.Cartographic.fromCartesian(positionCartesian);
+    //   // var lon = Cesium.Math.toDegrees(position.longitude);
+    //   // var lat = Cesium.Math.toDegrees(position.latitude);
+    //   // var h = globalVariable.viewer.camera.positionCartographic.height;
+    //   globalVariable.viewer.camera.setView({
+    //     destination: positionCartesian, //赤道上空1000km高度
+    //     orientation: {
+    //       heading: Cesium.Math.toRadians(heading), // 相机方向指向当地东向
+    //       pitch: 0.0, // 再将相机方向转向地心,此时Up方向指向当地东向
+    //       roll: 0.0,
+    //     },
+    //   });
+    // },
+
+    changeCamera(direction) {
+      switch (direction) {
+        case "left":
+          globalVariable.viewer.camera.lookLeft((Math.PI / 180) * 2);
+          break;
+
+        case "right":
+          globalVariable.viewer.camera.lookRight((Math.PI / 180) * 2);
+          break;
+
+        default:
+          break;
+      }
     },
 
-    cameraddte() {
-      globalVariable.viewer.camera
-      // 获取当前位置,当前方向,强制禁止X轴、Y轴
+    wetherScroll(func) {
+      let startX = 0;
+      let startY = 0;
+      let endX = 0;
+      let endY = 0;
+      let distanceX = 0;
+      let distanceY = 0;
+      let body = document.getElementsByTagName("body")[0];
+      var clientHeight = document.documentElement.clientHeight;
+      var clientWidth = document.documentElement.clientWidth;
+      body.addEventListener("touchstart", function (event) {
+        var touch = event.targetTouches[0];
+        //滑动起点的坐标
+        startX = touch.pageX;
+        startY = touch.pageY;
+        // console.log("startX:"+startX+","+"startY:"+startY);
+      });
+      body.addEventListener("touchmove", function (event) {
+        var touch = event.targetTouches[0];
+        //手势滑动时,手势坐标不断变化,取最后一点的坐标为最终的终点坐标
+        endX = touch.pageX;
+        endY = touch.pageY;
+        distanceX = endX - startX;
+        distanceY = endY - startY;
+        if (startX != Math.abs(distanceX)) {
+          //在滑动的距离超过屏幕高度的20%时,做某种操作
+          if (Math.abs(distanceX) > clientWidth * 0.05) {
+            //向下滑实行函数someAction1,向上滑实行函数someAction2
+            //向左滑实行函数someAction1,向右滑实行函数someAction2
+            distanceX < 0 ? func("left") : func("right");
+            startX = endX;
+            startY = endY;
+          }
+        }
+        // console.log("endX:"+endX+","+"endY:"+endY);
+      });
+      body.addEventListener("touchend", function (event) {
+        // distanceX = endX - startX;
+        // distanceY = endY - startY;
+        // // console.log("distanceX:"+distanceX+","+"distanceY:"+distanceY);
+        // //移动端设备的屏幕宽度
+        // var clientHeight = document.documentElement.clientHeight;
+        // // console.log(clientHeight;*0.2);
+        // //判断是否滑动了,而不是屏幕上单击了
+        // if (startY != Math.abs(distanceY)) {
+        //   //在滑动的距离超过屏幕高度的20%时,做某种操作
+        //   if (Math.abs(distanceY) > clientHeight * 0.2) {
+        //     //向下滑实行函数someAction1,向上滑实行函数someAction2
+        //     distanceY < 0 ? someAction1() : someAction2();
+        //   }
+        // }
+        startX = 0;
+        startY = 0;
+        endX = 0;
+        endY = 0;
+        distanceX = 0;
+        distanceY = 0;
+      });
     },
 
     // 禁用/开启 操作
     controlCZ(bool) {
-      globalVariable.viewer.scene.screenSpaceCameraController.enableLook = true;
-
-      globalVariable.viewer.scene.screenSpaceCameraController.enableRotate = true;
-      globalVariable.viewer.scene.screenSpaceCameraController.enableTilt = true;
-      globalVariable.viewer.scene.screenSpaceCameraController.enableTranslate = true;
+      globalVariable.viewer.scene.screenSpaceCameraController.enableLook = bool;
+      globalVariable.viewer.scene.screenSpaceCameraController.enableRotate =
+        bool;
+      globalVariable.viewer.scene.screenSpaceCameraController.enableTilt = bool;
+      globalVariable.viewer.scene.screenSpaceCameraController.enableTranslate =
+        bool;
       globalVariable.viewer.scene.screenSpaceCameraController.enableZoom = bool;
     },
 
@@ -592,6 +684,7 @@ export default {
 
     // 地图(模型上)左击事件
     singleClick2() {
+      let that = this;
       var handler = new Cesium.ScreenSpaceEventHandler(
         globalVariable.viewer.scene.canvas
       );
@@ -613,12 +706,14 @@ export default {
           lat:${lat}
           height:${height}
           `;
-          console.log(
+          that.showInfoDailog(
             JSON.stringify({
               lon: lon,
               lat: lat,
               h: height,
             })
+              .replaceAll("{", "")
+              .replaceAll("}", "")
           );
         }
       }, Cesium.ScreenSpaceEventType.LEFT_CLICK);

+ 51 - 23
src/components/Tool.vue

@@ -17,7 +17,7 @@
       closeable
       close-icon="close"
       :close-on-click-overlay="false"
-      :closed="hideInfoDailog"
+      :closed="hideIndexesInfoDailog"
     >
       <div class="indexesList">
         <div class="header">
@@ -61,6 +61,29 @@
     >
       <div class="pointInfoContent" v-html="pointInfos"></div>
     </van-popup>
+
+    <van-popup
+      v-model:show="sceneShow"
+      class="scene_popup"
+      :style="{ height: '50%', width: '80%', background: 'transparent' }"
+      closeable
+      close-icon="close"
+      :close-on-click-overlay="false"
+      :closed="hideSceneInfoDailog"
+    >
+    
+    </van-popup>
+    <van-popup
+      v-model:show="planeShow"
+      class="plane_popup"
+      :style="{ height: '50%', width: '80%', background: 'transparent' }"
+      closeable
+      close-icon="close"
+      :close-on-click-overlay="false"
+      :closed="hidePlaneInfoDailog"
+    >
+
+    </van-popup>
   </div>
 </template>
 
@@ -72,6 +95,8 @@ export default {
       viewClickHandle: null,
       indexesShow: false,
       pointShow: false,
+      sceneShow: false,
+      planeShow: false,
       pointInfos: "",
       Exection: null,
       cameraInfo: systemConfig.pointInfo.camera,
@@ -107,16 +132,15 @@ export default {
       },
       {
         label: "场景",
-        changeActive: true,
-        active: false,
-        // clickFunc: this.controlCZ,
-        clickFunc: this.undefinedFunction,
+        changeActive: false,
+        active: false, 
+        clickFunc: this.showScene,
       },
       {
         label: "平面图",
         changeActive: false,
         active: false,
-        clickFunc: this.undefinedFunction,
+        clickFunc: this.showPlane,
       },
     ];
     setTimeout(() => {
@@ -139,6 +163,24 @@ export default {
     showIndexes() {
       this.indexesShow = true;
     },
+    // 索引页面关闭
+    hideIndexesInfoDailog() {
+      this.indexesShow = false;
+    },
+    // 展示场景弹窗
+    showScene() {
+      this.sceneShow = true;
+    },
+    hideSceneInfoDailog() {
+      this.sceneShow = false;
+    },
+    // 展示平面图弹窗
+    showPlane() {
+      this.planeShow = true;
+    },
+    hidePlaneInfoDailog() {
+      this.planeShow = false;
+    },
 
     // 漫游
     lookaround(item) {
@@ -245,10 +287,6 @@ export default {
         });
       });
     },
-    // 索引页面关闭
-    hideInfoDailog() {
-      this.indexesShow = false;
-    },
 
     // 加载点位
     loadPoint(param) {
@@ -400,17 +438,7 @@ export default {
     hidePointInfoDailog() {
       this.pointShow = false;
     },
-
-    // 禁用/开启 操作
-    controlCZ(bool) {
-      globalVariable.viewer.scene.screenSpaceCameraController.enableRotate =
-        bool;
-      globalVariable.viewer.scene.screenSpaceCameraController.enableTranslate =
-        bool;
-      globalVariable.viewer.scene.screenSpaceCameraController.enableZoom = bool;
-      globalVariable.viewer.scene.screenSpaceCameraController.enableTilt = bool;
-      globalVariable.viewer.scene.screenSpaceCameraController.enableLook = bool;
-    },
+    
   },
 };
 </script>
@@ -570,7 +598,7 @@ export default {
       }
     }
   }
-  .point_popup {
+  :deep(.point_popup) {
     padding-top: 30px;
     .pointInfoContent {
       width: 100%;
@@ -587,7 +615,7 @@ export default {
       color: #ffffff;
       border-radius: 15px;
     }
-    :deep(.van-popup__close-icon--top-right) {
+    .van-popup__close-icon--top-right {
       top: 0px;
       right: 0px;
     }

+ 1 - 1
src/views/Home.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="home">
     <MainMap></MainMap>
-    <GamePad></GamePad>
+    <!-- <GamePad></GamePad> -->
   </div>
 </template>
 <script>