@juun-roh/cesium-utils 0.4.3 → 0.4.5
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/collection/index.js +1 -1
- package/dist/highlight/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1329 -6
- package/dist/index.d.ts +1329 -6
- package/dist/index.js +1 -1
- package/dist/terrain/dev/index.cjs +1 -1
- package/dist/terrain/dev/index.js +1 -1
- package/dist/terrain/index.cjs +1 -1
- package/dist/terrain/index.js +1 -1
- package/dist/viewer/index.js +1 -1
- package/package.json +85 -43
- package/dist/chunk-6I6OKECI.js +0 -0
- package/dist/chunk-PSCNWZUR.js +0 -1
- package/dist/chunk-WTOAUTEK.js +0 -1
- package/dist/chunk-XHMLNB5Q.js +0 -1
- package/dist/chunk-Z2COOTT4.js +0 -1
- package/dist/collection/index.d.cts +0 -553
- package/dist/collection/index.d.ts +0 -553
- package/dist/dev/index.d.cts +0 -98
- package/dist/dev/index.d.ts +0 -98
- package/dist/experimental/index.d.cts +0 -105
- package/dist/experimental/index.d.ts +0 -105
- package/dist/highlight/index.d.cts +0 -245
- package/dist/highlight/index.d.ts +0 -245
- package/dist/hybrid-terrain-provider-Th8n2hZ1.d.cts +0 -180
- package/dist/hybrid-terrain-provider-Th8n2hZ1.d.ts +0 -180
- package/dist/terrain/dev/index.d.cts +0 -125
- package/dist/terrain/dev/index.d.ts +0 -125
- package/dist/terrain/index.d.cts +0 -8
- package/dist/terrain/index.d.ts +0 -8
- package/dist/viewer/index.d.cts +0 -19
- package/dist/viewer/index.d.ts +0 -19
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,1329 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { DataSourceCollection, EntityCollection, ImageryLayerCollection, PrimitiveCollection, Billboard, Cesium3DTileset, GroundPrimitive, Label, PointPrimitive, Polyline, Primitive, DataSource, Entity, ImageryLayer, Color, Viewer, Model, Cesium3DTileFeature, TerrainProvider, TilingScheme, TileAvailability, Credit, Event, Request, TerrainData, Cartesian3, JulianDate, Rectangle } from 'cesium';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a path to any nested property in an object, using dot notation.
|
|
5
|
+
*
|
|
6
|
+
* The `(keyof T & string)` portion provides top-level key hints in autocomplete,
|
|
7
|
+
* while `(string & {})` allows any string input to pass through.
|
|
8
|
+
*
|
|
9
|
+
* Actual path validation is delegated to {@link NestedValueOf}, which returns `never`
|
|
10
|
+
* for invalid paths — causing a type error on the corresponding value parameter.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* function f<Path extends NestedKeyOf<Obj>>(
|
|
15
|
+
* key: Path,
|
|
16
|
+
* value: NestedValueOf<Obj, Path> // ← validation happens here
|
|
17
|
+
* ) {}
|
|
18
|
+
*
|
|
19
|
+
* f("a.b.c", 123); // ✅ valid path, correct value type
|
|
20
|
+
* f("invalid.path", 1); // ❌ NestedValueOf returns never
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
type NestedKeyOf<T extends object> = (keyof T & string) | (string & {});
|
|
24
|
+
/**
|
|
25
|
+
* Extracts the type of a nested property from a property path string.
|
|
26
|
+
*
|
|
27
|
+
* @template ObjectType - The object type to extract the value type from
|
|
28
|
+
* @template Path - The property path string (e.g., "a.b.c")
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* type Value = NestedValueOf<{ a: { b: number } }, "a.b">
|
|
32
|
+
* // Result: number
|
|
33
|
+
*/
|
|
34
|
+
type NestedValueOf<ObjectType, Path extends string> = Path extends `${infer Cur}.${infer Rest}` ? Cur extends keyof ObjectType ? NonNullable<ObjectType[Cur]> extends Function | ((...args: any[]) => any) ? never : NestedValueOf<NonNullable<ObjectType[Cur]>, Rest> : never : Path extends keyof ObjectType ? NonNullable<ObjectType[Path]> extends Function | ((...args: any[]) => any) ? never : ObjectType[Path] : never;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @class
|
|
38
|
+
* A wrapper class that enhances Cesium collection objects with tagging functionality.
|
|
39
|
+
* This class provides a consistent API for working with different types of Cesium collections
|
|
40
|
+
* and allows grouping and manipulating collection items by custom tags.
|
|
41
|
+
*
|
|
42
|
+
* @template C - The type of Cesium collection (e.g., EntityCollection, PrimitiveCollection)
|
|
43
|
+
* @template I - The type of items in the collection (e.g., Entity, Primitive)
|
|
44
|
+
*
|
|
45
|
+
* @see [Collection Demo](https://juun.vercel.app/cesium-utils/collection)
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // Example 1: Managing Complex Scene with Multiple Object Types
|
|
49
|
+
* class SceneOrganizer {
|
|
50
|
+
* private entities: Collection<EntityCollection, Entity>;
|
|
51
|
+
* private billboards: Collection<BillboardCollection, Billboard>;
|
|
52
|
+
* private primitives: Collection<PrimitiveCollection, Primitive>;
|
|
53
|
+
*
|
|
54
|
+
* constructor(viewer: Viewer) {
|
|
55
|
+
* this.entities = new Collection({ collection: viewer.entities });
|
|
56
|
+
* this.billboards = new Collection({
|
|
57
|
+
* collection: viewer.scene.primitives.add(new BillboardCollection())
|
|
58
|
+
* });
|
|
59
|
+
* this.primitives = new Collection({
|
|
60
|
+
* collection: viewer.scene.primitives
|
|
61
|
+
* });
|
|
62
|
+
* }
|
|
63
|
+
*
|
|
64
|
+
* // Unified API across different collection types!
|
|
65
|
+
* showLayer(layerName: string) {
|
|
66
|
+
* this.entities.show(layerName);
|
|
67
|
+
* this.billboards.show(layerName);
|
|
68
|
+
* this.primitives.show(layerName);
|
|
69
|
+
* }
|
|
70
|
+
*
|
|
71
|
+
* hideLayer(layerName: string) {
|
|
72
|
+
* this.entities.hide(layerName);
|
|
73
|
+
* this.billboards.hide(layerName);
|
|
74
|
+
* this.primitives.hide(layerName);
|
|
75
|
+
* }
|
|
76
|
+
*
|
|
77
|
+
* removeLayer(layerName: string) {
|
|
78
|
+
* this.entities.remove(layerName);
|
|
79
|
+
* this.billboards.remove(layerName);
|
|
80
|
+
* this.primitives.remove(layerName);
|
|
81
|
+
* }
|
|
82
|
+
* }
|
|
83
|
+
*
|
|
84
|
+
* // Example 2: Extend the class for Domain-Specific Needs
|
|
85
|
+
* class BuildingCollection extends Collection<EntityCollection, Entity> {
|
|
86
|
+
* constructor(viewer: Viewer) {
|
|
87
|
+
* super({ collection: viewer.entities, tag: 'buildings' });
|
|
88
|
+
* }
|
|
89
|
+
*
|
|
90
|
+
* addBuilding(options: {
|
|
91
|
+
* position: Cartesian3;
|
|
92
|
+
* height: number;
|
|
93
|
+
* floors: number;
|
|
94
|
+
* type: 'residential' | 'commercial' | 'industrial';
|
|
95
|
+
* }): Entity {
|
|
96
|
+
* const building = new Entity({
|
|
97
|
+
* position: options.position,
|
|
98
|
+
* box: {
|
|
99
|
+
* dimensions: new Cartesian3(50, 50, options.height),
|
|
100
|
+
* material: this.getMaterialForType(options.type)
|
|
101
|
+
* }
|
|
102
|
+
* });
|
|
103
|
+
*
|
|
104
|
+
* // Tag by type AND by floor count
|
|
105
|
+
* this.add(building, options.type);
|
|
106
|
+
* this.add(building, `floors-${options.floors}`);
|
|
107
|
+
*
|
|
108
|
+
* return building;
|
|
109
|
+
* }
|
|
110
|
+
*
|
|
111
|
+
* getByFloorRange(min: number, max: number): Entity[] {
|
|
112
|
+
* const results: Entity[] = [];
|
|
113
|
+
* for (let i = min; i <= max; i++) {
|
|
114
|
+
* results.push(...this.get(`floors-${i}`));
|
|
115
|
+
* }
|
|
116
|
+
* return results;
|
|
117
|
+
* }
|
|
118
|
+
*
|
|
119
|
+
* private getMaterialForType(type: string): Material {
|
|
120
|
+
* const colors = {
|
|
121
|
+
* residential: Color.GREEN,
|
|
122
|
+
* commercial: Color.BLUE,
|
|
123
|
+
* industrial: Color.YELLOW
|
|
124
|
+
* };
|
|
125
|
+
* return new ColorMaterialProperty(colors[type] || Color.WHITE);
|
|
126
|
+
* }
|
|
127
|
+
* }
|
|
128
|
+
*/
|
|
129
|
+
declare class Collection<C extends Collection.Base, I extends Collection.ItemFor<C>> {
|
|
130
|
+
/**
|
|
131
|
+
* Symbol used as a property key to store tags on collection items.
|
|
132
|
+
* Using a Symbol ensures no property naming conflicts with the item's own properties.
|
|
133
|
+
* @readonly
|
|
134
|
+
*/
|
|
135
|
+
static readonly symbol: unique symbol;
|
|
136
|
+
/**
|
|
137
|
+
* Default tag used when adding items without specifying a tag.
|
|
138
|
+
* @protected
|
|
139
|
+
*/
|
|
140
|
+
protected tag: Collection.Tag;
|
|
141
|
+
/**
|
|
142
|
+
* The underlying Cesium collection being wrapped.
|
|
143
|
+
* @protected
|
|
144
|
+
*/
|
|
145
|
+
protected collection: C;
|
|
146
|
+
/**
|
|
147
|
+
* Cache for values array to improve performance
|
|
148
|
+
* @private
|
|
149
|
+
*/
|
|
150
|
+
private _valuesCache;
|
|
151
|
+
/**
|
|
152
|
+
* Tag to items map for faster lookups
|
|
153
|
+
* @private
|
|
154
|
+
*/
|
|
155
|
+
private _tagMap;
|
|
156
|
+
/**
|
|
157
|
+
* Event listeners
|
|
158
|
+
* @private
|
|
159
|
+
*/
|
|
160
|
+
private _eventListeners;
|
|
161
|
+
/**
|
|
162
|
+
* For cleaning up the instances
|
|
163
|
+
* @private
|
|
164
|
+
*/
|
|
165
|
+
private _eventCleanupFunctions;
|
|
166
|
+
/**
|
|
167
|
+
* Creates a new Collection instance.
|
|
168
|
+
*
|
|
169
|
+
* @param options - Configuration options
|
|
170
|
+
* @param options.collection - The Cesium collection to wrap
|
|
171
|
+
* @param options.tag - The default tag to use for items (defaults to 'default')
|
|
172
|
+
*/
|
|
173
|
+
constructor({ collection, tag }: {
|
|
174
|
+
collection: C;
|
|
175
|
+
tag?: Collection.Tag;
|
|
176
|
+
});
|
|
177
|
+
/**
|
|
178
|
+
* Makes the collection directly iterable, allowing it to be used in `for...of` loops
|
|
179
|
+
* and with spread operators.
|
|
180
|
+
*
|
|
181
|
+
* @returns An iterator for the items in the collection
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* // Iterate through all items in the collection
|
|
185
|
+
* for (const entity of collection) {
|
|
186
|
+
* console.log(entity.id);
|
|
187
|
+
* }
|
|
188
|
+
*
|
|
189
|
+
* // Convert collection to array using spread syntax
|
|
190
|
+
* const entitiesArray = [...collection];
|
|
191
|
+
*/
|
|
192
|
+
[Symbol.iterator](): Iterator<I>;
|
|
193
|
+
/**
|
|
194
|
+
* Gets all item instances in the collection.
|
|
195
|
+
* This array should not be modified directly.
|
|
196
|
+
*
|
|
197
|
+
* @returns An array of all items in the collection
|
|
198
|
+
*/
|
|
199
|
+
get values(): I[];
|
|
200
|
+
/**
|
|
201
|
+
* Gets the number of items in the collection.
|
|
202
|
+
*
|
|
203
|
+
* @returns The item count
|
|
204
|
+
*/
|
|
205
|
+
get length(): number;
|
|
206
|
+
/**
|
|
207
|
+
* Gets all unique tags currently in use in the collection.
|
|
208
|
+
*
|
|
209
|
+
* @returns An array of all unique tags
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* // Get all tags
|
|
213
|
+
* const tags = collection.tags;
|
|
214
|
+
* console.log(`Collection has these tags: ${tags.join(', ')}`);
|
|
215
|
+
*/
|
|
216
|
+
get tags(): Collection.Tag[];
|
|
217
|
+
/**
|
|
218
|
+
* Registers an event listener for collection events.
|
|
219
|
+
*
|
|
220
|
+
* @param type - The event type to listen for
|
|
221
|
+
* @param handler - The callback function
|
|
222
|
+
* @returns The collection instance for method chaining
|
|
223
|
+
*/
|
|
224
|
+
addEventListener(type: Collection.Event, handler: Collection.EventHandler<I>): this;
|
|
225
|
+
/**
|
|
226
|
+
* Removes an event listener.
|
|
227
|
+
*
|
|
228
|
+
* @param type - The event type
|
|
229
|
+
* @param handler - The callback function to remove
|
|
230
|
+
* @returns The collection instance for method chaining
|
|
231
|
+
*/
|
|
232
|
+
removeEventListener(type: Collection.Event, handler: Collection.EventHandler<I>): this;
|
|
233
|
+
/**
|
|
234
|
+
* Adds a single item with a tag to the collection.
|
|
235
|
+
*
|
|
236
|
+
* @param item - The item to add to the collection
|
|
237
|
+
* @param tag - Tag to associate with this item (defaults to the collection's default tag)
|
|
238
|
+
* @param index - The index to add the item at (if supported by the collection)
|
|
239
|
+
* @returns The collection instance for method chaining
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* const entity = collection.add(new Entity({ ... }), 'landmarks');
|
|
243
|
+
*/
|
|
244
|
+
add(item: I, tag?: Collection.Tag, index?: number): this;
|
|
245
|
+
/**
|
|
246
|
+
* Adds multiple items with the same tag to the collection.
|
|
247
|
+
*
|
|
248
|
+
* @param items - The array of items to add to the collection
|
|
249
|
+
* @param tag - Tag to associate with this item (defaults to the collection's default tag)
|
|
250
|
+
* @returns The collection instance for method chaining
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* // Add multiple entities with the same tag
|
|
254
|
+
* const entities = [new Entity({ ... }), new Entity({ ... })];
|
|
255
|
+
* const addedEntities = collection.add(entities, 'buildings');
|
|
256
|
+
*/
|
|
257
|
+
add(items: I[], tag?: Collection.Tag): this;
|
|
258
|
+
/**
|
|
259
|
+
* Returns true if the provided item is in this collection, false otherwise.
|
|
260
|
+
*
|
|
261
|
+
* @param item - The item instance to check for
|
|
262
|
+
* @returns True if the item is in the collection, false otherwise
|
|
263
|
+
*/
|
|
264
|
+
contains(item: I): boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Checks if the collection has any items with the specified tag.
|
|
267
|
+
*
|
|
268
|
+
* @param tag - The tag to check for
|
|
269
|
+
* @returns True if items with the tag exist, false otherwise
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* if (collection.contains('temporary')) {
|
|
273
|
+
* console.log('Temporary items exist');
|
|
274
|
+
* }
|
|
275
|
+
*/
|
|
276
|
+
contains(tag: Collection.Tag): boolean;
|
|
277
|
+
/**
|
|
278
|
+
* Removes an item from the collection.
|
|
279
|
+
*
|
|
280
|
+
* @param item - The item to remove
|
|
281
|
+
* @returns The collection instance for method chaining
|
|
282
|
+
*/
|
|
283
|
+
remove(item: I): this;
|
|
284
|
+
/**
|
|
285
|
+
* Removes all items with the specified tag from the collection.
|
|
286
|
+
*
|
|
287
|
+
* @param by - The tag identifying which items to remove
|
|
288
|
+
* @returns The collection instance for method chaining
|
|
289
|
+
*/
|
|
290
|
+
remove(by: Collection.Tag): this;
|
|
291
|
+
/**
|
|
292
|
+
* Removes all items with the array of tags from the collection.
|
|
293
|
+
*
|
|
294
|
+
* @param by - The tags identifying which items to remove
|
|
295
|
+
* @returns The collection instance for method chaining
|
|
296
|
+
*/
|
|
297
|
+
remove(by: Collection.Tag[]): this;
|
|
298
|
+
/**
|
|
299
|
+
* Removes all items from the collection.
|
|
300
|
+
*/
|
|
301
|
+
removeAll(): void;
|
|
302
|
+
/**
|
|
303
|
+
* Permanently destroys this Collection instance.
|
|
304
|
+
* Removes all event listeners and clears internal state.
|
|
305
|
+
* The Collection instance should not be used after calling this method.
|
|
306
|
+
*/
|
|
307
|
+
destroy(): void;
|
|
308
|
+
/**
|
|
309
|
+
* Gets all items with the specified tag from the collection.
|
|
310
|
+
* Uses an optimized internal map for faster lookups.
|
|
311
|
+
*
|
|
312
|
+
* @param by - The tag to filter by
|
|
313
|
+
* @returns An array of items with the specified tag, or an empty array if none found
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* // Get all buildings
|
|
317
|
+
* const buildings = collection.get('buildings');
|
|
318
|
+
*/
|
|
319
|
+
get(by: Collection.Tag): I[];
|
|
320
|
+
/**
|
|
321
|
+
* Gets the first item matching the tag. More efficient than `get` when
|
|
322
|
+
* you only need one item, especially for large collections.
|
|
323
|
+
*
|
|
324
|
+
* @param by - The tag to search for
|
|
325
|
+
* @returns The first matching item or undefined if none found
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* // Get the first building
|
|
329
|
+
* const firstBuilding = collection.first('buildings');
|
|
330
|
+
*/
|
|
331
|
+
first(by: Collection.Tag): I | undefined;
|
|
332
|
+
/**
|
|
333
|
+
* Updates the tag for all items with the specified tag.
|
|
334
|
+
*
|
|
335
|
+
* @param from - The tag to replace
|
|
336
|
+
* @param to - The new tag to assign
|
|
337
|
+
* @returns The number of items updated
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* // Rename a tag
|
|
341
|
+
* const count = collection.update('temp', 'temporary');
|
|
342
|
+
* console.log(`Updated ${count} items`);
|
|
343
|
+
*/
|
|
344
|
+
update(from: Collection.Tag, to: Collection.Tag): number;
|
|
345
|
+
/**
|
|
346
|
+
* Makes all items with the specified tag visible.
|
|
347
|
+
* Only affects items that have a 'show' property.
|
|
348
|
+
*
|
|
349
|
+
* @param by - The tag identifying which items to show
|
|
350
|
+
* @returns The collection itself.
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* // Show all buildings
|
|
354
|
+
* collection.show('buildings');
|
|
355
|
+
*/
|
|
356
|
+
show(by: Collection.Tag): this;
|
|
357
|
+
/**
|
|
358
|
+
* Hides all items with the specified tag.
|
|
359
|
+
* Only affects items that have a 'show' property.
|
|
360
|
+
*
|
|
361
|
+
* @param by - The tag identifying which items to hide
|
|
362
|
+
* @returns The collection itself.
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* // Hide all buildings
|
|
366
|
+
* collection.hide('buildings');
|
|
367
|
+
*/
|
|
368
|
+
hide(by: Collection.Tag): this;
|
|
369
|
+
/**
|
|
370
|
+
* Toggles visibility of all items with the specified tag.
|
|
371
|
+
* Only affects items that have a 'show' property.
|
|
372
|
+
*
|
|
373
|
+
* @param by - The tag identifying which items to toggle
|
|
374
|
+
* @returns The collection itself.
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* // Toggle visibility of all buildings
|
|
378
|
+
* collection.toggle('buildings');
|
|
379
|
+
*/
|
|
380
|
+
toggle(by: Collection.Tag): this;
|
|
381
|
+
/**
|
|
382
|
+
* Sets a property value on all items with the specified tag.
|
|
383
|
+
* Supports nested property paths using dot notation (e.g., 'billboard.scale').
|
|
384
|
+
*
|
|
385
|
+
* @template Path - A nested property path type
|
|
386
|
+
*
|
|
387
|
+
* @param property - The property name or nested path to set (e.g., 'name' or 'billboard.scale')
|
|
388
|
+
* @param value - The value to set
|
|
389
|
+
* @param by - The tag identifying which items to update
|
|
390
|
+
* @returns The collection itself.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* // Change color of all buildings to red
|
|
394
|
+
* collection.setProperty('color', Color.RED, 'buildings');
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* // Change billboard scale using nested path
|
|
398
|
+
* collection.setProperty('billboard.scale', 2.0, 'buildings');
|
|
399
|
+
*/
|
|
400
|
+
setProperty<Path extends NestedKeyOf<I>>(property: Path, value: NestedValueOf<I, Path>, by?: Collection.Tag): this;
|
|
401
|
+
/**
|
|
402
|
+
* Filters items in the collection based on a predicate function.
|
|
403
|
+
* Optionally only filters items with a specific tag.
|
|
404
|
+
*
|
|
405
|
+
* @param predicate - Function that tests each item
|
|
406
|
+
* @param by - Optional tag to filter by before applying the predicate
|
|
407
|
+
* @returns Array of items that pass the test
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* // Get all buildings taller than 100 meters
|
|
411
|
+
* const tallBuildings = collection.filter(
|
|
412
|
+
* entity => entity.properties?.height?.getValue() > 100,
|
|
413
|
+
* 'buildings'
|
|
414
|
+
* );
|
|
415
|
+
*/
|
|
416
|
+
filter(predicate: (item: I) => boolean, by?: Collection.Tag): I[];
|
|
417
|
+
/**
|
|
418
|
+
* Executes a callback function for each item in the collection.
|
|
419
|
+
* Optionally filters items by tag before execution.
|
|
420
|
+
*
|
|
421
|
+
* @param callback - Function to execute for each item
|
|
422
|
+
* @param by - Optional tag to filter items (if not provided, processes all items)
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* // Highlight all buildings
|
|
426
|
+
* collection.forEach((entity) => {
|
|
427
|
+
* if (entity.polygon) {
|
|
428
|
+
* entity.polygon.material = new ColorMaterialProperty(Color.YELLOW);
|
|
429
|
+
* }
|
|
430
|
+
* }, 'buildings');
|
|
431
|
+
*/
|
|
432
|
+
forEach(callback: (value: I, index: number) => void, by?: Collection.Tag): void;
|
|
433
|
+
/**
|
|
434
|
+
* Creates a new array with the results of calling a provided function on every element
|
|
435
|
+
* in the collection. Optionally filters by tag before mapping.
|
|
436
|
+
*
|
|
437
|
+
* @param callbackfn - Function that produces an element of the new array
|
|
438
|
+
* @param by - Optional tag to filter items by before mapping
|
|
439
|
+
* @returns A new array with each element being the result of the callback function
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* // Get all entity IDs
|
|
443
|
+
* const entityIds = collection.map(entity => entity.id);
|
|
444
|
+
*
|
|
445
|
+
* // Get positions of all buildings
|
|
446
|
+
* const buildingPositions = collection.map(
|
|
447
|
+
* entity => entity.position.getValue(Cesium.JulianDate.now()),
|
|
448
|
+
* 'buildings'
|
|
449
|
+
* );
|
|
450
|
+
*/
|
|
451
|
+
map<R>(callbackfn: (value: I, index: number) => R, by?: Collection.Tag): R[];
|
|
452
|
+
/**
|
|
453
|
+
* Returns the first element in the collection that satisfies the provided testing function.
|
|
454
|
+
* Optionally filters by tag before searching.
|
|
455
|
+
*
|
|
456
|
+
* @param predicate - Function to test each element
|
|
457
|
+
* @param by - Optional tag to filter items by before searching
|
|
458
|
+
* @returns The first element that passes the test, or undefined if no elements pass
|
|
459
|
+
*
|
|
460
|
+
* @example
|
|
461
|
+
* // Find the first entity with a specific name
|
|
462
|
+
* const namedEntity = collection.find(entity => entity.name === 'Target');
|
|
463
|
+
*
|
|
464
|
+
* // Find the first building taller than 100 meters
|
|
465
|
+
* const tallBuilding = collection.find(
|
|
466
|
+
* entity => entity.properties?.height?.getValue() > 100,
|
|
467
|
+
* 'buildings'
|
|
468
|
+
* );
|
|
469
|
+
*/
|
|
470
|
+
find(predicate: (value: I) => boolean, by?: Collection.Tag): I | undefined;
|
|
471
|
+
/**
|
|
472
|
+
* Emits an event to all registered listeners.
|
|
473
|
+
*
|
|
474
|
+
* @private
|
|
475
|
+
* @param type - The event type
|
|
476
|
+
* @param data - Additional event data
|
|
477
|
+
*/
|
|
478
|
+
private _emit;
|
|
479
|
+
/**
|
|
480
|
+
* Adds an item to the internal tag map for quick lookups.
|
|
481
|
+
*
|
|
482
|
+
* @private
|
|
483
|
+
* @param item - The item to add
|
|
484
|
+
* @param tag - The tag to associate with the item
|
|
485
|
+
*/
|
|
486
|
+
private _addToTagMap;
|
|
487
|
+
/**
|
|
488
|
+
* Removes an item from the internal tag map.
|
|
489
|
+
*
|
|
490
|
+
* @private
|
|
491
|
+
* @param item - The item to remove
|
|
492
|
+
*/
|
|
493
|
+
private _removeFromTagMap;
|
|
494
|
+
/**
|
|
495
|
+
* Invalidates the values cache when collection changes.
|
|
496
|
+
*
|
|
497
|
+
* @private
|
|
498
|
+
*/
|
|
499
|
+
private _invalidateCache;
|
|
500
|
+
/**
|
|
501
|
+
* Sets up automatic cache invalidation by registering event listeners on the underlying Cesium collection.
|
|
502
|
+
*
|
|
503
|
+
* @private
|
|
504
|
+
* @param collection - The Cesium collection to monitor for changes
|
|
505
|
+
*
|
|
506
|
+
* @see {@link destroy} For cleanup of event listeners
|
|
507
|
+
* @see {@link _invalidateCache} For the actual cache invalidation logic
|
|
508
|
+
*/
|
|
509
|
+
private _setupCacheInvalidator;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* @namespace
|
|
513
|
+
*/
|
|
514
|
+
declare namespace Collection {
|
|
515
|
+
/**
|
|
516
|
+
* The underlying Cesium collection type being wrapped.
|
|
517
|
+
*/
|
|
518
|
+
export type Base = DataSourceCollection | EntityCollection | ImageryLayerCollection | PrimitiveCollection;
|
|
519
|
+
/**
|
|
520
|
+
* The item types that can be added to the `PrimitiveCollection` instance.
|
|
521
|
+
*/
|
|
522
|
+
type Primitives = Billboard | Cesium3DTileset | GroundPrimitive | Label | PointPrimitive | Polyline | Primitive;
|
|
523
|
+
/**
|
|
524
|
+
* Cesium item type that can be added to the {@link Collection.Base} instance.
|
|
525
|
+
*/
|
|
526
|
+
export type Item = DataSource | Entity | ImageryLayer | Primitives;
|
|
527
|
+
/**
|
|
528
|
+
* Gets the item type for a given collection type
|
|
529
|
+
*/
|
|
530
|
+
export type ItemFor<C extends Base> = C extends DataSourceCollection ? DataSource : C extends EntityCollection ? Entity : C extends ImageryLayerCollection ? ImageryLayer : C extends PrimitiveCollection ? Primitives : never;
|
|
531
|
+
/**
|
|
532
|
+
* Collection tag type.
|
|
533
|
+
*/
|
|
534
|
+
export type Tag = string | number;
|
|
535
|
+
export interface WithTag {
|
|
536
|
+
[key: symbol]: Tag;
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Collection event types
|
|
540
|
+
*/
|
|
541
|
+
export type Event = "add" | "remove" | "update" | "clear";
|
|
542
|
+
/**
|
|
543
|
+
* Event handler function type
|
|
544
|
+
*/
|
|
545
|
+
export type EventHandler<I> = (event: {
|
|
546
|
+
type: Event;
|
|
547
|
+
items?: I[];
|
|
548
|
+
tag?: Collection.Tag;
|
|
549
|
+
}) => void;
|
|
550
|
+
export { };
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* @class
|
|
555
|
+
* Lightweight multiton highlight manager for Cesium using flyweight pattern.
|
|
556
|
+
*
|
|
557
|
+
* @example
|
|
558
|
+
* ```
|
|
559
|
+
* // Setup
|
|
560
|
+
* const viewer1 = new Viewer('cesiumContainer1');
|
|
561
|
+
* const viewer2 = new Viewer('cesiumContainer2');
|
|
562
|
+
*
|
|
563
|
+
* const highlighter1 = Highlight.getInstance(viewer1);
|
|
564
|
+
* const highlighter2 = Highlight.getInstance(viewer2);
|
|
565
|
+
*
|
|
566
|
+
* // This highlight only affects viewer1
|
|
567
|
+
* highlighter1.show(someEntity, { color: Color.RED });
|
|
568
|
+
*
|
|
569
|
+
* // This highlight only affects viewer2
|
|
570
|
+
* highlighter2.show(someEntity, { color: Color.BLUE });
|
|
571
|
+
*
|
|
572
|
+
* // When done with viewers
|
|
573
|
+
* Highlight.releaseInstance(viewer1);
|
|
574
|
+
* Highlight.releaseInstance(viewer2);
|
|
575
|
+
* viewer1.destroy();
|
|
576
|
+
* viewer2.destroy();
|
|
577
|
+
* ```
|
|
578
|
+
*/
|
|
579
|
+
declare class Highlight {
|
|
580
|
+
private static instances;
|
|
581
|
+
private _surface;
|
|
582
|
+
private _silhouette;
|
|
583
|
+
private _color;
|
|
584
|
+
/**
|
|
585
|
+
* Creates a new `Highlight` instance.
|
|
586
|
+
* @private Use {@link getInstance `Highlight.getInstance()`}
|
|
587
|
+
* @param viewer A viewer to create highlight entity in
|
|
588
|
+
*/
|
|
589
|
+
private constructor();
|
|
590
|
+
/** Gets the highlight color. */
|
|
591
|
+
get color(): Color;
|
|
592
|
+
/**
|
|
593
|
+
* Sets the highlight color.
|
|
594
|
+
* @param color The new color for highlights
|
|
595
|
+
*/
|
|
596
|
+
set color(color: Color);
|
|
597
|
+
/**
|
|
598
|
+
* Gets or creates highlight instance from a viewer.
|
|
599
|
+
* @param viewer The viewer to get or create a new instance from.
|
|
600
|
+
*/
|
|
601
|
+
static getInstance(viewer: Viewer): Highlight;
|
|
602
|
+
/**
|
|
603
|
+
* Releases the highlight instance associated with a viewer.
|
|
604
|
+
* @param viewer The viewer whose highlight instance should be released.
|
|
605
|
+
*/
|
|
606
|
+
static releaseInstance(viewer: Viewer): void;
|
|
607
|
+
/**
|
|
608
|
+
* Highlights a picked object or a direct instance.
|
|
609
|
+
* @param picked The result of `Scene.pick()` or direct instance to be highlighted.
|
|
610
|
+
* @param options Optional style for the highlight.
|
|
611
|
+
* @see {@link Highlight.Options}
|
|
612
|
+
*/
|
|
613
|
+
show(picked: Highlight.Picked, options?: Highlight.Options): void | Entity;
|
|
614
|
+
private _getObject;
|
|
615
|
+
/**
|
|
616
|
+
* Clears the current highlight effects.
|
|
617
|
+
*/
|
|
618
|
+
hide(): void;
|
|
619
|
+
}
|
|
620
|
+
declare namespace Highlight {
|
|
621
|
+
export interface Base {
|
|
622
|
+
show(object: any, options?: Highlight.Options): void;
|
|
623
|
+
hide(): void;
|
|
624
|
+
destroy(): void;
|
|
625
|
+
color: Color;
|
|
626
|
+
}
|
|
627
|
+
export interface Options {
|
|
628
|
+
/** Color of the highlight */
|
|
629
|
+
color?: Color;
|
|
630
|
+
/** To apply outline style for the highlight */
|
|
631
|
+
outline?: boolean;
|
|
632
|
+
/** Outline width */
|
|
633
|
+
width?: number;
|
|
634
|
+
}
|
|
635
|
+
type PickedObject = {
|
|
636
|
+
id?: Entity;
|
|
637
|
+
primitive?: Primitive | GroundPrimitive | Model | Cesium3DTileset;
|
|
638
|
+
tileset?: Cesium3DTileset;
|
|
639
|
+
detail?: {
|
|
640
|
+
model?: Model;
|
|
641
|
+
};
|
|
642
|
+
};
|
|
643
|
+
export type Picked = Entity | Cesium3DTileFeature | GroundPrimitive | PickedObject;
|
|
644
|
+
export { };
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* @class
|
|
649
|
+
* An implementation for highlighting 3D objects in Cesium.
|
|
650
|
+
*
|
|
651
|
+
* **Supported Object Types:**
|
|
652
|
+
* - `Entity` with model graphics. (adjustable outline width)
|
|
653
|
+
* - `Cesium3DTileset` instances. (fixed outline width)
|
|
654
|
+
*
|
|
655
|
+
* Currently supports outline style only.
|
|
656
|
+
*
|
|
657
|
+
* @example
|
|
658
|
+
* ```typescript
|
|
659
|
+
* const viewer = new Viewer("cesiumContainer");
|
|
660
|
+
* const silhouetteHighlight = new SilhouetteHighlight(viewer);
|
|
661
|
+
*
|
|
662
|
+
* // Highlight an object
|
|
663
|
+
* const entity = viewer.entities.add(new Entity({
|
|
664
|
+
* model: new ModelGraphics(),
|
|
665
|
+
* }));
|
|
666
|
+
* silhouetteHighlight.show(entity);
|
|
667
|
+
* ```
|
|
668
|
+
*/
|
|
669
|
+
declare class SilhouetteHighlight implements Highlight.Base {
|
|
670
|
+
private _color;
|
|
671
|
+
private _silhouette;
|
|
672
|
+
private _composite;
|
|
673
|
+
private _stages;
|
|
674
|
+
private _entity?;
|
|
675
|
+
private _currentObject;
|
|
676
|
+
private _currentOptions;
|
|
677
|
+
/**
|
|
678
|
+
* Creates a new `Silhouette` instance.
|
|
679
|
+
* @param viewer A viewer to create highlight silhouette in
|
|
680
|
+
*/
|
|
681
|
+
constructor(viewer: Viewer);
|
|
682
|
+
/** Gets the highlight color. */
|
|
683
|
+
get color(): Color;
|
|
684
|
+
/** Sets the highlight color. */
|
|
685
|
+
set color(color: Color);
|
|
686
|
+
/** Gets the currently highlighted object */
|
|
687
|
+
get currentObject(): Cesium3DTileFeature | Entity | undefined;
|
|
688
|
+
/**
|
|
689
|
+
* Highlights a picked `Cesium3DTileset` by updating silhouette composite.
|
|
690
|
+
* @param object The object to be highlighted.
|
|
691
|
+
* @param options Optional style for the highlight.
|
|
692
|
+
*/
|
|
693
|
+
show(object: Cesium3DTileFeature, options?: Highlight.Options): void;
|
|
694
|
+
/**
|
|
695
|
+
* Highlights a picked `Entity` by updating the model properties.
|
|
696
|
+
* @param object The object to be highlighted.
|
|
697
|
+
* @param options Optional style for the highlight.
|
|
698
|
+
*/
|
|
699
|
+
show(object: Entity, options?: Highlight.Options): void;
|
|
700
|
+
/** Clears the current highlight */
|
|
701
|
+
hide(): void;
|
|
702
|
+
/** Clean up the instances */
|
|
703
|
+
destroy(): void;
|
|
704
|
+
/**
|
|
705
|
+
* Compares two Highlight.Options objects for equality
|
|
706
|
+
* @private
|
|
707
|
+
*/
|
|
708
|
+
private _optionsEqual;
|
|
709
|
+
/**
|
|
710
|
+
* Clears all current highlights
|
|
711
|
+
* @private
|
|
712
|
+
*/
|
|
713
|
+
private _clearHighlights;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* @class
|
|
718
|
+
* A flyweight implementation for highlighting 2D surface objects in Cesium.
|
|
719
|
+
*
|
|
720
|
+
* This class provides highlighting for ground-clamped geometries (polygons, polylines, rectangles)
|
|
721
|
+
*
|
|
722
|
+
* **Supported Geometry Types:**
|
|
723
|
+
* - `Entity` with polygon, polyline, or rectangle graphics
|
|
724
|
+
* - `GroundPrimitive` instances
|
|
725
|
+
*
|
|
726
|
+
* **Highlighting Modes:**
|
|
727
|
+
* - **Fill mode** (default): Creates a filled geometry using the original shape
|
|
728
|
+
* - **Outline mode**: Creates a polyline outline of the original geometry
|
|
729
|
+
*
|
|
730
|
+
* @example
|
|
731
|
+
* ```typescript
|
|
732
|
+
* // Basic usage
|
|
733
|
+
* const viewer = new Viewer('cesiumContainer');
|
|
734
|
+
* const surfaceHighlight = new SurfaceHighlight(viewer);
|
|
735
|
+
*
|
|
736
|
+
* // Highlight an entity with default red fill
|
|
737
|
+
* const entity = viewer.entities.add(new Entity({
|
|
738
|
+
* polygon: {
|
|
739
|
+
* hierarchy: Cartesian3.fromDegreesArray([-75, 35, -74, 35, -74, 36, -75, 36]),
|
|
740
|
+
* material: Color.BLUE
|
|
741
|
+
* }
|
|
742
|
+
* }));
|
|
743
|
+
* surfaceHighlight.show(entity);
|
|
744
|
+
* ```
|
|
745
|
+
*/
|
|
746
|
+
declare class SurfaceHighlight implements Highlight.Base {
|
|
747
|
+
private _color;
|
|
748
|
+
private _entity;
|
|
749
|
+
private _entities;
|
|
750
|
+
private _currentObject;
|
|
751
|
+
private _currentOptions;
|
|
752
|
+
/**
|
|
753
|
+
* Creates a new `SurfaceHighlight` instance.
|
|
754
|
+
* @param viewer A viewer to create highlight entity in
|
|
755
|
+
*/
|
|
756
|
+
constructor(viewer: Viewer);
|
|
757
|
+
/** Gets the highlight color. */
|
|
758
|
+
get color(): Color;
|
|
759
|
+
/** Sets the highlight color. */
|
|
760
|
+
set color(color: Color);
|
|
761
|
+
/** Gets the highlight entity */
|
|
762
|
+
get entity(): Entity;
|
|
763
|
+
/** Gets the currently highlighted object */
|
|
764
|
+
get currentObject(): Entity | GroundPrimitive | undefined;
|
|
765
|
+
/**
|
|
766
|
+
* Highlights a picked object by updating the reusable entity
|
|
767
|
+
* @param object The object to be highlighted.
|
|
768
|
+
* @param options Optional style for the highlight.
|
|
769
|
+
* @see {@link Highlight.Options}
|
|
770
|
+
*/
|
|
771
|
+
show(object: Entity | GroundPrimitive, options?: Highlight.Options): Entity | undefined;
|
|
772
|
+
/**
|
|
773
|
+
* Clears the current highlight
|
|
774
|
+
*/
|
|
775
|
+
hide(): void;
|
|
776
|
+
/** Clean up the instances */
|
|
777
|
+
destroy(): void;
|
|
778
|
+
/**
|
|
779
|
+
* Compares two Highlight.Options objects for equality
|
|
780
|
+
* @private
|
|
781
|
+
*/
|
|
782
|
+
private _optionsEqual;
|
|
783
|
+
/**
|
|
784
|
+
* Removes all geometry properties from the highlight entity
|
|
785
|
+
* @private
|
|
786
|
+
*/
|
|
787
|
+
private _clearGeometries;
|
|
788
|
+
/**
|
|
789
|
+
* Updates the highlight entity from an Entity object
|
|
790
|
+
* @private
|
|
791
|
+
*/
|
|
792
|
+
private _update;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* @class
|
|
797
|
+
* Provides terrain by delegating requests to different terrain providers
|
|
798
|
+
* based on geographic regions and zoom levels. This allows combining
|
|
799
|
+
* multiple terrain sources into a single seamless terrain.
|
|
800
|
+
*
|
|
801
|
+
* @example
|
|
802
|
+
* ``` typescript
|
|
803
|
+
* // Tile-coordinate based for precise control (multiple levels)
|
|
804
|
+
* const customTiles: TerrainTiles = new Map();
|
|
805
|
+
* customTiles.set(15, { x: [55852, 55871], y: [9556, 9575] });
|
|
806
|
+
* customTiles.set(16, { x: [111704, 111742], y: [19112, 19150] });
|
|
807
|
+
*
|
|
808
|
+
* const hybridTerrain = new HybridTerrainProvider({
|
|
809
|
+
* regions: [
|
|
810
|
+
* {
|
|
811
|
+
* provider: customProvider,
|
|
812
|
+
* tiles: customTiles,
|
|
813
|
+
* }
|
|
814
|
+
* ],
|
|
815
|
+
* defaultProvider: worldTerrain
|
|
816
|
+
* });
|
|
817
|
+
*
|
|
818
|
+
* viewer.terrainProvider = hybridTerrain;
|
|
819
|
+
* ```
|
|
820
|
+
*/
|
|
821
|
+
declare class HybridTerrainProvider implements TerrainProvider {
|
|
822
|
+
private _regions;
|
|
823
|
+
private _defaultProvider;
|
|
824
|
+
private _fallbackProvider;
|
|
825
|
+
private _tilingScheme;
|
|
826
|
+
private _ready;
|
|
827
|
+
private _availability?;
|
|
828
|
+
private _errorEvent;
|
|
829
|
+
private _removeEventListeners;
|
|
830
|
+
private _hasWaterMask;
|
|
831
|
+
private _hasVertexNormals;
|
|
832
|
+
private _credit?;
|
|
833
|
+
/**
|
|
834
|
+
* Creates a new `HybridTerrainProvider` instance.
|
|
835
|
+
* @param options {@link HybridTerrainProvider.ConstructorOptions}
|
|
836
|
+
* @returns A new `HybridTerrainProvider` instance.
|
|
837
|
+
*/
|
|
838
|
+
constructor(options: HybridTerrainProvider.ConstructorOptions);
|
|
839
|
+
/**
|
|
840
|
+
* Gets a value indicating whether or not the provider is ready for use,
|
|
841
|
+
* or a promise that resolves when the provider becomes ready.
|
|
842
|
+
*/
|
|
843
|
+
get ready(): boolean;
|
|
844
|
+
/**
|
|
845
|
+
* Gets the tiling scheme used by this provider.
|
|
846
|
+
*/
|
|
847
|
+
get tilingScheme(): TilingScheme;
|
|
848
|
+
/**
|
|
849
|
+
* Gets an object that can be used to determine availability of terrain from this provider.
|
|
850
|
+
*/
|
|
851
|
+
get availability(): TileAvailability | undefined;
|
|
852
|
+
/**
|
|
853
|
+
* Gets the list of terrain regions managed by this provider.
|
|
854
|
+
*/
|
|
855
|
+
get regions(): readonly HybridTerrainProvider.TerrainRegion[];
|
|
856
|
+
/**
|
|
857
|
+
* Gets the default terrain provider.
|
|
858
|
+
*/
|
|
859
|
+
get defaultProvider(): TerrainProvider;
|
|
860
|
+
/**
|
|
861
|
+
* Gets the fallback terrain provider.
|
|
862
|
+
*/
|
|
863
|
+
get fallbackProvider(): TerrainProvider;
|
|
864
|
+
/**
|
|
865
|
+
* Gets the credit to display when this terrain provider is active. Typically this is used to credit
|
|
866
|
+
* the source of the terrain.
|
|
867
|
+
*/
|
|
868
|
+
get credit(): Credit;
|
|
869
|
+
/**
|
|
870
|
+
* Gets an event that is raised when the terrain provider encounters an asynchronous error. By subscribing
|
|
871
|
+
* to the event, you will be notified of the error and can potentially recover from it. Event listeners
|
|
872
|
+
* are passed an instance of `TileProviderError`.
|
|
873
|
+
*/
|
|
874
|
+
get errorEvent(): Event;
|
|
875
|
+
/**
|
|
876
|
+
* Gets a value indicating whether or not the provider includes a water mask. The water mask
|
|
877
|
+
* indicates which areas of the globe are water rather than land, so they can be rendered
|
|
878
|
+
* as a reflective surface with animated waves.
|
|
879
|
+
*/
|
|
880
|
+
get hasWaterMask(): boolean;
|
|
881
|
+
/** Gets a value indicating whether or not the requested tiles include vertex normals. */
|
|
882
|
+
get hasVertexNormals(): boolean;
|
|
883
|
+
/**
|
|
884
|
+
* Makes sure we load availability data for a tile
|
|
885
|
+
* @param x - The X coordinate of the tile for which to request geometry.
|
|
886
|
+
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
887
|
+
* @param level - The level of the tile for which to request geometry.
|
|
888
|
+
* @returns Undefined if nothing need to be loaded or a Promise that resolves when all required tiles are loaded
|
|
889
|
+
*/
|
|
890
|
+
loadTileDataAvailability(x: number, y: number, level: number): Promise<void> | undefined;
|
|
891
|
+
/**
|
|
892
|
+
* Gets the maximum geometric error allowed in a tile at a given level, taken as the
|
|
893
|
+
* worst case across the default provider and all region providers. Because the hybrid
|
|
894
|
+
* provider's coverage is a composition of multiple sources, the reported error reflects
|
|
895
|
+
* the highest error any source could contribute at this level, ensuring the LOD system
|
|
896
|
+
* refines conservatively enough for all sources.
|
|
897
|
+
* @param level - The tile level for which to get the maximum geometric error.
|
|
898
|
+
* @returns The maximum geometric error across all providers.
|
|
899
|
+
*/
|
|
900
|
+
getLevelMaximumGeometricError(level: number): number;
|
|
901
|
+
/**
|
|
902
|
+
* Requests the terrain for a given tile coordinate.
|
|
903
|
+
* @param x The X coordinate of the tile.
|
|
904
|
+
* @param y The Y coordinate of the tile.
|
|
905
|
+
* @param level The zoom level of the tile.
|
|
906
|
+
* @param request The request.
|
|
907
|
+
* @returns A promise for the requested terrain.
|
|
908
|
+
*/
|
|
909
|
+
requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<TerrainData> | undefined;
|
|
910
|
+
/**
|
|
911
|
+
* Determines whether data for a tile is available to be loaded. Checks the specified terrain regions first.
|
|
912
|
+
* @param x - The X coordinate of the tile for which to request geometry.
|
|
913
|
+
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
914
|
+
* @param level - The level of the tile for which to request geometry.
|
|
915
|
+
* @returns Undefined if not supported by the terrain provider, otherwise true or false.
|
|
916
|
+
*/
|
|
917
|
+
getTileDataAvailable(x: number, y: number, level: number): boolean | undefined;
|
|
918
|
+
/**
|
|
919
|
+
* Cleans up resources used in the `HybridTerrainProvider`.
|
|
920
|
+
*
|
|
921
|
+
* This method only releases additional resources used to instantiate the `HybridTerrainProvider`.
|
|
922
|
+
*/
|
|
923
|
+
destroy(): void;
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* @namespace
|
|
927
|
+
* Contains types and factory methods for `HybridTerrainProvider` instance.
|
|
928
|
+
*/
|
|
929
|
+
declare namespace HybridTerrainProvider {
|
|
930
|
+
/** Initialization options for `HybridTerrainProvider` constructor. */
|
|
931
|
+
interface ConstructorOptions {
|
|
932
|
+
/** An array of terrain regions to include in the hybrid terrain. */
|
|
933
|
+
regions?: TerrainRegion[];
|
|
934
|
+
/** Default provider to use outside of specified terrain regions. */
|
|
935
|
+
defaultProvider: TerrainProvider;
|
|
936
|
+
/** Optional fallback provider when data is not available from default provider. @default EllipsoidTerrainProvider */
|
|
937
|
+
fallbackProvider?: TerrainProvider;
|
|
938
|
+
/** A credit for the data source, which is displayed on the canvas. */
|
|
939
|
+
credit?: Credit | string;
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* A factory function which creates a HybridTerrainProvider from tile-coordinate based regions.
|
|
943
|
+
* @param regions Array of regions with tile-coordinate bounds
|
|
944
|
+
* @param defaultProvider Default terrain provider
|
|
945
|
+
* @param fallbackProvider Optional fallback provider
|
|
946
|
+
*/
|
|
947
|
+
function fromTileRanges(regions: Array<{
|
|
948
|
+
provider: TerrainProvider;
|
|
949
|
+
tiles: Map<number, {
|
|
950
|
+
x: number | [number, number];
|
|
951
|
+
y: number | [number, number];
|
|
952
|
+
}>;
|
|
953
|
+
levels?: number[];
|
|
954
|
+
}>, defaultProvider: TerrainProvider, fallbackProvider?: TerrainProvider): HybridTerrainProvider;
|
|
955
|
+
/** Represents a terrain region with provider and geographic bounds. */
|
|
956
|
+
interface TerrainRegion {
|
|
957
|
+
/** The terrain provider for this region. */
|
|
958
|
+
provider: TerrainProvider;
|
|
959
|
+
/**
|
|
960
|
+
* Tile-coordinate based bounds (precise control).
|
|
961
|
+
* Map of level to tile coordinate ranges for that level.
|
|
962
|
+
*/
|
|
963
|
+
tiles?: Map<number, {
|
|
964
|
+
/** X tile coordinate range [min, max] or single value. */
|
|
965
|
+
x: number | [number, number];
|
|
966
|
+
/** Y tile coordinate range [min, max] or single value. */
|
|
967
|
+
y: number | [number, number];
|
|
968
|
+
}>;
|
|
969
|
+
/** Optional level constraints. If specified, region only applies to these levels. */
|
|
970
|
+
levels?: number[];
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* @namespace
|
|
974
|
+
* Utility functions for working with TerrainRegion objects.
|
|
975
|
+
*/
|
|
976
|
+
namespace TerrainRegion {
|
|
977
|
+
/**
|
|
978
|
+
* Checks if a terrain region contains the specified tile.
|
|
979
|
+
* @param region The terrain region to check
|
|
980
|
+
* @param x The X coordinate of the tile
|
|
981
|
+
* @param y The Y coordinate of the tile
|
|
982
|
+
* @param level The zoom level of the tile
|
|
983
|
+
* @returns True if the region contains the tile, false otherwise
|
|
984
|
+
*/
|
|
985
|
+
function contains(region: HybridTerrainProvider.TerrainRegion, x: number, y: number, level: number): boolean;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
type TerrainTiles = NonNullable<HybridTerrainProvider.TerrainRegion["tiles"]>;
|
|
990
|
+
type TerrainRegion = HybridTerrainProvider.TerrainRegion;
|
|
991
|
+
type TerrainOptions = HybridTerrainProvider.ConstructorOptions;
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* Copies configuration and state from one Cesium Viewer to another.
|
|
995
|
+
* @param source - The source viewer to copy properties from
|
|
996
|
+
* @param container - DOM element ID or element for the new viewer
|
|
997
|
+
* @param options - Optional override options for the new viewer
|
|
998
|
+
* @returns A new Viewer instance with copied properties
|
|
999
|
+
*/
|
|
1000
|
+
declare function cloneViewer(source: Viewer, container: Element | string, options?: Viewer.ConstructorOptions): Viewer;
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Copies camera state from source viewer to destination viewer.
|
|
1004
|
+
* @param source The source viewer to copy camera states from.
|
|
1005
|
+
* @param dest The destination viewer to apply camera properties from the source.
|
|
1006
|
+
*/
|
|
1007
|
+
declare function syncCamera(source: Viewer, dest: Viewer): void;
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
* Utility for managing deprecation warnings in the cesium-utils library.
|
|
1011
|
+
* Provides runtime warnings to help developers identify deprecated API usage.
|
|
1012
|
+
*/
|
|
1013
|
+
declare namespace Deprecate {
|
|
1014
|
+
/**
|
|
1015
|
+
* Configuration options for deprecation warnings.
|
|
1016
|
+
*/
|
|
1017
|
+
interface Options {
|
|
1018
|
+
/**
|
|
1019
|
+
* Whether to show the warning only once per deprecation message.
|
|
1020
|
+
* @default true
|
|
1021
|
+
*/
|
|
1022
|
+
once?: boolean;
|
|
1023
|
+
/**
|
|
1024
|
+
* Custom prefix for the warning message.
|
|
1025
|
+
* @default "[DEPRECATED]"
|
|
1026
|
+
*/
|
|
1027
|
+
prefix?: string;
|
|
1028
|
+
/**
|
|
1029
|
+
* Whether to include a stack trace in the warning.
|
|
1030
|
+
* @default true
|
|
1031
|
+
*/
|
|
1032
|
+
includeStack?: boolean;
|
|
1033
|
+
/**
|
|
1034
|
+
* Version when the feature will be removed.
|
|
1035
|
+
*/
|
|
1036
|
+
removeInVersion?: string;
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Displays a deprecation warning message.
|
|
1040
|
+
*
|
|
1041
|
+
* @param message - The deprecation message to display
|
|
1042
|
+
* @param options - Configuration options for the warning
|
|
1043
|
+
*
|
|
1044
|
+
* @example
|
|
1045
|
+
* ```typescript
|
|
1046
|
+
* // Basic usage
|
|
1047
|
+
* deprecationWarning("oldFunction() is deprecated. Use newFunction() instead.");
|
|
1048
|
+
*
|
|
1049
|
+
* // With removal version
|
|
1050
|
+
* deprecationWarning("TerrainArea is deprecated.", {
|
|
1051
|
+
* removeInVersion: "v0.3.0"
|
|
1052
|
+
* });
|
|
1053
|
+
*
|
|
1054
|
+
* // Allow multiple warnings
|
|
1055
|
+
* deprecationWarning("Repeated warning", { once: false });
|
|
1056
|
+
* ```
|
|
1057
|
+
*/
|
|
1058
|
+
function warn(message: string, options?: Options): void;
|
|
1059
|
+
/**
|
|
1060
|
+
* Creates a deprecation wrapper function that shows a warning when called.
|
|
1061
|
+
*
|
|
1062
|
+
* @param fn - The function to wrap
|
|
1063
|
+
* @param message - The deprecation message
|
|
1064
|
+
* @param options - Configuration options for the warning
|
|
1065
|
+
* @returns A wrapped function that shows a deprecation warning when called
|
|
1066
|
+
*
|
|
1067
|
+
* @example
|
|
1068
|
+
* ```typescript
|
|
1069
|
+
* const oldFunction = deprecate(
|
|
1070
|
+
* () => console.log("old implementation"),
|
|
1071
|
+
* "oldFunction() is deprecated. Use newFunction() instead."
|
|
1072
|
+
* );
|
|
1073
|
+
*
|
|
1074
|
+
* oldFunction(); // Shows warning and executes function
|
|
1075
|
+
* ```
|
|
1076
|
+
*/
|
|
1077
|
+
function deprecate<T extends (...args: any[]) => any>(fn: T, message: string, options?: Options): T;
|
|
1078
|
+
/**
|
|
1079
|
+
* Clears all shown warning messages.
|
|
1080
|
+
* Useful for testing or when you want to reset the warning state.
|
|
1081
|
+
*
|
|
1082
|
+
* @example
|
|
1083
|
+
* ```typescript
|
|
1084
|
+
* clearDeprecationWarnings();
|
|
1085
|
+
* deprecationWarning("This will show again");
|
|
1086
|
+
* ```
|
|
1087
|
+
*/
|
|
1088
|
+
function clear(): void;
|
|
1089
|
+
/**
|
|
1090
|
+
* Gets the count of unique deprecation warnings that have been shown.
|
|
1091
|
+
*
|
|
1092
|
+
* @returns The number of unique deprecation warnings shown
|
|
1093
|
+
*/
|
|
1094
|
+
function getWarningCount(): number;
|
|
1095
|
+
/**
|
|
1096
|
+
* Checks if a specific deprecation warning has been shown.
|
|
1097
|
+
*
|
|
1098
|
+
* @param message - The deprecation message to check
|
|
1099
|
+
* @returns True if the warning has been shown, false otherwise
|
|
1100
|
+
*/
|
|
1101
|
+
function hasShown(message: string): boolean;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
declare const deprecate: typeof Deprecate.deprecate;
|
|
1105
|
+
|
|
1106
|
+
/**
|
|
1107
|
+
* @since Cesium 1.132.0
|
|
1108
|
+
* @experimental
|
|
1109
|
+
* Point sunlight analysis utility for shadow calculations.
|
|
1110
|
+
*
|
|
1111
|
+
* ⚠️ **Warning**: This is an experimental feature that uses Cesium's internal APIs.
|
|
1112
|
+
* The API may change or break in future versions of Cesium or cesium-utils.
|
|
1113
|
+
*
|
|
1114
|
+
* @example
|
|
1115
|
+
* ```typescript
|
|
1116
|
+
* const sunlight = new Sunlight(viewer);
|
|
1117
|
+
* sunlight.analyze(point, JulianDate.now());
|
|
1118
|
+
* ```
|
|
1119
|
+
*/
|
|
1120
|
+
declare class Sunlight {
|
|
1121
|
+
private _uniformState;
|
|
1122
|
+
private _viewer;
|
|
1123
|
+
private _analyzing;
|
|
1124
|
+
private _pointEntityId?;
|
|
1125
|
+
private _objectsToExclude;
|
|
1126
|
+
private _polylines;
|
|
1127
|
+
private _points;
|
|
1128
|
+
constructor(viewer: Viewer);
|
|
1129
|
+
/** The sun position in 3D world coordinates at the current scene time. */
|
|
1130
|
+
get sunPositionWC(): Cartesian3;
|
|
1131
|
+
/** A normalized vector to the sun in 3D world coordinates at the current scene time. */
|
|
1132
|
+
get sunDirectionWC(): Cartesian3;
|
|
1133
|
+
/** Whether sunlight analysis is currently in progress. */
|
|
1134
|
+
get isAnalyzing(): boolean;
|
|
1135
|
+
/**
|
|
1136
|
+
* Gets virtual position and direction of the sun to reduce calculation overhead.
|
|
1137
|
+
*
|
|
1138
|
+
* @param from target point to start from
|
|
1139
|
+
* @param radius virtual distance between target point and the sun. Defaults to 10000 (10km)
|
|
1140
|
+
*/
|
|
1141
|
+
virtualSun(from: Cartesian3, radius?: number): {
|
|
1142
|
+
position: Cartesian3;
|
|
1143
|
+
direction: Cartesian3;
|
|
1144
|
+
};
|
|
1145
|
+
/**
|
|
1146
|
+
* Analyze the sunlight acceptance from a given point at a given time.
|
|
1147
|
+
* @param from target point to analyze
|
|
1148
|
+
* @param at time to analyze
|
|
1149
|
+
* @param options {@link Sunlight.AnalyzeOptions}
|
|
1150
|
+
*/
|
|
1151
|
+
analyze(from: Cartesian3, at: JulianDate, options?: Sunlight.AnalyzeOptions): Promise<Sunlight.AnalysisResult>;
|
|
1152
|
+
/**
|
|
1153
|
+
* Analyze the sunlight acceptance from a given point at a given time range.
|
|
1154
|
+
* @param from target point to analyze
|
|
1155
|
+
* @param range time range to analyze
|
|
1156
|
+
* @param options {@link Sunlight.AnalyzeOptions}
|
|
1157
|
+
*/
|
|
1158
|
+
analyze(from: Cartesian3, range: Sunlight.TimeRange, options?: Sunlight.AnalyzeOptions): Promise<Sunlight.AnalysisResult[]>;
|
|
1159
|
+
/**
|
|
1160
|
+
* Remove all instances created for debug purpose
|
|
1161
|
+
*/
|
|
1162
|
+
clear(): void;
|
|
1163
|
+
/**
|
|
1164
|
+
* Create an ellipsoid entity for ray collision detection to complement cesium's native click event accuracy
|
|
1165
|
+
* @param at where to create the entity
|
|
1166
|
+
* @param show whether to show point entity
|
|
1167
|
+
* @param errorBoundary size of the point entity for error tolerance
|
|
1168
|
+
*/
|
|
1169
|
+
setTargetPoint(at: Cartesian3, show?: boolean, errorBoundary?: number, color?: Color): Entity;
|
|
1170
|
+
private _analyzeSingleTime;
|
|
1171
|
+
private _analyzeTimeRange;
|
|
1172
|
+
/**
|
|
1173
|
+
* @returns A promise tht resolves to an object containing the object and position of the first intersection.
|
|
1174
|
+
* @see https://github.com/CesiumGS/cesium/blob/1.136/packages/engine/Source/Scene/Scene.js#L4868
|
|
1175
|
+
*/
|
|
1176
|
+
private _pick;
|
|
1177
|
+
private _getExcludedObjects;
|
|
1178
|
+
}
|
|
1179
|
+
declare namespace Sunlight {
|
|
1180
|
+
const DETECTION_ELLIPSOID_ID = "sunlight-detection-ellipsoid";
|
|
1181
|
+
/** for time-range analysis */
|
|
1182
|
+
interface TimeRange {
|
|
1183
|
+
/** When to start analysis */
|
|
1184
|
+
start: JulianDate;
|
|
1185
|
+
/** When to end analysis */
|
|
1186
|
+
end: JulianDate;
|
|
1187
|
+
/** Step interval (seconds) inside the range */
|
|
1188
|
+
step: number;
|
|
1189
|
+
}
|
|
1190
|
+
interface AnalyzeOptions {
|
|
1191
|
+
/** List of objects to exclude from ray pick */
|
|
1192
|
+
objectsToExclude?: any[];
|
|
1193
|
+
/** size of the point entity for error tolerance */
|
|
1194
|
+
errorBoundary?: number;
|
|
1195
|
+
/** Whether to show sunlight paths */
|
|
1196
|
+
debugShowRays?: boolean;
|
|
1197
|
+
/** Whether to show points */
|
|
1198
|
+
debugShowPoints?: boolean;
|
|
1199
|
+
}
|
|
1200
|
+
interface AnalysisResult {
|
|
1201
|
+
/** ISO time string */
|
|
1202
|
+
timestamp: string;
|
|
1203
|
+
/** Whether the sunlight has reached */
|
|
1204
|
+
result: boolean | any;
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
/**
|
|
1209
|
+
* @class
|
|
1210
|
+
* Utility class for visualizing terrain provider boundaries and debugging terrain loading.
|
|
1211
|
+
*/
|
|
1212
|
+
declare class TerrainVisualizer {
|
|
1213
|
+
private _viewer;
|
|
1214
|
+
private _terrainProvider;
|
|
1215
|
+
private _visible;
|
|
1216
|
+
private _tileCoordinatesLayer;
|
|
1217
|
+
private _hybridImageryLayer;
|
|
1218
|
+
private _colors;
|
|
1219
|
+
/**
|
|
1220
|
+
* Creates a new `TerrainVisualizer`.
|
|
1221
|
+
* @param viewer The Cesium viewer instance
|
|
1222
|
+
* @param options {@link TerrainVisualizer.ConstructorOptions}
|
|
1223
|
+
*/
|
|
1224
|
+
constructor(viewer: Viewer, options: TerrainVisualizer.ConstructorOptions);
|
|
1225
|
+
/**
|
|
1226
|
+
* Sets the terrain provider to visualize.
|
|
1227
|
+
* @param terrainProvider The terrain provider to visualize.
|
|
1228
|
+
*/
|
|
1229
|
+
setTerrainProvider(terrainProvider: HybridTerrainProvider): void;
|
|
1230
|
+
/**
|
|
1231
|
+
* Updates all active visualizations.
|
|
1232
|
+
*/
|
|
1233
|
+
update(): void;
|
|
1234
|
+
/**
|
|
1235
|
+
* Clears all visualizations.
|
|
1236
|
+
*/
|
|
1237
|
+
clear(): void;
|
|
1238
|
+
/**
|
|
1239
|
+
* Shows terrain visualization using HybridImageryProvider.
|
|
1240
|
+
* Optionally adds tile coordinate grid overlay.
|
|
1241
|
+
* @param options Visualization options
|
|
1242
|
+
*/
|
|
1243
|
+
show(options?: {
|
|
1244
|
+
/** Show tile coordinate labels. Default: true */
|
|
1245
|
+
showTileCoordinates?: boolean;
|
|
1246
|
+
/** Transparency level (0-1). Default: 0.5 */
|
|
1247
|
+
alpha?: number;
|
|
1248
|
+
}): void;
|
|
1249
|
+
private _ensureTileCoordinatesLayer;
|
|
1250
|
+
/**
|
|
1251
|
+
* Hides the terrain visualization.
|
|
1252
|
+
*/
|
|
1253
|
+
hide(): void;
|
|
1254
|
+
/**
|
|
1255
|
+
* Sets the colors used for visualization.
|
|
1256
|
+
* @param colors Map of role names to colors
|
|
1257
|
+
*/
|
|
1258
|
+
setColors(colors: Record<string, Color>): void;
|
|
1259
|
+
/**
|
|
1260
|
+
* Shows terrain regions using HybridImageryProvider (performant, global coverage).
|
|
1261
|
+
* This replaces the entity-based approach with an imagery layer.
|
|
1262
|
+
* @param alpha Transparency level (0-1), default 0.5
|
|
1263
|
+
*/
|
|
1264
|
+
showImageryOverlay(alpha?: number): void;
|
|
1265
|
+
/**
|
|
1266
|
+
* Hides the imagery overlay.
|
|
1267
|
+
*/
|
|
1268
|
+
hideImageryOverlay(): void;
|
|
1269
|
+
/**
|
|
1270
|
+
* Shows tile coordinate grid overlay.
|
|
1271
|
+
*/
|
|
1272
|
+
showTileCoordinates(): void;
|
|
1273
|
+
/**
|
|
1274
|
+
* Hides tile coordinate grid overlay.
|
|
1275
|
+
*/
|
|
1276
|
+
hideTileCoordinates(): void;
|
|
1277
|
+
/**
|
|
1278
|
+
* Sets the transparency of the imagery overlay.
|
|
1279
|
+
* @param alpha Transparency level (0-1), where 0 is fully transparent and 1 is fully opaque
|
|
1280
|
+
*/
|
|
1281
|
+
setAlpha(alpha: number): void;
|
|
1282
|
+
/**
|
|
1283
|
+
* Flies the camera to focus on a rectangle.
|
|
1284
|
+
* @param rectangle The rectangle to focus on.
|
|
1285
|
+
* @param options {@link Viewer.flyTo}
|
|
1286
|
+
*/
|
|
1287
|
+
flyTo(rectangle: Rectangle, options?: {
|
|
1288
|
+
duration?: number;
|
|
1289
|
+
}): void;
|
|
1290
|
+
/** Whether tile coordinates are currently visible. */
|
|
1291
|
+
get tileCoordinatesVisible(): boolean;
|
|
1292
|
+
/** Whether the grid is currently visible. */
|
|
1293
|
+
get visible(): boolean;
|
|
1294
|
+
/** The viewer used in the visualizer */
|
|
1295
|
+
get viewer(): Viewer;
|
|
1296
|
+
/** The colors used in the visualizer */
|
|
1297
|
+
get colors(): Map<string, Color>;
|
|
1298
|
+
/** The hybrid terrain instance used in the visualizer */
|
|
1299
|
+
get terrainProvider(): HybridTerrainProvider;
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* @namespace
|
|
1303
|
+
* Contains types, utility functions, and constants for terrain visualization.
|
|
1304
|
+
*/
|
|
1305
|
+
declare namespace TerrainVisualizer {
|
|
1306
|
+
/** Initialization options for `TerrainVisualizer` constructor. */
|
|
1307
|
+
interface ConstructorOptions {
|
|
1308
|
+
/** Colors to use for different visualization elements */
|
|
1309
|
+
colors?: Record<string, Color>;
|
|
1310
|
+
/** Whether to show tile grid initially. */
|
|
1311
|
+
tile?: boolean;
|
|
1312
|
+
/** Initial zoom level to use for visualizations. */
|
|
1313
|
+
activeLevel?: number;
|
|
1314
|
+
/** Terrain provider to visualize. */
|
|
1315
|
+
terrainProvider: HybridTerrainProvider;
|
|
1316
|
+
}
|
|
1317
|
+
/** Options for {@link TerrainVisualizer.visualize} */
|
|
1318
|
+
interface Options {
|
|
1319
|
+
color?: Color;
|
|
1320
|
+
show?: boolean;
|
|
1321
|
+
maxTilesToShow?: number;
|
|
1322
|
+
levels?: number[];
|
|
1323
|
+
tag?: string;
|
|
1324
|
+
alpha?: number;
|
|
1325
|
+
tileAlpha?: number;
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
export { Collection, Deprecate, Highlight, HybridTerrainProvider, SilhouetteHighlight, Sunlight, SurfaceHighlight, type TerrainOptions, TerrainRegion, type TerrainTiles, TerrainVisualizer, cloneViewer, deprecate, syncCamera };
|