From 2ee0ab96f3edfbf8aefc9e2c5d5f73332411eb99 Mon Sep 17 00:00:00 2001
From: wangjuncheng <1>
Date: 星期四, 17 四月 2025 16:30:09 +0800
Subject: [PATCH] change

---
 src/utils/tools.js |   57 ++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 40 insertions(+), 17 deletions(-)

diff --git a/src/utils/tools.js b/src/utils/tools.js
index 6604c70..6f0a779 100644
--- a/src/utils/tools.js
+++ b/src/utils/tools.js
@@ -3,6 +3,7 @@
 // import cameraIconSel from "../assets/images/base/瑙嗛娴嬬偣sel.png"
 import { ElLoading, ElMessage } from "element-plus";
 import RainEffect from './rain'
+import SnowEffect from './snow'
 let layerIsOpen = false;
 const Cesium = SmartEarth.Cesium;
 const colorAll = {
@@ -21,6 +22,7 @@
   slopeArrow: null,
   elevationTool: null,
   rainEffect: null,
+  snowEffect: null, // 鏂板闆晥鏋滃疄渚�
 
   init(earthCtrl) {
     this.earthCtrl = earthCtrl;
@@ -33,7 +35,20 @@
     const b = parseInt(hex.substring(4, 6), 16) / 255;
     return new Cesium.Color(r, g, b, 1.0);
   },
-  // 澶╂皵
+  // 娓呴櫎澶╂皵鐗规晥
+  delRain(){
+    if (this.rainEffect) {
+      this.rainEffect.destroy()
+      this.rainEffect = null
+    }
+  },
+  delSnow(){
+    if (this.snowEffect) {
+      this.snowEffect.destroy();
+      this.snowEffect = null;
+    }
+  },
+  // 闆ㄥぉ妯℃嫙
   toggleRain(option, show) {
     console.log(option, 'option')
     // 鍏堥攢姣佹棫瀹炰緥
@@ -47,6 +62,30 @@
       rainSpeed: option.rainSpeed, // 闆ㄧ殑閫熷害
       color: this.hexToColor(option.rainColor)  // 闆ㄧ殑棰滆壊
     })
+  },
+  // 闆ぉ妯℃嫙
+  toggleSnow(option = {}, show = true) {
+    console.log(option, 'option');
+    const defaultOption = {
+      snowSize: 0.02, // 榛樿闆殑澶у皬
+      snowSpeed: 100.0, // 榛樿闆殑閫熷害
+      snowColor: "#ffffff", // 榛樿棰滆壊锛氱櫧鑹�
+    };
+    option = { ...defaultOption, ...option };
+    if (this.snowEffect) {
+      this.snowEffect.destroy();
+      this.snowEffect = null;
+    }
+    this.snowEffect = new SnowEffect(earthCtrl.viewer, {
+      snowSize: option.snowSize, // 闆殑澶у皬
+      snowSpeed: option.snowSpeed, // 闆殑閫熷害
+      snowColor: this.hexToColor(option.snowColor), // 闆殑棰滆壊
+    });
+
+    // 鎺у埗鏄剧ず/闅愯棌
+    if (this.snowEffect) {
+      this.snowEffect.show(show);
+    }
   },
   // 鍧″害鍒嗘瀽
   pdfx(option) {
@@ -102,22 +141,6 @@
       this.slopeArrow.setSlopeType(0);
     }
   },
-
-
-  toggleSnow(weather = "snow", show) {
-    if (show) {
-      earthCtrl.environment.showEffect(weather);
-    } else {
-      let snowValue = {
-        test1: 2,
-        test2: 1.0,
-        test3: 0.5,
-        test4: 0.5,
-      };
-      earthCtrl.environment.disableEffect(weather);
-    }
-  },
-
   // 鏍囩粯
   CreateLabel(pic, show) {
     if (show) {

--
Gitblit v1.9.3