From 2eeaa4693e7389df008b6763074c48e9ffa367ca Mon Sep 17 00:00:00 2001
From: guonan <guonan201020@163.com>
Date: 星期四, 17 四月 2025 15:23:57 +0800
Subject: [PATCH] 更新雨

---
 src/utils/tools.js |   35 ++++++++++++++++++++++++++---------
 1 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/src/utils/tools.js b/src/utils/tools.js
index 9b23612..6604c70 100644
--- a/src/utils/tools.js
+++ b/src/utils/tools.js
@@ -2,6 +2,7 @@
 // import cameraIcon from "../assets/images/base/瑙嗛娴嬬偣.png"
 // import cameraIconSel from "../assets/images/base/瑙嗛娴嬬偣sel.png"
 import { ElLoading, ElMessage } from "element-plus";
+import RainEffect from './rain'
 let layerIsOpen = false;
 const Cesium = SmartEarth.Cesium;
 const colorAll = {
@@ -19,10 +20,33 @@
   analysisDXPMRes: [],
   slopeArrow: null,
   elevationTool: null,
+  rainEffect: null,
 
   init(earthCtrl) {
     this.earthCtrl = earthCtrl;
     return this;
+  },
+  hexToColor(hexColor) {
+    const hex = hexColor.replace('#', '');
+    const r = parseInt(hex.substring(0, 2), 16) / 255;
+    const g = parseInt(hex.substring(2, 4), 16) / 255;
+    const b = parseInt(hex.substring(4, 6), 16) / 255;
+    return new Cesium.Color(r, g, b, 1.0);
+  },
+  // 澶╂皵
+  toggleRain(option, show) {
+    console.log(option, 'option')
+    // 鍏堥攢姣佹棫瀹炰緥
+    if (this.rainEffect) {
+      this.rainEffect.destroy()
+      this.rainEffect = null
+    }
+    this.rainEffect = new RainEffect(earthCtrl.viewer, {
+      tiltAngle: -0.2, //鍊炬枩瑙掑害
+      rainSize: option.rainSize, // 闆ㄧ殑澶у皬
+      rainSpeed: option.rainSpeed, // 闆ㄧ殑閫熷害
+      color: this.hexToColor(option.rainColor)  // 闆ㄧ殑棰滆壊
+    })
   },
   // 鍧″害鍒嗘瀽
   pdfx(option) {
@@ -69,7 +93,7 @@
       this.slopeArrow.setPositions(polygonPosition);
       this.slopeArrow.setSlopeType(1);
       this.slopeArrow.setRegionEnabled(true);
-      console.log(this.slopeArrow,'slope')
+      console.log(this.slopeArrow, 'slope')
     });
   },
   // 鍏抽棴鍧″悜绠ご
@@ -79,14 +103,7 @@
     }
   },
 
-  // 澶╂皵
-  toggleRain(weather = "rain", show) {
-    if (show) {
-      earthCtrl.environment.showEffect(weather);
-    } else {
-      earthCtrl.environment.disableEffect(weather);
-    }
-  },
+
   toggleSnow(weather = "snow", show) {
     if (show) {
       earthCtrl.environment.showEffect(weather);

--
Gitblit v1.9.3