From f54c45de2ec6dfadc825c064b75e6707513bd094 Mon Sep 17 00:00:00 2001
From: wangjuncheng <1>
Date: 星期一, 28 四月 2025 10:07:08 +0800
Subject: [PATCH] change

---
 src/utils/water.js |  216 +++++++++++++++++++++++++++++------------------------
 1 files changed, 118 insertions(+), 98 deletions(-)

diff --git a/src/utils/water.js b/src/utils/water.js
index 333b865..a130c77 100644
--- a/src/utils/water.js
+++ b/src/utils/water.js
@@ -1,103 +1,123 @@
-import { cartesianToXY } from "@/utils/map"
-let water = null
+import { cartesianToXY } from "@/utils/map";
+let water = null;
 export function destoryWaterPrimitive() {
-	if (water) {
-		water.destroy()
-		water = null
-	}
+  if (water) {
+    water.destroy();
+    water = null;
+  }
 }
+// export function createWaterPrimitive(rainfall) {
+//   if (water) {
+//     water.rainfall = rainfall;
+//     return;
+//   }
+// //   let positionArray = [
+// //     {
+// //       x: -2172418.4199554003,
+// //       y: 4339741.174232391,
+// //       z: 4124707.9687457774,
+// //     },
+// //     {
+// //       x: -2173054.1197314346,
+// //       y: 4339420.091643301,
+// //       z: 4124710.896091218,
+// //     },
+// //     {
+// //       x: -2172832.10576698,
+// //       y: 4338665.615224519,
+// //       z: 4125615.341361447,
+// //     },
+// //     {
+// //       x: -2171464.714295606,
+// //       y: 4337884.628113293,
+// //       z: 4127145.919793182,
+// //     },
+// //     {
+// //       x: -2170738.824348358,
+// //       y: 4338621.865525843,
+// //       z: 4126755.442367371,
+// //     },
+// //     {
+// //       x: -2171270.181257778,
+// //       y: 4338967.11477535,
+// //       z: 4126117.1692552743,
+// //     },
+// //     {
+// //       x: -2171120.444962885,
+// //       y: 4339310.237335228,
+// //       z: 4125837.0031219805,
+// //     },
+// //     {
+// //       x: -2171911.8873938583,
+// //       y: 4339707.853907823,
+// //       z: 4125007.7462886167,
+// //     },
+// //     {
+// //       x: -2171934.494218292,
+// //       y: 4339685.285760623,
+// //       z: 4125019.506657141,
+// //     },
+// //   ];
+// //   const coordinates = [];
+// //   positionArray.forEach((item) => {
+// //     const result = cartesianToXY(item);
+// //     coordinates.push(result.longitude, result.latitude, result.height);
+// //   });
+//   // water = earthCtrl.analysis.createWaterSimulateGPU({
+//   // 	//isDraw: true, // 鏄惁缁樺埗姘撮潰
+//   // 	height: -5,
+//   // 	maxHeight: 2000,
+//   // 	coordinates: coordinates,
+//   // 	// coordinates: [
+//   // 	// 	116.57628914253382, 40.5654461866556, 0, 116.57628914253382, 40.552898897029046, 0,
+//   // 	// 	116.60855621443835, 40.552898897029046, 0, 116.60855621443835, 40.5654461866556, 0,
+//   // 	// ],
+//   // 	// coordinates: [
+//   // 	// 	116.568865, 40.590729, 0, 116.568865, 40.533505, 0,
+//   // 	// 	116.608505, 40.533505, 0, 116.608505, 40.590729, 0,
+//   // 	// ],
+//   // })
+//   water = earthCtrl.simulate.createWaterSimulateLayer({
+//     // baseUrl: "http://192.168.10.187:81/20250412",
+//     // baseUrl: "http://192.168.56.107:8088/simu/c2h1d", //浠跨湡鏈嶅姟url
+//     baseUrl: "/simu/c2h1dc", //浠跨湡鏈嶅姟url
+//     interval: 125, //涓ゅ抚璇锋眰鐨勬椂闂撮棿闅旓紝鍗曚綅ms
+//     // color: new SmartEarth.Cesium.Color.fromCssColorString('#f4a460'),
+//     //娓呮按鑹�
+//     color: new SmartEarth.Cesium.Color.fromCssColorString("#D4F2E7"),
+//     //娴戞按鑹�
+//     // color: new SmartEarth.Cesium.Color.fromCssColorString('#DEB887'),
+//   });
+//   console.log("water", water);
 
-export function createWaterPrimitive(rainfall) {
-	if (water) {
-		water.rainfall = rainfall
-		return
-	}
-	let positionArray = [
-		{
-			x: -2172418.4199554003,
-			y: 4339741.174232391,
-			z: 4124707.9687457774,
-		},
-		{
-			x: -2173054.1197314346,
-			y: 4339420.091643301,
-			z: 4124710.896091218,
-		},
-		{
-			x: -2172832.10576698,
-			y: 4338665.615224519,
-			z: 4125615.341361447,
-		},
-		{
-			x: -2171464.714295606,
-			y: 4337884.628113293,
-			z: 4127145.919793182,
-		},
-		{
-			x: -2170738.824348358,
-			y: 4338621.865525843,
-			z: 4126755.442367371,
-		},
-		{
-			x: -2171270.181257778,
-			y: 4338967.11477535,
-			z: 4126117.1692552743,
-		},
-		{
-			x: -2171120.444962885,
-			y: 4339310.237335228,
-			z: 4125837.0031219805,
-		},
-		{
-			x: -2171911.8873938583,
-			y: 4339707.853907823,
-			z: 4125007.7462886167,
-		},
-		{
-			x: -2171934.494218292,
-			y: 4339685.285760623,
-			z: 4125019.506657141,
-		},
-	]
-	const coordinates = []
-	positionArray.forEach(item => {
-		const result = cartesianToXY(item)
-		coordinates.push(result.longitude, result.latitude, result.height)
-	})
-	water = earthCtrl.analysis.createWaterSimulateGPU({
-		//isDraw: true, // 鏄惁缁樺埗姘撮潰
-		height: -5,
-		maxHeight: 2000,
-		coordinates: coordinates,
-		// coordinates: [
-		// 	116.57628914253382, 40.5654461866556, 0, 116.57628914253382, 40.552898897029046, 0,
-		// 	116.60855621443835, 40.552898897029046, 0, 116.60855621443835, 40.5654461866556, 0,
-		// ],
-		// coordinates: [
-		// 	116.568865, 40.590729, 0, 116.568865, 40.533505, 0,
-		// 	116.608505, 40.533505, 0, 116.608505, 40.590729, 0,
-		// ],
-	})
-	console.log("water", water)
-
-	// water.rainfall = 0.0001;    // 璋冭妭闆ㄩ噺
-	// water.rainPointMax = 2.0;   // 娓楁按闃堝��
-	// water.attenuation = 0.995;  // 琛板噺
-	// water.strenght = 0.25    // 姘存祦寮哄害
-}
-
+//   // water.rainfall = 0.0001;    // 璋冭妭闆ㄩ噺
+//   // water.rainPointMax = 2.0;   // 娓楁按闃堝��
+//   // water.attenuation = 0.995;  // 琛板噺
+//   // water.strenght = 0.25    // 姘存祦寮哄害
+// }
+export function createWaterPrimitive(options = {}) {
+	const { interval = 1000 } = options; // 榛樿 interval 涓� 1000
+  
+	water = earthCtrl.simulate.createWaterSimulateLayer({
+	  baseUrl: "/simu/c2h1dc", // 浠跨湡鏈嶅姟url
+	  interval, // 鍔ㄦ�佽缃� interval
+	  color: new SmartEarth.Cesium.Color.fromCssColorString("#D4F2E7"),
+	});
+	console.log(`Water simulation started with interval: ${interval}ms`);
+  }
 export function initeWaterPrimitiveView() {
-	let view = {
-		destination: {
-			x: -2173603.2294639186,
-			y: 4338938.333124211,
-			z: 4128027.401463165,
-		},
-		orientation: {
-			pitch: -0.6208443477400212,
-			roll: 0.000049799989940702005,
-			heading: 3.6294612473618644,
-		},
-	}
-	viewer.scene.camera.flyTo(view)
+  let view = {
+    destination: {
+      x: -2173603.2294639186,
+      y: 4338938.333124211,
+      z: 4128027.401463165,
+    },
+    orientation: {
+      pitch: -0.6208443477400212,
+      roll: 0.000049799989940702005,
+      heading: 3.6294612473618644,
+    },
+  };
+  viewer.scene.camera.flyTo(view);
 }
+

--
Gitblit v1.9.3