From 2800fa4f32f3900509cb4d6eefaf2bfaf54efdd7 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Mon, 21 Apr 2025 18:29:09 +0800
Subject: [PATCH] fix: 天气显示
---
src/utils/cesium/common.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/src/utils/cesium/common.js b/src/utils/cesium/common.js
index db8e80d..053ff70 100644
--- a/src/utils/cesium/common.js
+++ b/src/utils/cesium/common.js
@@ -157,3 +157,49 @@
return { longitude: newLon, latitude: newLat }
}
+
+/**
+ * 添加蓝色滤镜
+ * @param options
+ * @param viewer
+ * @param layer
+ */
+export const addBlueFilter = (options, viewer, layer) => {
+ if (layer){
+ layer.brightness = 0.6 // 亮度(默认值)
+ layer.contrast = 1.8 // 对比度(负值降低对比度)
+ layer.hue = 1 // 色相(弧度值,3.0可能导致紫色)
+ layer.saturation = 0 // 增加饱和度强化蓝色
+ layer.gamma = 0.3 // 伽马校正(小于1.0使颜色更鲜艳)
+ }
+
+ const { bInvertColor, bFilterColor, filterColor } = options
+
+ const color = new Cesium.Color.fromCssColorString(filterColor)
+ const filterRGB = [
+ Math.round(color.red * 255),
+ Math.round(color.green * 255),
+ Math.round(color.blue * 255)
+ ]
+ let fragShader = viewer.scene.globe._surfaceShaderSet.baseFragmentShaderSource.sources
+ for (let i = 0; i < fragShader.length; i++) {
+ const strS = 'color = czm_saturation(color, textureSaturation);\n#endif\n'
+ let strT = 'color = czm_saturation(color, textureSaturation);\n#endif\n'
+ if (bInvertColor) {
+ strT += `
+ color.r = 1.0 - color.r;
+ color.g = 1.0 - color.g;
+ color.b = 1.0 - color.b;
+ `
+ }
+ if (bFilterColor) {
+ strT += `
+ color.r = color.r * ${filterRGB[0]}.0/255.0;
+ color.g = color.g * ${filterRGB[1]}.0/255.0;
+ color.b = color.b * ${filterRGB[2]}.0/255.0;
+ `
+ }
+ fragShader[i] = fragShader[i].replace(strS, strT)
+ }
+}
+
--
Gitblit v1.9.3