@juun-roh/cesium-utils 0.2.0 → 0.2.2
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/README.md +15 -2
- package/dist/chunk-DGHCIGKJ.js +1 -0
- package/dist/chunk-N24M6GYI.js +1 -0
- package/dist/chunk-TUJQL7MC.js +1 -0
- package/dist/{chunk-2JNRK7SN.js → chunk-Z2COOTT4.js} +1 -1
- package/dist/collection/index.cjs +1 -1
- package/dist/collection/index.d.cts +1 -1
- package/dist/collection/index.d.ts +1 -1
- package/dist/collection/index.js +1 -1
- package/dist/dev/index.cjs +1 -0
- package/dist/{utils → dev}/index.d.cts +108 -11
- package/dist/{utils → dev}/index.d.ts +108 -11
- package/dist/dev/index.js +1 -0
- package/dist/hybrid-terrain-provider-C2V-igd9.d.cts +202 -0
- package/dist/hybrid-terrain-provider-C2V-igd9.d.ts +202 -0
- package/dist/{index-Bd_-DTWl.d.ts → index-C7kPHG5S.d.cts} +5 -1
- package/dist/{index-Bd_-DTWl.d.cts → index-C7kPHG5S.d.ts} +5 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -1
- package/dist/terrain/index.cjs +1 -1
- package/dist/terrain/index.d.cts +5 -274
- package/dist/terrain/index.d.ts +5 -274
- package/dist/terrain/index.js +1 -1
- package/dist/viewer/index.cjs +1 -1
- package/dist/viewer/index.js +1 -1
- package/package.json +15 -14
- package/dist/chunk-4HY6RL6I.js +0 -1
- package/dist/chunk-BXU5HNPI.js +0 -1
- package/dist/utils/index.cjs +0 -1
- package/dist/utils/index.js +0 -1
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { TerrainProvider, TilingScheme, TileAvailability, Credit, Request, TerrainData, Rectangle } from 'cesium';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @class
|
|
5
|
+
* Provides terrain by delegating requests to different terrain providers
|
|
6
|
+
* based on geographic regions and zoom levels. This allows combining
|
|
7
|
+
* multiple terrain sources into a single seamless terrain.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ``` typescript
|
|
11
|
+
* // Simple rectangle-based regions
|
|
12
|
+
* const hybridTerrain = new HybridTerrainProvider({
|
|
13
|
+
* regions: [
|
|
14
|
+
* {
|
|
15
|
+
* provider: customProvider,
|
|
16
|
+
* bounds: Rectangle.fromDegrees(-120, 30, -100, 50),
|
|
17
|
+
* levels: [10, 15] // optional
|
|
18
|
+
* }
|
|
19
|
+
* ],
|
|
20
|
+
* defaultProvider: worldTerrain
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Or tile-coordinate based for precise control (multiple levels)
|
|
24
|
+
* const tileRanges = new Map();
|
|
25
|
+
* tileRanges.set(15, { x: [55852, 55871], y: [9556, 9575] });
|
|
26
|
+
* tileRanges.set(16, { x: [111704, 111742], y: [19112, 19150] });
|
|
27
|
+
*
|
|
28
|
+
* const hybridTerrain = new HybridTerrainProvider({
|
|
29
|
+
* regions: [
|
|
30
|
+
* {
|
|
31
|
+
* provider: customProvider,
|
|
32
|
+
* tiles: tileRanges
|
|
33
|
+
* }
|
|
34
|
+
* ],
|
|
35
|
+
* defaultProvider: worldTerrain
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* viewer.terrainProvider = hybridTerrain;
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare class HybridTerrainProvider implements TerrainProvider {
|
|
42
|
+
private _regions;
|
|
43
|
+
private _defaultProvider;
|
|
44
|
+
private _fallbackProvider;
|
|
45
|
+
private _tilingScheme;
|
|
46
|
+
private _ready;
|
|
47
|
+
private _availability?;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new `HybridTerrainProvider` instance.
|
|
50
|
+
* @param options {@link HybridTerrainProvider.ConstructorOptions}
|
|
51
|
+
* @returns A new `HybridTerrainProvider` instance.
|
|
52
|
+
*/
|
|
53
|
+
constructor(options: HybridTerrainProvider.ConstructorOptions);
|
|
54
|
+
/**
|
|
55
|
+
* Gets a value indicating whether or not the provider is ready for use,
|
|
56
|
+
* or a promise that resolves when the provider becomes ready.
|
|
57
|
+
*/
|
|
58
|
+
get ready(): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Gets the tiling scheme used by this provider.
|
|
61
|
+
*/
|
|
62
|
+
get tilingScheme(): TilingScheme;
|
|
63
|
+
/**
|
|
64
|
+
* Gets an object that can be used to determine availability of terrain from this provider.
|
|
65
|
+
*/
|
|
66
|
+
get availability(): TileAvailability | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Gets the list of terrain regions managed by this provider.
|
|
69
|
+
*/
|
|
70
|
+
get regions(): readonly HybridTerrainProvider.TerrainRegion[];
|
|
71
|
+
/**
|
|
72
|
+
* Gets the default terrain provider.
|
|
73
|
+
*/
|
|
74
|
+
get defaultProvider(): TerrainProvider;
|
|
75
|
+
/**
|
|
76
|
+
* Gets the fallback terrain provider.
|
|
77
|
+
*/
|
|
78
|
+
get fallbackProvider(): TerrainProvider;
|
|
79
|
+
/**
|
|
80
|
+
* Gets the credit to display when this terrain provider is active. Typically this is used to credit
|
|
81
|
+
* the source of the terrain.
|
|
82
|
+
*/
|
|
83
|
+
get credit(): Credit;
|
|
84
|
+
/**
|
|
85
|
+
* Gets an event that is raised when the terrain provider encounters an asynchronous error. By subscribing
|
|
86
|
+
* to the event, you will be notified of the error and can potentially recover from it. Event listeners
|
|
87
|
+
* are passed an instance of `TileProviderError`.
|
|
88
|
+
*/
|
|
89
|
+
get errorEvent(): any;
|
|
90
|
+
/**
|
|
91
|
+
* Gets a value indicating whether or not the provider includes a water mask. The water mask
|
|
92
|
+
* indicates which areas of the globe are water rather than land, so they can be rendered
|
|
93
|
+
* as a reflective surface with animated waves.
|
|
94
|
+
*/
|
|
95
|
+
get hasWaterMask(): boolean;
|
|
96
|
+
/** Gets a value indicating whether or not the requested tiles include vertex normals. */
|
|
97
|
+
get hasVertexNormals(): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Makes sure we load availability data for a tile
|
|
100
|
+
* @param x - The X coordinate of the tile for which to request geometry.
|
|
101
|
+
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
102
|
+
* @param level - The level of the tile for which to request geometry.
|
|
103
|
+
* @returns Undefined if nothing need to be loaded or a Promise that resolves when all required tiles are loaded
|
|
104
|
+
*/
|
|
105
|
+
loadTileDataAvailability(x: number, y: number, level: number): Promise<void> | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Gets the maximum geometric error allowed in a tile at a given level.
|
|
108
|
+
* @param level - The tile level for which to get the maximum geometric error.
|
|
109
|
+
* @returns The maximum geometric error.
|
|
110
|
+
*/
|
|
111
|
+
getLevelMaximumGeometricError(level: number): number;
|
|
112
|
+
/**
|
|
113
|
+
* Requests the terrain for a given tile coordinate.
|
|
114
|
+
* @param x The X coordinate of the tile.
|
|
115
|
+
* @param y The Y coordinate of the tile.
|
|
116
|
+
* @param level The zoom level of the tile.
|
|
117
|
+
* @param request The request.
|
|
118
|
+
* @returns A promise for the requested terrain.
|
|
119
|
+
*/
|
|
120
|
+
requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<Awaited<TerrainData>> | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Determines whether data for a tile is available to be loaded. Checks the specified terrain regions first.
|
|
123
|
+
* @param x - The X coordinate of the tile for which to request geometry.
|
|
124
|
+
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
125
|
+
* @param level - The level of the tile for which to request geometry.
|
|
126
|
+
* @returns Undefined if not supported by the terrain provider, otherwise true or false.
|
|
127
|
+
*/
|
|
128
|
+
getTileDataAvailable(x: number, y: number, level: number): boolean | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Checks if a terrain region contains the specified tile.
|
|
131
|
+
* @private
|
|
132
|
+
*/
|
|
133
|
+
private _regionContains;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* @namespace
|
|
137
|
+
* Contains types and factory methods for `HybridTerrainProvider` instance.
|
|
138
|
+
*/
|
|
139
|
+
declare namespace HybridTerrainProvider {
|
|
140
|
+
/** Initialization options for `HybridTerrainProvider` constructor. */
|
|
141
|
+
interface ConstructorOptions {
|
|
142
|
+
/** An array of terrain regions to include in the hybrid terrain. */
|
|
143
|
+
regions?: TerrainRegion[];
|
|
144
|
+
/** Default provider to use outside of specified terrain regions. */
|
|
145
|
+
defaultProvider: TerrainProvider;
|
|
146
|
+
/** Optional fallback provider when data is not available from default provider. @default EllipsoidTerrainProvider */
|
|
147
|
+
fallbackProvider?: TerrainProvider;
|
|
148
|
+
}
|
|
149
|
+
/** Represents a terrain region with provider and geographic bounds. */
|
|
150
|
+
interface TerrainRegion {
|
|
151
|
+
/** The terrain provider for this region. */
|
|
152
|
+
provider: TerrainProvider;
|
|
153
|
+
/** Rectangle-based geographic bounds (simpler). */
|
|
154
|
+
bounds?: Rectangle;
|
|
155
|
+
/**
|
|
156
|
+
* Tile-coordinate based bounds (precise control).
|
|
157
|
+
* Map of level to tile coordinate ranges for that level.
|
|
158
|
+
*/
|
|
159
|
+
tiles?: Map<number, {
|
|
160
|
+
/** X tile coordinate range [min, max] or single value. */
|
|
161
|
+
x: number | [number, number];
|
|
162
|
+
/** Y tile coordinate range [min, max] or single value. */
|
|
163
|
+
y: number | [number, number];
|
|
164
|
+
}>;
|
|
165
|
+
/** Optional level constraints. If specified, region only applies to these levels. */
|
|
166
|
+
levels?: number[];
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Creates a HybridTerrainProvider from rectangle-based regions.
|
|
170
|
+
* @param regions Array of regions with rectangle bounds
|
|
171
|
+
* @param defaultProvider Default terrain provider
|
|
172
|
+
* @param fallbackProvider Optional fallback provider
|
|
173
|
+
*/
|
|
174
|
+
function fromRectangles(regions: Array<{
|
|
175
|
+
provider: TerrainProvider;
|
|
176
|
+
bounds: Rectangle;
|
|
177
|
+
levels?: number[];
|
|
178
|
+
}>, defaultProvider: TerrainProvider, fallbackProvider?: TerrainProvider): HybridTerrainProvider;
|
|
179
|
+
/**
|
|
180
|
+
* Creates a HybridTerrainProvider from tile-coordinate based regions.
|
|
181
|
+
* @param regions Array of regions with tile-coordinate bounds
|
|
182
|
+
* @param defaultProvider Default terrain provider
|
|
183
|
+
* @param fallbackProvider Optional fallback provider
|
|
184
|
+
*/
|
|
185
|
+
function fromTileRanges(regions: Array<{
|
|
186
|
+
provider: TerrainProvider;
|
|
187
|
+
tiles: Map<number, {
|
|
188
|
+
x: number | [number, number];
|
|
189
|
+
y: number | [number, number];
|
|
190
|
+
}>;
|
|
191
|
+
levels?: number[];
|
|
192
|
+
}>, defaultProvider: TerrainProvider, fallbackProvider?: TerrainProvider): HybridTerrainProvider;
|
|
193
|
+
/**
|
|
194
|
+
* @deprecated Use Rectangle.fromDegrees() instead. This method is maintained for backward compatibility.
|
|
195
|
+
* Calculates a bounding rectangle that encompasses all the specified tile ranges.
|
|
196
|
+
* @param tilingScheme The tiling scheme to use for calculation.
|
|
197
|
+
* @param from Tile ranges to calculate from.
|
|
198
|
+
*/
|
|
199
|
+
function computeRectangle(tilingScheme: TilingScheme, from: Map<number, any>): Rectangle;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export { HybridTerrainProvider as H };
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { TerrainProvider, TilingScheme, TileAvailability, Credit, Request, TerrainData, Rectangle } from 'cesium';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @class
|
|
5
|
+
* Provides terrain by delegating requests to different terrain providers
|
|
6
|
+
* based on geographic regions and zoom levels. This allows combining
|
|
7
|
+
* multiple terrain sources into a single seamless terrain.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ``` typescript
|
|
11
|
+
* // Simple rectangle-based regions
|
|
12
|
+
* const hybridTerrain = new HybridTerrainProvider({
|
|
13
|
+
* regions: [
|
|
14
|
+
* {
|
|
15
|
+
* provider: customProvider,
|
|
16
|
+
* bounds: Rectangle.fromDegrees(-120, 30, -100, 50),
|
|
17
|
+
* levels: [10, 15] // optional
|
|
18
|
+
* }
|
|
19
|
+
* ],
|
|
20
|
+
* defaultProvider: worldTerrain
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Or tile-coordinate based for precise control (multiple levels)
|
|
24
|
+
* const tileRanges = new Map();
|
|
25
|
+
* tileRanges.set(15, { x: [55852, 55871], y: [9556, 9575] });
|
|
26
|
+
* tileRanges.set(16, { x: [111704, 111742], y: [19112, 19150] });
|
|
27
|
+
*
|
|
28
|
+
* const hybridTerrain = new HybridTerrainProvider({
|
|
29
|
+
* regions: [
|
|
30
|
+
* {
|
|
31
|
+
* provider: customProvider,
|
|
32
|
+
* tiles: tileRanges
|
|
33
|
+
* }
|
|
34
|
+
* ],
|
|
35
|
+
* defaultProvider: worldTerrain
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* viewer.terrainProvider = hybridTerrain;
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare class HybridTerrainProvider implements TerrainProvider {
|
|
42
|
+
private _regions;
|
|
43
|
+
private _defaultProvider;
|
|
44
|
+
private _fallbackProvider;
|
|
45
|
+
private _tilingScheme;
|
|
46
|
+
private _ready;
|
|
47
|
+
private _availability?;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new `HybridTerrainProvider` instance.
|
|
50
|
+
* @param options {@link HybridTerrainProvider.ConstructorOptions}
|
|
51
|
+
* @returns A new `HybridTerrainProvider` instance.
|
|
52
|
+
*/
|
|
53
|
+
constructor(options: HybridTerrainProvider.ConstructorOptions);
|
|
54
|
+
/**
|
|
55
|
+
* Gets a value indicating whether or not the provider is ready for use,
|
|
56
|
+
* or a promise that resolves when the provider becomes ready.
|
|
57
|
+
*/
|
|
58
|
+
get ready(): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Gets the tiling scheme used by this provider.
|
|
61
|
+
*/
|
|
62
|
+
get tilingScheme(): TilingScheme;
|
|
63
|
+
/**
|
|
64
|
+
* Gets an object that can be used to determine availability of terrain from this provider.
|
|
65
|
+
*/
|
|
66
|
+
get availability(): TileAvailability | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Gets the list of terrain regions managed by this provider.
|
|
69
|
+
*/
|
|
70
|
+
get regions(): readonly HybridTerrainProvider.TerrainRegion[];
|
|
71
|
+
/**
|
|
72
|
+
* Gets the default terrain provider.
|
|
73
|
+
*/
|
|
74
|
+
get defaultProvider(): TerrainProvider;
|
|
75
|
+
/**
|
|
76
|
+
* Gets the fallback terrain provider.
|
|
77
|
+
*/
|
|
78
|
+
get fallbackProvider(): TerrainProvider;
|
|
79
|
+
/**
|
|
80
|
+
* Gets the credit to display when this terrain provider is active. Typically this is used to credit
|
|
81
|
+
* the source of the terrain.
|
|
82
|
+
*/
|
|
83
|
+
get credit(): Credit;
|
|
84
|
+
/**
|
|
85
|
+
* Gets an event that is raised when the terrain provider encounters an asynchronous error. By subscribing
|
|
86
|
+
* to the event, you will be notified of the error and can potentially recover from it. Event listeners
|
|
87
|
+
* are passed an instance of `TileProviderError`.
|
|
88
|
+
*/
|
|
89
|
+
get errorEvent(): any;
|
|
90
|
+
/**
|
|
91
|
+
* Gets a value indicating whether or not the provider includes a water mask. The water mask
|
|
92
|
+
* indicates which areas of the globe are water rather than land, so they can be rendered
|
|
93
|
+
* as a reflective surface with animated waves.
|
|
94
|
+
*/
|
|
95
|
+
get hasWaterMask(): boolean;
|
|
96
|
+
/** Gets a value indicating whether or not the requested tiles include vertex normals. */
|
|
97
|
+
get hasVertexNormals(): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Makes sure we load availability data for a tile
|
|
100
|
+
* @param x - The X coordinate of the tile for which to request geometry.
|
|
101
|
+
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
102
|
+
* @param level - The level of the tile for which to request geometry.
|
|
103
|
+
* @returns Undefined if nothing need to be loaded or a Promise that resolves when all required tiles are loaded
|
|
104
|
+
*/
|
|
105
|
+
loadTileDataAvailability(x: number, y: number, level: number): Promise<void> | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Gets the maximum geometric error allowed in a tile at a given level.
|
|
108
|
+
* @param level - The tile level for which to get the maximum geometric error.
|
|
109
|
+
* @returns The maximum geometric error.
|
|
110
|
+
*/
|
|
111
|
+
getLevelMaximumGeometricError(level: number): number;
|
|
112
|
+
/**
|
|
113
|
+
* Requests the terrain for a given tile coordinate.
|
|
114
|
+
* @param x The X coordinate of the tile.
|
|
115
|
+
* @param y The Y coordinate of the tile.
|
|
116
|
+
* @param level The zoom level of the tile.
|
|
117
|
+
* @param request The request.
|
|
118
|
+
* @returns A promise for the requested terrain.
|
|
119
|
+
*/
|
|
120
|
+
requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<Awaited<TerrainData>> | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Determines whether data for a tile is available to be loaded. Checks the specified terrain regions first.
|
|
123
|
+
* @param x - The X coordinate of the tile for which to request geometry.
|
|
124
|
+
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
125
|
+
* @param level - The level of the tile for which to request geometry.
|
|
126
|
+
* @returns Undefined if not supported by the terrain provider, otherwise true or false.
|
|
127
|
+
*/
|
|
128
|
+
getTileDataAvailable(x: number, y: number, level: number): boolean | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Checks if a terrain region contains the specified tile.
|
|
131
|
+
* @private
|
|
132
|
+
*/
|
|
133
|
+
private _regionContains;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* @namespace
|
|
137
|
+
* Contains types and factory methods for `HybridTerrainProvider` instance.
|
|
138
|
+
*/
|
|
139
|
+
declare namespace HybridTerrainProvider {
|
|
140
|
+
/** Initialization options for `HybridTerrainProvider` constructor. */
|
|
141
|
+
interface ConstructorOptions {
|
|
142
|
+
/** An array of terrain regions to include in the hybrid terrain. */
|
|
143
|
+
regions?: TerrainRegion[];
|
|
144
|
+
/** Default provider to use outside of specified terrain regions. */
|
|
145
|
+
defaultProvider: TerrainProvider;
|
|
146
|
+
/** Optional fallback provider when data is not available from default provider. @default EllipsoidTerrainProvider */
|
|
147
|
+
fallbackProvider?: TerrainProvider;
|
|
148
|
+
}
|
|
149
|
+
/** Represents a terrain region with provider and geographic bounds. */
|
|
150
|
+
interface TerrainRegion {
|
|
151
|
+
/** The terrain provider for this region. */
|
|
152
|
+
provider: TerrainProvider;
|
|
153
|
+
/** Rectangle-based geographic bounds (simpler). */
|
|
154
|
+
bounds?: Rectangle;
|
|
155
|
+
/**
|
|
156
|
+
* Tile-coordinate based bounds (precise control).
|
|
157
|
+
* Map of level to tile coordinate ranges for that level.
|
|
158
|
+
*/
|
|
159
|
+
tiles?: Map<number, {
|
|
160
|
+
/** X tile coordinate range [min, max] or single value. */
|
|
161
|
+
x: number | [number, number];
|
|
162
|
+
/** Y tile coordinate range [min, max] or single value. */
|
|
163
|
+
y: number | [number, number];
|
|
164
|
+
}>;
|
|
165
|
+
/** Optional level constraints. If specified, region only applies to these levels. */
|
|
166
|
+
levels?: number[];
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Creates a HybridTerrainProvider from rectangle-based regions.
|
|
170
|
+
* @param regions Array of regions with rectangle bounds
|
|
171
|
+
* @param defaultProvider Default terrain provider
|
|
172
|
+
* @param fallbackProvider Optional fallback provider
|
|
173
|
+
*/
|
|
174
|
+
function fromRectangles(regions: Array<{
|
|
175
|
+
provider: TerrainProvider;
|
|
176
|
+
bounds: Rectangle;
|
|
177
|
+
levels?: number[];
|
|
178
|
+
}>, defaultProvider: TerrainProvider, fallbackProvider?: TerrainProvider): HybridTerrainProvider;
|
|
179
|
+
/**
|
|
180
|
+
* Creates a HybridTerrainProvider from tile-coordinate based regions.
|
|
181
|
+
* @param regions Array of regions with tile-coordinate bounds
|
|
182
|
+
* @param defaultProvider Default terrain provider
|
|
183
|
+
* @param fallbackProvider Optional fallback provider
|
|
184
|
+
*/
|
|
185
|
+
function fromTileRanges(regions: Array<{
|
|
186
|
+
provider: TerrainProvider;
|
|
187
|
+
tiles: Map<number, {
|
|
188
|
+
x: number | [number, number];
|
|
189
|
+
y: number | [number, number];
|
|
190
|
+
}>;
|
|
191
|
+
levels?: number[];
|
|
192
|
+
}>, defaultProvider: TerrainProvider, fallbackProvider?: TerrainProvider): HybridTerrainProvider;
|
|
193
|
+
/**
|
|
194
|
+
* @deprecated Use Rectangle.fromDegrees() instead. This method is maintained for backward compatibility.
|
|
195
|
+
* Calculates a bounding rectangle that encompasses all the specified tile ranges.
|
|
196
|
+
* @param tilingScheme The tiling scheme to use for calculation.
|
|
197
|
+
* @param from Tile ranges to calculate from.
|
|
198
|
+
*/
|
|
199
|
+
function computeRectangle(tilingScheme: TilingScheme, from: Map<number, any>): Rectangle;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export { HybridTerrainProvider as H };
|
|
@@ -106,7 +106,7 @@ type NonFunction<T> = {
|
|
|
106
106
|
* }
|
|
107
107
|
* }
|
|
108
108
|
*/
|
|
109
|
-
declare class Collection<C extends Collection.Base, I extends Collection.
|
|
109
|
+
declare class Collection<C extends Collection.Base, I extends Collection.ItemFor<C>> {
|
|
110
110
|
/**
|
|
111
111
|
* Symbol used as a property key to store tags on collection items.
|
|
112
112
|
* Using a Symbol ensures no property naming conflicts with the item's own properties.
|
|
@@ -499,6 +499,10 @@ declare namespace Collection {
|
|
|
499
499
|
* Cesium item type that can be added to the {@link Collection.Base} instance.
|
|
500
500
|
*/
|
|
501
501
|
export type Item = DataSource | Entity | ImageryLayer | Primitives;
|
|
502
|
+
/**
|
|
503
|
+
* Gets the item type for a given collection type
|
|
504
|
+
*/
|
|
505
|
+
export type ItemFor<C extends Base> = C extends DataSourceCollection ? DataSource : C extends EntityCollection ? Entity : C extends ImageryLayerCollection ? ImageryLayer : C extends PrimitiveCollection ? Primitives : never;
|
|
502
506
|
/**
|
|
503
507
|
* Collection tag type.
|
|
504
508
|
*/
|
|
@@ -106,7 +106,7 @@ type NonFunction<T> = {
|
|
|
106
106
|
* }
|
|
107
107
|
* }
|
|
108
108
|
*/
|
|
109
|
-
declare class Collection<C extends Collection.Base, I extends Collection.
|
|
109
|
+
declare class Collection<C extends Collection.Base, I extends Collection.ItemFor<C>> {
|
|
110
110
|
/**
|
|
111
111
|
* Symbol used as a property key to store tags on collection items.
|
|
112
112
|
* Using a Symbol ensures no property naming conflicts with the item's own properties.
|
|
@@ -499,6 +499,10 @@ declare namespace Collection {
|
|
|
499
499
|
* Cesium item type that can be added to the {@link Collection.Base} instance.
|
|
500
500
|
*/
|
|
501
501
|
export type Item = DataSource | Entity | ImageryLayer | Primitives;
|
|
502
|
+
/**
|
|
503
|
+
* Gets the item type for a given collection type
|
|
504
|
+
*/
|
|
505
|
+
export type ItemFor<C extends Base> = C extends DataSourceCollection ? DataSource : C extends EntityCollection ? Entity : C extends ImageryLayerCollection ? ImageryLayer : C extends PrimitiveCollection ? Primitives : never;
|
|
502
506
|
/**
|
|
503
507
|
* Collection tag type.
|
|
504
508
|
*/
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var V=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var $=(n,e)=>{for(var t in e)V(n,t,{get:e[t],enumerable:!0})},K=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of U(e))!X.call(n,r)&&r!==t&&V(n,r,{get:()=>e[r],enumerable:!(i=W(e,r))||i.enumerable});return n};var J=n=>K(V({},"__esModule",{value:!0}),n);var Q={};$(Q,{Collection:()=>T,Highlight:()=>k,HybridTerrainProvider:()=>w,SilhouetteHighlight:()=>f,SurfaceHighlight:()=>p,TerrainArea:()=>P,TerrainVisualizer:()=>_,cloneViewer:()=>N,isGetterOnly:()=>C,syncCamera:()=>R});module.exports=J(Q);var g=require("cesium");var c=require("cesium");var _=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",c.Color.RED],["default",c.Color.BLUE],["fallback",c.Color.GRAY],["grid",c.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new T({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(n.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new c.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:c.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(s=>{this._collection.add(s.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(c.Rectangle.northwest(e),t),o=i.positionToTileXY(c.Rectangle.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],s=Math.min(e.end.x-e.start.x+1,100),l=Math.min(e.end.y-e.start.y+1,100);for(let d=e.start.x;d<e.start.x+s;d++)for(let m=e.start.y;m<e.start.y+l;m++)try{let v=this._createTileEntity(d,m,t,i);v&&r.push({entity:v})}catch(v){console.warn(`Error creating tile (${d}, ${m}, ${t}):`,v)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let s=this._getTileColor(e,t,i),l=n.createRectangle(o,s.withAlpha(.3));return l.properties?.addProperty("tileX",e),l.properties?.addProperty("tileY",t),l.properties?.addProperty("tileLevel",i),l}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||c.Color.TRANSPARENT;for(let r of this._terrainProvider.terrainAreas)if(r.contains(e,t,i))return r.isCustom?this._colors.get("custom")||c.Color.RED:this._colors.get("default")||c.Color.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||c.Color.BLUE:this._colors.get("fallback")||c.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new c.Entity({rectangle:{coordinates:r,material:o,heightReference:c.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,s){let l=s?.tag||"terrain_area_visualization",d=s?.color||c.Color.RED,m=s?.maxTilesToShow||100,v=s?.show??!0,O=s?.alpha||.7,x=s?.tileAlpha||.2,y=new T({collection:o.entities,tag:l}),{rectangle:S}=r;if(y.add(i.createRectangle(S,d.withAlpha(O)),l),v&&r.tileRanges.size>0){let{tilingScheme:q}=r.terrainProvider,I=0;r.tileRanges.forEach((L,z)=>{for(let M=L.start.x;M<=L.end.x&&I<m;M++)for(let H=L.start.y;H<=L.end.y&&I<m;H++){let Y=q.tileXYToRectangle(M,H,z);y.add(e(Y,d.withAlpha(x)),`${l}_tile`),I++}})}return y}i.visualize=t})(_||={});function C(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var G=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof g.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof g.PrimitiveCollection?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof g.DataSourceCollection?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof g.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof g.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,g.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,g.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,g.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r)if(e in o&&typeof o[e]!="function"){if(C(o,e))throw Error(`Cannot set read-only property '${String(e)}' on ${o.constructor.name}`);o[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,o)=>e(r,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},T=G;var u=require("cesium");var h=require("cesium"),f=class{_color=h.Color.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=h.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=h.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}show(e,t){if((0,h.defined)(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{if(e instanceof h.Cesium3DTileFeature)this._silhouette.uniforms.color=t?.color||this._color,this._silhouette.selected.push(e);else{if(!e.model)return;this._entity=e,e.model.silhouetteSize=new h.ConstantProperty(t?.width||2),e.model.silhouetteColor=new h.ConstantProperty(t?.color||this._color)}this._currentObject=e,this._currentOptions=t?{...t}:void 0}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0}}}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&h.Color.equals(e.color||this._color,t.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new h.ConstantProperty(h.Color.TRANSPARENT),this._entity.model.silhouetteSize=new h.ConstantProperty(0),this._entity=void 0)}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}};var a=require("cesium"),p=class{_color=a.Color.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new a.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}show(e,t){if(!(!(0,a.defined)(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof a.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof a.GroundPrimitive)this._update(e,t);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=e,this._currentOptions=t?{...t}:void 0,this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0;return}}}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&a.Color.equals(e.color||this._color,t.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof a.Entity){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let r;i.positions.length>0&&!a.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new a.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new a.PolygonGraphics({hierarchy:i,material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||a.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let r=e.polyline.width?.getValue();this._entity.polyline=new a.PolylineGraphics({positions:i,material:t.color,width:r+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let r=[a.Cartesian3.fromRadians(i.west,i.north),a.Cartesian3.fromRadians(i.east,i.north),a.Cartesian3.fromRadians(i.east,i.south),a.Cartesian3.fromRadians(i.west,i.south),a.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new a.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new a.RectangleGraphics({coordinates:i,material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND}))}}else if(e instanceof a.GroundPrimitive){let i=e.geometryInstances,r=Array.isArray(i)?i[0]:i;if(!r.geometry.attributes.position)return;let o=r.geometry.attributes.position.values,s=[];for(let l=0;l<o.length;l+=3)s.push(new a.Cartesian3(o[l],o[l+1],o[l+2]));t.outline?this._entity.polyline=new a.PolylineGraphics({positions:s,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new a.PolygonGraphics({hierarchy:new a.PolygonHierarchy(s),material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND,classificationType:a.ClassificationType.BOTH})}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}};var D=class n{static instances=new WeakMap;_surface;_silhouette;_color=u.Color.RED;constructor(e){this._surface=new p(e),this._silhouette=new f(e),this._surface.color=this._color,this._silhouette.color=this._color}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,i=n.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),n.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if((0,u.defined)(i))return i instanceof u.Cesium3DTileFeature?this._silhouette.show(i,t):i instanceof u.Entity&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if((0,u.defined)(e)){if(e instanceof u.Entity||e instanceof u.Cesium3DTileFeature||e instanceof u.GroundPrimitive)return e;if(e.id instanceof u.Entity)return e.id;if(e.primitive instanceof u.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}},k=D;var E=require("cesium");var B=require("cesium");var b=class{_terrainProvider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(e){this._terrainProvider=e.terrainProvider,this._tileRanges=e.tileRanges,this._credit=e.credit||"custom",this._isCustom=e.isCustom!==void 0?e.isCustom:!0,this._rectangle=w.computeRectangle(e.terrainProvider.tilingScheme,e.tileRanges),e.tileRanges.forEach((t,i)=>{this._terrainProvider.availability?.addAvailableTileRange(i,t.start.x,t.start.y,t.end.x,t.end.y)}),this._ready=!0}contains(e,t,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let r=this._tileRanges.get(i);return e>=r.start.x&&e<=r.end.x&&t>=r.start.y&&t<=r.end.y}requestTileGeometry(e,t,i,r){if(!(!this._ready||!this.contains(e,t,i)))return this._terrainProvider.requestTileGeometry(e,t,i,r)}getTileDataAvailable(e,t,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let r=this._tileRanges.get(i);return e>=r.start.x&&e<=r.end.x&&t>=r.start.y&&t<=r.end.y}get isCustom(){return this._isCustom}get credit(){return this._credit}get terrainProvider(){return this._terrainProvider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(t=>{async function n(i,r,o){let s=o?.credit||"custom",l=await B.CesiumTerrainProvider.fromUrl(i,{...o,credit:s});return new t({terrainProvider:l,tileRanges:r,credit:s})}t.fromUrl=n;class e extends Array{add(r){if(Array.isArray(r)){for(let s of r)this.add(s);return this}let o;return r instanceof t?o=r:o=new t(r),this.push(o),this}remove(r){if(Array.isArray(r))return r.forEach(s=>this.remove(s)),this;let o=this.indexOf(r);return o>=0&&this.splice(o,1),this}removeAll(){this.length=0}}t.Collection=e})(b||={});var P=b;var A=class{_terrainAreas;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._terrainProvider=e.terrainProvider,this._fallbackProvider=e.fallbackProvider||new E.EllipsoidTerrainProvider,this._tilingScheme=e.terrainProvider.tilingScheme,this._terrainAreas=new P.Collection(...e.terrainAreas),this._availability=e.terrainProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get terrainAreas(){return[...this._terrainAreas]}get defaultProvider(){return this._terrainProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._terrainProvider?.credit}get errorEvent(){return this._terrainProvider.errorEvent}get hasWaterMask(){return this._terrainProvider.hasWaterMask}get hasVertexNormals(){return this._terrainProvider.hasVertexNormals}loadTileDataAvailability(e,t,i){return this._terrainProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){return this._terrainProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,i,r){if(this._ready){for(let o of this._terrainAreas)if(o.contains(e,t,i))return o.requestTileGeometry(e,t,i,r);return this._terrainProvider.getTileDataAvailable(e,t,i)?this._terrainProvider.requestTileGeometry(e,t,i,r):this._fallbackProvider.requestTileGeometry(e,t,i,r)}}getTileDataAvailable(e,t,i){for(let r of this._terrainAreas)if(r.contains(e,t,i))return r.getTileDataAvailable(e,t,i);return this._terrainProvider.getTileDataAvailable(e,t,i)}};(e=>{function n(t,i){if(i.size===0)return new E.Rectangle;let r=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,d=Array.from(i.keys()),m=Math.min(...d),v=i.get(m);if(v){let{start:O,end:x}=v,y=t.tileXYToRectangle(O.x,O.y,m),S=t.tileXYToRectangle(x.x,x.y,m);r=Math.min(y.west,r),o=Math.min(S.south,o),s=Math.max(S.east,s),l=Math.max(y.north,l)}return new E.Rectangle(r,o,s,l)}e.computeRectangle=n})(A||={});var w=A;var j=require("cesium");var F=require("cesium");function R(n,e){if((0,F.defined)(n)&&(0,F.defined)(e)){let{camera:t}=n;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}function N(n,e,t){let i={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},r=new j.Viewer(e,{...i,...t});R(n,r);let o=n.imageryLayers;r.imageryLayers.removeAll();for(let d=0;d<o.length;d++){let m=o.get(d);r.imageryLayers.addImageryProvider(m.imageryProvider,d)}r.clock.startTime=n.clock.startTime.clone(),r.clock.stopTime=n.clock.stopTime.clone(),r.clock.currentTime=n.clock.currentTime.clone(),r.clock.multiplier=n.clock.multiplier,r.clock.clockStep=n.clock.clockStep,r.clock.clockRange=n.clock.clockRange,r.clock.shouldAnimate=n.clock.shouldAnimate,r.scene.globe.enableLighting=n.scene.globe.enableLighting,r.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,r.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let s=n.scene.screenSpaceCameraController.tiltEventTypes;s&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(s)?[...s]:s);let l=n.scene.screenSpaceCameraController.zoomEventTypes;return l&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(l)?[...l]:l),r}
|
|
1
|
+
"use strict";var L=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var X=(n,e)=>{for(var t in e)L(n,t,{get:e[t],enumerable:!0})},K=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of $(e))!U.call(n,r)&&r!==t&&L(n,r,{get:()=>e[r],enumerable:!(i=q(e,r))||i.enumerable});return n};var J=n=>K(L({},"__esModule",{value:!0}),n);var Q={};X(Q,{Collection:()=>w,Highlight:()=>V,HybridTerrainProvider:()=>G,SilhouetteHighlight:()=>T,SurfaceHighlight:()=>b,cloneViewer:()=>F,syncCamera:()=>R});module.exports=J(Q);var g=require("cesium");var j;(l=>{let n=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(c,d={}){if(!e)return;let{once:v=!0,prefix:p="[DEPRECATED]",includeStack:_=!0,removeInVersion:y}=d;if(v&&n.has(c))return;let C=`${p} ${c}`;y&&(C+=` This feature will be removed in ${y}.`),typeof console<"u"&&console.warn&&(_?(console.warn(C),console.trace("Deprecation stack trace:")):console.warn(C)),v&&n.add(c)}l.warn=t;function i(c,d,v={}){let p=(..._)=>(t(d,v),c(..._));return Object.defineProperty(p,"name",{value:c.name,configurable:!0}),p}l.deprecate=i;function r(){n.clear()}l.clear=r;function o(){return n.size}l.getWarningCount=o;function s(c){return n.has(c)}l.hasShown=s})(j||={});var S=j;var h=require("cesium");var O=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",h.Color.RED],["default",h.Color.BLUE],["fallback",h.Color.GRAY],["grid",h.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new w({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(n.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new h.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:h.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(s=>{this._collection.add(s.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(h.Rectangle.northwest(e),t),o=i.positionToTileXY(h.Rectangle.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],s=Math.min(e.end.x-e.start.x+1,100),l=Math.min(e.end.y-e.start.y+1,100);for(let c=e.start.x;c<e.start.x+s;c++)for(let d=e.start.y;d<e.start.y+l;d++)try{let v=this._createTileEntity(c,d,t,i);v&&r.push({entity:v})}catch(v){console.warn(`Error creating tile (${c}, ${d}, ${t}):`,v)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let s=this._getTileColor(e,t,i),l=n.createRectangle(o,s.withAlpha(.3));return l.properties?.addProperty("tileX",e),l.properties?.addProperty("tileY",t),l.properties?.addProperty("tileLevel",i),l}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||h.Color.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||h.Color.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||h.Color.BLUE:this._colors.get("fallback")||h.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){this._viewer.camera.flyTo({destination:e,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new h.Entity({rectangle:{coordinates:r,material:o,heightReference:h.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,s){let l=s?.tag||"terrain_region_visualization",c=s?.color||h.Color.RED,d=s?.maxTilesToShow||100,v=s?.show??!0,p=s?.alpha||.7,_=s?.tileAlpha||.2,y=new w({collection:o.entities,tag:l});if(r.bounds&&y.add(i.createRectangle(r.bounds,c.withAlpha(p)),l),v&&r.tiles&&r.tiles.size>0){let C=r.provider.tilingScheme,P=0;r.tiles.forEach((f,W)=>{let N=Array.isArray(f.x)?f.x:[f.x,f.x],B=Array.isArray(f.y)?f.y:[f.y,f.y];for(let I=N[0];I<=N[1]&&P<d;I++)for(let A=B[0];A<=B[1]&&P<d;A++){let Y=C.tileXYToRectangle(I,A,W);y.add(e(Y,c.withAlpha(_)),`${l}_tile`),P++}})}return y}i.visualize=t})(O||={});function H(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var de=S.deprecate;var M=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof g.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof g.PrimitiveCollection?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof g.DataSourceCollection?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof g.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof g.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,g.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,g.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,g.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r)if(e in o&&typeof o[e]!="function"){if(H(o,e))throw Error(`Cannot set read-only property '${String(e)}' on ${o.constructor.name}`);o[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,o)=>e(r,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},w=M;var m=require("cesium");var u=require("cesium"),T=class{_color=u.Color.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=u.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=u.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}show(e,t){if((0,u.defined)(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{if(e instanceof u.Cesium3DTileFeature)this._silhouette.uniforms.color=t?.color||this._color,this._silhouette.selected.push(e);else{if(!e.model)return;this._entity=e,e.model.silhouetteSize=new u.ConstantProperty(t?.width||2),e.model.silhouetteColor=new u.ConstantProperty(t?.color||this._color)}this._currentObject=e,this._currentOptions=t?{...t}:void 0}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0}}}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&u.Color.equals(e.color||this._color,t.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new u.ConstantProperty(u.Color.TRANSPARENT),this._entity.model.silhouetteSize=new u.ConstantProperty(0),this._entity=void 0)}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}};var a=require("cesium"),b=class{_color=a.Color.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new a.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}show(e,t){if(!(!(0,a.defined)(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof a.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof a.GroundPrimitive)this._update(e,t);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=e,this._currentOptions=t?{...t}:void 0,this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0;return}}}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&a.Color.equals(e.color||this._color,t.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof a.Entity){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let r;i.positions.length>0&&!a.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new a.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new a.PolygonGraphics({hierarchy:i,material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||a.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let r=e.polyline.width?.getValue();this._entity.polyline=new a.PolylineGraphics({positions:i,material:t.color,width:r+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let r=[a.Cartesian3.fromRadians(i.west,i.north),a.Cartesian3.fromRadians(i.east,i.north),a.Cartesian3.fromRadians(i.east,i.south),a.Cartesian3.fromRadians(i.west,i.south),a.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new a.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new a.RectangleGraphics({coordinates:i,material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND}))}}else if(e instanceof a.GroundPrimitive){let i=e.geometryInstances,r=Array.isArray(i)?i[0]:i;if(!r.geometry.attributes.position)return;let o=r.geometry.attributes.position.values,s=[];for(let l=0;l<o.length;l+=3)s.push(new a.Cartesian3(o[l],o[l+1],o[l+2]));t.outline?this._entity.polyline=new a.PolylineGraphics({positions:s,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new a.PolygonGraphics({hierarchy:new a.PolygonHierarchy(s),material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND,classificationType:a.ClassificationType.BOTH})}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}};var D=class n{static instances=new WeakMap;_surface;_silhouette;_color=m.Color.RED;constructor(e){this._surface=new b(e),this._silhouette=new T(e),this._surface.color=this._color,this._silhouette.color=this._color}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,i=n.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),n.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if((0,m.defined)(i))return i instanceof m.Cesium3DTileFeature?this._silhouette.show(i,t):i instanceof m.Entity&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if((0,m.defined)(e)){if(e instanceof m.Entity||e instanceof m.Cesium3DTileFeature||e instanceof m.GroundPrimitive)return e;if(e.id instanceof m.Entity)return e.id;if(e.primitive instanceof m.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}},V=D;var E=require("cesium");var x=class{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new E.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,t,i){return this._defaultProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,i,r){if(this._ready){for(let o of this._regions)if(this._regionContains(o,e,t,i))return o.provider.requestTileGeometry(e,t,i,r);return this._defaultProvider.getTileDataAvailable(e,t,i)?this._defaultProvider.requestTileGeometry(e,t,i,r):this._fallbackProvider.requestTileGeometry(e,t,i,r)}}getTileDataAvailable(e,t,i){for(let r of this._regions)if(this._regionContains(r,e,t,i))return r.provider.getTileDataAvailable(e,t,i);return this._defaultProvider.getTileDataAvailable(e,t,i)}_regionContains(e,t,i,r){if(e.levels&&!e.levels.includes(r))return!1;if(e.tiles){let o=e.tiles.get(r);if(!o)return!1;let[s,l]=Array.isArray(o.x)?o.x:[o.x,o.x],[c,d]=Array.isArray(o.y)?o.y:[o.y,o.y];return t>=s&&t<=l&&i>=c&&i<=d}if(e.bounds){let o=this._tilingScheme.tileXYToRectangle(t,i,r);return E.Rectangle.intersection(o,e.bounds)!==void 0}return!1}};(i=>{function n(r,o,s){return new i({regions:r.map(l=>({...l})),defaultProvider:o,fallbackProvider:s})}i.fromRectangles=n;function e(r,o,s){return new i({regions:r.map(l=>({...l})),defaultProvider:o,fallbackProvider:s})}i.fromTileRanges=e;function t(r,o){if(S.warn("computeRectangle() is deprecated. Use Rectangle.fromDegrees() instead.",{removeInVersion:"v0.3.0"}),o.size===0)return new E.Rectangle;let s=Number.POSITIVE_INFINITY,l=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,d=Number.NEGATIVE_INFINITY,v=Array.from(o.keys()),p=Math.min(...v),_=o.get(p);if(_){let{start:y,end:C}=_,P=r.tileXYToRectangle(y.x,y.y,p),f=r.tileXYToRectangle(C.x,C.y,p);s=Math.min(P.west,s),l=Math.min(f.south,l),c=Math.max(f.east,c),d=Math.max(P.north,d)}return new E.Rectangle(s,l,c,d)}i.computeRectangle=t})(x||={});var G=x;var z=require("cesium");var k=require("cesium");function R(n,e){if((0,k.defined)(n)&&(0,k.defined)(e)){let{camera:t}=n;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}function F(n,e,t){let i={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},r=new z.Viewer(e,{...i,...t});R(n,r);let o=n.imageryLayers;r.imageryLayers.removeAll();for(let c=0;c<o.length;c++){let d=o.get(c);r.imageryLayers.addImageryProvider(d.imageryProvider,c)}r.clock.startTime=n.clock.startTime.clone(),r.clock.stopTime=n.clock.stopTime.clone(),r.clock.currentTime=n.clock.currentTime.clone(),r.clock.multiplier=n.clock.multiplier,r.clock.clockStep=n.clock.clockStep,r.clock.clockRange=n.clock.clockRange,r.clock.shouldAnimate=n.clock.shouldAnimate,r.scene.globe.enableLighting=n.scene.globe.enableLighting,r.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,r.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let s=n.scene.screenSpaceCameraController.tiltEventTypes;s&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(s)?[...s]:s);let l=n.scene.screenSpaceCameraController.zoomEventTypes;return l&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(l)?[...l]:l),r}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { C as Collection
|
|
1
|
+
export { C as Collection } from './index-C7kPHG5S.cjs';
|
|
2
2
|
export { Highlight, SilhouetteHighlight, SurfaceHighlight } from './highlight/index.cjs';
|
|
3
|
-
export { HybridTerrainProvider
|
|
4
|
-
export { TerrainVisualizer } from './utils/index.cjs';
|
|
3
|
+
export { H as HybridTerrainProvider } from './hybrid-terrain-provider-C2V-igd9.cjs';
|
|
5
4
|
export { cloneViewer, syncCamera } from './viewer/index.cjs';
|
|
6
5
|
import 'cesium';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { C as Collection
|
|
1
|
+
export { C as Collection } from './index-C7kPHG5S.js';
|
|
2
2
|
export { Highlight, SilhouetteHighlight, SurfaceHighlight } from './highlight/index.js';
|
|
3
|
-
export { HybridTerrainProvider
|
|
4
|
-
export { TerrainVisualizer } from './utils/index.js';
|
|
3
|
+
export { H as HybridTerrainProvider } from './hybrid-terrain-provider-C2V-igd9.js';
|
|
5
4
|
export { cloneViewer, syncCamera } from './viewer/index.js';
|
|
6
5
|
import 'cesium';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-RXMNSDKR.js";import{
|
|
1
|
+
import"./chunk-RXMNSDKR.js";import{d as r}from"./chunk-N24M6GYI.js";import{a as i,b as o,c as e}from"./chunk-RZ3PTU3G.js";import{a as t}from"./chunk-DGHCIGKJ.js";import"./chunk-TUJQL7MC.js";import{a as m,b as h}from"./chunk-Z2COOTT4.js";export{r as Collection,e as Highlight,t as HybridTerrainProvider,i as SilhouetteHighlight,o as SurfaceHighlight,h as cloneViewer,m as syncCamera};
|
package/dist/terrain/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var g=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var A=(a,e)=>{for(var i in e)g(a,i,{get:e[i],enumerable:!0})},w=(a,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of R(e))!I.call(a,r)&&r!==i&&g(a,r,{get:()=>e[r],enumerable:!(n=x(e,r))||n.enumerable});return a};var E=a=>w(g({},"__esModule",{value:!0}),a);var N={};A(N,{HybridTerrainProvider:()=>_});module.exports=E(N);var b=require("cesium");var P;(l=>{let a=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function i(o,u={}){if(!e)return;let{once:c=!0,prefix:d="[DEPRECATED]",includeStack:m=!0,removeInVersion:f}=u;if(c&&a.has(o))return;let v=`${d} ${o}`;f&&(v+=` This feature will be removed in ${f}.`),typeof console<"u"&&console.warn&&(m?(console.warn(v),console.trace("Deprecation stack trace:")):console.warn(v)),c&&a.add(o)}l.warn=i;function n(o,u,c={}){let d=(...m)=>(i(u,c),o(...m));return Object.defineProperty(d,"name",{value:o.name,configurable:!0}),d}l.deprecate=n;function r(){a.clear()}l.clear=r;function t(){return a.size}l.getWarningCount=t;function s(o){return a.has(o)}l.hasShown=s})(P||={});var y=P;var T=class{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new b.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,i,n){return this._defaultProvider.loadTileDataAvailability(e,i,n)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,i,n,r){if(this._ready){for(let t of this._regions)if(this._regionContains(t,e,i,n))return t.provider.requestTileGeometry(e,i,n,r);return this._defaultProvider.getTileDataAvailable(e,i,n)?this._defaultProvider.requestTileGeometry(e,i,n,r):this._fallbackProvider.requestTileGeometry(e,i,n,r)}}getTileDataAvailable(e,i,n){for(let r of this._regions)if(this._regionContains(r,e,i,n))return r.provider.getTileDataAvailable(e,i,n);return this._defaultProvider.getTileDataAvailable(e,i,n)}_regionContains(e,i,n,r){if(e.levels&&!e.levels.includes(r))return!1;if(e.tiles){let t=e.tiles.get(r);if(!t)return!1;let[s,l]=Array.isArray(t.x)?t.x:[t.x,t.x],[o,u]=Array.isArray(t.y)?t.y:[t.y,t.y];return i>=s&&i<=l&&n>=o&&n<=u}if(e.bounds){let t=this._tilingScheme.tileXYToRectangle(i,n,r);return b.Rectangle.intersection(t,e.bounds)!==void 0}return!1}};(n=>{function a(r,t,s){return new n({regions:r.map(l=>({...l})),defaultProvider:t,fallbackProvider:s})}n.fromRectangles=a;function e(r,t,s){return new n({regions:r.map(l=>({...l})),defaultProvider:t,fallbackProvider:s})}n.fromTileRanges=e;function i(r,t){if(y.warn("computeRectangle() is deprecated. Use Rectangle.fromDegrees() instead.",{removeInVersion:"v0.3.0"}),t.size===0)return new b.Rectangle;let s=Number.POSITIVE_INFINITY,l=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,u=Number.NEGATIVE_INFINITY,c=Array.from(t.keys()),d=Math.min(...c),m=t.get(d);if(m){let{start:f,end:v}=m,p=r.tileXYToRectangle(f.x,f.y,d),h=r.tileXYToRectangle(v.x,v.y,d);s=Math.min(p.west,s),l=Math.min(h.south,l),o=Math.max(h.east,o),u=Math.max(p.north,u)}return new b.Rectangle(s,l,o,u)}n.computeRectangle=i})(T||={});var _=T;
|