@juun-roh/cesium-utils 0.0.2 → 0.0.4

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
@@ -1,834 +1,6 @@
1
- import { BillboardCollection, DataSourceCollection, EntityCollection, ImageryLayerCollection, LabelCollection, PointPrimitiveCollection, PolylineCollection, PrimitiveCollection, Billboard, DataSource, Entity, ImageryLayer, Label, PointPrimitive, Polyline, Primitive, Cesium3DTileset, GroundPrimitive, TilingScheme, TerrainProvider, Rectangle, Request, TerrainData, Credit, TileAvailability, Viewer, Color } from 'cesium';
2
-
3
- type CesiumCollection = BillboardCollection | DataSourceCollection | EntityCollection | ImageryLayerCollection | LabelCollection | PointPrimitiveCollection | PolylineCollection | PrimitiveCollection;
4
- type Primitives = Primitive | Cesium3DTileset | GroundPrimitive;
5
- type CesiumCollectionItem = Billboard | DataSource | Entity | ImageryLayer | Label | PointPrimitive | Polyline | Primitives;
6
- type Tag = string | number;
7
- interface WithTag {
8
- [key: symbol]: Tag;
9
- }
10
- /**
11
- * Collection event types
12
- */
13
- type CollectionEventType = 'add' | 'remove' | 'update' | 'clear';
14
- /**
15
- * Event handler function type
16
- */
17
- type EventHandler<I> = (event: {
18
- type: CollectionEventType;
19
- items?: I[];
20
- tag?: Tag;
21
- }) => void;
22
- /**
23
- * Abstract class that enhances Cesium collection objects with tagging functionality.
24
- * This class provides a consistent API for working with different types of Cesium collections
25
- * and allows grouping and manipulating collection items by custom tags.
26
- *
27
- * @abstract
28
- * @template C - The type of Cesium collection (e.g., EntityCollection, PrimitiveCollection)
29
- * @template I - The type of items in the collection (e.g., Entity, Primitive)
30
- *
31
- * @example
32
- * // Creating a specialized collection for entities
33
- * class MyEntities extends Collection<EntityCollection, Entity> {
34
- * constructor(viewer) {
35
- * super({ collection: viewer.entities, tag: 'myEntities' });
36
- * }
37
- *
38
- * get values() {
39
- * return this.collection.values;
40
- * }
41
- * }
42
- *
43
- * const entities = new MyEntities(viewer);
44
- * entities.add(new Entity({ ... }), 'buildings');
45
- * entities.add(new Entity({ ... }), 'roads');
46
- *
47
- * // Later, show only buildings
48
- * entities.show('buildings');
49
- * entities.hide('roads');
50
- */
51
- declare abstract class Collection<C extends CesiumCollection, I extends CesiumCollectionItem> {
52
- /**
53
- * Symbol used as a property key to store tags on collection items.
54
- * Using a Symbol ensures no property naming conflicts with the item's own properties.
55
- * @readonly
56
- */
57
- static readonly symbol: unique symbol;
58
- /**
59
- * Default tag used when adding items without specifying a tag.
60
- * @protected
61
- */
62
- protected tag: Tag;
63
- /**
64
- * The underlying Cesium collection being wrapped.
65
- * @protected
66
- */
67
- protected collection: C;
68
- /**
69
- * Cache for values array to improve performance
70
- * @private
71
- */
72
- private _valuesCache;
73
- /**
74
- * Tag to items map for faster lookups
75
- * @private
76
- */
77
- private _tagMap;
78
- /**
79
- * Event listeners
80
- * @private
81
- */
82
- private _eventListeners;
83
- /**
84
- * Creates a new Collection instance.
85
- *
86
- * @param options - Configuration options
87
- * @param options.collection - The Cesium collection to wrap
88
- * @param options.tag - The default tag to use for items (defaults to 'default')
89
- */
90
- constructor({ collection, tag }: {
91
- collection: C;
92
- tag?: Tag;
93
- });
94
- /**
95
- * Emits an event to all registered listeners.
96
- *
97
- * @private
98
- * @param type - The event type
99
- * @param data - Additional event data
100
- */
101
- private _emit;
102
- /**
103
- * Adds an item to the internal tag map for quick lookups.
104
- *
105
- * @private
106
- * @param item - The item to add
107
- * @param tag - The tag to associate with the item
108
- */
109
- private _addToTagMap;
110
- /**
111
- * Removes an item from the internal tag map.
112
- *
113
- * @private
114
- * @param item - The item to remove
115
- */
116
- private _removeFromTagMap;
117
- /**
118
- * Invalidates the values cache when collection changes.
119
- *
120
- * @private
121
- */
122
- private _invalidateCache;
123
- /**
124
- * Registers an event listener for collection events.
125
- *
126
- * @param type - The event type to listen for
127
- * @param handler - The callback function
128
- * @returns The collection instance for method chaining
129
- */
130
- addEventListener(type: CollectionEventType, handler: EventHandler<I>): this;
131
- /**
132
- * Removes an event listener.
133
- *
134
- * @param type - The event type
135
- * @param handler - The callback function to remove
136
- * @returns The collection instance for method chaining
137
- */
138
- removeEventListener(type: CollectionEventType, handler: EventHandler<I>): this;
139
- /**
140
- * Adds a single item with a tag to the collection.
141
- *
142
- * @param item - The item to add to the collection
143
- * @param tag - Tag to associate with this item (defaults to the collection's default tag)
144
- * @param index - The index to add the item at (if supported by the collection)
145
- * @returns The added item for chaining
146
- *
147
- * @example
148
- * const entity = collection.add(new Entity({ ... }), 'landmarks');
149
- */
150
- add(item: I, tag?: Tag, index?: number): I;
151
- /**
152
- * Adds multiple items with the same tag to the collection.
153
- *
154
- * @param items - The array of items to add to the collection
155
- * @param tag - Tag to associate with this item (defaults to the collection's default tag)
156
- * @returns The array of added items
157
- *
158
- * @example
159
- * // Add multiple entities with the same tag
160
- * const entities = [new Entity({ ... }), new Entity({ ... })];
161
- * const addedEntities = collection.add(entities, 'buildings');
162
- */
163
- add(items: I[], tag?: Tag): I[];
164
- /**
165
- * Returns true if the provided item is in this collection, false otherwise.
166
- *
167
- * @param item - The item to check for
168
- * @returns True if the item is in the collection, false otherwise
169
- */
170
- contains(item: I): boolean;
171
- /**
172
- * Removes an item from the collection.
173
- *
174
- * @param item - The item to remove
175
- * @returns True if the item was removed, false if it wasn't found
176
- */
177
- remove(item: I & WithTag): boolean;
178
- /**
179
- * Removes all items from the collection.
180
- */
181
- removeAll(): void;
182
- /**
183
- * Gets all item instances in the collection.
184
- * This array should not be modified directly.
185
- *
186
- * @returns An array of all items in the collection
187
- */
188
- get values(): I[];
189
- /**
190
- * Gets the number of items in the collection.
191
- *
192
- * @returns The item count
193
- */
194
- get length(): number;
195
- /**
196
- * Gets all items with the specified tag from the collection.
197
- * Uses an optimized internal map for faster lookups.
198
- *
199
- * @param tag - The tag to filter by
200
- * @returns An array of items with the specified tag, or an empty array if none found
201
- *
202
- * @example
203
- * // Get all buildings
204
- * const buildings = collection.getByTag('buildings');
205
- */
206
- getByTag(tag: Tag): I[];
207
- /**
208
- * Gets the first item matching the tag. More efficient than getByTag when
209
- * you only need one item, especially for large collections.
210
- *
211
- * @param tag - The tag to search for
212
- * @returns The first matching item or undefined if none found
213
- *
214
- * @example
215
- * // Get the first building
216
- * const firstBuilding = collection.getFirstByTag('buildings');
217
- */
218
- getFirstByTag(tag: Tag): I | undefined;
219
- /**
220
- * Gets all unique tags currently in use in the collection.
221
- *
222
- * @returns An array of all unique tags
223
- *
224
- * @example
225
- * // Get all tags
226
- * const tags = collection.getTags();
227
- * console.log(`Collection has these tags: ${tags.join(', ')}`);
228
- */
229
- getTags(): Tag[];
230
- /**
231
- * Checks if the collection has any items with the specified tag.
232
- *
233
- * @param tag - The tag to check for
234
- * @returns True if items with the tag exist, false otherwise
235
- *
236
- * @example
237
- * if (collection.hasTag('temporary')) {
238
- * console.log('Temporary items exist');
239
- * }
240
- */
241
- hasTag(tag: Tag): boolean;
242
- /**
243
- * Updates the tag for all items with the specified tag.
244
- *
245
- * @param oldTag - The tag to replace
246
- * @param newTag - The new tag to assign
247
- * @returns The number of items updated
248
- *
249
- * @example
250
- * // Rename a tag
251
- * const count = collection.updateTag('temp', 'temporary');
252
- * console.log(`Updated ${count} items`);
253
- */
254
- updateTag(oldTag: Tag, newTag: Tag): number;
255
- /**
256
- * Removes all items with the specified tag from the collection.
257
- *
258
- * @param tag - The tag identifying which items to remove
259
- * @returns The number of items removed
260
- *
261
- * @example
262
- * // Remove all temporary markers
263
- * const count = collection.removeByTag('temporary');
264
- * console.log(`Removed ${count} items`);
265
- */
266
- removeByTag(tag: Tag): number;
267
- /**
268
- * Removes all items with the array of tags from the collection.
269
- *
270
- * @param tag - The tags identifying which items to remove
271
- * @returns The number of items removed
272
- *
273
- * @example
274
- * // Remove all items containing tags
275
- * const count = collection.removeByTag('temporary', 'default', 'tag');
276
- * console.log(`Removed ${count} items`);
277
- */
278
- removeByTag(tag: Tag[]): number;
279
- /**
280
- * Makes all items with the specified tag visible.
281
- * Only affects items that have a 'show' property.
282
- *
283
- * @param tag - The tag identifying which items to show
284
- * @returns The number of items affected
285
- *
286
- * @example
287
- * // Show all buildings
288
- * collection.show('buildings');
289
- */
290
- show(tag: Tag): number;
291
- /**
292
- * Hides all items with the specified tag.
293
- * Only affects items that have a 'show' property.
294
- *
295
- * @param tag - The tag identifying which items to hide
296
- * @returns The number of items affected
297
- *
298
- * @example
299
- * // Hide all buildings
300
- * collection.hide('buildings');
301
- */
302
- hide(tag: Tag): number;
303
- /**
304
- * Toggles visibility of all items with the specified tag.
305
- * Only affects items that have a 'show' property.
306
- *
307
- * @param tag - The tag identifying which items to toggle
308
- * @returns The number of items affected
309
- *
310
- * @example
311
- * // Toggle visibility of all buildings
312
- * collection.toggle('buildings');
313
- */
314
- toggle(tag: Tag): number;
315
- /**
316
- * Sets a property value on all items with the specified tag.
317
- *
318
- * @param tag - The tag identifying which items to update
319
- * @param property - The property name to set
320
- * @param value - The value to set
321
- * @returns The number of items updated
322
- *
323
- * @example
324
- * // Change color of all buildings to red
325
- * collection.setProperty('buildings', 'color', Color.RED);
326
- */
327
- setProperty<K extends string, V>(tag: Tag, property: K, value: V): number;
328
- /**
329
- * Filters items in the collection based on a predicate function.
330
- * Optionally only filters items with a specific tag.
331
- *
332
- * @param predicate - Function that tests each item
333
- * @param tag - Optional tag to filter by before applying the predicate
334
- * @returns Array of items that pass the test
335
- *
336
- * @example
337
- * // Get all buildings taller than 100 meters
338
- * const tallBuildings = collection.filter(
339
- * entity => entity.properties?.height?.getValue() > 100,
340
- * 'buildings'
341
- * );
342
- */
343
- filter(predicate: (item: I) => boolean, tag?: Tag): I[];
344
- /**
345
- * Executes a callback function for each item in the collection.
346
- * Optionally filters items by tag before execution.
347
- *
348
- * @param callback - Function to execute for each item
349
- * @param tag - Optional tag to filter items (if not provided, processes all items)
350
- *
351
- * @example
352
- * // Highlight all buildings
353
- * collection.forEach((entity) => {
354
- * if (entity.polygon) {
355
- * entity.polygon.material = new ColorMaterialProperty(Color.YELLOW);
356
- * }
357
- * }, 'buildings');
358
- */
359
- forEach(callback: (item: I, index: number) => void, tag?: Tag): void;
360
- }
361
-
362
- /** A range of tiles from `start` to `end` */
363
- type TileRange = {
364
- /** Top Left tile coordinates */
365
- start: {
366
- x: number;
367
- y: number;
368
- };
369
- /** Bottom Right tile coordinates */
370
- end: {
371
- x: number;
372
- y: number;
373
- };
374
- };
375
- /** A `TileRange` map with specific levels as their keys. */
376
- type TileRanges = Map<number, TileRange>;
377
- /**
378
- * Defines the geographic boundaries for a terrain area and handles tile availability checks.
379
- * @class
380
- */
381
- declare class TerrainBounds {
382
- private _rectangle;
383
- private _tilingScheme;
384
- private _tileRanges;
385
- private _levels;
386
- /**
387
- * Creates a new instance of TerrainBounds.
388
- * @param options {@link TerrainBounds.ConstructorOptions}
389
- * @param tilingScheme (optional) The tiling scheme to use for coordinate calculations.
390
- */
391
- constructor(options: TerrainBounds.ConstructorOptions, tilingScheme?: TilingScheme);
392
- /**
393
- * Checks if the specified tile coordinates are within the bounds.
394
- * @param x The tile X coordinate.
395
- * @param y The tile Y coordinate.
396
- * @param level The tile level.
397
- * @returns `true` if the tile is within bounds, `false` otherwise.
398
- */
399
- contains(x: number, y: number, level: number): boolean;
400
- /**
401
- *
402
- * Configures a terrain provider's availability based on these bounds.
403
- * @see WARNING This method is accessing private property of {@link https://cesium.com/learn/csiumjs/ref-doc/TileAvailability.html `TileAvailability`}.
404
- * @param provider The terrain provider to configure.
405
- */
406
- configureAvailability(provider: TerrainProvider): void;
407
- /**
408
- * Gets the rectangle representing these bounds.
409
- */
410
- get rectangle(): Rectangle;
411
- /**
412
- * Gets the tiling scheme used by these bounds.
413
- */
414
- get tilingScheme(): TilingScheme;
415
- /**
416
- * Gets the tile ranges defined for these bounds.
417
- */
418
- get tileRanges(): TileRanges;
419
- /**
420
- * Gets the levels for which tile ranges are defined.
421
- */
422
- get levels(): Set<number>;
423
- /**
424
- * Calculates a bounding rectangle that encompasses all the specified tile ranges.
425
- * @private
426
- */
427
- private _calculateRectangleFromTileRanges;
428
- }
429
- /**
430
- * Contains types and factory methods for creating `TerrainBounds` instances.
431
- * @namespace
432
- */
433
- declare namespace TerrainBounds {
434
- /** Initialization options for Terrain Bounds constructor */
435
- interface ConstructorOptions {
436
- /** Type of bounds definition. */
437
- type: 'tileRange' | 'rectangle';
438
- /**
439
- * Tile ranges by level when using tileRange type.
440
- * Keys are zoom levels, values define the range of tiles at that level.
441
- * Can be provided either as a Map or as a plain object with numeric keys.
442
- */
443
- tileRanges?: Map<number, TileRange> | Record<string | number, TileRange>;
444
- /** Rectangle bounds when using rectangle type. */
445
- rectangle?: Rectangle;
446
- }
447
- /**
448
- * Creates `TerrainBounds` from tile coordinates at a specific level.
449
- * @param x The tile X coordinate.
450
- * @param y The tile Y coordinate.
451
- * @param level The tile level.
452
- * @param tilingScheme The tiling scheme to use.
453
- * @returns A new `TerrainBounds` instance for the specified tile.
454
- */
455
- function fromTile(x: number, y: number, level: number, tilingScheme?: TilingScheme): TerrainBounds;
456
- /**
457
- * Creates `TerrainBounds` from a rectangle.
458
- * @param rectangle The rectangle defining the bounds.
459
- * @param tilingScheme The tiling scheme to use.
460
- * @returns A new `TerrainBounds` instance for the specified rectangle.
461
- */
462
- function fromRectangle(rectangle: Rectangle, tilingScheme?: TilingScheme): TerrainBounds;
463
- }
464
-
465
- /**
466
- * @class
467
- * Represents a geographic area with a specific terrain provider.
468
- * `TerrainArea` pairs a provider with geographic bounds and level constraints.
469
- */
470
- declare class TerrainArea {
471
- private _provider;
472
- private _bounds;
473
- private _levels;
474
- private _ready;
475
- private _credit;
476
- private _isCustom;
477
- /**
478
- * Creates a new instance of `TerrainArea`.
479
- * @param options Object describing initialization options
480
- * @private Use {@link TerrainArea.create} instead.
481
- */
482
- private constructor();
483
- /**
484
- * Asynchronously creates a new instance of `TerrainArea`.
485
- * @param options {@link TerrainArea.ConstructorOptions}
486
- * @returns A promise that resolves to a new `TerrainArea` instance.
487
- */
488
- static create(options: TerrainArea.ConstructorOptions): Promise<TerrainArea>;
489
- /**
490
- * @see {@link TerrainBounds.contains}
491
- */
492
- contains(x: number, y: number, level: number): boolean;
493
- /**
494
- * Requests the terrain for a given tile coordinate.
495
- * @param x The X coordinate of the tile.
496
- * @param y The Y coordinate of the tile.
497
- * @param level The zoom level of the tile.
498
- * @param request The request.
499
- * @returns A promise for the requested terrain.
500
- */
501
- requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<Awaited<TerrainData>> | undefined;
502
- getTileDataAvailable(x: number, y: number, level: number): boolean;
503
- /** Checks if this terrain provider is marked as a custom provider. */
504
- get isCustom(): boolean;
505
- /** Gets the credit associated with this terrain area. */
506
- get credit(): string | Credit;
507
- /** Gets the terrain provider for this terrain area. */
508
- get provider(): TerrainProvider | undefined;
509
- get bounds(): TerrainBounds;
510
- get levels(): Set<number>;
511
- get ready(): boolean;
512
- }
513
- /**
514
- * @namespace
515
- * Contains types and factory methods for creating `TerrainArea` instances.
516
- */
517
- declare namespace TerrainArea {
518
- /** Initialization options for `TerrainArea` constructor. */
519
- interface ConstructorOptions {
520
- /** The terrain provider for this area or a URL to create one from. */
521
- provider: TerrainProvider | string;
522
- /** The geographic bounds of this terrain area. */
523
- bounds: TerrainBounds | TerrainBounds.ConstructorOptions;
524
- /**
525
- * The zoom levels this terrain area applies to.
526
- * If empty, the area applies to all levels.
527
- */
528
- levels?: number[];
529
- /**
530
- * Credit to associate with this terrain provider.
531
- * Used to identify custom terrain providers.
532
- * @default custom
533
- */
534
- credit?: string | Credit;
535
- /**
536
- * Whether this is a custom terrain provider.
537
- * @default true
538
- */
539
- isCustom?: boolean;
540
- }
541
- /**
542
- * Creates a `TerrainArea` from a URL and tile ranges.
543
- * @param url The URL to create the terrain provider from.
544
- * @param tileRanges Tile ranges by level.
545
- * @param levels The zoom levels this area applies to.
546
- * @param credit Credit to associate with this terrain provider.
547
- * @returns A promise resolving to a new `TerrainArea`
548
- */
549
- function fromUrl(url: string, tileRanges: TileRanges, levels?: number[], credit?: string | Credit): Promise<Awaited<TerrainArea>>;
550
- }
551
-
552
- /**
553
- * @class
554
- * Provides terrain by delegating requests to different terrain providers
555
- * based on geographic regions and zoom levels. This allows combining
556
- * multiple terrain sources into a single seamless terrain.
557
- *
558
- * @example
559
- * ``` typescript
560
- * const hybridTerrain = await HybridTerrainProvider.create({
561
- * terrainAreas: [
562
- * provider: 'custom-terrain-url',
563
- * bounds: {
564
- * type: 'tileRange',
565
- * tileRanges: {
566
- * 15: {
567
- * start: { x: 55852, y: 9556 },
568
- * end: { x: 55871, y: 9575 },
569
- * },
570
- * },
571
- * levels: [15],
572
- * }
573
- * ],
574
- * terrainProvider: 'default-terrain-url',
575
- * fallbackProvider: new EllipsoidTerrainProvider(),
576
- * });
577
- *
578
- * viewer.terrainProvider = hybridTerrain;
579
- * ```
580
- */
581
- declare class HybridTerrainProvider implements TerrainProvider {
582
- private _terrainAreas;
583
- private _terrainProvider;
584
- private _fallbackProvider;
585
- private _tilingScheme;
586
- private _ready;
587
- private _availability?;
588
- /**
589
- * Creates a new `HybridTerrainProvider`. Use the {@link HybridTerrainProvider.create}
590
- * instead of the constructor for async initialization.
591
- * @param terrainProvider The initialized default terrain provider
592
- * @param fallbackProvider The initialized fallback terrain provider
593
- * @param terrainAreas The array of initialized terrain areas
594
- * @private - Use {@link HybridTerrainProvider.create} instead.
595
- */
596
- private constructor();
597
- /**
598
- * Asynchronously creates a new `HybridTerrainProvider`.
599
- * @param options {@link HybridTerrainProvider.ConstructorOptions}
600
- * @returns A promise that resolves to a new `HybridTerrainProvider` instance.
601
- */
602
- static create(options: HybridTerrainProvider.ConstructorOptions): Promise<HybridTerrainProvider>;
603
- /**
604
- * Gets a value indicating whether or not the provider is ready for use,
605
- * or a promise that resolves when the provider becomes ready.
606
- */
607
- get ready(): boolean;
608
- /**
609
- * Gets the tiling scheme used by this provider.
610
- */
611
- get tilingScheme(): TilingScheme;
612
- /**
613
- * Gets an object that can be used to determine availability of terrain from this provider.
614
- */
615
- get availability(): TileAvailability | undefined;
616
- /**
617
- * Gets the list of terrain areas managed by this provider.
618
- */
619
- get terrainAreas(): readonly TerrainArea[];
620
- /**
621
- * Gets the default terrain provider.
622
- */
623
- get defaultProvider(): TerrainProvider;
624
- /**
625
- * Gets the fallback terrain provider.
626
- */
627
- get fallbackProvider(): TerrainProvider;
628
- /**
629
- * @see {@link TerrainProvider.credit}
630
- */
631
- get credit(): any;
632
- /**
633
- * @see {@link TerrainProvider.errorEvent}
634
- */
635
- get errorEvent(): any;
636
- /**
637
- * @see {@link TerrainProvider.hasWaterMask}
638
- */
639
- get hasWaterMask(): boolean;
640
- /**
641
- * @see {@link TerrainProvider.hasVertexNormals}
642
- */
643
- get hasVertexNormals(): boolean;
644
- /**
645
- * @see {@link TerrainProvider.loadTileDataAvailability}
646
- */
647
- loadTileDataAvailability(x: number, y: number, level: number): Promise<void> | undefined;
648
- /**
649
- * @see {@link TerrainProvider.getLevelMaximumGeometricError}
650
- */
651
- getLevelMaximumGeometricError(level: number): number;
652
- /**
653
- * Requests the terrain for a given tile coordinate.
654
- * @param x The X coordinate of the tile.
655
- * @param y The Y coordinate of the tile.
656
- * @param level The zoom level of the tile.
657
- * @param request The request.
658
- * @returns A promise for the requested terrain.
659
- */
660
- requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<Awaited<TerrainData>> | undefined;
661
- /**
662
- * @see {@link TerrainProvider.getTileDataAvailable}
663
- * @param x
664
- * @param y
665
- * @param level
666
- */
667
- getTileDataAvailable(x: number, y: number, level: number): boolean | undefined;
668
- }
669
- /**
670
- * @namespace
671
- * Contains types and factory methods for creating `HybridTerrainProvider` instance.
672
- */
673
- declare namespace HybridTerrainProvider {
674
- /**
675
- * Initialization options for `HybridTerrainProvider` constructor.
676
- */
677
- interface ConstructorOptions {
678
- /** An array of terrain areas to include in the hybrid terrain. */
679
- terrainAreas: TerrainArea.ConstructorOptions[];
680
- /** Default provider to use outside of specified terrain areas. */
681
- terrainProvider: TerrainProvider | string;
682
- /** Optional fallback provider when data is not available from default provider. @default EllipsoidTerrainProvider */
683
- fallbackProvider?: TerrainProvider | string;
684
- }
685
- /**
686
- * Creates a `HybridTerrainProvider` with a custom terrain area overlaid on a base terrain.
687
- * @param customTerrainUrl URL to the custom terrain.
688
- * @param baseTerrainUrl URL to the base terrain.
689
- * @param tileRanges Tile ranges defining the custom terrain area.
690
- * @param levels Levels to apply the custom terrain.
691
- * @returns A promise resolving to a new `HybridTerrainProvider`.
692
- */
693
- function createOverlay(customTerrainUrl: string, baseTerrainUrl: string, tileRanges: TileRanges, levels?: number[]): Promise<Awaited<HybridTerrainProvider>>;
694
- }
695
-
696
- declare class TerrainEntities extends Collection<EntityCollection, Entity> {
697
- }
698
- /**
699
- * @class
700
- * Utility class for visualizing terrain provider boundaries and debugging terrain loading.
701
- */
702
- declare class TerrainVisualizer {
703
- private _viewer;
704
- private _collection;
705
- private _hybridTerrain?;
706
- private _visible;
707
- private _level;
708
- private _tileCoordinatesLayer;
709
- private _colors;
710
- /**
711
- * Creates a new `TerrainVisualizer`.
712
- * @param viewer The Cesium viewer instance
713
- * @param options {@link TerrainVisualizer.ConstructorOptions}
714
- */
715
- constructor(viewer: Viewer, options?: TerrainVisualizer.ConstructorOptions);
716
- /**
717
- * Sets the terrain provider to visualize.
718
- * @param terrainProvider The terrain provider to visualize.
719
- */
720
- setTerrainProvider(terrainProvider: HybridTerrainProvider): void;
721
- /**
722
- * Updates all active visualizations.
723
- */
724
- update(): void;
725
- /**
726
- * Clears all visualizations.
727
- */
728
- clear(): void;
729
- /**
730
- * Shows a grid of tiles at the specified level.
731
- * @param level The zoom level to visualize
732
- */
733
- show(level?: number): void;
734
- /**
735
- * Hides the tile grid.
736
- */
737
- hide(): void;
738
- /**
739
- * Sets the colors used for visualization.
740
- * @param colors Map of role names to colors
741
- */
742
- setColors(colors: Record<string, Color>): void;
743
- /**
744
- * Flies the camera to focus on a terrain area.
745
- * @param area The terrain area to focus on.
746
- * @param options {@link Viewer.flyTo}
747
- */
748
- flyTo(area: TerrainArea, options?: {
749
- duration?: number;
750
- }): void;
751
- /**
752
- * Gets the rectangle representing the current view.
753
- * @returns The current view rectangle or undefined.
754
- * @private
755
- */
756
- private _getVisibleRectangle;
757
- /** The current zoom level set on the visualizer. */
758
- get level(): number;
759
- /** Set zoom level on the visualizer. */
760
- set level(level: number);
761
- /** Whether the grid is currently visible. */
762
- get visible(): boolean;
763
- /** The collection used in the visualizer. */
764
- get collection(): TerrainEntities;
765
- /** The viewer used in the visualizer */
766
- get viewer(): Viewer;
767
- }
768
- /**
769
- * @namespace
770
- * Contains types, utility functions, and constants for terrain visualization.
771
- */
772
- declare namespace TerrainVisualizer {
773
- /** Initialization options for `TerrainVisualizer` constructor. */
774
- interface ConstructorOptions {
775
- /** Colors to use for different visualization elements */
776
- colors?: Record<string, Color>;
777
- /** Whether to show boundaries initially. */
778
- boundaries?: boolean;
779
- /** Whether to show tile grid initially. */
780
- tile?: boolean;
781
- /** Initial zoom level to use for visualizations. */
782
- activeLevel?: number;
783
- /** Terrain provider to visualize. */
784
- terrainProvider?: HybridTerrainProvider;
785
- }
786
- /** Tag constants for entity collection management. */
787
- const tag: {
788
- default: string;
789
- boundary: string;
790
- grid: string;
791
- };
792
- /**
793
- * Creates a rectangle entity fo r visualization.
794
- * @param rectangle The rectangle to visualize
795
- * @param color The color to use
796
- * @returns A new entity
797
- */
798
- function createRectangle(rectangle: Rectangle, color: Color): Entity;
799
- /** Options for {@link TerrainVisualizer.visualize} */
800
- interface Options {
801
- color?: Color;
802
- show?: boolean;
803
- maxTilesToShow?: number;
804
- levels?: number[];
805
- tag?: string;
806
- alpha?: number;
807
- tileAlpha?: number;
808
- }
809
- /**
810
- * Visualizes a specific terrain area in a viewer.
811
- * @param terrain The terrain area to visualize.
812
- * @param viewer The Cesium viewer.
813
- * @param options Visualization options.
814
- * @returns Collection of created entities.
815
- */
816
- function visualize(terrain: TerrainArea | TerrainBounds, viewer: Viewer, options?: Options): Collection<EntityCollection, Entity>;
817
- }
818
-
819
- /**
820
- * Copies configuration and state from one Cesium Viewer to another.
821
- * @param source - The source viewer to copy properties from
822
- * @param container - DOM element ID or element for the new viewer
823
- * @param options - Optional override options for the new viewer
824
- * @returns A new Viewer instance with copied properties
825
- */
826
- declare function cloneViewer(source: Viewer, container: Element | string, options?: Viewer.ConstructorOptions): Viewer;
827
- /**
828
- * Copies camera state from source viewer to destination viewer.
829
- * @param source The source viewer to copy camera states from.
830
- * @param dest The destination viewer to apply camera properties from the source.
831
- */
832
- declare function syncCameraState(source: Viewer, dest: Viewer): void;
833
-
834
- export { Collection, HybridTerrainProvider, TerrainArea, TerrainBounds, TerrainVisualizer, cloneViewer, syncCameraState };
1
+ export { CesiumCollection, CesiumCollectionItem, Collection, CollectionEventType, EventHandler, Primitives, Tag, WithTag } from './collection/index.js';
2
+ export { H as HybridTerrainProvider, T as TerrainArea, a as TerrainBounds, b as TileRange, c as TileRanges } from './hybrid-terrain-provider-C6aXdtyo.js';
3
+ export { TerrainAreas } from './terrain/index.js';
4
+ export { TerrainVisualizer, syncCamera } from './utils/index.js';
5
+ export { cloneViewer } from './viewer/index.js';
6
+ import 'cesium';