@metagl/sdk-render 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lacdt.render.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import * as Cesium from 'cesium';
1
+ import * as Cesium$1 from 'cesium';
2
2
  import { Cartesian3, Color, Viewer, PostProcessStage, Cartesian4, Rectangle, Primitive, Cesium3DTileset, ClippingPolygonCollection } from 'cesium';
3
3
  import { Render as Render$1 } from '@/system/RenderCore';
4
+ import { VectorTileset } from '@metagl/sdk-mbtiles';
4
5
 
5
6
  /**
6
7
  * RenderSystem
@@ -233,6 +234,8 @@ interface VolumetricCloudsConfig {
233
234
  cloudThickness?: number;
234
235
  cloudLightIntensity?: number;
235
236
  cloudIntensity?: number;
237
+ cloudOpacityMin?: number;
238
+ cloudOpacityMax?: number;
236
239
  visibility?: CloudVisibilityConfig;
237
240
  }
238
241
  /**
@@ -527,6 +530,12 @@ interface HeightFogConfig {
527
530
  enabled?: boolean;
528
531
  fogByHeight?: Cartesian4;
529
532
  fogColor?: Color;
533
+ /** Henyey-Greenstein 前向散射系数 [0,1],默认 0.70 */
534
+ fogG?: number;
535
+ /** 太阳方向散射强度乘数,默认 1.2 */
536
+ fogScattering?: number;
537
+ /** 环境光散射占比 [0,1],默认 0.25 */
538
+ fogAmbient?: number;
530
539
  visibility?: FogVisibilityConfig;
531
540
  }
532
541
  /**
@@ -732,6 +741,8 @@ declare class PostProcessingSystem implements RenderSystem {
732
741
  disable(): void;
733
742
  update(config: Partial<PostProcessingConfig>): void;
734
743
  getStatus(): boolean;
744
+ /** 返回当前已加入队列的自定义 Stage 列表(供 RenderCore 做顺序修正)*/
745
+ getCustomStages(): PostProcessStage[];
735
746
  getConfig(): PostProcessingConfig;
736
747
  saveConfig(): any;
737
748
  destroy(): void;
@@ -1131,6 +1142,10 @@ declare class WaterSystem implements RenderSystem {
1131
1142
  * 直接修改已存在水图元的材质参数
1132
1143
  */
1133
1144
  updateWaterLayerEffect(config: Partial<WaterConfig>): void;
1145
+ /**
1146
+ * 更新单个图元的材质参数
1147
+ */
1148
+ private updateSinglePrimitiveMaterial;
1134
1149
  /**
1135
1150
  * 获取系统状态
1136
1151
  */
@@ -1471,7 +1486,7 @@ declare class LayerSystem implements RenderSystem {
1471
1486
  }
1472
1487
 
1473
1488
  interface ViewshedConfig {
1474
- position: Cesium.Cartesian3;
1489
+ position: Cesium$1.Cartesian3;
1475
1490
  heading: number;
1476
1491
  pitch: number;
1477
1492
  distance: number;
@@ -1481,8 +1496,8 @@ interface ViewshedConfig {
1481
1496
  texelSnap?: boolean;
1482
1497
  minHeight?: number;
1483
1498
  near?: number;
1484
- visibleColor?: Cesium.Color;
1485
- hiddenColor?: Cesium.Color;
1499
+ visibleColor?: Cesium$1.Color;
1500
+ hiddenColor?: Cesium$1.Color;
1486
1501
  }
1487
1502
  /**
1488
1503
  * 视域分析系统 - 支持多视域实例和多视锥体模式
@@ -1550,7 +1565,7 @@ declare class ViewshedAnalysisSystem implements RenderSystem {
1550
1565
  /**
1551
1566
  * 使用 direction 和 up 向量更新视域方向(参考 DirectionCameraBinding)
1552
1567
  */
1553
- updateViewshedOrientation(id: string, position: Cesium.Cartesian3, direction: Cesium.Cartesian3, up: Cesium.Cartesian3): void;
1568
+ updateViewshedOrientation(id: string, position: Cesium$1.Cartesian3, direction: Cesium$1.Cartesian3, up: Cesium$1.Cartesian3): void;
1554
1569
  /**
1555
1570
  * 更新可视距离
1556
1571
  */
@@ -1650,7 +1665,7 @@ declare class ViewshedAnalysisSystem implements RenderSystem {
1650
1665
  }
1651
1666
 
1652
1667
  interface SingleViewshedConfig {
1653
- position: Cesium.Cartesian3;
1668
+ position: Cesium$1.Cartesian3;
1654
1669
  heading: number;
1655
1670
  pitch: number;
1656
1671
  distance: number;
@@ -2511,6 +2526,9 @@ declare class Render {
2511
2526
  *
2512
2527
  * 修正方式:直接操作 PostProcessStageCollection 的内部 _stages 数组调整顺序,
2513
2528
  * 不调用 remove()(remove 会 destroy GPU 资源),不触发 Shader 重编译,无视觉闪烁。
2529
+ *
2530
+ * 目标顺序:云 → 大气 → 后处理(whiteBalance/colorAdjustment/...)
2531
+ * 原因:后处理的 exposure 等效果作用在大气之后才正确;大气需读取未经后处理的原始场景。
2514
2532
  */
2515
2533
  private ensurePostProcessStageOrder;
2516
2534
  private registerSystems;
@@ -2535,6 +2553,11 @@ declare class Render {
2535
2553
  * 清除当前预设,关闭所有环境系统
2536
2554
  */
2537
2555
  clearPreset(): void;
2556
+ /**
2557
+ * 重置所有环境系统到默认配置(单一出口)
2558
+ * 等效于 applyConfig(DEFAULT_CONFIG),所有系统参数回到 DefaultConfig.ts 定义的值并禁用。
2559
+ */
2560
+ resetConfig(): void;
2538
2561
  /**
2539
2562
  * 获取当前激活的预设 ID,未激活时返回 null
2540
2563
  */
@@ -2543,6 +2566,19 @@ declare class Render {
2543
2566
  * 启用所有系统
2544
2567
  */
2545
2568
  enableAllSystems(): void;
2569
+ /**
2570
+ * 以 DefaultConfig 参数启用所有环境系统
2571
+ *
2572
+ * 与直接调用 enableSystem() 的区别:
2573
+ * - 先将所有系统参数重置为 DefaultConfig(清除预设残留)
2574
+ * - 再启用所有环境系统
2575
+ *
2576
+ * 解决问题:
2577
+ * "全部开启"按钮点击时,若之前曾应用过预设,系统内部仍持有预设参数
2578
+ * (如 ACES 色调映射 / exposure 1.20 / 暖色温),导致视觉结果与 DefaultConfig 不一致。
2579
+ * 此方法保证"全部开启"始终以 DefaultConfig 参数运行。
2580
+ */
2581
+ enableAllWithDefaults(): void;
2546
2582
  /**
2547
2583
  * 禁用所有系统
2548
2584
  */
@@ -4495,227 +4531,173 @@ declare class CameraUrlManager {
4495
4531
  destroy(): void;
4496
4532
  }
4497
4533
 
4498
- /**
4499
- * 矩形区域定义
4500
- */
4501
- interface RainBounds {
4502
- /** 左上角经度 */
4503
- west: number;
4504
- /** 左上角纬度 */
4505
- north: number;
4506
- /** 右下角经度 */
4507
- east: number;
4508
- /** 右下角纬度 */
4509
- south: number;
4534
+ interface WeatherAreaData {
4535
+ gger: string;
4536
+ minLon: number;
4537
+ maxLon: number;
4538
+ minLat: number;
4539
+ maxLat: number;
4540
+ weatherType: 'rainy' | 'snowy' | 'foggy' | 'sunny';
4510
4541
  }
4511
- /**
4512
- * 下雨系统配置接口
4513
- */
4514
- interface RainConfig {
4515
- /** 是否启用下雨系统 */
4516
- enabled: boolean;
4517
- /** 雨滴发射率 (个/秒) */
4518
- emissionRate: number;
4519
- /** 雨滴大小 */
4520
- particleSize: number;
4521
- /** 最小生命周期(秒) */
4522
- minimumParticleLife: number;
4523
- /** 最大生命周期(秒) */
4524
- maximumParticleLife: number;
4525
- /** 最小速度 */
4526
- minimumSpeed: number;
4527
- /** 最大速度 */
4528
- maximumSpeed: number;
4529
- /** 雨滴颜色 */
4530
- color: Color;
4531
- /** 重力因子(负值向下,正值向上) */
4532
- gravity: number;
4533
- /** 下雨区域范围(矩形) */
4534
- bounds?: RainBounds;
4535
- /** 相机高度超过此值时隐藏雨滴(单位:米),默认5000 */
4536
- hideAltitude?: number;
4537
- /** 雨滴纹理图片路径,默认 './image/rain.png' */
4538
- imagePath?: string;
4539
- /** 雨滴纹理类型: 'rain' | 'hail' | 'snow' */
4540
- imageType?: 'rain' | 'hail' | 'snow';
4542
+ declare class RainSystem {
4543
+ private _viewer;
4544
+ private _effects;
4545
+ private _anchorEntities;
4546
+ private _allAreas;
4547
+ private _lastCameraPosition;
4548
+ private _effectPaused;
4549
+ private _isPageVisible;
4550
+ private _isWindowFocused;
4551
+ private _rainCanvas;
4552
+ private _snowCanvas;
4553
+ private _fogCanvas;
4554
+ private readonly MAX_EFFECTS;
4555
+ private readonly UPDATE_THRESHOLD;
4556
+ private _pendingAdd;
4557
+ private _pendingRemove;
4558
+ private _isUpdating;
4559
+ private _lastUpdateTime;
4560
+ private readonly THROTTLE_MS;
4561
+ private _tickHandler;
4562
+ constructor(viewer: any, Cesium?: any);
4563
+ /**
4564
+ * 从JSON数组加载天气效果
4565
+ */
4566
+ loadFromJson(areas: WeatherAreaData[]): void;
4567
+ private _setupVisibilityHandler;
4568
+ private _updatePauseState;
4569
+ private _setEffectsPaused;
4570
+ private _pauseAllEffects;
4571
+ private _resumeAllEffects;
4572
+ private _startCameraWatch;
4573
+ private _scheduleUpdate;
4574
+ private _computePendingChanges;
4575
+ private _processNextPending;
4576
+ private _updateVisibleEffects;
4577
+ private _getVisibleAreas;
4578
+ /**
4579
+ * 添加单个天气区域
4580
+ */
4581
+ addWeatherArea(area: WeatherAreaData): void;
4582
+ /**
4583
+ * 移除指定区域天气效果
4584
+ */
4585
+ removeWeatherArea(id: string): void;
4586
+ /**
4587
+ * 清空所有天气效果
4588
+ */
4589
+ clearAll(): void;
4590
+ private _createSunnyEffect;
4591
+ private _createRainEffect;
4592
+ private _createSnowEffect;
4593
+ private _createFogEffect;
4594
+ private _createSunCoreCanvas;
4595
+ private _createRainCanvas;
4596
+ private _createSnowCanvas;
4597
+ private _createFogCanvas;
4598
+ private _getParticleSystemMatrix;
4599
+ }
4600
+
4601
+ interface VectorTileSystemConfig {
4602
+ enabled?: boolean;
4603
+ style?: string | object;
4604
+ showTileColor?: boolean;
4605
+ workerUrl?: string;
4606
+ maximumActiveTasks?: number;
4541
4607
  }
4542
4608
  /**
4543
- * 默认下雨配置
4544
- */
4545
- declare const defaultRainConfig: RainConfig;
4546
- /**
4547
- * 下雨系统类
4548
- * 负责管理场景中的局部下雨效果
4609
+ * 矢量瓦片系统类
4610
+ * 用于加载和显示Mapbox矢量瓦片
4611
+ * 参考: sdk-mbtiles/examples/index.js
4549
4612
  */
4550
- declare class RainSystem implements RenderSystem {
4613
+ declare class VectorTileSystem {
4551
4614
  private viewer;
4552
- private config;
4553
- private rainParticleSystems;
4554
- private isInitialized;
4555
4615
  private isEnabled;
4556
- private rainImage;
4557
- private hideAltitude;
4558
- private lastAltitudeCheck;
4559
- private readonly altitudeCheckInterval;
4560
- private shaderRainStage;
4561
- private useShaderRain;
4562
- private shaderRainHeight;
4563
- private currentImageType;
4564
- private weatherIconElement;
4565
- private weatherIconVisible;
4566
- constructor(viewer: Viewer, config?: Partial<RainConfig>);
4567
- /**
4568
- * 初始化下雨系统
4569
- */
4570
- initialize(): void;
4571
- /**
4572
- * 在指定矩形范围内创建下雨效果
4573
- */
4574
- private createRainSystemsInBounds;
4575
- /**
4576
- * 创建网格点的下雨粒子系统
4577
- */
4578
- private createGridRainSystem;
4579
- /**
4580
- * 计算发射器模型矩阵
4581
- * 让发射方向向下(旋转使发射器朝向地面)
4582
- */
4583
- private computeEmitterModelMatrix;
4584
- /**
4585
- * 创建雨滴纹理图像 - 使用 Canvas 程序生成细长的雨丝
4586
- */
4587
- private createRainImage;
4588
- /**
4589
- * 创建 Canvas 雨滴纹理
4590
- */
4591
- private createCanvashailImage;
4592
- private createCanvasSnowImage;
4593
- /**
4594
- * 设置雨滴纹理类型
4595
- * @param type 纹理类型: 'rain' | 'hail' | 'snow'
4596
- */
4597
- setRainImageType(type: 'rain' | 'hail' | 'snow'): void;
4598
- /**
4599
- * 设置自定义雨滴纹理路径
4600
- * @param imagePath 纹理图片路径,如 './image/rain.png'
4601
- */
4602
- setRainImage(imagePath: string): void;
4603
- /**
4604
- * 创建着色器雨效(后期处理方式)
4605
- * 参考 natureSimulate.js 的 FS_Rain 实现,兼容 WebGL 2.0
4606
- */
4607
- private createShaderRainStage;
4608
- /**
4609
- * 根据相机高度切换雨效模式
4610
- * 500米以内使用着色器雨效,500米以上使用粒子系统
4611
- */
4612
- private switchRainEffectMode;
4613
- /**
4614
- * 获取相机正下方地形的海拔高度
4615
- */
4616
- private getTerrainHeightBelowCamera;
4617
- /**
4618
- * 应用重力效果 - 雨滴下落
4619
- */
4620
- private applyGravity;
4621
- /**
4622
- * 根据相机高度更新雨滴可见性
4623
- * 当相机高度超过 hideAltitude 时隐藏雨滴,拉近时重新显示
4624
- * 同时更新天气图标的显示状态
4625
- */
4626
- updateCameraVisibility(): void;
4627
- /**
4628
- * 创建天气图标 DOM 元素
4629
- */
4630
- private createWeatherIcon;
4616
+ private config;
4617
+ private tileset;
4618
+ private style;
4619
+ constructor(viewer: Cesium.Viewer, config?: VectorTileSystemConfig);
4631
4620
  /**
4632
- * 获取当前天气类型的图标信息
4621
+ * 初始化系统
4633
4622
  */
4634
- private getWeatherIconInfo;
4623
+ private init;
4635
4624
  /**
4636
- * 显示天气图标
4625
+ * 设置样式并重新加载
4626
+ * @param style Mapbox样式URL或样式对象
4637
4627
  */
4638
- private showWeatherIcon;
4628
+ setStyle(style: string | object): Promise<void>;
4639
4629
  /**
4640
- * 隐藏天气图标
4630
+ * 获取当前样式
4641
4631
  */
4642
- private hideWeatherIcon;
4632
+ getStyle(): string | object | null;
4643
4633
  /**
4644
- * 更新天气图标显示内容
4634
+ * 设置图层布局属性
4635
+ * @param layerId 图层ID
4636
+ * @param name 属性名
4637
+ * @param value 属性值
4645
4638
  */
4646
- private updateWeatherIconContent;
4639
+ setLayoutProperty(layerId: string, name: string, value: any): boolean;
4647
4640
  /**
4648
- * 启用下雨系统
4641
+ * 设置图层绘制属性
4642
+ * @param layerId 图层ID
4643
+ * @param name 属性名
4644
+ * @param value 属性值
4649
4645
  */
4650
- enable(): void;
4646
+ setPaintProperty(layerId: string, name: string, value: any): boolean;
4651
4647
  /**
4652
- * 设置相机高度追踪
4653
- * 在每一帧渲染后检测相机高度,超过阈值时隐藏雨滴
4654
- * 同时根据高度切换着色器雨效和粒子系统
4648
+ * 设置图层过滤器
4649
+ * @param layerId 图层ID
4650
+ * @param filter 过滤器
4655
4651
  */
4656
- private cameraTrackingCallback;
4652
+ setFilter(layerId: string, filter: any): boolean;
4657
4653
  /**
4658
- * 设置相机追踪
4654
+ * 获取矢量瓦片集实例
4659
4655
  */
4660
- private setupCameraTracking;
4656
+ getTileset(): VectorTileset | null;
4661
4657
  /**
4662
- * 禁用下雨系统
4658
+ * 获取就绪状态
4663
4659
  */
4664
- disable(): void;
4660
+ isReady(): boolean;
4665
4661
  /**
4666
- * 更新系统配置 - 实时天气数据更新的统一公共接口
4667
- * 支持不同天气状态间的动态平滑过渡(例如强度由小雨转大雨,或类型由雨转雪)
4668
- * @param config 部分配置参数,将与现有配置合并
4662
+ * 设置显示状态
4669
4663
  */
4670
- update(config: Partial<RainConfig>): void;
4664
+ setVisible(visible: boolean): void;
4671
4665
  /**
4672
- * 更新下雨区域范围
4673
- * @param bounds 新的区域范围
4666
+ * 获取显示状态
4674
4667
  */
4675
- private updateBounds;
4668
+ getVisible(): boolean;
4676
4669
  /**
4677
- * 平滑过渡到新的天气强度
4678
- * @param targetEmissionRate 目标发射率
4679
- * @param duration 过渡持续时间(毫秒)
4670
+ * 启用系统
4680
4671
  */
4681
- transitionToIntensity(targetEmissionRate: number, duration?: number): void;
4672
+ enable(): Promise<void>;
4682
4673
  /**
4683
- * 平滑过渡到新的天气类型
4684
- * @param targetType 目标天气类型
4685
- * @param duration 过渡持续时间(毫秒)
4674
+ * 禁用系统
4686
4675
  */
4687
- transitionToType(targetType: 'rain' | 'hail' | 'snow', duration?: number): void;
4676
+ disable(): Promise<void>;
4688
4677
  /**
4689
- * 获取系统状态
4678
+ * 获取启用状态
4690
4679
  */
4691
4680
  getStatus(): boolean;
4692
4681
  /**
4693
- * 设置相机隐藏高度
4694
- * @param altitude 相机高度超过此值时隐藏雨滴(单位:米)
4682
+ * 切换启用状态
4695
4683
  */
4696
- setHideAltitude(altitude: number): void;
4684
+ toggle(): Promise<boolean>;
4697
4685
  /**
4698
- * 获取当前相机高度
4686
+ * 更新配置
4699
4687
  */
4700
- getCurrentCameraHeight(): number;
4688
+ update(newConfig: Partial<VectorTileSystemConfig>): Promise<void>;
4701
4689
  /**
4702
- * 设置是否启用着色器雨效模式
4703
- * @param enabled 是否启用着色器雨效(相机低于500米时自动切换)
4690
+ * 获取当前配置
4704
4691
  */
4705
- setShaderRainEnabled(enabled: boolean): void;
4692
+ getConfig(): VectorTileSystemConfig;
4706
4693
  /**
4707
- * 设置着色器雨效切换高度
4708
- * @param height 相机高度低于此值时切换到着色器雨效(单位:米)
4694
+ * 移除矢量瓦片集
4709
4695
  */
4710
- setShaderRainHeight(height: number): void;
4696
+ private removeTileset;
4711
4697
  /**
4712
4698
  * 销毁系统
4713
4699
  */
4714
- destroy(): void;
4715
- /**
4716
- * 获取当前配置
4717
- */
4718
- getConfig(): RainConfig;
4700
+ destroy(): Promise<void>;
4719
4701
  }
4720
4702
 
4721
4703
  declare global {
@@ -4762,6 +4744,8 @@ declare const render: {
4762
4744
  RainSystem: typeof RainSystem;
4763
4745
  /** 海洋系统 */
4764
4746
  SeaSystem: typeof SeaSystem;
4747
+ /** 矢量瓦片系统 */
4748
+ VectorTileSystem: typeof VectorTileSystem;
4765
4749
  };
4766
4750
 
4767
- export { AtmosphereControl, type AtmosphereScatteringConfig, AtmosphereScatteringSystem, BuildingControl, BuildingSystem, CameraListener, type CameraListenerConfig, CameraListenerSystem, type CameraListenerSystemConfig, type CameraParams, CameraUrlManager, type CameraUrlManagerConfig, type DirectionalLightConfig, type DistanceFogConfig, DistanceFogSystem, EnvironmentControl, FogControl, type HeightFogConfig, HeightFogSystem, LayerControl, LayerSystem, LightingControl, LightingSystem, PlottingControl, type PostProcessingConfig, PostProcessingControl, PostProcessingSystem, type RainBounds, type RainConfig, RainSystem, Render, type RenderConfig, RenderControl, type SeaConfig, SeaSystem, type ShadowConfig, ShadowControl, ShadowSystem, SidebarControl, TilesetManager, TilesetSearchControl, ToolboxControl, ToolboxSystem, VolumetricCloudControl, type VolumetricCloudsConfig, VolumetricCloudsSystem, type WaterConfig, WaterControl, WaterSystem, defaultRainConfig, render };
4751
+ export { AtmosphereControl, type AtmosphereScatteringConfig, AtmosphereScatteringSystem, BuildingControl, BuildingSystem, CameraListener, type CameraListenerConfig, CameraListenerSystem, type CameraListenerSystemConfig, type CameraParams, CameraUrlManager, type CameraUrlManagerConfig, type DirectionalLightConfig, type DistanceFogConfig, DistanceFogSystem, EnvironmentControl, FogControl, type HeightFogConfig, HeightFogSystem, LayerControl, LayerSystem, LightingControl, LightingSystem, PlottingControl, type PostProcessingConfig, PostProcessingControl, PostProcessingSystem, RainSystem, Render, type RenderConfig, RenderControl, type SeaConfig, SeaSystem, type ShadowConfig, ShadowControl, ShadowSystem, SidebarControl, TilesetManager, TilesetSearchControl, ToolboxControl, ToolboxSystem, VectorTileSystem, VolumetricCloudControl, type VolumetricCloudsConfig, VolumetricCloudsSystem, type WaterConfig, WaterControl, WaterSystem, type WeatherAreaData, render };