deac3a6e213c82069da9921d532974d587a5ba32..fa541dda36e58de1d491b3ff4073c51b16606515
2025-06-25 wangjuncheng
2
fa541d 对比 | 目录
2025-06-25 guonan
提交初版实时模拟
2f3876 对比 | 目录
2025-06-25 wangjuncheng
11111111
1190b6 对比 | 目录
已修改7个文件
415 ■■■■■ 文件已修改
src/api/trApi.js 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/menu/TimeLine.vue 282 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/monifangzhen/echartInfo.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/monifangzhen/schemeCard.vue 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/tools/LayerTree.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/simulation.js 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/water.js 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/trApi.js
@@ -38,7 +38,7 @@
export async function getSimDataById(id) {
  try {
    const res = await instance.get(`/simu/selectPage?id=${id}`);
    return res.data;
    return res.data;
  } catch (error) {
    console.error("Error fetching data:", error);
    throw error; // 抛出错误,让调用方可以捕获
@@ -117,22 +117,44 @@
  }
}
// 通过接口去请求json,将请求的json解析获取泥石流参数
export async function fetchWaterSimulationData(serviceInfo) {
// // 通过接口去请求json,将请求的json解析获取泥石流参数
// export async function fetchWaterSimulationData(serviceInfo) {
//   try {
//     const response = await fetch(`/simu/${serviceInfo}/layer.json`); // 发起请求
//     // const response = await fetch(`/simu/c2h1dc/layer.json`); // 发起请求
//     if (!response.ok) {
//       throw new Error(`HTTP error! status: ${response.status}`);
//     }
//     const jsonData = await response.json(); // 解析 JSON 数据
//     // console.log(jsonData, "jsonjsonjsonjson");
//     return parseWaterSimulationData(jsonData); // 调用解析函数
//   } catch (error) {
//     console.error("请求或解析数据时出错:", error);
//     return null;
//   }
// }
export async function fetchWaterSimulationData(serviceInfo, timestamp = null) {
  try {
    const response = await fetch(`/simu/${serviceInfo}/layer.json`); // 发起请求
    // const response = await fetch(`/simu/c2h1dc/layer.json`); // 发起请求
    // 根据是否提供时间戳来决定文件名
    let fileName = timestamp ? timestamp : 'layer.json';
    const url = `/simu/${serviceInfo}/${fileName}`;
    const response = await fetch(url); // 发起请求
    console.log(url,'aaaaaaaaa')
    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }
    const jsonData = await response.json(); // 解析 JSON 数据
    // console.log(jsonData, "jsonjsonjsonjson");
    return parseWaterSimulationData(jsonData); // 调用解析函数
    return parseWaterSimulationData(jsonData); // 调用解析函数处理数据
  } catch (error) {
    console.error("请求或解析数据时出错:", error);
    return null;
  }
}
// 获取水位水深
export async function getFlowRate(data) {
  // console.log(data,'发送的数据!');
src/components/menu/TimeLine.vue
@@ -2,30 +2,20 @@
  <div class="timeline-container">
    <div class="controls">
      <div class="control-btn" @click="skipBackward">
        <img
          src="@/assets/img/timeline/left.png"
          class="fas fa-step-backward"
        />
        <img src="@/assets/img/timeline/left.png" class="fas fa-step-backward" />
      </div>
      <div class="control-btn play-btn" @click="togglePlay">
        <img v-show="isPlaying" src="@/assets/img/timeline/stop.png" />
        <img v-show="!isPlaying" src="@/assets/img/timeline/start.png" />
      </div>
      <div class="control-btn" @click="skipForward">
        <img
          src="@/assets/img/timeline/right.png"
          class="fas fa-step-forward"
        />
        <img src="@/assets/img/timeline/right.png" class="fas fa-step-forward" />
      </div>
      <div class="speed-control" v-show="speedShow">
        <div @click="toggleSpeedMenu">{{ playbackRate }}X</div>
        <div class="speed-menu" v-show="showSpeedMenu">
          <div
            v-for="rate in playbackRates"
            :key="rate"
            @click.capture="setPlaybackRate(rate)"
            :class="{ active: playbackRate === rate }"
          >
          <div v-for="rate in playbackRates" :key="rate" @click.capture="setPlaybackRate(rate)"
            :class="{ active: playbackRate === rate }">
            {{ rate }}X
          </div>
        </div>
@@ -35,33 +25,19 @@
    <div class="timeline">
      <div class="dates">
        <div class="current-date">当前播放时间:{{ currentPlayingTime }}</div>
        <div
          v-for="(date, index) in visibleDates"
          :key="index"
          class="date-label"
        >
        <div v-for="(date, index) in visibleDates" :key="index" class="date-label">
          <!-- {{ formatDate(date) }} -->
        </div>
        <div>
          专题渲染:
          <el-switch
            v-model="isColorRenderEnabled"
            @change="handleColorRenderChange"
            style="margin-top: -3px"
            :disabled="!isPlaying || !isWaterPrimitiveCreated"
          />
          <el-switch v-model="isColorRenderEnabled" @change="handleColorRenderChange" style="margin-top: -3px"
            :disabled="!isPlaying || !isWaterPrimitiveCreated" />
          <!-- active-text="开" inactive-text="关" -->
        </div>
      </div>
      <div class="timeline-track" ref="timelineTrack" @click="seekToPosition">
        <div
          class="timeline-progress"
          :style="{ width: progressPercentage + '%' }"
        ></div>
        <div
          class="timeline-cursor"
          :style="{ left: progressPercentage + '%' }"
        ></div>
        <div class="timeline-progress" :style="{ width: progressPercentage + '%' }"></div>
        <div class="timeline-cursor" :style="{ left: progressPercentage + '%' }"></div>
        <div class="scale-markers">
          <div class="scale-marker" style="left: 0%"></div>
          <div class="scale-marker" style="left: 25%"></div>
@@ -70,12 +46,8 @@
          <div class="scale-marker" style="left: 100%"></div>
        </div>
        <div class="time-markers">
          <div
            v-for="(time, index) in timeMarkers"
            :key="index"
            class="time-marker"
            :style="{ left: `${index * 25}%`, transform: 'translateX(-50%)' }"
          >
          <div v-for="(time, index) in timeMarkers" :key="index" class="time-marker"
            :style="{ left: `${index * 25}%`, transform: 'translateX(-50%)' }">
            <div class="date-part">{{ time.split(" ")[0] }}</div>
            <div class="time-part">{{ time.split(" ")[1] }}</div>
          </div>
@@ -84,38 +56,27 @@
    </div>
    <div>
      <div style="display: flex">
        <ratelevel
          ref="ratelevelRef"
          :playing-time="sendCurrentPlayingTime"
          @finish-calculation="handleFinishCalculation"
          style="
        <ratelevel ref="ratelevelRef" :playing-time="sendCurrentPlayingTime"
          @finish-calculation="handleFinishCalculation" style="
            margin-top: 12px;
            margin-left: 28px;
            margin-right: 10px;
            justify-content: flex-end;
          "
        />
        <crossanalysis
          ref="crossRef"
          style="
          " />
        <crossanalysis ref="crossRef" style="
            margin-top: 12px;
            margin-left: 16px;
            margin-right: 20px;
            justify-content: flex-end;
          "
        />
          " />
      </div>
      <el-button
        @click="handleBack"
        style="
      <el-button @click="handleBack" style="
          margin-top: 3px;
          margin-left: 28px;
          margin-right: 10px;
          width: 75%;
          height: 30%;
        "
        >结束模拟</el-button
      >
        ">结束模拟</el-button>
    </div>
  </div>
</template>
@@ -152,7 +113,7 @@
import { useSimStore } from "@/store/simulation";
import { storeToRefs } from "pinia";
const simStore = useSimStore();
const { selectedScheme, frameNum } = storeToRefs(simStore);
const { selectedScheme, frameNum, layerDate } = storeToRefs(simStore);
const emit = defineEmits([
  "timeUpdate",
@@ -191,7 +152,7 @@
const isWaterPrimitiveCreated = ref(false);
let playInterval = null;
let timeStepInfo = null;
let rainTotalInfo = ([]);
let rainTotalInfo = [];
const isRainEnabled = ref(false);
const rainParams = reactive({
  rainSize: 0.5,
@@ -201,6 +162,9 @@
});
let minFlowRate = ref();
let maxFlowRate = ref();
// 全局变量记录最大阶段和透明度
let maxStage = 0;
let maxAlpha = -0.3; // 初始透明度对应stage 0
// 计算属性
const progressPercentage = computed(
  () => (currentTime.value / duration.value) * 100
@@ -348,10 +312,10 @@
  const rainfallList = data.rainfalls;
  console.log("最终的 rainfallList:", rainfallList);
  rainTotalInfo.value = rainfallList
  calculateTimeStep(rainTotalInfo.value)
  rainTotalInfo.value = rainfallList;
  calculateTimeStep(rainTotalInfo.value);
  // 使用示例
 timeStepInfo = calculateTimeStep(rainTotalInfo.value);
  timeStepInfo = calculateTimeStep(rainTotalInfo.value);
  // 提取 intensity 值
  rainFallValues.value = rainfallList.map((r) => r.intensity);
@@ -430,13 +394,13 @@
function calculateTimeStep(dataArray) {
  if (!dataArray || dataArray.length < 2) {
    console.warn('数据不足,无法计算时间步长');
    console.warn("数据不足,无法计算时间步长");
    return null;
  }
  // 解析时间字符串为 Date 对象
  function parseTime(timeStr) {
    return new Date(timeStr.replace(' ', 'T')); // 兼容 ISO 格式
    return new Date(timeStr.replace(" ", "T")); // 兼容 ISO 格式
  }
  const firstTime = parseTime(dataArray[0].time);
@@ -454,45 +418,161 @@
    const next = parseTime(dataArray[i + 1].time);
    const step = Math.abs(next - current) / (1000 * 60 * 60); // 毫秒 -> 小时
    if (Math.abs(step - timeStepHours) > 0.01) {
      console.warn(`在索引 ${i} 处发现了不同的时间步长: ${step.toFixed(2)} 小时`);
      console.warn(
        `在索引 ${i} 处发现了不同的时间步长: ${step.toFixed(2)} 小时`
      );
    }
  }
  return timeStepHours;
}
// 全局状态记录
const colorState = {
  maxStage: 0,       // 记录历史最高阶段
  maxAlpha: -0.3,    // 记录历史最小透明度(负值)
  maxLuminance: 240.4, // 记录历史最低亮度(对应stage 0初始值)
  currentColor: "#F5F0E6" // 当前颜色
};
function updateWaterColorByTime() {
  if (!rainTotalInfo.value || rainTotalInfo.value.length === 0) return;
  const progress = currentTime.value / duration.value;
  const floatIndex = progress * (rainTotalInfo.value.length - 1);
  const index = Math.floor(floatIndex);
  const nextIndex = Math.min(index + 1, rainTotalInfo.value.length - 1);
  const currentData = rainTotalInfo.value[index];
  const nextData = rainTotalInfo.value[nextIndex];
  // 启用插值(alpha 平滑过渡)
  const alpha = floatIndex - index;
  const currentTotal = currentData.total;
  const nextTotal = nextData.total;
  const total = currentTotal + (nextTotal - currentTotal) * alpha;
  console.log(`计算得到的时间步长为: ${timeStepInfo} 小时`);
  // 根据 total 设置颜色
  let color = "#D4F2E7"; // 默认蓝色
  if (total >= 150) {
    color = '#663300';
  } else if (total >= 125) {
    color = '#B26633';
  } else if (total >= 100) {
    color = '#CC9966';
  } else if (total >= 75) {
    color = '#CCE5FF';
  } else if (total >= 50) {
    color = '#99CCFF';
  } else if (total >= 25) {
    color = '#66B3FF';
  // 1. 计算基础数据
  const { intensity, IR } = calculateRainData();
  // 2. 颜色配置(亮度严格递减)
  const COLOR_STOPS = [
    { hex: "#F5F0E6", luminance: 240.4 }, // stage 0
    { hex: "#D4F2E7", luminance: 231.8 }, // stage 1
    { hex: "#E6D5B8", luminance: 214.8 }, // stage 2
    { hex: "#D4B483", luminance: 184.0 }, // stage 3
    { hex: "#B78B6A", luminance: 148.4 }, // stage 4
    { hex: "#8B5A3A", luminance: 101.0 }, // stage 5
    { hex: "#4A3123", luminance: 54.9 }   // stage 6
  ];
  const alphaStops = [1
    -0.3,   // stage 0
    -0.4,   // stage 1
    -0.5,   // stage 2
    -0.6,   // stage 3
    -0.7,   // stage 4
    -0.75,  // stage 5
    -0.8    // stage 6
  ];
  // 3. 更新阶段状态
  updateStageState(intensity, IR);
  // 4. 计算并锁定颜色(确保亮度不回升)
  updateColorState(COLOR_STOPS, intensity, IR);
  // 5. 应用颜色
  updateWaterColor(colorState.currentColor, colorState.maxAlpha);
  // --- 辅助函数 ---
  function calculateRainData() {
    const initialTimestamp = new Date(rainTotalInfo.value[0].time).getTime();
    const currentTimestamp = new Date(
      rainTotalInfo.value[Math.min(
        Math.floor(currentTime.value / duration.value * (rainTotalInfo.value.length - 1)),
        rainTotalInfo.value.length - 2
      )].time
    ).getTime();
    // 降雨强度计算(带插值)
    const progress = currentTime.value / duration.value;
    const floatIndex = progress * (rainTotalInfo.value.length - 1);
    let index = Math.floor(floatIndex);
    if (index >= rainTotalInfo.value.length - 1) {
      index = rainTotalInfo.value.length - 2; // 防止 index+1 越界
    }
    const lerpAlpha = floatIndex - index;
    const intensity = rainTotalInfo.value[index].intensity * (1 - lerpAlpha) +
      rainTotalInfo.value[index + 1].intensity * lerpAlpha;
    // 临界降雨强度计算
    const D = (currentTimestamp - initialTimestamp) / (1000 * 60 * 60) + 0.0001;
    const IR = 56.9 * Math.pow(D, -0.746);
    return { intensity, IR };
  }
  // console.log(`当前 total: ${total.toFixed(2)}, 颜色: ${color}`);
  // updateWaterColor(color)
  function updateStageState(intensity, IR) {
    // 计算理论阶段
    let stage = 0;
    const thresholds = [0, 0.2, 0.4, 0.6, 0.8, 1.0];
    for (let i = thresholds.length - 1; i >= 0; i--) {
      if (intensity >= thresholds[i] * IR) {
        stage = i + 1;
        break;
      }
    }
    // 更新最大阶段(单向递增)
    colorState.maxStage = Math.max(colorState.maxStage, stage);
  }
  function updateColorState(colorStops, intensity, IR) {
    // 已达最终阶段
    if (colorState.maxStage >= colorStops.length - 1) {
      colorState.currentColor = colorStops[colorStops.length - 1].hex;
      colorState.maxAlpha = -0.8;
      colorState.maxLuminance = colorStops[colorStops.length - 1].luminance;
      return;
    }
    // 计算当前阶段进度
    const stageThresholds = [0, 0.2, 0.4, 0.6, 0.8, 1.0];
    const lowerThreshold = stageThresholds[colorState.maxStage - 1] * IR;
    const upperThreshold = stageThresholds[colorState.maxStage] * IR;
    const ratio = Math.min(1, Math.max(0, (intensity - lowerThreshold) / (upperThreshold - lowerThreshold)));
    // 颜色插值
    const startColor = colorStops[colorState.maxStage];
    const endColor = colorStops[colorState.maxStage + 1];
    const newColor = lerpColor(startColor.hex, endColor.hex, ratio);
    const newLuminance = calculateLuminance(newColor);
    // 只接受更暗的颜色(亮度更低)
    if (newLuminance < colorState.maxLuminance) {
      colorState.currentColor = newColor;
      colorState.maxLuminance = newLuminance;
      colorState.maxAlpha = Math.min(
        colorState.maxAlpha,
        lerp(alphaStops[colorState.maxStage], alphaStops[colorState.maxStage + 1], ratio)
      );
    }
    console.log(`阶段: ${colorState.maxStage} | 亮度: ${colorState.maxLuminance.toFixed(1)} | 颜色: ${colorState.currentColor}`);
  }
  // 颜色插值工具函数
  function lerpColor(c1, c2, t) {
    const [r1, g1, b1] = hexToRgb(c1);
    const [r2, g2, b2] = hexToRgb(c2);
    return rgbToHex(
      r1 + (r2 - r1) * t,
      g1 + (g2 - g1) * t,
      b1 + (b2 - b1) * t
    );
  }
  function calculateLuminance(hex) {
    const [r, g, b] = hexToRgb(hex);
    return 0.299 * r + 0.587 * g + 0.114 * b;
  }
  function hexToRgb(hex) {
    const bigint = parseInt(hex.slice(1), 16);
    return [(bigint >> 16) & 255, (bigint >> 8) & 255, bigint & 255];
  }
  function rgbToHex(r, g, b) {
    return `#${[r, g, b].map(x => Math.round(x).toString(16).padStart(2, '0')).join('')}`;
  }
  function lerp(a, b, t) {
    return a + (b - a) * t;
  }
}
function updateWeatherByProgress() {
@@ -509,11 +589,11 @@
  // const rainValue = currentRain + (nextRain - currentRain) * alpha;
  const rainValue = currentRain + (nextRain - currentRain);
  // 打印当前处理的雨量数据
  console.log(
    `正在处理的雨量数据点: 当前=${currentRain}, 下一个=${nextRain}, 插值后=${rainValue.toFixed(
      2
    )}, 索引=${index}`
  );
  // console.log(
  //   `正在处理的雨量数据点: 当前=${currentRain}, 下一个=${nextRain}, 插值后=${rainValue.toFixed(
  //     2
  //   )}, 索引=${index}`
  // );
  // 如果当前索引未变化且插值差异不大,跳过重复更新
  if (index === lastUsedIndex && Math.abs(rainValue - lastRainValue) < 0.1) {
    // console.log('由于数据无显著变化,跳过本次更新');
@@ -698,12 +778,16 @@
  try {
    // 当前方案的所有信息
    const schemeInfo = selectedScheme.value;
    const jsonFetch = ref(null);
    serviceInfo = schemeInfo.serviceName;
    if (selectedScheme.value.type == 2) {
      speedShow.value = false;
      jsonFetch.value = layerDate.value;
      // serviceInfo = layerDate.value;
    } else {
      getRainfallData();
      speedShow.value = true;
      jsonFetch.value = null;
    }
    // console.log('获取到的 serviceName:', serviceInfo);
@@ -713,7 +797,7 @@
      waterTimestamps: timestamps,
      watersMaxHeight,
      watersMinHeight,
    } = await fetchWaterSimulationData(serviceInfo);
    } = await fetchWaterSimulationData(serviceInfo, jsonFetch.value);
    console.log(
      "当前方案下的最大水位深度和最小水位深度",
      watersMaxHeight,
src/components/monifangzhen/echartInfo.vue
@@ -309,7 +309,6 @@
  if (nowTime.value) {
    const timeParts = nowTime.value.split(" ");
    const timeOnly = timeParts[1]; // 获取 "mm:ss" 部分
    console.log(nowTime.value, "nowTime.valuenowTime.value");
    return timeOnly;
  }
};
src/components/monifangzhen/schemeCard.vue
@@ -74,7 +74,6 @@
  selectedId.value = id;
}
function formatTime(time) {
  return dayjs(time).format("YYYY-MM-DD HH:mm:ss");
}
@@ -93,6 +92,9 @@
function close() {
  messageShow.value = false;
}
// 实时模拟五分钟请求一次的定时器
const realTimeSimInterval = ref(null);
async function startPlay(item) {
  if (item.status === 2) {
@@ -127,7 +129,7 @@
    return;
  }
  // 调用求解器(不在实时模拟的情况下)
  // 新建方案,没有 status 和 serviceName 且 type != 2
  if (!item.status && !item.serviceName && item.type !== 2) {
    try {
      await getSimStart(item.id);
@@ -143,23 +145,21 @@
    return;
  }
  // 实时模拟
  // 处理 type == 2 的情况(实时模拟)
  if (item.type === 2) {
    try {
      // 实时模拟调用求解器会直接在接口中返回结果
      const ress = await getSimStart(item.id);
      const res = await getSimDataById(item.id);
      item.serviceName = res.data[0]?.serviceName || null;
      simStore.setSelectedScheme(item);
      getScheme();
      if (ress.code === 200) {
        initeWaterPrimitiveView();
        emit("start");
      }
    } catch (e) {
      console.error("实时模拟获取模拟数据失败:", e);
    // 清除已有定时器,防止重复启动
    if (realTimeSimInterval.value) {
      clearInterval(realTimeSimInterval.value);
    }
    // 即刻执行一次
    await executeRealTimeSimulation(item);
    // 每隔 5 分钟执行一次
    realTimeSimInterval.value = setInterval(() => {
      executeRealTimeSimulation(item);
    }, 5 * 60 * 1000); // 5分钟
    return;
  }
@@ -167,7 +167,28 @@
  simStore.setSelectedScheme(item);
}
// 封装实时模拟的异步操作
async function executeRealTimeSimulation(item) {
  try {
    const ress = await getSimStart(item.id);
    console.log(ress, "resssssssss");
    const res = await getSimDataById(item.id);
    item.serviceName = res.data[0]?.serviceName || null;
    simStore.setSelectedScheme(item);
    getScheme();
    if (ress.code === 200) {
      simStore.layerDate = ress.data;
      console.log(simStore.layerDate,'aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbb')
      initeWaterPrimitiveView();
      emit("start");
    }
  } catch (e) {
    console.error("实时模拟获取模拟数据失败:", e);
  }
}
function handleBack(value) {
  if (value === false) {
src/components/tools/LayerTree.vue
@@ -76,7 +76,7 @@
  try {
    TerrainLayer = await earthCtrl.factory.createTerrainLayer({
      sourceType: "ctb",
      url: "http://106.120.22.26:9103/gisserver/ctsserver/sunhugoudem",
      url: "http://106.120.22.26:9103/gisserver/ctsserver/sunhugoudem84",
      requestVertexNormals: true,
    });
    treeMap.set("地形数据", TerrainLayer);
src/store/simulation.js
@@ -2,6 +2,7 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useSimStore = defineStore('simulation', () => {
    const layerDate = ref("")
    // 帧数
    const frameNum = ref(0)
    // 目录树选中
@@ -46,7 +47,6 @@
        selectedScheme.value = scheme
        rainFalls.value = JSON.parse(scheme.data).rainfalls
        intensityUnit.value = JSON.parse(scheme.data).intensityUnit
        console.log(intensityUnit.value, 'shceme')
    }
    const clearSelectedScheme = () => {
        selectedScheme.value = null
@@ -196,6 +196,7 @@
        userSelectedLayers,
        devices,
        frameNum,
        layerDate,
        // 方案相关方法
        setSchemCard,
src/utils/water.js
@@ -12,7 +12,7 @@
    enableWaterArrowFlow(false);
    water.destroy();
    water = null;
    console.log("Water simulation destroyed.");
    // console.log("Water simulation destroyed.");
  }
}
@@ -78,9 +78,9 @@
  }
  waterLegendData.value = waterHeightLevels;
  console.log(waterLegendData.value, "图例数据");
  // console.log(waterLegendData.value, "图例数据");
  water = await earthCtrl.simulate.createWaterSimulateLayer({
    baseUrl,
    interval,
@@ -92,11 +92,11 @@
    colorRender,
    sizeIndex: 0,
  });
  enableWaterArrowFlow(false);
  // enableWaterArrowFlow(false);
  toggleWaterShadow(false);
  console.log(
    `仿真模拟参数:请求路径 ${baseUrl}, 帧间间隔 ${interval}ms, 是否开启专题渲染 ${colorRender}`
  );
  // console.log(
  //   `仿真模拟参数:请求路径 ${baseUrl}, 帧间间隔 ${interval}ms, 是否开启专题渲染 ${colorRender}`
  // );
}
/**
 * 初始化水体模拟视图
@@ -118,12 +118,12 @@
  // console.log("Camera view initialized for water simulation.");
}
/**
 * 更新水颜色
 * 更换水透明度
 */
export function updateWaterColor(color) {
export function updateWaterColor(color,alpha) {
  if (water) {
    water.color = Cesium.Color.fromCssColorString(color);
    console.log("切换颜色为:",color);
    water.alphaByDepth = alpha;
  } else {
    console.warn("No water simulation to pause.");
  }
@@ -134,7 +134,7 @@
export function pauseWaterSimulation() {
  if (water) {
    water.pause();
    console.log("暂停仿真");
    // console.log("暂停仿真");
  } else {
    console.warn("No water simulation to pause.");
  }
@@ -146,7 +146,7 @@
export function resumeWaterSimulation() {
  if (water) {
    water.resume();
    console.log("继续仿真");
    // console.log("继续仿真");
  } else {
    console.warn("No water simulation to resume.");
  }
@@ -165,9 +165,9 @@
      return;
    }
    // const idx = Math.floor(Math.random() * imageList.length); //随机索引跳转,实际中用不到,只用作演示
    console.log(
      `Jumping to timestamp: count:[${imageList.length}], index:[${closestIndex}]`
    );
    // console.log(
    //   `Jumping to timestamp: count:[${imageList.length}], index:[${closestIndex}]`
    // );
    water.setTime(imageList[closestIndex]);
  } else {
    console.warn("No water simulation to set time for.");
@@ -181,7 +181,7 @@
export function toggleWaterColorRender(enabled) {
  if (water) {
    water.colorRender = enabled;
    console.log(`是否开启专题渲染 ${enabled}`);
    // console.log(`是否开启专题渲染 ${enabled}`);
  } else {
    console.warn("No water simulation to toggle color rendering.");
  }
@@ -196,7 +196,7 @@
  if (water) {
    // 默认关闭状态
    water.flowEnabled = enabled; // 假设 SDK 支持此属性
    console.log(`箭头流向动画已${enabled ? "开启" : "关闭"}`);
    // console.log(`箭头流向动画已${enabled ? "开启" : "关闭"}`);
  } else {
    console.warn("未找到水体模拟图层,请先启动洪水模拟");
  }
@@ -218,7 +218,7 @@
      earthCtrl.shadowMap.maximumDistance = 10000.0; //最大距离
      earthCtrl.shadowMap.pointLightRadius = 50.0; //点光源半径
    }
    console.log(`阴影效果已${enabled ? "开启" : "关闭"}`);
    // console.log(`阴影效果已${enabled ? "开启" : "关闭"}`);
  } catch (error) {
    console.error("设置阴影失败:", error);
  }