From f41e347a34d2859c149c59691bda6d179b209d44 Mon Sep 17 00:00:00 2001
From: yxl <584911253@qq.com>
Date: 星期三, 22 一月 2025 17:42:53 +0800
Subject: [PATCH] 最新修改

---
 src/assets/js/mapSetFunc.js |  120 +++++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 78 insertions(+), 42 deletions(-)

diff --git a/src/assets/js/mapSetFunc.js b/src/assets/js/mapSetFunc.js
index 2c8d2f9..53959f6 100644
--- a/src/assets/js/mapSetFunc.js
+++ b/src/assets/js/mapSetFunc.js
@@ -13,6 +13,9 @@
       case "aroundPoi":
         this.creatAroundPoi(res);
         break;
+      case "getStrike":
+        this.creatAroundPoi(res);
+        break;
       case "queryRelationship":
         this.creatQueryRelationship(res);
         break;
@@ -24,6 +27,9 @@
         break;
       case "getParam":
         this.addTetrahedron(res);
+        break;
+      case "attackentity":
+        this.addPolyLine(res);
         break;
     }
   },
@@ -395,6 +401,7 @@
     });
     this.addRaderLayer(res);
   },
+  //闆疯揪閬僵鎵弿
   addRaderLayer(res) {
     //闆疯揪閬僵鎵弿锛堣嚜瀹氫箟锛�
     const option = {
@@ -421,7 +428,13 @@
   },
   //瑙嗛敟
   addTetrahedron(res) {
-    res.data.forEach((item,index) => {
+    const modelLayer = mapServer.listData.filter((obj) => {
+      if (obj.name == config.modelLayer) {
+        return obj;
+      }
+    });
+    let ids = [];
+    res.data.forEach((item, index) => {
       const tetrahedron = earthCtrl.factory.addTetrahedron({
         position: {
           lon: item.lontitude,
@@ -429,56 +442,74 @@
           height: item.height
         },
         multiple: 0.05,
-        scale: new SmartEarth.Cesium.Cartesian3(100, 100, 100),
+        scale: new SmartEarth.Cesium.Cartesian3(30, 30, 30),
         color: "#FF0000",
         outlineColor: "#FF0000"
       });
       if (index == 0) {
-        earthCtrl.camera.flyTo(item.lontitude, item.lattitude, 5000, 0, -90, 0, 2);
-        const modelLayer = mapServer.listData.filter((obj) => {
-          if (obj.name == config.modelLayer) {
-            return obj;
-          }
+        // 灏嗙粡绾害杞崲涓篊artesian3鍧愭爣
+        const position = Cesium.Cartesian3.fromDegrees(item.lontitude, item.lattitude - 0.01, 500);
+        // 鍒涘缓涓�涓竟鐣岀悆 (Bounding Sphere)锛屽亣璁惧崐寰勪负500
+        const boundingSphere = new Cesium.BoundingSphere(position, 1000);
+        // 浣跨敤 flyToBoundingSphere 瀹氫綅鐩告満
+        earthCtrl.viewer.camera.flyToBoundingSphere(boundingSphere, {
+          duration: 3.0,  // 椋炶鐨勬椂闂�
+          offset: new Cesium.HeadingPitchRange(0, Cesium.Math.toRadians(-30), 6.28316028073749),
         });
-        // debugger
-        if (modelLayer.length <= 0) return;
-        // earthCtrl.userScene.flyTo(modelLayer[0].layer);
-        // modelLayer[0].layer.style = new Cesium.Cesium3DTileStyle({
-        //   color: {
-        //     evaluateColor: (feature) => {
-        //       const id = feature.getProperty("id");
-        //       // if (id === 'de9b9f1f-bea5-11ef-bbd1-ac82473c08a6') {
-        //       //   debugger
-        //       //   // const boundingVolume = feature.tileset.root.boundingVolume
-        //       //   // const center = Cesium.BoundingVolume.computeBoundingVolume(boundingVolume, feature.tileset.root.transform);
-        //       //   // debugger
-        //       //   earthCtrl.viewer.camera.flyTo({
-        //       //     destination: center,
-        //       //     duration: 2.0
-        //       //   });
-        //       //   // earthCtrl.userScene.flyTo(feature);
-        //       //   // return new SmartEarth.Cesium.Color.fromCssColorString(
-        //       //   //   '#FF0000'
-        //       //   // );
-        //       // }
-        //       // console.log("id**********", id);
-        //       // const color = res.filter((item) => {
-        //       //   if (item.ids.indexOf(id) > -1) {
-        //       //     return item;
-        //       //   }
-        //       // });
-        //       // if (color.length > 0) {
-        //         // return new SmartEarth.Cesium.Color.fromCssColorString(
-        //         //   color[0].color
-        //         // );
-        //       // }
-        //     }
-        //   }
-        // });
+        // earthCtrl.camera.flyTo(item.lontitude, item.lattitude, 5000, 0, -90, 0, 2);
       }
+      ids.push(item.uuid);
       this.layerList.push({
         layer: tetrahedron,
         func: 'tetrahedron'
+      });
+    });
+    modelLayer[0].layer.style = new Cesium.Cesium3DTileStyle({
+      color: {
+        evaluateColor: (feature) => {
+          const id = feature.getProperty("id");
+          if (ids.indexOf(id) > -1) {
+            console.log("id**********", id);
+            return new SmartEarth.Cesium.Color.fromCssColorString(
+              '#FF0000'
+            );
+          }
+        }
+      }
+    });
+  },
+
+  //缁樺埗绾�
+  addPolyLine(res) {
+    // 瑙f瀽 LINESTRING 瀛楃涓蹭负缁忕含搴﹀潗鏍囨暟缁�
+    const coordinates = res.bombpoint
+      .replace("LINESTRING", "") // 鍘婚櫎 'LINESTRING' 閮ㄥ垎
+      .replace(/[()]/g, "") // 鍘婚櫎鎷彿
+      .split(",") // 鎸夐�楀彿鍒嗗壊
+      .map(coord => {
+        const [lon, lat] = coord.trim().split(" "); // 灏嗘瘡瀵瑰潗鏍囧垎寮�
+        return [parseFloat(lon), parseFloat(lat)]; // 杞崲涓烘暟瀛�
+      });
+    const positions = coordinates.map(coord => {
+      return {
+        x: coord[0],
+        y: coord[1],
+        z: 21
+      };
+    });
+    positions.forEach((item,index) => {
+      const particle = earthCtrl.factory.createParticleEffect("flame", item, {
+        translation: SmartEarth.Cesium.Cartesian3.fromElements(0, 0, 0), //骞崇Щ
+        emissionRate: 500,
+        startScale: 15,
+        endScale: 45,
+      });
+      if (index == positions.length/2) {
+        earthCtrl.camera.flyTo(item.x, item.y, 3000, 0, -90, 0, 2);
+      }
+      this.layerList.push({
+        layer: particle,
+        func: 'attackentity'
       });
     })
   },
@@ -535,6 +566,11 @@
         this.layerList.splice(i, 1);
         i--;
       }
+      else if (obj.func == "attackentity") {
+        this.layerList[i].layer.deleteObject();
+        this.layerList.splice(i, 1);
+        i--;
+      }
     }
     if (!window.terrain) {
       window.terrain = earthCtrl.factory.createTerrainLayer({

--
Gitblit v1.9.3