diff --git a/src/Map/Cesium_Map.tsx b/src/Map/Cesium_Map.tsx index 4fd0a5c..0b27e83 100644 --- a/src/Map/Cesium_Map.tsx +++ b/src/Map/Cesium_Map.tsx @@ -399,10 +399,18 @@ export class Cesium_Map extends enhance.Base { this.viewer.scene.msaaSamples = config.msaaSamples; this.viewer.scene.postProcessStages.fxaa.enabled = config.fxaa; this.viewer.shadows = config.shadows; - this.viewer.scene.globe.enableLighting = config.enableLighting; + this.viewer.scene.globe.enableLighting = config.enableLighting || config.solarLighting; + this.viewer.scene.globe.dynamicAtmosphereLighting = config.solarLighting; + this.viewer.scene.globe.dynamicAtmosphereLightingFromSun = config.solarLighting; + this.viewer.scene.globe.atmosphereLightIntensity = config.solarLightIntensity; + this.viewer.scene.light = new Cesium.SunLight({intensity: config.solarLightIntensity}); + this.viewer.clock.clockStep = config.solarLighting ? Cesium.ClockStep.SYSTEM_CLOCK : Cesium.ClockStep.SYSTEM_CLOCK_MULTIPLIER; + this.viewer.clock.shouldAnimate = config.solarLighting; + this.viewer.scene.maximumRenderTimeChange = config.solarLighting ? 60 : Number.POSITIVE_INFINITY; this.viewer.scene.globe.maximumScreenSpaceError = config.maximumScreenSpaceError; this.viewer.scene.verticalExaggeration = config.terrainExaggeration; this.viewer.scene.verticalExaggerationRelativeHeight = 0.0; + this.viewer.scene.requestRender(); } apply_model_config() { for (const record of this.entity_map.values()) { diff --git a/src/Map/Cesium_Render_Settings.tsx b/src/Map/Cesium_Render_Settings.tsx index bf1dd3a..483b254 100644 --- a/src/Map/Cesium_Render_Settings.tsx +++ b/src/Map/Cesium_Render_Settings.tsx @@ -22,6 +22,10 @@ export type Cesium_Graphics_Config = { shadows: boolean // 地球光照开关,开启后地表按光源方向产生明暗。 enableLighting: boolean + // 真实日照模式,使用太阳方向、系统时间和动态大气表达昼夜状态。 + solarLighting: boolean + // 真实日照模式下的太阳光强度,只影响视觉明暗。 + solarLightIntensity: number // 地球瓦片屏幕空间误差,值越大越快但地面细节越粗。 maximumScreenSpaceError: number // 仅 3D 模式加载 Terrarium 真实地形,2D/2.5D 不加载。 @@ -44,6 +48,8 @@ export const default_cesium_graphics_config: Cesium_Graphics_Config = { fxaa: false, shadows: false, enableLighting: false, + solarLighting: false, + solarLightIntensity: 1.5, maximumScreenSpaceError: 4, terrainEnabledIn3D: false, terrainExaggeration: 1.0, @@ -52,7 +58,7 @@ export const default_cesium_graphics_config: Cesium_Graphics_Config = { terrainCacheTiles: 128 }; export const cesium_graphics_config_event = "ecap_cesium_graphics_config_changed"; -type Number_Config_Key = "targetFrameRate" | "resolutionScale" | "msaaSamples" | "maximumScreenSpaceError" | "terrainExaggeration" | "terrainMaximumLevel" | "terrainCacheTiles" +type Number_Config_Key = "targetFrameRate" | "resolutionScale" | "msaaSamples" | "solarLightIntensity" | "maximumScreenSpaceError" | "terrainExaggeration" | "terrainMaximumLevel" | "terrainCacheTiles" type Boolean_Config_Key = Exclude const graphics_presets: Record<"low" | "medium" | "high", Cesium_Graphics_Config> = { low: {...default_cesium_graphics_config}, @@ -65,6 +71,8 @@ const graphics_presets: Record<"low" | "medium" | "high", Cesium_Graphics_Config fxaa: true, shadows: false, enableLighting: false, + solarLighting: false, + solarLightIntensity: 1.5, maximumScreenSpaceError: 3, terrainEnabledIn3D: true, terrainExaggeration: 1.0, @@ -81,6 +89,8 @@ const graphics_presets: Record<"low" | "medium" | "high", Cesium_Graphics_Config fxaa: true, shadows: false, enableLighting: true, + solarLighting: true, + solarLightIntensity: 1.5, maximumScreenSpaceError: 2, terrainEnabledIn3D: true, terrainExaggeration: 1.0, @@ -97,7 +107,9 @@ const graphics_help: Record = { msaaSamples: ["几何边缘多重采样抗锯齿。", "1 表示关闭;数值越高边缘越平滑,GPU 开销越大。"], fxaa: ["屏幕空间后处理抗锯齿。", "开销通常低于 MSAA,但可能让文字和细线变软。"], shadows: ["控制模型、Primitive 和地形阴影。", "画面更真实,但对大量模型和地形开销明显。"], - enableLighting: ["根据场景光源给地球表面做明暗。", "有昼夜和山体受光效果,性能优先时建议关闭。"], + enableLighting: ["根据场景光源给地球表面做明暗。", "这个开关不驱动系统时间;需要真实昼夜时打开“真实日照”。"], + solarLighting: ["使用 Cesium 太阳方向、系统时间和动态大气表达昼夜。", "地球和地面对象保持地固坐标,不手动旋转地球;需要更真实的时间态势时开启。"], + solarLightIntensity: ["真实日照模式下的太阳光强度。", "数值越大白天越亮、明暗对比越强;不会改变飞机、基站和轨迹数据。"], maximumScreenSpaceError: ["控制地球瓦片 LOD 的屏幕误差。", "数值越大越快但地面更粗糙;4 是集显平衡档。"], terrainEnabledIn3D: ["3D 模式下加载 Terrarium 真实高程地形。", "会增加网络、解码、CPU 和 GPU 压力;2D/2.5D 默认不加载。"], terrainExaggeration: ["控制地形垂直方向的视觉夸张倍率。", "1.0 为真实高度;0.0 压平地形;只改变视觉起伏,不增加高程精度,前端不限制范围。"], @@ -114,6 +126,8 @@ type Cesium_Graphics_Config_Json = { fxaa: boolean shadows: boolean enable_lighting: boolean + solar_lighting: boolean + solar_light_intensity: number maximum_screen_space_error: number terrain_enabled_in_3d: boolean terrain_exaggeration: number @@ -143,6 +157,8 @@ export function normalize_cesium_graphics_config(data: Partial): Cesium_ fxaa: data.fxaa, shadows: data.shadows, enableLighting: data.enable_lighting, + solarLighting: data.solar_lighting, + solarLightIntensity: data.solar_light_intensity, maximumScreenSpaceError: data.maximum_screen_space_error, terrainEnabledIn3D: data.terrain_enabled_in_3d, terrainExaggeration: data.terrain_exaggeration, @@ -180,6 +198,8 @@ function to_server_config(config: Cesium_Graphics_Config): Cesium_Graphics_Confi fxaa: normalized.fxaa, shadows: normalized.shadows, enable_lighting: normalized.enableLighting, + solar_lighting: normalized.solarLighting, + solar_light_intensity: normalized.solarLightIntensity, maximum_screen_space_error: normalized.maximumScreenSpaceError, terrain_enabled_in_3d: normalized.terrainEnabledIn3D, terrain_exaggeration: normalized.terrainExaggeration, @@ -318,6 +338,8 @@ export class Cesium_Render_Settings extends enhance.Base { {this.render_switch("FXAA", "fxaa")} {this.render_switch("阴影", "shadows")} {this.render_switch("地球光照", "enableLighting")} + {this.render_switch("真实日照", "solarLighting")} + {this.render_number("太阳光强度", "solarLightIntensity", 0, 10, 0.1)} {this.render_number("地球细节误差", "maximumScreenSpaceError", 1, 16, 1)} {this.render_switch("3D启用地形", "terrainEnabledIn3D")} {this.render_terrain_exaggeration()}