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

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';
@@ -3275,6 +3277,37 @@ declare type LayerOptions = {
3275
3277
  depthOffset?: number;
3276
3278
  };
3277
3279
 
3280
+ /** 闪电系统 */
3281
+ declare class LightningSystem {
3282
+ private readonly _scene;
3283
+ private _hw;
3284
+ private _hh;
3285
+ private _bolts;
3286
+ private _flashMesh;
3287
+ private _flashOpacity;
3288
+ private _flickerLeft;
3289
+ private _flickerTick;
3290
+ private _intervalMin;
3291
+ private _intervalMax;
3292
+ private _lastTriggerTime;
3293
+ private _nextInterval;
3294
+ constructor(scene: Scene);
3295
+ /** 设置闪电间隔范围(毫秒) */
3296
+ setTriggerInterval(min: number, max: number): void;
3297
+ /** 获取当前间隔设置 */
3298
+ getTriggerInterval(): [number, number];
3299
+ trigger(): void;
3300
+ /** 内部用:重置下次触发间隔 */
3301
+ private _resetNextInterval;
3302
+ /**
3303
+ * 每帧调用,自动触发闪电
3304
+ * @param delta 帧间隔(秒)
3305
+ */
3306
+ update(delta: number, now?: number): void;
3307
+ resize(hw: number, hh: number): void;
3308
+ dispose(): void;
3309
+ }
3310
+
3278
3311
  export declare interface LightStyle extends BaseStyle {
3279
3312
  type: 'light';
3280
3313
  /** 点颜色 */
@@ -7699,6 +7732,8 @@ export declare class Viewer extends ViewerBase {
7699
7732
  /** 雾效因子 */
7700
7733
  private _fogFactor;
7701
7734
  private _sceneSize;
7735
+ /** 天气效果实例 */
7736
+ private _weatherEffect;
7702
7737
  /** 地面网格 */
7703
7738
  private gorund;
7704
7739
  /** 地图实例 */
@@ -7921,6 +7956,54 @@ export declare class Viewer extends ViewerBase {
7921
7956
  */
7922
7957
  getWidthHeight(): number[];
7923
7958
  _createGorund(): Mesh<PlaneGeometry, MeshStandardMaterial, Object3DEventMap>;
7959
+ /**
7960
+ * 初始化天气效果
7961
+ * 内部方法,由构造函数调用
7962
+ * @private
7963
+ */
7964
+ private _initWeather;
7965
+ /**
7966
+ * 设置天气效果
7967
+ * @param type 天气类型:'rain' | 'snow' | 'fog' | null(关闭)
7968
+ * @param options 额外配置项
7969
+ * @returns this
7970
+ * @example
7971
+ * viewer.setWeather('rain');
7972
+ * viewer.setWeather('snow', { speed: 0.5 });
7973
+ * viewer.setWeather('fog', { opacity: 0.8, speed: 1.5 });
7974
+ * viewer.setWeather(null); // 关闭天气效果
7975
+ */
7976
+ setWeather(type: WeatherType | null, options?: WeatherEffectOptions): this;
7977
+ /**
7978
+ * 获取当前天气效果实例
7979
+ * 用于直接操作 shader uniforms 等高级用法
7980
+ * @returns WeatherEffect 实例或 null
7981
+ */
7982
+ getWeatherEffect(): WeatherEffect | null;
7983
+ /**
7984
+ * 设置天气速度(雨/雾)
7985
+ * @param speed 速度值
7986
+ * @returns this
7987
+ */
7988
+ setWeatherSpeed(speed: number): this;
7989
+ /**
7990
+ * 设置天气透明度/浓度
7991
+ * @param opacity 透明度值
7992
+ * @returns this
7993
+ */
7994
+ setWeatherOpacity(opacity: number): this;
7995
+ /**
7996
+ * 设置雨倾斜角度
7997
+ * @param angle 角度(弧度)
7998
+ * @returns this
7999
+ */
8000
+ setWeatherRainAngle(angle: number): this;
8001
+ /**
8002
+ * 设置雨量/雨强(0.0 ~ 1.0)
8003
+ * @param intensity 雨强值,值越大雨滴越多/越密
8004
+ * @returns this
8005
+ */
8006
+ setWeatherRainIntensity(intensity: number): this;
7924
8007
  /**
7925
8008
  * 销毁viewer实例,释放所有资源
7926
8009
  * @description
@@ -8070,6 +8153,19 @@ export declare type ViewerOptions = {
8070
8153
  minDistance?: number;
8071
8154
  /** Maximum controller zoom distance (how far the camera can move), default is 60000 控制器最大缩放距离(相机能拉多远),默认为 60000 */
8072
8155
  maxDistance?: number;
8156
+ /** 天气效果配置(可选) Weather effect configuration */
8157
+ weather?: {
8158
+ /** 天气类型:'rain' | 'snow' | 'fog' | null */
8159
+ type?: WeatherType | null;
8160
+ /** 速度(雨/雾),默认 1.0 */
8161
+ speed?: number;
8162
+ /** 透明度/浓度(雾),默认 1.0 */
8163
+ opacity?: number;
8164
+ /** 雨倾斜角度(弧度),默认 -0.1 */
8165
+ rainAngle?: number;
8166
+ /** 雨量/雨强(0.0 ~ 1.0),默认 1.0 */
8167
+ rainIntensity?: number;
8168
+ };
8073
8169
  };
8074
8170
 
8075
8171
  /**
@@ -8082,6 +8178,95 @@ export declare function waitFor(condition: boolean, delay?: number): Promise<voi
8082
8178
  */
8083
8179
  export declare type WaterStyle = BaseWaterStyle | LightWaterStyle;
8084
8180
 
8181
+ export declare class WeatherEffect {
8182
+ /** 天气专用正交场景 */
8183
+ readonly scene: Scene;
8184
+ /** 天气专用正交相机 */
8185
+ readonly camera: OrthographicCamera;
8186
+ /** 全屏 mesh */
8187
+ readonly mesh: Mesh;
8188
+ /** 雨材质 */
8189
+ readonly rainMaterial: ShaderMaterial;
8190
+ /** 雪材质 */
8191
+ readonly snowMaterial: ShaderMaterial;
8192
+ /** 雾材质 */
8193
+ readonly fogMaterial: ShaderMaterial;
8194
+ /** 闪电系统 */
8195
+ readonly lightningSystem: LightningSystem;
8196
+ /** 当前天气类型 */
8197
+ private _type;
8198
+ /** 当前激活的材质 */
8199
+ private _activeMaterial;
8200
+ /**
8201
+ * 构造函数
8202
+ * @param width 容器宽度
8203
+ * @param height 容器高度
8204
+ * @param options 初始化配置
8205
+ */
8206
+ constructor(width: number, height: number, options?: WeatherEffectOptions);
8207
+ /** 获取当前天气类型 */
8208
+ get type(): WeatherType | null;
8209
+ /**
8210
+ * 切换天气类型
8211
+ * @param type 天气类型,为 null 时关闭天气效果
8212
+ */
8213
+ setWeather(type: WeatherType | null): this;
8214
+ /**
8215
+ * 设置速度(雨 speed / 雾 speed)
8216
+ * @param speed 速度值
8217
+ */
8218
+ setSpeed(speed: number): this;
8219
+ /**
8220
+ * 设置透明度/浓度
8221
+ * @param opacity 透明度值
8222
+ */
8223
+ setOpacity(opacity: number): this;
8224
+ /**
8225
+ * 设置雨倾斜角度(弧度)
8226
+ * @param angle 角度(弧度)
8227
+ */
8228
+ setRainAngle(angle: number): this;
8229
+ /**
8230
+ * 设置雨量/雨强(0.0 ~ 1.0)
8231
+ * @param intensity 雨强值,值越大雨滴越多/越密
8232
+ */
8233
+ setRainIntensity(intensity: number): this;
8234
+ /**
8235
+ * 触发一次闪电(可随时调用,常配合雷暴天气使用)
8236
+ */
8237
+ triggerLightning(): void;
8238
+ /**
8239
+ * 每帧调用,更新 iTime uniform
8240
+ * @param delta 帧间隔时间(秒)
8241
+ */
8242
+ update(delta: number): void;
8243
+ /**
8244
+ * 响应容器尺寸变化
8245
+ * @param width 新宽度
8246
+ * @param height 新高度
8247
+ */
8248
+ resize(width: number, height: number): void;
8249
+ /** 销毁资源 */
8250
+ dispose(): void;
8251
+ }
8252
+
8253
+ /** 天气效果配置选项 */
8254
+ export declare interface WeatherEffectOptions {
8255
+ /** 默认天气类型,默认为 null(无天气) */
8256
+ type?: WeatherType | null;
8257
+ /** 速度(雨/雾),默认 1.0 */
8258
+ speed?: number;
8259
+ /** 透明度/浓度,默认 1.0 */
8260
+ opacity?: number;
8261
+ /** 雨倾斜角度(弧度),默认 -0.1 */
8262
+ rainAngle?: number;
8263
+ /** 雨量/雨强(0.0 ~ 1.0),默认 1.0 */
8264
+ rainIntensity?: number;
8265
+ }
8266
+
8267
+ /** 天气类型 */
8268
+ export declare type WeatherType = 'rain' | 'snow' | 'fog';
8269
+
8085
8270
  /**
8086
8271
  * WMTS标准瓦片数据源
8087
8272
  * @description 实现OGC WMTS 1.0.0标准的瓦片数据源