@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
package/dist/terrain/index.d.cts
CHANGED
|
@@ -1,276 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-C2V-igd9.cjs';
|
|
2
|
+
import 'cesium';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Represents a geographic area with a specific terrain provider.
|
|
6
|
-
* `TerrainArea` pairs a provider with geographic bounds and level constraints.
|
|
7
|
-
*/
|
|
8
|
-
declare class TerrainArea {
|
|
9
|
-
private _terrainProvider;
|
|
10
|
-
private _rectangle;
|
|
11
|
-
private _tileRanges;
|
|
12
|
-
private _ready;
|
|
13
|
-
private _credit;
|
|
14
|
-
private _isCustom;
|
|
15
|
-
/**
|
|
16
|
-
* Creates a new instance of `TerrainArea`.
|
|
17
|
-
* @param options Object describing initialization options
|
|
18
|
-
*/
|
|
19
|
-
constructor(options: TerrainArea.ConstructorOptions);
|
|
20
|
-
/**
|
|
21
|
-
* Checks if the specified tile coordinates are within the bounds.
|
|
22
|
-
* @param x The tile X coordinate.
|
|
23
|
-
* @param y The tile Y coordinate.
|
|
24
|
-
* @param level The tile level.
|
|
25
|
-
* @returns `true` if the tile is within bounds, `false` otherwise.
|
|
26
|
-
*/
|
|
27
|
-
contains(x: number, y: number, level: number): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Requests the geometry for a given tile. The result must include terrain data and
|
|
30
|
-
* may optionally include a water mask and an indication of which child tiles are available.
|
|
31
|
-
* @param x - The X coordinate of the tile for which to request geometry.
|
|
32
|
-
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
33
|
-
* @param level - The level of the tile for which to request geometry.
|
|
34
|
-
* @param [request] - The request object. Intended for internal use only.
|
|
35
|
-
* @returns A promise for the requested geometry. If this method
|
|
36
|
-
* returns undefined instead of a promise, it is an indication that too many requests are already
|
|
37
|
-
* pending and the request will be retried later.
|
|
38
|
-
*/
|
|
39
|
-
requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<Awaited<TerrainData>> | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* Determines whether data for a tile is available to be loaded.
|
|
42
|
-
* @param x - The X coordinate of the tile for which to request geometry.
|
|
43
|
-
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
44
|
-
* @param level - The level of the tile for which to request geometry.
|
|
45
|
-
* @returns Undefined if not supported by the terrain provider, otherwise true or false.
|
|
46
|
-
* @see {@link TerrainProvider.getTileDataAvailable} */
|
|
47
|
-
getTileDataAvailable(x: number, y: number, level: number): boolean;
|
|
48
|
-
/** Checks if this terrain provider is marked as a custom provider. */
|
|
49
|
-
get isCustom(): boolean;
|
|
50
|
-
/** Gets the credit associated with this terrain area. */
|
|
51
|
-
get credit(): string | Credit;
|
|
52
|
-
/** Gets the terrain provider for this terrain area. */
|
|
53
|
-
get terrainProvider(): TerrainProvider;
|
|
54
|
-
/** Gets available tile ranges with zoom levels set with this terrain area. */
|
|
55
|
-
get tileRanges(): Map<number, TerrainArea.TileRange>;
|
|
56
|
-
/** Gets the rectangle representing this terrain area. */
|
|
57
|
-
get rectangle(): Rectangle;
|
|
58
|
-
/** Gets if this terrain area is ready. */
|
|
59
|
-
get ready(): boolean;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* @namespace
|
|
63
|
-
* Contains types and factory methods for creating `TerrainArea` instances.
|
|
64
|
-
*/
|
|
65
|
-
declare namespace TerrainArea {
|
|
66
|
-
/** Initialization options for `TerrainArea` constructor. */
|
|
67
|
-
interface ConstructorOptions {
|
|
68
|
-
/** The terrain provider for this area or a URL to create one from. */
|
|
69
|
-
terrainProvider: TerrainProvider;
|
|
70
|
-
/**
|
|
71
|
-
* Tile ranges by level when using tileRange type.
|
|
72
|
-
* Keys are zoom levels, values define the range of tiles at that level.
|
|
73
|
-
*/
|
|
74
|
-
tileRanges: Map<number, TileRange>;
|
|
75
|
-
/**
|
|
76
|
-
* Credit to associate with this terrain provider.
|
|
77
|
-
* Used to identify custom terrain providers.
|
|
78
|
-
* @default custom
|
|
79
|
-
*/
|
|
80
|
-
credit?: string | Credit;
|
|
81
|
-
/**
|
|
82
|
-
* Whether this is a custom terrain provider.
|
|
83
|
-
* @default true
|
|
84
|
-
*/
|
|
85
|
-
isCustom?: boolean;
|
|
86
|
-
}
|
|
87
|
-
/** A range of tiles from `start` to `end` */
|
|
88
|
-
type TileRange = {
|
|
89
|
-
/** Top Left tile coordinates */
|
|
90
|
-
start: {
|
|
91
|
-
x: number;
|
|
92
|
-
y: number;
|
|
93
|
-
};
|
|
94
|
-
/** Bottom Right tile coordinates */
|
|
95
|
-
end: {
|
|
96
|
-
x: number;
|
|
97
|
-
y: number;
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Creates a `TerrainArea` from a URL and tile ranges.
|
|
102
|
-
* @param url The URL to create the terrain provider from.
|
|
103
|
-
* @param tileRanges Tile ranges by level.
|
|
104
|
-
* @param options: Constructor options for CesiumTerrainProvider.
|
|
105
|
-
* @returns A promise resolving to a new `TerrainArea`
|
|
106
|
-
*/
|
|
107
|
-
function fromUrl(url: string, tileRanges: Map<number, TileRange>, options?: CesiumTerrainProvider.ConstructorOptions): Promise<Awaited<TerrainArea>>;
|
|
108
|
-
/**
|
|
109
|
-
* @extends Array
|
|
110
|
-
* @class
|
|
111
|
-
* Collection-like Extended Array Class of `TerrainArea`.
|
|
112
|
-
*/
|
|
113
|
-
class Collection extends Array<TerrainArea> {
|
|
114
|
-
/**
|
|
115
|
-
* Adds a new terrain area to the collection.
|
|
116
|
-
* @param area A TerrainArea instance or constructor options
|
|
117
|
-
* @returns The index of the added item
|
|
118
|
-
*/
|
|
119
|
-
add(area: TerrainArea | TerrainArea.ConstructorOptions): this;
|
|
120
|
-
/**
|
|
121
|
-
* Adds terrain areas to the collection.
|
|
122
|
-
* @param areas An array of TerrainArea instance or constructor options
|
|
123
|
-
* @returns The index of the added item
|
|
124
|
-
*/
|
|
125
|
-
add(areas: (TerrainArea | TerrainArea.ConstructorOptions)[]): this;
|
|
126
|
-
/**
|
|
127
|
-
* Removes a terrain area from the collection.
|
|
128
|
-
* @param area The terrain area to remove.
|
|
129
|
-
*/
|
|
130
|
-
remove(area: TerrainArea): this;
|
|
131
|
-
/**
|
|
132
|
-
* Removes multiple terrain areas from the collection.
|
|
133
|
-
* @param areas The terrain areas to remove.
|
|
134
|
-
*/
|
|
135
|
-
remove(areas: TerrainArea[]): this;
|
|
136
|
-
/**
|
|
137
|
-
* Clears all terrain areas.
|
|
138
|
-
*/
|
|
139
|
-
removeAll(): void;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
4
|
+
type TerrainRegion = HybridTerrainProvider.TerrainRegion;
|
|
5
|
+
type TerrainOptions = HybridTerrainProvider.ConstructorOptions;
|
|
142
6
|
|
|
143
|
-
|
|
144
|
-
* @class
|
|
145
|
-
* Provides terrain by delegating requests to different terrain providers
|
|
146
|
-
* based on geographic regions and zoom levels. This allows combining
|
|
147
|
-
* multiple terrain sources into a single seamless terrain.
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* ``` typescript
|
|
151
|
-
* // Set up tile ranges
|
|
152
|
-
* const tileRanges = new Map<number, TerrainArea.TileRange>;
|
|
153
|
-
* tileRanges.set(15, { start: { x: 55852, y: 9556 }, end: { x: 55871, y: 9575 } });
|
|
154
|
-
* // Set up tile areas
|
|
155
|
-
* const area = new TerrainArea({ terrainProvider: provider, tileRanges });
|
|
156
|
-
*
|
|
157
|
-
* const hybridTerrain = new HybridTerrainProvider({
|
|
158
|
-
* terrainAreas: [area],
|
|
159
|
-
* terrainProvider: new EllipsoidTerrainProvider(),
|
|
160
|
-
* });
|
|
161
|
-
*
|
|
162
|
-
* viewer.terrainProvider = hybridTerrain;
|
|
163
|
-
* ```
|
|
164
|
-
*/
|
|
165
|
-
declare class HybridTerrainProvider implements TerrainProvider {
|
|
166
|
-
private _terrainAreas;
|
|
167
|
-
private _terrainProvider;
|
|
168
|
-
private _fallbackProvider;
|
|
169
|
-
private _tilingScheme;
|
|
170
|
-
private _ready;
|
|
171
|
-
private _availability?;
|
|
172
|
-
/**
|
|
173
|
-
* Creates a new `HybridTerrainProvider` instance.
|
|
174
|
-
* @param options {@link HybridTerrainProvider.ConstructorOptions}
|
|
175
|
-
* @returns A new `HybridTerrainProvider` instance.
|
|
176
|
-
*/
|
|
177
|
-
constructor(options: HybridTerrainProvider.ConstructorOptions);
|
|
178
|
-
/**
|
|
179
|
-
* Gets a value indicating whether or not the provider is ready for use,
|
|
180
|
-
* or a promise that resolves when the provider becomes ready.
|
|
181
|
-
*/
|
|
182
|
-
get ready(): boolean;
|
|
183
|
-
/**
|
|
184
|
-
* Gets the tiling scheme used by this provider.
|
|
185
|
-
*/
|
|
186
|
-
get tilingScheme(): TilingScheme;
|
|
187
|
-
/**
|
|
188
|
-
* Gets an object that can be used to determine availability of terrain from this provider.
|
|
189
|
-
*/
|
|
190
|
-
get availability(): TileAvailability | undefined;
|
|
191
|
-
/**
|
|
192
|
-
* Gets the list of terrain areas managed by this provider.
|
|
193
|
-
*/
|
|
194
|
-
get terrainAreas(): readonly TerrainArea[];
|
|
195
|
-
/**
|
|
196
|
-
* Gets the default terrain provider.
|
|
197
|
-
*/
|
|
198
|
-
get defaultProvider(): TerrainProvider;
|
|
199
|
-
/**
|
|
200
|
-
* Gets the fallback terrain provider.
|
|
201
|
-
*/
|
|
202
|
-
get fallbackProvider(): TerrainProvider;
|
|
203
|
-
/**
|
|
204
|
-
* Gets the credit to display when this terrain provider is active. Typically this is used to credit
|
|
205
|
-
* the source of the terrain.
|
|
206
|
-
*/
|
|
207
|
-
get credit(): Credit;
|
|
208
|
-
/**
|
|
209
|
-
* Gets an event that is raised when the terrain provider encounters an asynchronous error. By subscribing
|
|
210
|
-
* to the event, you will be notified of the error and can potentially recover from it. Event listeners
|
|
211
|
-
* are passed an instance of `TileProviderError`.
|
|
212
|
-
*/
|
|
213
|
-
get errorEvent(): any;
|
|
214
|
-
/**
|
|
215
|
-
* Gets a value indicating whether or not the provider includes a water mask. The water mask
|
|
216
|
-
* indicates which areas of the globe are water rather than land, so they can be rendered
|
|
217
|
-
* as a reflective surface with animated waves.
|
|
218
|
-
*/
|
|
219
|
-
get hasWaterMask(): boolean;
|
|
220
|
-
/** Gets a value indicating whether or not the requested tiles include vertex normals. */
|
|
221
|
-
get hasVertexNormals(): boolean;
|
|
222
|
-
/**
|
|
223
|
-
* Makes sure we load availability data for a tile
|
|
224
|
-
* @param x - The X coordinate of the tile for which to request geometry.
|
|
225
|
-
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
226
|
-
* @param level - The level of the tile for which to request geometry.
|
|
227
|
-
* @returns Undefined if nothing need to be loaded or a Promise that resolves when all required tiles are loaded
|
|
228
|
-
*/
|
|
229
|
-
loadTileDataAvailability(x: number, y: number, level: number): Promise<void> | undefined;
|
|
230
|
-
/**
|
|
231
|
-
* Gets the maximum geometric error allowed in a tile at a given level.
|
|
232
|
-
* @param level - The tile level for which to get the maximum geometric error.
|
|
233
|
-
* @returns The maximum geometric error.
|
|
234
|
-
*/
|
|
235
|
-
getLevelMaximumGeometricError(level: number): number;
|
|
236
|
-
/**
|
|
237
|
-
* Requests the terrain for a given tile coordinate.
|
|
238
|
-
* @param x The X coordinate of the tile.
|
|
239
|
-
* @param y The Y coordinate of the tile.
|
|
240
|
-
* @param level The zoom level of the tile.
|
|
241
|
-
* @param request The request.
|
|
242
|
-
* @returns A promise for the requested terrain.
|
|
243
|
-
*/
|
|
244
|
-
requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<Awaited<TerrainData>> | undefined;
|
|
245
|
-
/**
|
|
246
|
-
* Determines whether data for a tile is available to be loaded. Checks the specified terrain areas first.
|
|
247
|
-
* @param x - The X coordinate of the tile for which to request geometry.
|
|
248
|
-
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
249
|
-
* @param level - The level of the tile for which to request geometry.
|
|
250
|
-
* @returns Undefined if not supported by the terrain provider, otherwise true or false.
|
|
251
|
-
*/
|
|
252
|
-
getTileDataAvailable(x: number, y: number, level: number): boolean | undefined;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* @namespace
|
|
256
|
-
* Contains types and factory methods for `HybridTerrainProvider` instance.
|
|
257
|
-
*/
|
|
258
|
-
declare namespace HybridTerrainProvider {
|
|
259
|
-
/** Initialization options for `HybridTerrainProvider` constructor. */
|
|
260
|
-
interface ConstructorOptions {
|
|
261
|
-
/** An array of terrain areas to include in the hybrid terrain. */
|
|
262
|
-
terrainAreas: TerrainArea[];
|
|
263
|
-
/** Default provider to use outside of specified terrain areas. */
|
|
264
|
-
terrainProvider: TerrainProvider;
|
|
265
|
-
/** Optional fallback provider when data is not available from default provider. @default EllipsoidTerrainProvider */
|
|
266
|
-
fallbackProvider?: TerrainProvider;
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Calculates a bounding rectangle that encompasses all the specified tile ranges.
|
|
270
|
-
* @param tilingScheme The tiling scheme to use for calculation.
|
|
271
|
-
* @param from Tile ranges to calculate from.
|
|
272
|
-
*/
|
|
273
|
-
function computeRectangle(tilingScheme: TilingScheme, from: Map<number, TerrainArea.TileRange>): Rectangle;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
export { HybridTerrainProvider, TerrainArea };
|
|
7
|
+
export { HybridTerrainProvider, type TerrainOptions, type TerrainRegion };
|
package/dist/terrain/index.d.ts
CHANGED
|
@@ -1,276 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-C2V-igd9.js';
|
|
2
|
+
import 'cesium';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Represents a geographic area with a specific terrain provider.
|
|
6
|
-
* `TerrainArea` pairs a provider with geographic bounds and level constraints.
|
|
7
|
-
*/
|
|
8
|
-
declare class TerrainArea {
|
|
9
|
-
private _terrainProvider;
|
|
10
|
-
private _rectangle;
|
|
11
|
-
private _tileRanges;
|
|
12
|
-
private _ready;
|
|
13
|
-
private _credit;
|
|
14
|
-
private _isCustom;
|
|
15
|
-
/**
|
|
16
|
-
* Creates a new instance of `TerrainArea`.
|
|
17
|
-
* @param options Object describing initialization options
|
|
18
|
-
*/
|
|
19
|
-
constructor(options: TerrainArea.ConstructorOptions);
|
|
20
|
-
/**
|
|
21
|
-
* Checks if the specified tile coordinates are within the bounds.
|
|
22
|
-
* @param x The tile X coordinate.
|
|
23
|
-
* @param y The tile Y coordinate.
|
|
24
|
-
* @param level The tile level.
|
|
25
|
-
* @returns `true` if the tile is within bounds, `false` otherwise.
|
|
26
|
-
*/
|
|
27
|
-
contains(x: number, y: number, level: number): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Requests the geometry for a given tile. The result must include terrain data and
|
|
30
|
-
* may optionally include a water mask and an indication of which child tiles are available.
|
|
31
|
-
* @param x - The X coordinate of the tile for which to request geometry.
|
|
32
|
-
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
33
|
-
* @param level - The level of the tile for which to request geometry.
|
|
34
|
-
* @param [request] - The request object. Intended for internal use only.
|
|
35
|
-
* @returns A promise for the requested geometry. If this method
|
|
36
|
-
* returns undefined instead of a promise, it is an indication that too many requests are already
|
|
37
|
-
* pending and the request will be retried later.
|
|
38
|
-
*/
|
|
39
|
-
requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<Awaited<TerrainData>> | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* Determines whether data for a tile is available to be loaded.
|
|
42
|
-
* @param x - The X coordinate of the tile for which to request geometry.
|
|
43
|
-
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
44
|
-
* @param level - The level of the tile for which to request geometry.
|
|
45
|
-
* @returns Undefined if not supported by the terrain provider, otherwise true or false.
|
|
46
|
-
* @see {@link TerrainProvider.getTileDataAvailable} */
|
|
47
|
-
getTileDataAvailable(x: number, y: number, level: number): boolean;
|
|
48
|
-
/** Checks if this terrain provider is marked as a custom provider. */
|
|
49
|
-
get isCustom(): boolean;
|
|
50
|
-
/** Gets the credit associated with this terrain area. */
|
|
51
|
-
get credit(): string | Credit;
|
|
52
|
-
/** Gets the terrain provider for this terrain area. */
|
|
53
|
-
get terrainProvider(): TerrainProvider;
|
|
54
|
-
/** Gets available tile ranges with zoom levels set with this terrain area. */
|
|
55
|
-
get tileRanges(): Map<number, TerrainArea.TileRange>;
|
|
56
|
-
/** Gets the rectangle representing this terrain area. */
|
|
57
|
-
get rectangle(): Rectangle;
|
|
58
|
-
/** Gets if this terrain area is ready. */
|
|
59
|
-
get ready(): boolean;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* @namespace
|
|
63
|
-
* Contains types and factory methods for creating `TerrainArea` instances.
|
|
64
|
-
*/
|
|
65
|
-
declare namespace TerrainArea {
|
|
66
|
-
/** Initialization options for `TerrainArea` constructor. */
|
|
67
|
-
interface ConstructorOptions {
|
|
68
|
-
/** The terrain provider for this area or a URL to create one from. */
|
|
69
|
-
terrainProvider: TerrainProvider;
|
|
70
|
-
/**
|
|
71
|
-
* Tile ranges by level when using tileRange type.
|
|
72
|
-
* Keys are zoom levels, values define the range of tiles at that level.
|
|
73
|
-
*/
|
|
74
|
-
tileRanges: Map<number, TileRange>;
|
|
75
|
-
/**
|
|
76
|
-
* Credit to associate with this terrain provider.
|
|
77
|
-
* Used to identify custom terrain providers.
|
|
78
|
-
* @default custom
|
|
79
|
-
*/
|
|
80
|
-
credit?: string | Credit;
|
|
81
|
-
/**
|
|
82
|
-
* Whether this is a custom terrain provider.
|
|
83
|
-
* @default true
|
|
84
|
-
*/
|
|
85
|
-
isCustom?: boolean;
|
|
86
|
-
}
|
|
87
|
-
/** A range of tiles from `start` to `end` */
|
|
88
|
-
type TileRange = {
|
|
89
|
-
/** Top Left tile coordinates */
|
|
90
|
-
start: {
|
|
91
|
-
x: number;
|
|
92
|
-
y: number;
|
|
93
|
-
};
|
|
94
|
-
/** Bottom Right tile coordinates */
|
|
95
|
-
end: {
|
|
96
|
-
x: number;
|
|
97
|
-
y: number;
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Creates a `TerrainArea` from a URL and tile ranges.
|
|
102
|
-
* @param url The URL to create the terrain provider from.
|
|
103
|
-
* @param tileRanges Tile ranges by level.
|
|
104
|
-
* @param options: Constructor options for CesiumTerrainProvider.
|
|
105
|
-
* @returns A promise resolving to a new `TerrainArea`
|
|
106
|
-
*/
|
|
107
|
-
function fromUrl(url: string, tileRanges: Map<number, TileRange>, options?: CesiumTerrainProvider.ConstructorOptions): Promise<Awaited<TerrainArea>>;
|
|
108
|
-
/**
|
|
109
|
-
* @extends Array
|
|
110
|
-
* @class
|
|
111
|
-
* Collection-like Extended Array Class of `TerrainArea`.
|
|
112
|
-
*/
|
|
113
|
-
class Collection extends Array<TerrainArea> {
|
|
114
|
-
/**
|
|
115
|
-
* Adds a new terrain area to the collection.
|
|
116
|
-
* @param area A TerrainArea instance or constructor options
|
|
117
|
-
* @returns The index of the added item
|
|
118
|
-
*/
|
|
119
|
-
add(area: TerrainArea | TerrainArea.ConstructorOptions): this;
|
|
120
|
-
/**
|
|
121
|
-
* Adds terrain areas to the collection.
|
|
122
|
-
* @param areas An array of TerrainArea instance or constructor options
|
|
123
|
-
* @returns The index of the added item
|
|
124
|
-
*/
|
|
125
|
-
add(areas: (TerrainArea | TerrainArea.ConstructorOptions)[]): this;
|
|
126
|
-
/**
|
|
127
|
-
* Removes a terrain area from the collection.
|
|
128
|
-
* @param area The terrain area to remove.
|
|
129
|
-
*/
|
|
130
|
-
remove(area: TerrainArea): this;
|
|
131
|
-
/**
|
|
132
|
-
* Removes multiple terrain areas from the collection.
|
|
133
|
-
* @param areas The terrain areas to remove.
|
|
134
|
-
*/
|
|
135
|
-
remove(areas: TerrainArea[]): this;
|
|
136
|
-
/**
|
|
137
|
-
* Clears all terrain areas.
|
|
138
|
-
*/
|
|
139
|
-
removeAll(): void;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
4
|
+
type TerrainRegion = HybridTerrainProvider.TerrainRegion;
|
|
5
|
+
type TerrainOptions = HybridTerrainProvider.ConstructorOptions;
|
|
142
6
|
|
|
143
|
-
|
|
144
|
-
* @class
|
|
145
|
-
* Provides terrain by delegating requests to different terrain providers
|
|
146
|
-
* based on geographic regions and zoom levels. This allows combining
|
|
147
|
-
* multiple terrain sources into a single seamless terrain.
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* ``` typescript
|
|
151
|
-
* // Set up tile ranges
|
|
152
|
-
* const tileRanges = new Map<number, TerrainArea.TileRange>;
|
|
153
|
-
* tileRanges.set(15, { start: { x: 55852, y: 9556 }, end: { x: 55871, y: 9575 } });
|
|
154
|
-
* // Set up tile areas
|
|
155
|
-
* const area = new TerrainArea({ terrainProvider: provider, tileRanges });
|
|
156
|
-
*
|
|
157
|
-
* const hybridTerrain = new HybridTerrainProvider({
|
|
158
|
-
* terrainAreas: [area],
|
|
159
|
-
* terrainProvider: new EllipsoidTerrainProvider(),
|
|
160
|
-
* });
|
|
161
|
-
*
|
|
162
|
-
* viewer.terrainProvider = hybridTerrain;
|
|
163
|
-
* ```
|
|
164
|
-
*/
|
|
165
|
-
declare class HybridTerrainProvider implements TerrainProvider {
|
|
166
|
-
private _terrainAreas;
|
|
167
|
-
private _terrainProvider;
|
|
168
|
-
private _fallbackProvider;
|
|
169
|
-
private _tilingScheme;
|
|
170
|
-
private _ready;
|
|
171
|
-
private _availability?;
|
|
172
|
-
/**
|
|
173
|
-
* Creates a new `HybridTerrainProvider` instance.
|
|
174
|
-
* @param options {@link HybridTerrainProvider.ConstructorOptions}
|
|
175
|
-
* @returns A new `HybridTerrainProvider` instance.
|
|
176
|
-
*/
|
|
177
|
-
constructor(options: HybridTerrainProvider.ConstructorOptions);
|
|
178
|
-
/**
|
|
179
|
-
* Gets a value indicating whether or not the provider is ready for use,
|
|
180
|
-
* or a promise that resolves when the provider becomes ready.
|
|
181
|
-
*/
|
|
182
|
-
get ready(): boolean;
|
|
183
|
-
/**
|
|
184
|
-
* Gets the tiling scheme used by this provider.
|
|
185
|
-
*/
|
|
186
|
-
get tilingScheme(): TilingScheme;
|
|
187
|
-
/**
|
|
188
|
-
* Gets an object that can be used to determine availability of terrain from this provider.
|
|
189
|
-
*/
|
|
190
|
-
get availability(): TileAvailability | undefined;
|
|
191
|
-
/**
|
|
192
|
-
* Gets the list of terrain areas managed by this provider.
|
|
193
|
-
*/
|
|
194
|
-
get terrainAreas(): readonly TerrainArea[];
|
|
195
|
-
/**
|
|
196
|
-
* Gets the default terrain provider.
|
|
197
|
-
*/
|
|
198
|
-
get defaultProvider(): TerrainProvider;
|
|
199
|
-
/**
|
|
200
|
-
* Gets the fallback terrain provider.
|
|
201
|
-
*/
|
|
202
|
-
get fallbackProvider(): TerrainProvider;
|
|
203
|
-
/**
|
|
204
|
-
* Gets the credit to display when this terrain provider is active. Typically this is used to credit
|
|
205
|
-
* the source of the terrain.
|
|
206
|
-
*/
|
|
207
|
-
get credit(): Credit;
|
|
208
|
-
/**
|
|
209
|
-
* Gets an event that is raised when the terrain provider encounters an asynchronous error. By subscribing
|
|
210
|
-
* to the event, you will be notified of the error and can potentially recover from it. Event listeners
|
|
211
|
-
* are passed an instance of `TileProviderError`.
|
|
212
|
-
*/
|
|
213
|
-
get errorEvent(): any;
|
|
214
|
-
/**
|
|
215
|
-
* Gets a value indicating whether or not the provider includes a water mask. The water mask
|
|
216
|
-
* indicates which areas of the globe are water rather than land, so they can be rendered
|
|
217
|
-
* as a reflective surface with animated waves.
|
|
218
|
-
*/
|
|
219
|
-
get hasWaterMask(): boolean;
|
|
220
|
-
/** Gets a value indicating whether or not the requested tiles include vertex normals. */
|
|
221
|
-
get hasVertexNormals(): boolean;
|
|
222
|
-
/**
|
|
223
|
-
* Makes sure we load availability data for a tile
|
|
224
|
-
* @param x - The X coordinate of the tile for which to request geometry.
|
|
225
|
-
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
226
|
-
* @param level - The level of the tile for which to request geometry.
|
|
227
|
-
* @returns Undefined if nothing need to be loaded or a Promise that resolves when all required tiles are loaded
|
|
228
|
-
*/
|
|
229
|
-
loadTileDataAvailability(x: number, y: number, level: number): Promise<void> | undefined;
|
|
230
|
-
/**
|
|
231
|
-
* Gets the maximum geometric error allowed in a tile at a given level.
|
|
232
|
-
* @param level - The tile level for which to get the maximum geometric error.
|
|
233
|
-
* @returns The maximum geometric error.
|
|
234
|
-
*/
|
|
235
|
-
getLevelMaximumGeometricError(level: number): number;
|
|
236
|
-
/**
|
|
237
|
-
* Requests the terrain for a given tile coordinate.
|
|
238
|
-
* @param x The X coordinate of the tile.
|
|
239
|
-
* @param y The Y coordinate of the tile.
|
|
240
|
-
* @param level The zoom level of the tile.
|
|
241
|
-
* @param request The request.
|
|
242
|
-
* @returns A promise for the requested terrain.
|
|
243
|
-
*/
|
|
244
|
-
requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<Awaited<TerrainData>> | undefined;
|
|
245
|
-
/**
|
|
246
|
-
* Determines whether data for a tile is available to be loaded. Checks the specified terrain areas first.
|
|
247
|
-
* @param x - The X coordinate of the tile for which to request geometry.
|
|
248
|
-
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
249
|
-
* @param level - The level of the tile for which to request geometry.
|
|
250
|
-
* @returns Undefined if not supported by the terrain provider, otherwise true or false.
|
|
251
|
-
*/
|
|
252
|
-
getTileDataAvailable(x: number, y: number, level: number): boolean | undefined;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* @namespace
|
|
256
|
-
* Contains types and factory methods for `HybridTerrainProvider` instance.
|
|
257
|
-
*/
|
|
258
|
-
declare namespace HybridTerrainProvider {
|
|
259
|
-
/** Initialization options for `HybridTerrainProvider` constructor. */
|
|
260
|
-
interface ConstructorOptions {
|
|
261
|
-
/** An array of terrain areas to include in the hybrid terrain. */
|
|
262
|
-
terrainAreas: TerrainArea[];
|
|
263
|
-
/** Default provider to use outside of specified terrain areas. */
|
|
264
|
-
terrainProvider: TerrainProvider;
|
|
265
|
-
/** Optional fallback provider when data is not available from default provider. @default EllipsoidTerrainProvider */
|
|
266
|
-
fallbackProvider?: TerrainProvider;
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Calculates a bounding rectangle that encompasses all the specified tile ranges.
|
|
270
|
-
* @param tilingScheme The tiling scheme to use for calculation.
|
|
271
|
-
* @param from Tile ranges to calculate from.
|
|
272
|
-
*/
|
|
273
|
-
function computeRectangle(tilingScheme: TilingScheme, from: Map<number, TerrainArea.TileRange>): Rectangle;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
export { HybridTerrainProvider, TerrainArea };
|
|
7
|
+
export { HybridTerrainProvider, type TerrainOptions, type TerrainRegion };
|
package/dist/terrain/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{a}from"../chunk-DGHCIGKJ.js";import"../chunk-TUJQL7MC.js";export{a as HybridTerrainProvider};
|
package/dist/viewer/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var m=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var T=(e,i)=>{for(var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var T=(e,i)=>{for(var t in i)m(e,t,{get:i[t],enumerable:!0})},v=(e,i,t,o)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of k(i))!C.call(e,n)&&n!==t&&m(e,n,{get:()=>i[n],enumerable:!(o=g(i,n))||o.enumerable});return e};var b=e=>v(m({},"__esModule",{value:!0}),e);var h={};T(h,{cloneViewer:()=>y,syncCamera:()=>l});module.exports=b(h);var p=require("cesium");var d=require("cesium");function l(e,i){if((0,d.defined)(e)&&(0,d.defined)(i)){let{camera:t}=e;i.camera.position=t.positionWC.clone(),i.camera.direction=t.directionWC.clone(),i.camera.up=t.upWC.clone()}}function y(e,i,t){let o={baseLayerPicker:e.baseLayerPicker!==void 0,geocoder:e.geocoder!==void 0,homeButton:e.homeButton!==void 0,sceneModePicker:e.sceneModePicker!==void 0,timeline:e.timeline!==void 0,navigationHelpButton:e.navigationHelpButton!==void 0,animation:e.animation!==void 0,fullscreenButton:e.fullscreenButton!==void 0,shouldAnimate:e.clock.shouldAnimate,terrainProvider:e.terrainProvider,requestRenderMode:e.scene.requestRenderMode,infoBox:e.infoBox!==void 0},n=new p.Viewer(i,{...o,...t});l(e,n);let s=e.imageryLayers;n.imageryLayers.removeAll();for(let c=0;c<s.length;c++){let f=s.get(c);n.imageryLayers.addImageryProvider(f.imageryProvider,c)}n.clock.startTime=e.clock.startTime.clone(),n.clock.stopTime=e.clock.stopTime.clone(),n.clock.currentTime=e.clock.currentTime.clone(),n.clock.multiplier=e.clock.multiplier,n.clock.clockStep=e.clock.clockStep,n.clock.clockRange=e.clock.clockRange,n.clock.shouldAnimate=e.clock.shouldAnimate,n.scene.globe.enableLighting=e.scene.globe.enableLighting,n.scene.globe.depthTestAgainstTerrain=e.scene.globe.depthTestAgainstTerrain,n.scene.screenSpaceCameraController.enableCollisionDetection=e.scene.screenSpaceCameraController.enableCollisionDetection;let r=e.scene.screenSpaceCameraController.tiltEventTypes;r&&(n.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(r)?[...r]:r);let a=e.scene.screenSpaceCameraController.zoomEventTypes;return a&&(n.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(a)?[...a]:a),n}
|
package/dist/viewer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"../chunk-
|
|
1
|
+
import{a,b}from"../chunk-Z2COOTT4.js";export{b as cloneViewer,a as syncCamera};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juun-roh/cesium-utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Utilities to handle Cesium classes easier.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"3d",
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"import": "./dist/terrain/index.js",
|
|
57
57
|
"require": "./dist/terrain/index.cjs"
|
|
58
58
|
},
|
|
59
|
-
"./
|
|
60
|
-
"types": "./dist/
|
|
61
|
-
"import": "./dist/
|
|
62
|
-
"require": "./dist/
|
|
59
|
+
"./dev": {
|
|
60
|
+
"types": "./dist/dev/index.d.ts",
|
|
61
|
+
"import": "./dist/dev/index.js",
|
|
62
|
+
"require": "./dist/dev/index.cjs"
|
|
63
63
|
},
|
|
64
64
|
"./viewer": {
|
|
65
65
|
"types": "./dist/viewer/index.d.ts",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"node": ">=20.0.0"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"cesium": "^1"
|
|
74
|
+
"cesium": "^1.131.0"
|
|
75
75
|
},
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"access": "public"
|
|
@@ -88,23 +88,24 @@
|
|
|
88
88
|
"@commitlint/cz-commitlint": "^19.8.1",
|
|
89
89
|
"@commitlint/format": "^19.8.1",
|
|
90
90
|
"@commitlint/types": "^19.8.1",
|
|
91
|
-
"@eslint/js": "^9.
|
|
92
|
-
"@
|
|
93
|
-
"@typescript-eslint/
|
|
91
|
+
"@eslint/js": "^9.32.0",
|
|
92
|
+
"@types/node": "^24.1.0",
|
|
93
|
+
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
94
|
+
"@typescript-eslint/parser": "^8.38.0",
|
|
94
95
|
"@vitest/coverage-v8": "^3.2.4",
|
|
95
96
|
"cesium": "^1.131.0",
|
|
96
|
-
"eslint": "^9.
|
|
97
|
-
"eslint-plugin-jsdoc": "^
|
|
98
|
-
"eslint-plugin-prettier": "^5.5.
|
|
97
|
+
"eslint": "^9.32.0",
|
|
98
|
+
"eslint-plugin-jsdoc": "^52.0.0",
|
|
99
|
+
"eslint-plugin-prettier": "^5.5.3",
|
|
99
100
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
100
101
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
101
102
|
"husky": "^9.1.7",
|
|
102
103
|
"jsdom": "^26.1.0",
|
|
103
104
|
"rimraf": "^6.0.1",
|
|
104
105
|
"tsup": "^8.5.0",
|
|
105
|
-
"typedoc": "^0.28.
|
|
106
|
+
"typedoc": "^0.28.8",
|
|
106
107
|
"typescript": "^5.8.3",
|
|
107
|
-
"vite": "^7.0.
|
|
108
|
+
"vite": "^7.0.6",
|
|
108
109
|
"vitest": "^3.2.4"
|
|
109
110
|
},
|
|
110
111
|
"scripts": {
|
package/dist/chunk-4HY6RL6I.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Color as s,Entity as O,HeightReference as F,Rectangle as E,TileCoordinatesImageryProvider as V}from"cesium";import{DataSourceCollection as A,defined as _,EntityCollection as b,ImageryLayerCollection as S,PrimitiveCollection as M}from"cesium";var y=class o{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(n=>n(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[o.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 b?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof M?(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 A?(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 S&&(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,o.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 b)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,o.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)_(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)_(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)_(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let n of r)if(e in n&&typeof n[e]!="function"){if(C(n,e))throw Error(`Cannot set read-only property '${String(e)}' on ${n.constructor.name}`);n[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,n)=>e(r,n))}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=y;var v=class o{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",s.RED],["default",s.BLUE],["fallback",s.GRAY],["grid",s.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new T({collection:e.entities,tag:o.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(o.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 V({tilingScheme:this._terrainProvider.tilingScheme,color:s.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(a=>{this._collection.add(a.entity,o.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(E.northwest(e),t),n=i.positionToTileXY(E.southeast(e),t);if(!r||!n)throw new Error("Failed to calculate tile bounds");return{start:r,end:n}}_generateVisibleTiles(e,t,i){let r=[],a=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+a;c++)for(let h=e.start.y;h<e.start.y+l;h++)try{let d=this._createTileEntity(c,h,t,i);d&&r.push({entity:d})}catch(d){console.warn(`Error creating tile (${c}, ${h}, ${t}):`,d)}return r}_createTileEntity(e,t,i,r){let n=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(n))return null;let a=this._getTileColor(e,t,i),l=o.createRectangle(n,a.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")||s.TRANSPARENT;for(let r of this._terrainProvider.terrainAreas)if(r.contains(e,t,i))return r.isCustom?this._colors.get("custom")||s.RED:this._colors.get("default")||s.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||s.BLUE:this._colors.get("fallback")||s.GRAY}hide(){this._collection.remove(o.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,n){return new O({rectangle:{coordinates:r,material:n,heightReference:F.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,n,a){let l=a?.tag||"terrain_area_visualization",c=a?.color||s.RED,h=a?.maxTilesToShow||100,d=a?.show??!0,w=a?.alpha||.7,L=a?.tileAlpha||.2,m=new T({collection:n.entities,tag:l}),{rectangle:I}=r;if(m.add(i.createRectangle(I,c.withAlpha(w)),l),d&&r.tileRanges.size>0){let{tilingScheme:P}=r.terrainProvider,g=0;r.tileRanges.forEach((u,R)=>{for(let f=u.start.x;f<=u.end.x&&g<h;f++)for(let p=u.start.y;p<=u.end.y&&g<h;p++){let x=P.tileXYToRectangle(f,p,R);m.add(e(x,c.withAlpha(L)),`${l}_tile`),g++}})}return m}i.visualize=t})(v||={});function C(o,e){let t=!1,i=Object.getOwnPropertyDescriptor(o,e);if(!i){let r=Object.getPrototypeOf(o);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}export{v as a,C as b,T as c};
|