@terra.gl/core 0.0.1-alpha.61 → 0.0.1-alpha.62

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/dist/index.d.ts CHANGED
@@ -29,6 +29,7 @@ import { MultiPolygon } from 'geojson';
29
29
  import { NormalBufferAttributes } from 'three';
30
30
  import { Object3D } from 'three';
31
31
  import { Object3DEventMap } from 'three';
32
+ import { OrthographicCamera } from 'three';
32
33
  import { PerspectiveCamera } from 'three';
33
34
  import { PlaneGeometry } from 'three';
34
35
  import { Point as Point_2 } from 'geojson';
@@ -37,6 +38,7 @@ import { PointsMaterial } from 'three';
37
38
  import { Polygon as Polygon_2 } from 'geojson';
38
39
  import { Raycaster } from 'three';
39
40
  import { Scene } from 'three';
41
+ import { ShaderMaterial } from 'three';
40
42
  import { Sprite } from 'three';
41
43
  import { Texture } from 'three';
42
44
  import { TileLoadingManager as TileLoadingManager_2 } from './LoaderFactory';
@@ -7699,6 +7701,8 @@ export declare class Viewer extends ViewerBase {
7699
7701
  /** 雾效因子 */
7700
7702
  private _fogFactor;
7701
7703
  private _sceneSize;
7704
+ /** 天气效果实例 */
7705
+ private _weatherEffect;
7702
7706
  /** 地面网格 */
7703
7707
  private gorund;
7704
7708
  /** 地图实例 */
@@ -7921,6 +7925,54 @@ export declare class Viewer extends ViewerBase {
7921
7925
  */
7922
7926
  getWidthHeight(): number[];
7923
7927
  _createGorund(): Mesh<PlaneGeometry, MeshStandardMaterial, Object3DEventMap>;
7928
+ /**
7929
+ * 初始化天气效果
7930
+ * 内部方法,由构造函数调用
7931
+ * @private
7932
+ */
7933
+ private _initWeather;
7934
+ /**
7935
+ * 设置天气效果
7936
+ * @param type 天气类型:'rain' | 'snow' | 'fog' | null(关闭)
7937
+ * @param options 额外配置项
7938
+ * @returns this
7939
+ * @example
7940
+ * viewer.setWeather('rain');
7941
+ * viewer.setWeather('snow', { speed: 0.5 });
7942
+ * viewer.setWeather('fog', { opacity: 0.8, speed: 1.5 });
7943
+ * viewer.setWeather(null); // 关闭天气效果
7944
+ */
7945
+ setWeather(type: WeatherType | null, options?: WeatherEffectOptions): this;
7946
+ /**
7947
+ * 获取当前天气效果实例
7948
+ * 用于直接操作 shader uniforms 等高级用法
7949
+ * @returns WeatherEffect 实例或 null
7950
+ */
7951
+ getWeatherEffect(): WeatherEffect | null;
7952
+ /**
7953
+ * 设置天气速度(雨/雾)
7954
+ * @param speed 速度值
7955
+ * @returns this
7956
+ */
7957
+ setWeatherSpeed(speed: number): this;
7958
+ /**
7959
+ * 设置天气透明度/浓度
7960
+ * @param opacity 透明度值
7961
+ * @returns this
7962
+ */
7963
+ setWeatherOpacity(opacity: number): this;
7964
+ /**
7965
+ * 设置雨倾斜角度
7966
+ * @param angle 角度(弧度)
7967
+ * @returns this
7968
+ */
7969
+ setWeatherRainAngle(angle: number): this;
7970
+ /**
7971
+ * 设置雨量/雨强(0.0 ~ 1.0)
7972
+ * @param intensity 雨强值,值越大雨滴越多/越密
7973
+ * @returns this
7974
+ */
7975
+ setWeatherRainIntensity(intensity: number): this;
7924
7976
  /**
7925
7977
  * 销毁viewer实例,释放所有资源
7926
7978
  * @description
@@ -8070,6 +8122,19 @@ export declare type ViewerOptions = {
8070
8122
  minDistance?: number;
8071
8123
  /** Maximum controller zoom distance (how far the camera can move), default is 60000 控制器最大缩放距离(相机能拉多远),默认为 60000 */
8072
8124
  maxDistance?: number;
8125
+ /** 天气效果配置(可选) Weather effect configuration */
8126
+ weather?: {
8127
+ /** 天气类型:'rain' | 'snow' | 'fog' | null */
8128
+ type?: WeatherType | null;
8129
+ /** 速度(雨/雾),默认 1.0 */
8130
+ speed?: number;
8131
+ /** 透明度/浓度(雾),默认 1.0 */
8132
+ opacity?: number;
8133
+ /** 雨倾斜角度(弧度),默认 -0.1 */
8134
+ rainAngle?: number;
8135
+ /** 雨量/雨强(0.0 ~ 1.0),默认 1.0 */
8136
+ rainIntensity?: number;
8137
+ };
8073
8138
  };
8074
8139
 
8075
8140
  /**
@@ -8082,6 +8147,89 @@ export declare function waitFor(condition: boolean, delay?: number): Promise<voi
8082
8147
  */
8083
8148
  export declare type WaterStyle = BaseWaterStyle | LightWaterStyle;
8084
8149
 
8150
+ export declare class WeatherEffect {
8151
+ /** 天气专用正交场景 */
8152
+ readonly scene: Scene;
8153
+ /** 天气专用正交相机 */
8154
+ readonly camera: OrthographicCamera;
8155
+ /** 全屏 mesh */
8156
+ readonly mesh: Mesh;
8157
+ /** 雨材质 */
8158
+ readonly rainMaterial: ShaderMaterial;
8159
+ /** 雪材质 */
8160
+ readonly snowMaterial: ShaderMaterial;
8161
+ /** 雾材质 */
8162
+ readonly fogMaterial: ShaderMaterial;
8163
+ /** 当前天气类型 */
8164
+ private _type;
8165
+ /** 当前激活的材质 */
8166
+ private _activeMaterial;
8167
+ /**
8168
+ * 构造函数
8169
+ * @param width 容器宽度
8170
+ * @param height 容器高度
8171
+ * @param options 初始化配置
8172
+ */
8173
+ constructor(width: number, height: number, options?: WeatherEffectOptions);
8174
+ /** 获取当前天气类型 */
8175
+ get type(): WeatherType | null;
8176
+ /**
8177
+ * 切换天气类型
8178
+ * @param type 天气类型,为 null 时关闭天气效果
8179
+ */
8180
+ setWeather(type: WeatherType | null): this;
8181
+ /**
8182
+ * 设置速度(雨 speed / 雾 speed)
8183
+ * @param speed 速度值
8184
+ */
8185
+ setSpeed(speed: number): this;
8186
+ /**
8187
+ * 设置透明度/浓度
8188
+ * @param opacity 透明度值
8189
+ */
8190
+ setOpacity(opacity: number): this;
8191
+ /**
8192
+ * 设置雨倾斜角度(弧度)
8193
+ * @param angle 角度(弧度)
8194
+ */
8195
+ setRainAngle(angle: number): this;
8196
+ /**
8197
+ * 设置雨量/雨强(0.0 ~ 1.0)
8198
+ * @param intensity 雨强值,值越大雨滴越多/越密
8199
+ */
8200
+ setRainIntensity(intensity: number): this;
8201
+ /**
8202
+ * 每帧调用,更新 iTime uniform
8203
+ * @param delta 帧间隔时间(秒)
8204
+ */
8205
+ update(delta: number): void;
8206
+ /**
8207
+ * 响应容器尺寸变化
8208
+ * @param width 新宽度
8209
+ * @param height 新高度
8210
+ */
8211
+ resize(width: number, height: number): void;
8212
+ /** 销毁资源 */
8213
+ dispose(): void;
8214
+ }
8215
+
8216
+ /** 天气效果配置选项 */
8217
+ export declare interface WeatherEffectOptions {
8218
+ /** 默认天气类型,默认为 null(无天气) */
8219
+ type?: WeatherType | null;
8220
+ /** 速度(雨/雾),默认 1.0 */
8221
+ speed?: number;
8222
+ /** 透明度/浓度,默认 1.0 */
8223
+ opacity?: number;
8224
+ /** 雨倾斜角度(弧度),默认 -0.1 */
8225
+ rainAngle?: number;
8226
+ /** 雨量/雨强(0.0 ~ 1.0),默认 1.0 */
8227
+ rainIntensity?: number;
8228
+ }
8229
+
8230
+ /** 天气类型 */
8231
+ export declare type WeatherType = 'rain' | 'snow' | 'fog';
8232
+
8085
8233
  /**
8086
8234
  * WMTS标准瓦片数据源
8087
8235
  * @description 实现OGC WMTS 1.0.0标准的瓦片数据源