@juun-roh/cesium-utils 0.3.8 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-B3AVU53O.js +1 -0
- package/dist/chunk-WCOPDVHL.js +1 -0
- package/dist/collection/index.cjs +1 -1
- package/dist/collection/index.d.cts +514 -2
- package/dist/collection/index.d.ts +514 -2
- package/dist/collection/index.js +1 -1
- package/dist/dev/index.cjs +1 -1
- package/dist/dev/index.d.cts +42 -51
- package/dist/dev/index.d.ts +42 -51
- package/dist/dev/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/type-check-B-zGL1Ne.d.cts +16 -0
- package/dist/type-check-B-zGL1Ne.d.ts +16 -0
- package/package.json +20 -20
- package/dist/chunk-R4DSXQCN.js +0 -1
- package/dist/chunk-RXMNSDKR.js +0 -0
- package/dist/index-iIlou-Sq.d.cts +0 -528
- package/dist/index-iIlou-Sq.d.ts +0 -528
package/dist/dev/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Viewer, Color, Rectangle
|
|
2
|
-
import { C as Collection } from '../index-iIlou-Sq.cjs';
|
|
3
|
-
export { N as NonFunction, i as isGetterOnly } from '../index-iIlou-Sq.cjs';
|
|
1
|
+
import { Viewer, Color, Rectangle } from 'cesium';
|
|
4
2
|
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-CVTrsFR5.cjs';
|
|
3
|
+
export { N as NonFunction, i as isGetterOnly } from '../type-check-B-zGL1Ne.cjs';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Utility for managing deprecation warnings in the cesium-utils library.
|
|
@@ -104,18 +103,17 @@ declare namespace Deprecate {
|
|
|
104
103
|
*/
|
|
105
104
|
declare class TerrainVisualizer {
|
|
106
105
|
private _viewer;
|
|
107
|
-
private
|
|
108
|
-
private _terrainProvider?;
|
|
106
|
+
private _terrainProvider;
|
|
109
107
|
private _visible;
|
|
110
|
-
private _level;
|
|
111
108
|
private _tileCoordinatesLayer;
|
|
109
|
+
private _hybridImageryLayer;
|
|
112
110
|
private _colors;
|
|
113
111
|
/**
|
|
114
112
|
* Creates a new `TerrainVisualizer`.
|
|
115
113
|
* @param viewer The Cesium viewer instance
|
|
116
114
|
* @param options {@link TerrainVisualizer.ConstructorOptions}
|
|
117
115
|
*/
|
|
118
|
-
constructor(viewer: Viewer, options
|
|
116
|
+
constructor(viewer: Viewer, options: TerrainVisualizer.ConstructorOptions);
|
|
119
117
|
/**
|
|
120
118
|
* Sets the terrain provider to visualize.
|
|
121
119
|
* @param terrainProvider The terrain provider to visualize.
|
|
@@ -130,19 +128,19 @@ declare class TerrainVisualizer {
|
|
|
130
128
|
*/
|
|
131
129
|
clear(): void;
|
|
132
130
|
/**
|
|
133
|
-
* Shows
|
|
134
|
-
*
|
|
131
|
+
* Shows terrain visualization using HybridImageryProvider.
|
|
132
|
+
* Optionally adds tile coordinate grid overlay.
|
|
133
|
+
* @param options Visualization options
|
|
135
134
|
*/
|
|
136
|
-
show(
|
|
135
|
+
show(options?: {
|
|
136
|
+
/** Show tile coordinate labels. Default: true */
|
|
137
|
+
showTileCoordinates?: boolean;
|
|
138
|
+
/** Transparency level (0-1). Default: 0.5 */
|
|
139
|
+
alpha?: number;
|
|
140
|
+
}): void;
|
|
137
141
|
private _ensureTileCoordinatesLayer;
|
|
138
|
-
private _isValidRectangle;
|
|
139
|
-
private _displayTileGrid;
|
|
140
|
-
private _calculateTileBounds;
|
|
141
|
-
private _generateVisibleTiles;
|
|
142
|
-
private _createTileEntity;
|
|
143
|
-
private _getTileColor;
|
|
144
142
|
/**
|
|
145
|
-
* Hides the
|
|
143
|
+
* Hides the terrain visualization.
|
|
146
144
|
*/
|
|
147
145
|
hide(): void;
|
|
148
146
|
/**
|
|
@@ -150,6 +148,29 @@ declare class TerrainVisualizer {
|
|
|
150
148
|
* @param colors Map of role names to colors
|
|
151
149
|
*/
|
|
152
150
|
setColors(colors: Record<string, Color>): void;
|
|
151
|
+
/**
|
|
152
|
+
* Shows terrain regions using HybridImageryProvider (performant, global coverage).
|
|
153
|
+
* This replaces the entity-based approach with an imagery layer.
|
|
154
|
+
* @param alpha Transparency level (0-1), default 0.5
|
|
155
|
+
*/
|
|
156
|
+
showImageryOverlay(alpha?: number): void;
|
|
157
|
+
/**
|
|
158
|
+
* Hides the imagery overlay.
|
|
159
|
+
*/
|
|
160
|
+
hideImageryOverlay(): void;
|
|
161
|
+
/**
|
|
162
|
+
* Shows tile coordinate grid overlay.
|
|
163
|
+
*/
|
|
164
|
+
showTileCoordinates(): void;
|
|
165
|
+
/**
|
|
166
|
+
* Hides tile coordinate grid overlay.
|
|
167
|
+
*/
|
|
168
|
+
hideTileCoordinates(): void;
|
|
169
|
+
/**
|
|
170
|
+
* Sets the transparency of the imagery overlay.
|
|
171
|
+
* @param alpha Transparency level (0-1), where 0 is fully transparent and 1 is fully opaque
|
|
172
|
+
*/
|
|
173
|
+
setAlpha(alpha: number): void;
|
|
153
174
|
/**
|
|
154
175
|
* Flies the camera to focus on a rectangle.
|
|
155
176
|
* @param rectangle The rectangle to focus on.
|
|
@@ -158,26 +179,16 @@ declare class TerrainVisualizer {
|
|
|
158
179
|
flyTo(rectangle: Rectangle, options?: {
|
|
159
180
|
duration?: number;
|
|
160
181
|
}): void;
|
|
161
|
-
/**
|
|
162
|
-
|
|
163
|
-
* @returns The current view rectangle or undefined.
|
|
164
|
-
* @private
|
|
165
|
-
*/
|
|
166
|
-
private _getVisibleRectangle;
|
|
167
|
-
/** The current zoom level set on the visualizer. */
|
|
168
|
-
get level(): number;
|
|
169
|
-
/** Set zoom level on the visualizer. */
|
|
170
|
-
set level(level: number);
|
|
182
|
+
/** Whether tile coordinates are currently visible. */
|
|
183
|
+
get tileCoordinatesVisible(): boolean;
|
|
171
184
|
/** Whether the grid is currently visible. */
|
|
172
185
|
get visible(): boolean;
|
|
173
|
-
/** The collection used in the visualizer. */
|
|
174
|
-
get collection(): Collection<EntityCollection, Entity>;
|
|
175
186
|
/** The viewer used in the visualizer */
|
|
176
187
|
get viewer(): Viewer;
|
|
177
188
|
/** The colors used in the visualizer */
|
|
178
189
|
get colors(): Map<string, Color>;
|
|
179
190
|
/** The hybrid terrain instance used in the visualizer */
|
|
180
|
-
get terrainProvider(): HybridTerrainProvider
|
|
191
|
+
get terrainProvider(): HybridTerrainProvider;
|
|
181
192
|
}
|
|
182
193
|
/**
|
|
183
194
|
* @namespace
|
|
@@ -193,20 +204,8 @@ declare namespace TerrainVisualizer {
|
|
|
193
204
|
/** Initial zoom level to use for visualizations. */
|
|
194
205
|
activeLevel?: number;
|
|
195
206
|
/** Terrain provider to visualize. */
|
|
196
|
-
terrainProvider
|
|
207
|
+
terrainProvider: HybridTerrainProvider;
|
|
197
208
|
}
|
|
198
|
-
/** Tag constants for entity collection management. */
|
|
199
|
-
const tag: {
|
|
200
|
-
default: string;
|
|
201
|
-
grid: string;
|
|
202
|
-
};
|
|
203
|
-
/**
|
|
204
|
-
* Creates a ground-clamped rectangle entity for visualization.
|
|
205
|
-
* @param rectangle The rectangle to visualize
|
|
206
|
-
* @param color The color to use
|
|
207
|
-
* @returns A new entity
|
|
208
|
-
*/
|
|
209
|
-
function createRectangle(rectangle: Rectangle, color: Color): Entity;
|
|
210
209
|
/** Options for {@link TerrainVisualizer.visualize} */
|
|
211
210
|
interface Options {
|
|
212
211
|
color?: Color;
|
|
@@ -217,14 +216,6 @@ declare namespace TerrainVisualizer {
|
|
|
217
216
|
alpha?: number;
|
|
218
217
|
tileAlpha?: number;
|
|
219
218
|
}
|
|
220
|
-
/**
|
|
221
|
-
* Visualizes a terrain region in a viewer.
|
|
222
|
-
* @param region The terrain region to visualize.
|
|
223
|
-
* @param viewer The Cesium viewer.
|
|
224
|
-
* @param options Visualization options.
|
|
225
|
-
* @returns Collection of created entities.
|
|
226
|
-
*/
|
|
227
|
-
function visualize(region: HybridTerrainProvider.TerrainRegion, viewer: Viewer, options?: Options): Collection<EntityCollection, Entity>;
|
|
228
219
|
}
|
|
229
220
|
|
|
230
221
|
declare const deprecate: typeof Deprecate.deprecate;
|
package/dist/dev/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Viewer, Color, Rectangle
|
|
2
|
-
import { C as Collection } from '../index-iIlou-Sq.js';
|
|
3
|
-
export { N as NonFunction, i as isGetterOnly } from '../index-iIlou-Sq.js';
|
|
1
|
+
import { Viewer, Color, Rectangle } from 'cesium';
|
|
4
2
|
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-CVTrsFR5.js';
|
|
3
|
+
export { N as NonFunction, i as isGetterOnly } from '../type-check-B-zGL1Ne.js';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Utility for managing deprecation warnings in the cesium-utils library.
|
|
@@ -104,18 +103,17 @@ declare namespace Deprecate {
|
|
|
104
103
|
*/
|
|
105
104
|
declare class TerrainVisualizer {
|
|
106
105
|
private _viewer;
|
|
107
|
-
private
|
|
108
|
-
private _terrainProvider?;
|
|
106
|
+
private _terrainProvider;
|
|
109
107
|
private _visible;
|
|
110
|
-
private _level;
|
|
111
108
|
private _tileCoordinatesLayer;
|
|
109
|
+
private _hybridImageryLayer;
|
|
112
110
|
private _colors;
|
|
113
111
|
/**
|
|
114
112
|
* Creates a new `TerrainVisualizer`.
|
|
115
113
|
* @param viewer The Cesium viewer instance
|
|
116
114
|
* @param options {@link TerrainVisualizer.ConstructorOptions}
|
|
117
115
|
*/
|
|
118
|
-
constructor(viewer: Viewer, options
|
|
116
|
+
constructor(viewer: Viewer, options: TerrainVisualizer.ConstructorOptions);
|
|
119
117
|
/**
|
|
120
118
|
* Sets the terrain provider to visualize.
|
|
121
119
|
* @param terrainProvider The terrain provider to visualize.
|
|
@@ -130,19 +128,19 @@ declare class TerrainVisualizer {
|
|
|
130
128
|
*/
|
|
131
129
|
clear(): void;
|
|
132
130
|
/**
|
|
133
|
-
* Shows
|
|
134
|
-
*
|
|
131
|
+
* Shows terrain visualization using HybridImageryProvider.
|
|
132
|
+
* Optionally adds tile coordinate grid overlay.
|
|
133
|
+
* @param options Visualization options
|
|
135
134
|
*/
|
|
136
|
-
show(
|
|
135
|
+
show(options?: {
|
|
136
|
+
/** Show tile coordinate labels. Default: true */
|
|
137
|
+
showTileCoordinates?: boolean;
|
|
138
|
+
/** Transparency level (0-1). Default: 0.5 */
|
|
139
|
+
alpha?: number;
|
|
140
|
+
}): void;
|
|
137
141
|
private _ensureTileCoordinatesLayer;
|
|
138
|
-
private _isValidRectangle;
|
|
139
|
-
private _displayTileGrid;
|
|
140
|
-
private _calculateTileBounds;
|
|
141
|
-
private _generateVisibleTiles;
|
|
142
|
-
private _createTileEntity;
|
|
143
|
-
private _getTileColor;
|
|
144
142
|
/**
|
|
145
|
-
* Hides the
|
|
143
|
+
* Hides the terrain visualization.
|
|
146
144
|
*/
|
|
147
145
|
hide(): void;
|
|
148
146
|
/**
|
|
@@ -150,6 +148,29 @@ declare class TerrainVisualizer {
|
|
|
150
148
|
* @param colors Map of role names to colors
|
|
151
149
|
*/
|
|
152
150
|
setColors(colors: Record<string, Color>): void;
|
|
151
|
+
/**
|
|
152
|
+
* Shows terrain regions using HybridImageryProvider (performant, global coverage).
|
|
153
|
+
* This replaces the entity-based approach with an imagery layer.
|
|
154
|
+
* @param alpha Transparency level (0-1), default 0.5
|
|
155
|
+
*/
|
|
156
|
+
showImageryOverlay(alpha?: number): void;
|
|
157
|
+
/**
|
|
158
|
+
* Hides the imagery overlay.
|
|
159
|
+
*/
|
|
160
|
+
hideImageryOverlay(): void;
|
|
161
|
+
/**
|
|
162
|
+
* Shows tile coordinate grid overlay.
|
|
163
|
+
*/
|
|
164
|
+
showTileCoordinates(): void;
|
|
165
|
+
/**
|
|
166
|
+
* Hides tile coordinate grid overlay.
|
|
167
|
+
*/
|
|
168
|
+
hideTileCoordinates(): void;
|
|
169
|
+
/**
|
|
170
|
+
* Sets the transparency of the imagery overlay.
|
|
171
|
+
* @param alpha Transparency level (0-1), where 0 is fully transparent and 1 is fully opaque
|
|
172
|
+
*/
|
|
173
|
+
setAlpha(alpha: number): void;
|
|
153
174
|
/**
|
|
154
175
|
* Flies the camera to focus on a rectangle.
|
|
155
176
|
* @param rectangle The rectangle to focus on.
|
|
@@ -158,26 +179,16 @@ declare class TerrainVisualizer {
|
|
|
158
179
|
flyTo(rectangle: Rectangle, options?: {
|
|
159
180
|
duration?: number;
|
|
160
181
|
}): void;
|
|
161
|
-
/**
|
|
162
|
-
|
|
163
|
-
* @returns The current view rectangle or undefined.
|
|
164
|
-
* @private
|
|
165
|
-
*/
|
|
166
|
-
private _getVisibleRectangle;
|
|
167
|
-
/** The current zoom level set on the visualizer. */
|
|
168
|
-
get level(): number;
|
|
169
|
-
/** Set zoom level on the visualizer. */
|
|
170
|
-
set level(level: number);
|
|
182
|
+
/** Whether tile coordinates are currently visible. */
|
|
183
|
+
get tileCoordinatesVisible(): boolean;
|
|
171
184
|
/** Whether the grid is currently visible. */
|
|
172
185
|
get visible(): boolean;
|
|
173
|
-
/** The collection used in the visualizer. */
|
|
174
|
-
get collection(): Collection<EntityCollection, Entity>;
|
|
175
186
|
/** The viewer used in the visualizer */
|
|
176
187
|
get viewer(): Viewer;
|
|
177
188
|
/** The colors used in the visualizer */
|
|
178
189
|
get colors(): Map<string, Color>;
|
|
179
190
|
/** The hybrid terrain instance used in the visualizer */
|
|
180
|
-
get terrainProvider(): HybridTerrainProvider
|
|
191
|
+
get terrainProvider(): HybridTerrainProvider;
|
|
181
192
|
}
|
|
182
193
|
/**
|
|
183
194
|
* @namespace
|
|
@@ -193,20 +204,8 @@ declare namespace TerrainVisualizer {
|
|
|
193
204
|
/** Initial zoom level to use for visualizations. */
|
|
194
205
|
activeLevel?: number;
|
|
195
206
|
/** Terrain provider to visualize. */
|
|
196
|
-
terrainProvider
|
|
207
|
+
terrainProvider: HybridTerrainProvider;
|
|
197
208
|
}
|
|
198
|
-
/** Tag constants for entity collection management. */
|
|
199
|
-
const tag: {
|
|
200
|
-
default: string;
|
|
201
|
-
grid: string;
|
|
202
|
-
};
|
|
203
|
-
/**
|
|
204
|
-
* Creates a ground-clamped rectangle entity for visualization.
|
|
205
|
-
* @param rectangle The rectangle to visualize
|
|
206
|
-
* @param color The color to use
|
|
207
|
-
* @returns A new entity
|
|
208
|
-
*/
|
|
209
|
-
function createRectangle(rectangle: Rectangle, color: Color): Entity;
|
|
210
209
|
/** Options for {@link TerrainVisualizer.visualize} */
|
|
211
210
|
interface Options {
|
|
212
211
|
color?: Color;
|
|
@@ -217,14 +216,6 @@ declare namespace TerrainVisualizer {
|
|
|
217
216
|
alpha?: number;
|
|
218
217
|
tileAlpha?: number;
|
|
219
218
|
}
|
|
220
|
-
/**
|
|
221
|
-
* Visualizes a terrain region in a viewer.
|
|
222
|
-
* @param region The terrain region to visualize.
|
|
223
|
-
* @param viewer The Cesium viewer.
|
|
224
|
-
* @param options Visualization options.
|
|
225
|
-
* @returns Collection of created entities.
|
|
226
|
-
*/
|
|
227
|
-
function visualize(region: HybridTerrainProvider.TerrainRegion, viewer: Viewer, options?: Options): Collection<EntityCollection, Entity>;
|
|
228
219
|
}
|
|
229
220
|
|
|
230
221
|
declare const deprecate: typeof Deprecate.deprecate;
|
package/dist/dev/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d}from"../chunk-
|
|
1
|
+
import{a,b,c,d}from"../chunk-B3AVU53O.js";import"../chunk-6ABRDFE5.js";export{a as Deprecate,b as TerrainVisualizer,d as deprecate,c as isGetterOnly};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var L=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var U=(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))!Y.call(n,r)&&r!==t&&L(n,r,{get:()=>e[r],enumerable:!(i=z(e,r))||i.enumerable});return n};var X=n=>K(L({},"__esModule",{value:!0}),n);var J={};U(J,{Collection:()=>P,Highlight:()=>M,HybridTerrainProvider:()=>E,SilhouetteHighlight:()=>_,SurfaceHighlight:()=>C,cloneViewer:()=>V,syncCamera:()=>O});module.exports=X(J);var g=require("cesium");var F;(l=>{let n=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(c,h={}){if(!e)return;let{once:v=!0,prefix:f="[DEPRECATED]",includeStack:p=!0,removeInVersion:b}=h;if(v&&n.has(c))return;let T=`${f} ${c}`;b&&(T+=` This feature will be removed in ${b}.`),typeof console<"u"&&console.warn&&(p?(console.warn(T),console.trace("Deprecation stack trace:")):console.warn(T)),v&&n.add(c)}l.warn=t;function i(c,h,v={}){let f=((...p)=>(t(h,v),c(...p)));return Object.defineProperty(f,"name",{value:c.name,configurable:!0}),f}l.deprecate=i;function r(){n.clear()}l.clear=r;function o(){return n.size}l.getWarningCount=o;function a(c){return n.has(c)}l.hasShown=a})(F||={});var j=F;var d=require("cesium");var B=require("cesium"),w=class n{_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,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(n.TerrainRegion.contains(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(n.TerrainRegion.contains(r,e,t,i)&&r.provider.getTileDataAvailable(e,t,i))return!0;return this._defaultProvider.getTileDataAvailable(e,t,i)}};(t=>{function n(i,r,o){return new t({regions:i.map(a=>({...a})),defaultProvider:r,fallbackProvider:o})}t.fromTileRanges=n;let e;(r=>{function i(o,a,l,c){if(o.levels&&!o.levels.includes(c))return!1;if(o.tiles){let h=o.tiles.get(c);if(!h)return!1;let[v,f]=Array.isArray(h.x)?h.x:[h.x,h.x],[p,b]=Array.isArray(h.y)?h.y:[h.y,h.y];return a>=v&&a<=f&&l>=p&&l<=b}return!1}r.contains=i})(e=t.TerrainRegion||={})})(w||={});var E=w;var x=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",d.Color.RED],["default",d.Color.BLUE],["fallback",d.Color.GRAY],["grid",d.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new P({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 d.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:d.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(a=>{this._collection.add(a.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(d.Rectangle.northwest(e),t),o=i.positionToTileXY(d.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=[],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 v=this._createTileEntity(c,h,t,i);v&&r.push({entity:v})}catch(v){console.warn(`Error creating tile (${c}, ${h}, ${t}):`,v)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let a=this._getTileColor(e,t,i),l=n.createRectangle(o,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")||d.Color.TRANSPARENT;for(let r of this._terrainProvider.regions)if(E.TerrainRegion.contains(r,e,t,i))return this._colors.get("custom")||d.Color.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||d.Color.BLUE:this._colors.get("fallback")||d.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",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new d.Entity({rectangle:{coordinates:r,material:o,heightReference:d.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,a){let l=a?.tag||"terrain_region_visualization",c=a?.color||d.Color.RED,h=a?.maxTilesToShow||100,v=a?.show??!0,f=a?.tileAlpha||.2,p=new P({collection:o.entities,tag:l});if(v&&r.tiles&&r.tiles.size>0){let b=r.provider.tilingScheme,T=0;r.tiles.forEach((y,W)=>{let G=Array.isArray(y.x)?y.x:[y.x,y.x],k=Array.isArray(y.y)?y.y:[y.y,y.y];for(let S=G[0];S<=G[1]&&T<h;S++)for(let R=k[0];R<=k[1]&&T<h;R++){let q=b.tileXYToRectangle(S,R,W);p.add(e(q,c.withAlpha(f)),`${l}_tile`),T++}})}return p}i.visualize=t})(x||={});function A(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 ue=j.deprecate;var I=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]()}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 tags(){return Array.from(this._tagMap.keys())}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(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}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(A(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)}_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)))}},P=I;var m=require("cesium");var u=require("cesium"),_=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)}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}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}}}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}_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)}};var s=require("cesium"),C=class{_color=s.Color.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new s.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}show(e,t){if(!(!(0,s.defined)(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof s.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof s.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}}}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}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&s.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 s.Entity){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let r;i.positions.length>0&&!s.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new s.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new s.PolygonGraphics({hierarchy:i,material:t.color,heightReference:s.HeightReference.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||s.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let r=e.polyline.width?.getValue();this._entity.polyline=new s.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=[s.Cartesian3.fromRadians(i.west,i.north),s.Cartesian3.fromRadians(i.east,i.north),s.Cartesian3.fromRadians(i.east,i.south),s.Cartesian3.fromRadians(i.west,i.south),s.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new s.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new s.RectangleGraphics({coordinates:i,material:t.color,heightReference:s.HeightReference.CLAMP_TO_GROUND}))}}else if(e instanceof s.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,a=[];for(let l=0;l<o.length;l+=3)a.push(new s.Cartesian3(o[l],o[l+1],o[l+2]));t.outline?this._entity.polyline=new s.PolylineGraphics({positions:a,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new s.PolygonGraphics({hierarchy:new s.PolygonHierarchy(a),material:t.color,heightReference:s.HeightReference.CLAMP_TO_GROUND,classificationType:s.ClassificationType.BOTH})}}};var H=class n{static instances=new WeakMap;_surface;_silhouette;_color=m.Color.RED;constructor(e){this._surface=new C(e),this._silhouette=new _(e),this._surface.color=this._color,this._silhouette.color=this._color}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}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()}},M=H;var N=require("cesium");var D=require("cesium");function O(n,e){if((0,D.defined)(n)&&(0,D.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 V(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 N.Viewer(e,{...i,...t});O(n,r);let o=n.imageryLayers;r.imageryLayers.removeAll();for(let c=0;c<o.length;c++){let h=o.get(c);r.imageryLayers.addImageryProvider(h.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 a=n.scene.screenSpaceCameraController.tiltEventTypes;a&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(a)?[...a]:a);let l=n.scene.screenSpaceCameraController.zoomEventTypes;return l&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(l)?[...l]:l),r}
|
|
1
|
+
"use strict";var w=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var B=(r,e)=>{for(var t in e)w(r,t,{get:e[t],enumerable:!0})},W=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of j(e))!F.call(r,n)&&n!==t&&w(r,n,{get:()=>e[n],enumerable:!(i=V(e,n))||i.enumerable});return r};var q=r=>W(w({},"__esModule",{value:!0}),r);var N={};B(N,{Collection:()=>O,Highlight:()=>I,HybridTerrainProvider:()=>T,SilhouetteHighlight:()=>v,SurfaceHighlight:()=>f,cloneViewer:()=>H,syncCamera:()=>C});module.exports=q(N);var m=require("cesium");var A;(u=>{let r=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(s,d={}){if(!e)return;let{once:g=!0,prefix:p="[DEPRECATED]",includeStack:y=!0,removeInVersion:b}=d;if(g&&r.has(s))return;let P=`${p} ${s}`;b&&(P+=` This feature will be removed in ${b}.`),typeof console<"u"&&console.warn&&(y?(console.warn(P),console.trace("Deprecation stack trace:")):console.warn(P)),g&&r.add(s)}u.warn=t;function i(s,d,g={}){let p=((...y)=>(t(d,g),s(...y)));return Object.defineProperty(p,"name",{value:s.name,configurable:!0}),p}u.deprecate=i;function n(){r.clear()}u.clear=n;function a(){return r.size}u.getWarningCount=a;function c(s){return r.has(s)}u.hasShown=c})(A||={});var R=A;var G=require("cesium");var D=require("cesium");var M=require("cesium"),_=class r{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new M.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,n){if(this._ready){for(let a of this._regions)if(r.TerrainRegion.contains(a,e,t,i))return a.provider.requestTileGeometry(e,t,i,n);return this._defaultProvider.getTileDataAvailable(e,t,i)?this._defaultProvider.requestTileGeometry(e,t,i,n):this._fallbackProvider.requestTileGeometry(e,t,i,n)}}getTileDataAvailable(e,t,i){for(let n of this._regions)if(r.TerrainRegion.contains(n,e,t,i)&&n.provider.getTileDataAvailable(e,t,i))return!0;return this._defaultProvider.getTileDataAvailable(e,t,i)}};(t=>{function r(i,n,a){return new t({regions:i.map(c=>({...c})),defaultProvider:n,fallbackProvider:a})}t.fromTileRanges=r;let e;(n=>{function i(a,c,u,s){if(a.levels&&!a.levels.includes(s))return!1;if(a.tiles){let d=a.tiles.get(s);if(!d)return!1;let[g,p]=Array.isArray(d.x)?d.x:[d.x,d.x],[y,b]=Array.isArray(d.y)?d.y:[d.y,d.y];return c>=g&&c<=p&&u>=y&&u<=b}return!1}n.contains=i})(e=t.TerrainRegion||={})})(_||={});var T=_;function E(r,e){let t=!1,i=Object.getOwnPropertyDescriptor(r,e);if(!i){let n=Object.getPrototypeOf(r);for(;n&&!i;)i=Object.getOwnPropertyDescriptor(n,e),n=Object.getPrototypeOf(n)}return i&&i.get&&!i.set&&(t=!0),t}var se=R.deprecate;var L=class r{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]()}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof m.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 tags(){return Array.from(this._tagMap.keys())}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(n=>{this.add(n,t)}):(Object.defineProperty(e,r.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(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}update(e,t){let i=this.get(e);for(let n of i)this._removeFromTagMap(n),Object.defineProperty(n,r.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(n,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,m.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,m.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,m.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let n=this.get(i);for(let a of n)if(e in a&&typeof a[e]!="function"){if(E(a,e))throw Error(`Cannot set read-only property '${String(e)}' on ${a.constructor.name}`);a[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((n,a)=>e(n,a))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}_emit(e,t){let i=this._eventListeners.get(e);if(i){let n={type:e,...t};i.forEach(a=>a(n))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[r.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 m.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof m.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 m.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 m.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)))}},O=L;var h=require("cesium");var l=require("cesium"),v=class{_color=l.Color.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=l.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=l.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}show(e,t){if((0,l.defined)(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{if(e instanceof l.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 l.ConstantProperty(t?.width||2),e.model.silhouetteColor=new l.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}}}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}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&l.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 l.ConstantProperty(l.Color.TRANSPARENT),this._entity.model.silhouetteSize=new l.ConstantProperty(0),this._entity=void 0)}};var o=require("cesium"),f=class{_color=o.Color.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new o.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}show(e,t){if(!(!(0,o.defined)(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof o.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof o.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}}}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}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&o.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 o.Entity){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let n;i.positions.length>0&&!o.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?n=[...i.positions,i.positions[0]]:n=i.positions,this._entity.polyline=new o.PolylineGraphics({positions:n,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new o.PolygonGraphics({hierarchy:i,material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||o.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let n=e.polyline.width?.getValue();this._entity.polyline=new o.PolylineGraphics({positions:i,material:t.color,width:n+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let n=[o.Cartesian3.fromRadians(i.west,i.north),o.Cartesian3.fromRadians(i.east,i.north),o.Cartesian3.fromRadians(i.east,i.south),o.Cartesian3.fromRadians(i.west,i.south),o.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new o.PolylineGraphics({positions:n,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new o.RectangleGraphics({coordinates:i,material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND}))}}else if(e instanceof o.GroundPrimitive){let i=e.geometryInstances,n=Array.isArray(i)?i[0]:i;if(!n.geometry.attributes.position)return;let a=n.geometry.attributes.position.values,c=[];for(let u=0;u<a.length;u+=3)c.push(new o.Cartesian3(a[u],a[u+1],a[u+2]));t.outline?this._entity.polyline=new o.PolylineGraphics({positions:c,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new o.PolygonGraphics({hierarchy:new o.PolygonHierarchy(c),material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND,classificationType:o.ClassificationType.BOTH})}}};var x=class r{static instances=new WeakMap;_surface;_silhouette;_color=h.Color.RED;constructor(e){this._surface=new f(e),this._silhouette=new v(e),this._surface.color=this._color,this._silhouette.color=this._color}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}static getInstance(e){let t=e.container;return r.instances.has(t)||r.instances.set(t,new r(e)),r.instances.get(t)}static releaseInstance(e){let t=e.container,i=r.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),r.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if((0,h.defined)(i))return i instanceof h.Cesium3DTileFeature?this._silhouette.show(i,t):i instanceof h.Entity&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if((0,h.defined)(e)){if(e instanceof h.Entity||e instanceof h.Cesium3DTileFeature||e instanceof h.GroundPrimitive)return e;if(e.id instanceof h.Entity)return e.id;if(e.primitive instanceof h.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}},I=x;var k=require("cesium");var S=require("cesium");function C(r,e){if((0,S.defined)(r)&&(0,S.defined)(e)){let{camera:t}=r;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}function H(r,e,t){let i={baseLayerPicker:r.baseLayerPicker!==void 0,geocoder:r.geocoder!==void 0,homeButton:r.homeButton!==void 0,sceneModePicker:r.sceneModePicker!==void 0,timeline:r.timeline!==void 0,navigationHelpButton:r.navigationHelpButton!==void 0,animation:r.animation!==void 0,fullscreenButton:r.fullscreenButton!==void 0,shouldAnimate:r.clock.shouldAnimate,terrainProvider:r.terrainProvider,requestRenderMode:r.scene.requestRenderMode,infoBox:r.infoBox!==void 0},n=new k.Viewer(e,{...i,...t});C(r,n);let a=r.imageryLayers;n.imageryLayers.removeAll();for(let s=0;s<a.length;s++){let d=a.get(s);n.imageryLayers.addImageryProvider(d.imageryProvider,s)}n.clock.startTime=r.clock.startTime.clone(),n.clock.stopTime=r.clock.stopTime.clone(),n.clock.currentTime=r.clock.currentTime.clone(),n.clock.multiplier=r.clock.multiplier,n.clock.clockStep=r.clock.clockStep,n.clock.clockRange=r.clock.clockRange,n.clock.shouldAnimate=r.clock.shouldAnimate,n.scene.globe.enableLighting=r.scene.globe.enableLighting,n.scene.globe.depthTestAgainstTerrain=r.scene.globe.depthTestAgainstTerrain,n.scene.screenSpaceCameraController.enableCollisionDetection=r.scene.screenSpaceCameraController.enableCollisionDetection;let c=r.scene.screenSpaceCameraController.tiltEventTypes;c&&(n.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(c)?[...c]:c);let u=r.scene.screenSpaceCameraController.zoomEventTypes;return u&&(n.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(u)?[...u]:u),n}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Collection } from './collection/index.cjs';
|
|
2
2
|
export { Highlight, SilhouetteHighlight, SurfaceHighlight } from './highlight/index.cjs';
|
|
3
3
|
export { TerrainOptions, TerrainRegion, TerrainTiles } from './terrain/index.cjs';
|
|
4
4
|
export { cloneViewer, syncCamera } from './viewer/index.cjs';
|
|
5
5
|
export { H as HybridTerrainProvider } from './hybrid-terrain-provider-CVTrsFR5.cjs';
|
|
6
6
|
import 'cesium';
|
|
7
|
+
import './type-check-B-zGL1Ne.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Collection } from './collection/index.js';
|
|
2
2
|
export { Highlight, SilhouetteHighlight, SurfaceHighlight } from './highlight/index.js';
|
|
3
3
|
export { TerrainOptions, TerrainRegion, TerrainTiles } from './terrain/index.js';
|
|
4
4
|
export { cloneViewer, syncCamera } from './viewer/index.js';
|
|
5
5
|
export { H as HybridTerrainProvider } from './hybrid-terrain-provider-CVTrsFR5.js';
|
|
6
6
|
import 'cesium';
|
|
7
|
+
import './type-check-B-zGL1Ne.js';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import{a as e}from"./chunk-WCOPDVHL.js";import"./chunk-B3AVU53O.js";import{a as i,b as o,c as t}from"./chunk-PSCNWZUR.js";import"./chunk-6I6OKECI.js";import{a as r}from"./chunk-6ABRDFE5.js";import{a as p,b as m}from"./chunk-Z2COOTT4.js";export{e as Collection,t as Highlight,r as HybridTerrainProvider,i as SilhouetteHighlight,o as SurfaceHighlight,m as cloneViewer,p as syncCamera};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime type validator to identify the non-function property.
|
|
3
|
+
*/
|
|
4
|
+
type NonFunction<T> = {
|
|
5
|
+
[K in keyof T]: T[K] extends Function ? never : K;
|
|
6
|
+
}[keyof T];
|
|
7
|
+
/**
|
|
8
|
+
* Examine the property descriptors at runtime
|
|
9
|
+
* to detect properties that only have getters.
|
|
10
|
+
* (read-only accessor properties)
|
|
11
|
+
* @param o The object to examine.
|
|
12
|
+
* @param k The key value of the property.
|
|
13
|
+
*/
|
|
14
|
+
declare function isGetterOnly(o: object, k: string | number | symbol): boolean;
|
|
15
|
+
|
|
16
|
+
export { type NonFunction as N, isGetterOnly as i };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime type validator to identify the non-function property.
|
|
3
|
+
*/
|
|
4
|
+
type NonFunction<T> = {
|
|
5
|
+
[K in keyof T]: T[K] extends Function ? never : K;
|
|
6
|
+
}[keyof T];
|
|
7
|
+
/**
|
|
8
|
+
* Examine the property descriptors at runtime
|
|
9
|
+
* to detect properties that only have getters.
|
|
10
|
+
* (read-only accessor properties)
|
|
11
|
+
* @param o The object to examine.
|
|
12
|
+
* @param k The key value of the property.
|
|
13
|
+
*/
|
|
14
|
+
declare function isGetterOnly(o: object, k: string | number | symbol): boolean;
|
|
15
|
+
|
|
16
|
+
export { type NonFunction as N, isGetterOnly as i };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juun-roh/cesium-utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "Solve common Cesium.js challenges: combine multiple terrain sources, tag and filter entity collections, and add visual highlights.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cesium",
|
|
@@ -92,31 +92,31 @@
|
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
|
-
"@changesets/cli": "^2.29.
|
|
96
|
-
"@commitlint/cli": "^20.
|
|
97
|
-
"@commitlint/config-conventional": "^20.
|
|
98
|
-
"@commitlint/cz-commitlint": "^20.
|
|
99
|
-
"@commitlint/format": "^20.
|
|
100
|
-
"@commitlint/types": "^20.
|
|
101
|
-
"@eslint/js": "^9.39.
|
|
102
|
-
"@types/node": "^24.10.
|
|
103
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
104
|
-
"@typescript-eslint/parser": "^8.
|
|
105
|
-
"@vitest/coverage-v8": "^4.0.
|
|
106
|
-
"cesium": "^1.
|
|
107
|
-
"eslint": "^9.39.
|
|
108
|
-
"eslint-plugin-jsdoc": "^61.
|
|
95
|
+
"@changesets/cli": "^2.29.8",
|
|
96
|
+
"@commitlint/cli": "^20.2.0",
|
|
97
|
+
"@commitlint/config-conventional": "^20.2.0",
|
|
98
|
+
"@commitlint/cz-commitlint": "^20.2.0",
|
|
99
|
+
"@commitlint/format": "^20.2.0",
|
|
100
|
+
"@commitlint/types": "^20.2.0",
|
|
101
|
+
"@eslint/js": "^9.39.2",
|
|
102
|
+
"@types/node": "^24.10.4",
|
|
103
|
+
"@typescript-eslint/eslint-plugin": "^8.49.0",
|
|
104
|
+
"@typescript-eslint/parser": "^8.49.0",
|
|
105
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
106
|
+
"cesium": "^1.136.0",
|
|
107
|
+
"eslint": "^9.39.2",
|
|
108
|
+
"eslint-plugin-jsdoc": "^61.5.0",
|
|
109
109
|
"eslint-plugin-prettier": "^5.5.4",
|
|
110
110
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
111
111
|
"eslint-plugin-unused-imports": "^4.3.0",
|
|
112
112
|
"husky": "^9.1.7",
|
|
113
|
-
"jsdom": "^27.
|
|
114
|
-
"rimraf": "^6.1.
|
|
113
|
+
"jsdom": "^27.3.0",
|
|
114
|
+
"rimraf": "^6.1.2",
|
|
115
115
|
"tsup": "^8.5.1",
|
|
116
|
-
"typedoc": "^0.28.
|
|
116
|
+
"typedoc": "^0.28.15",
|
|
117
117
|
"typescript": "^5.9.3",
|
|
118
|
-
"vite": "^7.2.
|
|
119
|
-
"vitest": "^4.0.
|
|
118
|
+
"vite": "^7.2.7",
|
|
119
|
+
"vitest": "^4.0.15"
|
|
120
120
|
},
|
|
121
121
|
"scripts": {
|
|
122
122
|
"build": "tsup",
|
package/dist/chunk-R4DSXQCN.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as x}from"./chunk-6ABRDFE5.js";var I;(h=>{let o=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(a,l={}){if(!e)return;let{once:c=!0,prefix:m="[DEPRECATED]",includeStack:g=!0,removeInVersion:f}=l;if(c&&o.has(a))return;let u=`${m} ${a}`;f&&(u+=` This feature will be removed in ${f}.`),typeof console<"u"&&console.warn&&(g?(console.warn(u),console.trace("Deprecation stack trace:")):console.warn(u)),c&&o.add(a)}h.warn=t;function i(a,l,c={}){let m=((...g)=>(t(l,c),a(...g)));return Object.defineProperty(m,"name",{value:a.name,configurable:!0}),m}h.deprecate=i;function r(){o.clear()}h.clear=r;function n(){return o.size}h.getWarningCount=n;function s(a){return o.has(a)}h.hasShown=s})(I||={});var P=I;import{Color as d,Entity as V,HeightReference as j,Rectangle as R,TileCoordinatesImageryProvider as G}from"cesium";import{DataSourceCollection as O,defined as _,EntityCollection as S,ImageryLayerCollection as F,PrimitiveCollection as D}from"cesium";var T=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]()}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof S)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 tags(){return Array.from(this._tagMap.keys())}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(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}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(b(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)}_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 S?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof D?(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 O?(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 F&&(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)))}},E=T;var p=class o{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",d.RED],["default",d.BLUE],["fallback",d.GRAY],["grid",d.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new E({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 G({tilingScheme:this._terrainProvider.tilingScheme,color:d.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,o.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(R.northwest(e),t),n=i.positionToTileXY(R.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=[],s=Math.min(e.end.x-e.start.x+1,100),h=Math.min(e.end.y-e.start.y+1,100);for(let a=e.start.x;a<e.start.x+s;a++)for(let l=e.start.y;l<e.start.y+h;l++)try{let c=this._createTileEntity(a,l,t,i);c&&r.push({entity:c})}catch(c){console.warn(`Error creating tile (${a}, ${l}, ${t}):`,c)}return r}_createTileEntity(e,t,i,r){let n=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(n))return null;let s=this._getTileColor(e,t,i),h=o.createRectangle(n,s.withAlpha(.3));return h.properties?.addProperty("tileX",e),h.properties?.addProperty("tileY",t),h.properties?.addProperty("tileLevel",i),h}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||d.TRANSPARENT;for(let r of this._terrainProvider.regions)if(x.TerrainRegion.contains(r,e,t,i))return this._colors.get("custom")||d.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||d.BLUE:this._colors.get("fallback")||d.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){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",grid:"Terrain Visualizer Tile Grid"};function e(r,n){return new V({rectangle:{coordinates:r,material:n,heightReference:j.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,n,s){let h=s?.tag||"terrain_region_visualization",a=s?.color||d.RED,l=s?.maxTilesToShow||100,c=s?.show??!0,m=s?.tileAlpha||.2,g=new E({collection:n.entities,tag:h});if(c&&r.tiles&&r.tiles.size>0){let f=r.provider.tilingScheme,u=0;r.tiles.forEach((v,A)=>{let w=Array.isArray(v.x)?v.x:[v.x,v.x],L=Array.isArray(v.y)?v.y:[v.y,v.y];for(let y=w[0];y<=w[1]&&u<l;y++)for(let C=L[0];C<=L[1]&&u<l;C++){let M=f.tileXYToRectangle(y,C,A);g.add(e(M,a.withAlpha(m)),`${h}_tile`),u++}})}return g}i.visualize=t})(p||={});function b(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}var te=P.deprecate;export{P as a,p as b,b as c,te as d,E as e};
|
package/dist/chunk-RXMNSDKR.js
DELETED
|
File without changes
|