@vesium/shared 1.0.1-beta.25

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.
@@ -0,0 +1,409 @@
1
+ import { Cartesian2 } from 'cesium';
2
+ import { Cartesian3 } from 'cesium';
3
+ import { Cartographic } from 'cesium';
4
+ import { Cesium3DTileset } from 'cesium';
5
+ import { CustomDataSource } from 'cesium';
6
+ import { CzmlDataSource } from 'cesium';
7
+ import { DataSource } from 'cesium';
8
+ import { Event as Event_2 } from 'cesium';
9
+ import { GeoJsonDataSource } from 'cesium';
10
+ import { GpxDataSource } from 'cesium';
11
+ import { JulianDate } from 'cesium';
12
+ import { KmlDataSource } from 'cesium';
13
+ import { Material } from 'cesium';
14
+ import { MaterialProperty } from 'cesium';
15
+ import { Primitive } from 'cesium';
16
+ import { PrimitiveCollection } from 'cesium';
17
+ import { Property } from 'cesium';
18
+ import { Scene } from 'cesium';
19
+ import { TextureMagnificationFilter } from 'cesium';
20
+ import { TextureMinificationFilter } from 'cesium';
21
+
22
+ /**
23
+ * Add material to Cesium's material cache, alias of `Material._materialCache.addMaterial`
24
+ */
25
+ export declare function addMaterialCache(type: string, material: CesiumMaterialConstructorOptions<any>): void;
26
+
27
+ export declare type AnyFn = (...args: any[]) => any;
28
+
29
+ export declare type ArgsFn<Args extends any[] = any[], Return = void> = (...args: Args) => Return;
30
+
31
+ /**
32
+ * 计算两个数组的差异,返回新增和删除的元素
33
+ */
34
+ export declare function arrayDifference<T>(list: T[], oldList: T[] | undefined): ArrayDifferenceRetrun<T>;
35
+
36
+ export declare interface ArrayDifferenceRetrun<T> {
37
+ added: T[];
38
+ removed: T[];
39
+ }
40
+
41
+ export declare function assertError(condition: boolean, error: any): void;
42
+
43
+ export declare type BasicType = number | string | boolean | symbol | bigint | null | undefined;
44
+
45
+ /**
46
+ * Convert canvas coordinates to Cartesian coordinates
47
+ *
48
+ * @param canvasCoord Canvas coordinates
49
+ * @param scene Cesium.Scene instance
50
+ * @param mode optional values are 'pickPosition' | 'globePick' | 'auto' | 'noHeight' @default 'auto'
51
+ *
52
+ * `pickPosition`: Use scene.pickPosition for conversion, which can be used for picking models, oblique photography, etc.
53
+ * However, if depth detection is not enabled (globe.depthTestAgainstTerrain=false), picking terrain or inaccurate issues may occur
54
+ *
55
+ * `globePick`: Use camera.getPickRay for conversion, which cannot be used for picking models or oblique photography,
56
+ * but can be used for picking terrain. If terrain does not exist, the picked elevation is 0
57
+ *
58
+ * `auto`: Automatically determine which picking content to return
59
+ *
60
+ * Calculation speed comparison: globePick > auto >= pickPosition
61
+ */
62
+ export declare function canvasCoordToCartesian(canvasCoord: Cartesian2, scene: Scene, mode?: 'pickPosition' | 'globePick' | 'auto'): Cartesian3 | undefined;
63
+
64
+ /**
65
+ * Convert Cartesian coordinates to canvas coordinates
66
+ *
67
+ * @param position Cartesian coordinates
68
+ * @param scene Cesium.Scene instance
69
+ */
70
+ export declare function cartesianToCanvasCoord(position: Cartesian3, scene: Scene): Cartesian2;
71
+
72
+ /**
73
+ * Common DataSource
74
+ */
75
+ export declare type CesiumDataSource = DataSource | CustomDataSource | CzmlDataSource | GeoJsonDataSource | GpxDataSource | KmlDataSource;
76
+
77
+ /**
78
+ * Determines if two Cesium objects are equal.
79
+ *
80
+ * This function not only judges whether the instances are equal,
81
+ * but also judges the equals method in the example.
82
+ *
83
+ * @param left The first Cesium object
84
+ * @param right The second Cesium object
85
+ * @returns Returns true if the two Cesium objects are equal, otherwise false
86
+ */
87
+ export declare function cesiumEquals(left: any, right: any): boolean;
88
+
89
+ /**
90
+ * 仅作为`Cesium.Material`的类型修复
91
+ */
92
+ export declare class CesiumMaterial<U> extends Material {
93
+ constructor(options: CesiumMaterialConstructorOptions<U>);
94
+ /**
95
+ * 矩阵配置
96
+ */
97
+ fabric: CesiumMaterialFabricOptions<U>;
98
+ }
99
+
100
+ /**
101
+ * Cesium.Material参数
102
+ */
103
+ export declare interface CesiumMaterialConstructorOptions<U> {
104
+ /**
105
+ * 严格模式
106
+ */
107
+ strict?: boolean;
108
+ /**
109
+ * translucent
110
+ */
111
+ translucent?: boolean | ((...params: any[]) => any);
112
+ /**
113
+ * 缩小滤镜
114
+ */
115
+ minificationFilter?: TextureMinificationFilter;
116
+ /**
117
+ * 放大滤镜
118
+ */
119
+ magnificationFilter?: TextureMagnificationFilter;
120
+ /**
121
+ * 矩阵配置
122
+ */
123
+ fabric: CesiumMaterialFabricOptions<U>;
124
+ }
125
+
126
+ /**
127
+ * Cesium.Material.fabric参数
128
+ */
129
+ export declare interface CesiumMaterialFabricOptions<U> {
130
+ /**
131
+ * 用于声明 fabric 对象最终会生成什么材质,如果是官方内置的,直接用官方内置的,否则则创建自定义的材质并缓存。
132
+ */
133
+ type: string;
134
+ /**
135
+ * 可再塞进去一层子级的 fabric,构成复合材质
136
+ */
137
+ materials?: Material;
138
+ /**
139
+ * glsl代码
140
+ */
141
+ source?: string;
142
+ components?: {
143
+ diffuse?: string;
144
+ alpha?: string;
145
+ };
146
+ /**
147
+ * 传glsl代码的变量
148
+ */
149
+ uniforms?: U & Record<string, any>;
150
+ }
151
+
152
+ /**
153
+ * 仅作为`Cesium.MaterialProperty`的类型修复
154
+ */
155
+ export declare interface CesiumMaterialProperty<V> extends MaterialProperty {
156
+ get isConstant(): boolean;
157
+ get definitionChanged(): Event_2<(scope: this, field: string, value: any, previous: any) => void>;
158
+ getType: (time: JulianDate) => string;
159
+ getValue: (time: JulianDate, result?: V) => V;
160
+ equals: (other?: any) => boolean;
161
+ }
162
+
163
+ export declare type CesiumPrimitive = Primitive | PrimitiveCollection | Cesium3DTileset | any;
164
+
165
+ /**
166
+ * Common Coordinate
167
+ * Can be a Cartesian3 point, a Cartographic point, an array, or an object containing longitude, latitude, and optional height information
168
+ */
169
+ export declare type CommonCoord = Cartesian3 | Cartographic | CoordArray | CoordArray_ALT | CoordObject | CoordObject_ALT;
170
+
171
+ /**
172
+ * 2D Coordinate System
173
+ */
174
+ export declare type CoordArray = [longitude: number, latitude: number];
175
+
176
+ /**
177
+ * 3D Coordinate System
178
+ */
179
+ export declare type CoordArray_ALT = [longitude: number, latitude: number, height?: number];
180
+
181
+ /**
182
+ * 2D Coordinate System
183
+ */
184
+ export declare interface CoordObject {
185
+ longitude: number;
186
+ latitude: number;
187
+ }
188
+
189
+ /**
190
+ * 3D Coordinate System
191
+ */
192
+ export declare interface CoordObject_ALT {
193
+ longitude: number;
194
+ latitude: number;
195
+ height?: number;
196
+ }
197
+
198
+ export declare function createCesiumAttribute<Scope extends object>(scope: Scope, key: keyof Scope, value: any, options?: CreateCesiumAttributeOptions): void;
199
+
200
+ export declare interface CreateCesiumAttributeOptions {
201
+ readonly?: boolean;
202
+ toProperty?: boolean;
203
+ /**
204
+ * The event name that triggers the change
205
+ * @default 'definitionChanged'
206
+ */
207
+ changedEventKey?: string;
208
+ shallowClone?: boolean;
209
+ }
210
+
211
+ export declare function createCesiumProperty<Scope extends object>(scope: Scope, key: keyof Scope, value: any, options?: CreateCesiumPropertyOptions): void;
212
+
213
+ export declare interface CreateCesiumPropertyOptions {
214
+ readonly?: boolean;
215
+ /**
216
+ * The event name that triggers the change
217
+ * @default 'definitionChanged'
218
+ */
219
+ changedEventKey?: string;
220
+ }
221
+
222
+ /**
223
+ * Create a Cesium property key
224
+ *
225
+ * @param scope The host object
226
+ * @param field The property name
227
+ * @param maybeProperty Optional property or getter
228
+ * @param readonly Whether the property is read-only
229
+ */
230
+ export declare function createPropertyField<T>(scope: any, field: string, maybeProperty?: MaybePropertyOrGetter<T>, readonly?: boolean): void;
231
+
232
+ /**
233
+ * Convert latitude and longitude coordinates to degrees-minutes-seconds format
234
+ *
235
+ * @param position The latitude and longitude coordinates
236
+ * @param precision The number of decimal places to retain for 'seconds', default is 3
237
+ * @returns Returns the coordinates in degrees-minutes-seconds format, or undefined if the conversion fails
238
+ */
239
+ export declare function degreesToDms(position: CommonCoord, precision?: number): DMSCoord | undefined;
240
+
241
+ export declare type DMSCoord = [longitude: string, latitude: string, height?: number];
242
+
243
+ /**
244
+ * Decode a DMS (Degrees Minutes Seconds) formatted string to a decimal angle value
245
+ *
246
+ * @param dmsCode DMS formatted string, e.g. "120°30′45″N"
247
+ * @returns The decoded decimal angle value, or 0 if decoding fails
248
+ */
249
+ export declare function dmsDecode(dmsCode: string): number;
250
+
251
+ /**
252
+ * Convert degrees to DMS (Degrees Minutes Seconds) format string
253
+ *
254
+ * @param degrees The angle value
255
+ * @param precision The number of decimal places to retain for the seconds, defaults to 3
256
+ * @returns A DMS formatted string in the format: degrees° minutes′ seconds″
257
+ */
258
+ export declare function dmsEncode(degrees: number, precision?: number): string;
259
+
260
+ /**
261
+ * Convert DMS (Degrees Minutes Seconds) format to decimal degrees for latitude and longitude coordinates
262
+ *
263
+ * @param dms The latitude or longitude coordinate in DMS format
264
+ * @returns Returns the coordinate in decimal degrees format, or undefined if the conversion fails
265
+ */
266
+ export declare function dmsToDegrees(dms: DMSCoord): CoordArray_ALT | undefined;
267
+
268
+ /**
269
+ * Get material from cache, alias of `Material._materialCache.getMaterial`
270
+ */
271
+ export declare function getMaterialCache<T extends Material = CesiumMaterial<any>>(type: string): T | undefined;
272
+
273
+ export declare const isArray: (arg: any) => arg is any[];
274
+
275
+ export declare function isBase64(val: string): boolean;
276
+
277
+ export declare function isBoolean(val: any): val is boolean;
278
+
279
+ /**
280
+ * Determines if the Cesium property is a constant.
281
+ *
282
+ * @param value Cesium property
283
+ */
284
+ export declare function isCesiumConstant(value: MaybeProperty): boolean;
285
+
286
+ export declare function isDef<T = any>(val?: T): val is T;
287
+
288
+ export declare function isElement<T extends Element>(val: any): val is T;
289
+
290
+ export declare function isFunction<T extends AnyFn>(val: any): val is T;
291
+
292
+ export declare function isNumber(val: any): val is number;
293
+
294
+ export declare function isObject(val: any): val is object;
295
+
296
+ export declare function isPromise<T extends Promise<any>>(val: any): val is T;
297
+
298
+ /**
299
+ * Is Cesium.Property
300
+ * @param value - The target object
301
+ */
302
+ export declare function isProperty(value: any): value is Property;
303
+
304
+ export declare function isString(val: unknown): val is string;
305
+
306
+ export declare function isWindow(val: any): val is Window;
307
+
308
+ export declare type MaybePromise<T = any> = T | (() => T) | Promise<T> | (() => Promise<T>);
309
+
310
+ export declare type MaybeProperty<T = any> = T | {
311
+ getValue: (time?: JulianDate) => T;
312
+ };
313
+
314
+ export declare type MaybePropertyOrGetter<T = any> = MaybeProperty<T> | (() => T);
315
+
316
+ export declare type Nullable<T> = T | null | undefined;
317
+
318
+ /**
319
+ * Determine if the given array of graphics is hit by Cesium's `scene.pick`
320
+ *
321
+ * @param pick The `scene.pick` object used for matching
322
+ * @param graphic An array of graphics to check for hits
323
+ */
324
+ export declare function pickHitGraphic(pick: any, graphic: any | any[]): boolean;
325
+
326
+ export declare type PropertyCallback<T = any> = (time: JulianDate, result?: T) => T;
327
+
328
+ /**
329
+ * Analyze the result of Cesium's `scene.pick` and convert it to an array format
330
+ */
331
+ export declare function resolvePick(pick?: any): any[];
332
+
333
+ /**
334
+ * Throttle function, which limits the frequency of execution of the function
335
+ *
336
+ * @param callback raw function
337
+ * @param delay Throttled delay duration (ms)
338
+ * @param trailing Trigger callback function after last call @default true
339
+ * @param leading Trigger the callback function immediately on the first call @default false
340
+ * @returns Throttle function
341
+ */
342
+ export declare function throttle<T extends any[]>(callback: ThrottleCallback<T>, delay?: number, trailing?: boolean, leading?: boolean): ThrottleCallback<T>;
343
+
344
+ export declare type ThrottleCallback<T extends any[]> = (...rest: T) => void;
345
+
346
+ /**
347
+ * Converts position to a coordinate point in the Cartesian coordinate system
348
+ *
349
+ * @param position Position information, which can be a Cartesian coordinate point (Cartesian3), a geographic coordinate point (Cartographic), an array, or an object containing WGS84 latitude, longitude, and height information
350
+ * @returns The converted Cartesian coordinate point. If the input parameter is invalid, undefined is returned
351
+ */
352
+ export declare function toCartesian3(position?: CommonCoord): Cartesian3 | undefined;
353
+
354
+ /**
355
+ * Converts a position to a Cartographic coordinate point
356
+ *
357
+ * @param position Position information, which can be a Cartesian3 coordinate point, a Cartographic coordinate point, an array, or an object containing WGS84 longitude, latitude, and height information
358
+ * @returns The converted Cartographic coordinate point, or undefined if the input parameter is invalid
359
+ */
360
+ export declare function toCartographic(position?: CommonCoord): Cartographic | undefined;
361
+
362
+ /**
363
+ * Converts coordinates to an array or object in the specified format.
364
+ *
365
+ * @param position The coordinate to be converted, which can be a Cartesian3, Cartographic, array, or object.
366
+ * @param options Conversion options, including conversion type and whether to include altitude information.
367
+ * @returns The converted coordinate, which may be an array or object. If the input position is empty, undefined is returned.
368
+ *
369
+ * @template T Conversion type, optional values are 'Array' or 'Object', @default 'Array'.
370
+ * @template Alt Whether to include altitude information, default is false
371
+ */
372
+ export declare function toCoord<T extends 'Array' | 'Object' = 'Array', Alt extends boolean = false>(position?: CommonCoord, options?: ToCoordOptions<T, Alt>): ToCoordReturn<T, Alt> | undefined;
373
+
374
+ declare interface ToCoordOptions<T extends 'Array' | 'Object', Alt extends boolean> {
375
+ /**
376
+ * Return type
377
+ * @default 'Array'
378
+ */
379
+ type?: T;
380
+ /**
381
+ * Whether to return altitude information
382
+ */
383
+ alt?: Alt;
384
+ }
385
+
386
+ export declare type ToCoordReturn<T extends 'Array' | 'Object', Alt extends boolean> = T extends 'Array' ? Alt extends true ? CoordArray_ALT : CoordArray : Alt extends true ? CoordObject_ALT : CoordObject;
387
+
388
+ /**
389
+ * Converts a value that may be a Property into a Property object, @see {toPropertyValue} for the reverse operation
390
+ *
391
+ * @param value - The property value or getter to convert, can be undefined or null
392
+ * @param isConstant - The second parameter for converting to CallbackProperty
393
+ * @returns Returns the converted Property object, if value is undefined or null, returns undefined
394
+ */
395
+ export declare function toProperty<T>(value?: MaybePropertyOrGetter<T>, isConstant?: boolean): Property;
396
+
397
+ /**
398
+ * Converts a value that may be a Property into its target value, @see {toProperty} for the reverse operation
399
+ * ```typescript
400
+ * toPropertyValue('val') //=> 'val'
401
+ * toPropertyValue(new ConstantProperty('val')) //=> 'val'
402
+ * toPropertyValue(new CallbackProperty(()=>'val')) //=> 'val'
403
+ * ```
404
+ *
405
+ * @param value - The value to convert
406
+ */
407
+ export declare function toPropertyValue<T = unknown>(value: MaybeProperty<T>, time?: JulianDate): T;
408
+
409
+ export { }