@juun-roh/cesium-utils 0.1.1 → 0.1.3

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.
@@ -0,0 +1,243 @@
1
+ import { Entity, Cesium3DTileFeature, GroundPrimitive, Primitive, Model, Cesium3DTileset, Color, Viewer } from 'cesium';
2
+
3
+ interface IHighlight {
4
+ show(object: any, options?: HighlightOptions): void;
5
+ hide(): void;
6
+ destroy(): void;
7
+ color: Color;
8
+ }
9
+ interface HighlightOptions {
10
+ /** Color of the highlight */
11
+ color?: Color;
12
+ /** To apply outline style for the highlight */
13
+ outline?: boolean;
14
+ /** Outline width */
15
+ width?: number;
16
+ }
17
+ type PickedObject = {
18
+ id?: Entity;
19
+ primitive?: Primitive | GroundPrimitive | Model | Cesium3DTileset;
20
+ tileset?: Cesium3DTileset;
21
+ detail?: {
22
+ model?: Model;
23
+ };
24
+ };
25
+ type Picked = Entity | Cesium3DTileFeature | GroundPrimitive | PickedObject;
26
+
27
+ /**
28
+ * @class
29
+ * Lightweight multiton highlight manager for Cesium using flyweight pattern.
30
+ *
31
+ * @example
32
+ * ```
33
+ * // Setup
34
+ * const viewer1 = new Viewer('cesiumContainer1');
35
+ * const viewer2 = new Viewer('cesiumContainer2');
36
+ *
37
+ * const highlighter1 = Highlight.getInstance(viewer1);
38
+ * const highlighter2 = Highlight.getInstance(viewer2);
39
+ *
40
+ * // This highlight only affects viewer1
41
+ * highlighter1.show(someEntity, { color: Color.RED });
42
+ *
43
+ * // This highlight only affects viewer2
44
+ * highlighter2.show(someEntity, { color: Color.BLUE });
45
+ *
46
+ * // When done with viewers
47
+ * Highlight.releaseInstance(viewer1);
48
+ * Highlight.releaseInstance(viewer2);
49
+ * viewer1.destroy();
50
+ * viewer2.destroy();
51
+ * ```
52
+ */
53
+ declare class Highlight {
54
+ private static instances;
55
+ private _surface;
56
+ private _silhouette;
57
+ private _color;
58
+ /**
59
+ * Creates a new `Highlight` instance.
60
+ * @private Use {@link getInstance `Highlight.getInstance()`}
61
+ * @param viewer A viewer to create highlight entity in
62
+ */
63
+ private constructor();
64
+ /**
65
+ * Gets or creates highlight instance from a viewer.
66
+ * @param viewer The viewer to get or create a new instance from.
67
+ */
68
+ static getInstance(viewer: Viewer): Highlight;
69
+ /**
70
+ * Releases the highlight instance associated with a viewer.
71
+ * @param viewer The viewer whose highlight instance should be released.
72
+ */
73
+ static releaseInstance(viewer: Viewer): void;
74
+ /**
75
+ * Highlights a picked object or a direct instance.
76
+ * @param picked The result of `Scene.pick()` or direct instance to be highlighted.
77
+ * @param options Optional style for the highlight.
78
+ * @see {@link HighlightOptions}
79
+ */
80
+ show(picked: Picked, options?: HighlightOptions): void | Entity;
81
+ private _getObject;
82
+ /**
83
+ * Clears the current highlight effects.
84
+ */
85
+ hide(): void;
86
+ /** Gets the highlight color. */
87
+ get color(): Color;
88
+ /**
89
+ * Sets the highlight color.
90
+ * @param color The new color for highlights
91
+ */
92
+ set color(color: Color);
93
+ }
94
+
95
+ /**
96
+ * @class
97
+ * An implementation for highlighting 3D objects in Cesium.
98
+ *
99
+ * **Supported Object Types:**
100
+ * - `Entity` with model graphics. (adjustable outline width)
101
+ * - `Cesium3DTileset` instances. (fixed outline width)
102
+ *
103
+ * Currently supports outline style only.
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * const viewer = new Viewer("cesiumContainer");
108
+ * const silhouetteHighlight = new SilhouetteHighlight(viewer);
109
+ *
110
+ * // Highlight an object
111
+ * const entity = viewer.entities.add(new Entity({
112
+ * model: new ModelGraphics(),
113
+ * }));
114
+ * silhouetteHighlight.show(entity);
115
+ * ```
116
+ */
117
+ declare class SilhouetteHighlight implements IHighlight {
118
+ private _color;
119
+ private _silhouette;
120
+ private _composite;
121
+ private _stages;
122
+ private _entity?;
123
+ private _currentObject;
124
+ private _currentOptions;
125
+ /**
126
+ * Creates a new `Silhouette` instance.
127
+ * @param viewer A viewer to create highlight silhouette in
128
+ */
129
+ constructor(viewer: Viewer);
130
+ /**
131
+ * Highlights a picked `Cesium3DTileset` by updating silhouette composite.
132
+ * @param object The object to be highlighted.
133
+ * @param options Optional style for the highlight.
134
+ */
135
+ show(object: Cesium3DTileFeature, options?: HighlightOptions): void;
136
+ /**
137
+ * Highlights a picked `Entity` by updating the model properties.
138
+ * @param object The object to be highlighted.
139
+ * @param options Optional style for the highlight.
140
+ */
141
+ show(object: Entity, options?: HighlightOptions): void;
142
+ /**
143
+ * Compares two HighlightOptions objects for equality
144
+ * @private
145
+ */
146
+ private _optionsEqual;
147
+ /**
148
+ * Clears all current highlights
149
+ * @private
150
+ */
151
+ private _clearHighlights;
152
+ /** Clears the current highlight */
153
+ hide(): void;
154
+ /** Clean up the instances */
155
+ destroy(): void;
156
+ /** Gets the highlight color. */
157
+ get color(): Color;
158
+ /** Sets the highlight color. */
159
+ set color(color: Color);
160
+ /** Gets the currently highlighted object */
161
+ get currentObject(): Cesium3DTileFeature | Entity | undefined;
162
+ }
163
+
164
+ /**
165
+ * @class
166
+ * A flyweight implementation for highlighting 2D surface objects in Cesium.
167
+ *
168
+ * This class provides highlighting for ground-clamped geometries (polygons, polylines, rectangles)
169
+ *
170
+ * **Supported Geometry Types:**
171
+ * - `Entity` with polygon, polyline, or rectangle graphics
172
+ * - `GroundPrimitive` instances
173
+ *
174
+ * **Highlighting Modes:**
175
+ * - **Fill mode** (default): Creates a filled geometry using the original shape
176
+ * - **Outline mode**: Creates a polyline outline of the original geometry
177
+ *
178
+ * @example
179
+ * ```typescript
180
+ * // Basic usage
181
+ * const viewer = new Viewer('cesiumContainer');
182
+ * const surfaceHighlight = new SurfaceHighlight(viewer);
183
+ *
184
+ * // Highlight an entity with default red fill
185
+ * const entity = viewer.entities.add(new Entity({
186
+ * polygon: {
187
+ * hierarchy: Cartesian3.fromDegreesArray([-75, 35, -74, 35, -74, 36, -75, 36]),
188
+ * material: Color.BLUE
189
+ * }
190
+ * }));
191
+ * surfaceHighlight.show(entity);
192
+ * ```
193
+ */
194
+ declare class SurfaceHighlight implements IHighlight {
195
+ private _color;
196
+ private _entity;
197
+ private _entities;
198
+ private _currentObject;
199
+ private _currentOptions;
200
+ /**
201
+ * Creates a new `SurfaceHighlight` instance.
202
+ * @param viewer A viewer to create highlight entity in
203
+ */
204
+ constructor(viewer: Viewer);
205
+ /**
206
+ * Highlights a picked object by updating the reusable entity
207
+ * @param object The object to be highlighted.
208
+ * @param options Optional style for the highlight.
209
+ * @see {@link HighlightOptions}
210
+ */
211
+ show(object: Entity | GroundPrimitive, options?: HighlightOptions): Entity | undefined;
212
+ /**
213
+ * Compares two HighlightOptions objects for equality
214
+ * @private
215
+ */
216
+ private _optionsEqual;
217
+ /**
218
+ * Removes all geometry properties from the highlight entity
219
+ * @private
220
+ */
221
+ private _clearGeometries;
222
+ /**
223
+ * Updates the highlight entity from an Entity object
224
+ * @private
225
+ */
226
+ private _update;
227
+ /**
228
+ * Clears the current highlight
229
+ */
230
+ hide(): void;
231
+ /** Clean up the instances */
232
+ destroy(): void;
233
+ /** Gets the highlight color. */
234
+ get color(): Color;
235
+ /** Sets the highlight color. */
236
+ set color(color: Color);
237
+ /** Gets the highlight entity */
238
+ get entity(): Entity;
239
+ /** Gets the currently highlighted object */
240
+ get currentObject(): Entity | GroundPrimitive | undefined;
241
+ }
242
+
243
+ export { Highlight, type HighlightOptions, type IHighlight, type Picked, type PickedObject, SilhouetteHighlight, SurfaceHighlight };
@@ -0,0 +1 @@
1
+ import{a,b,c}from"../chunk-VMZ2PVXH.js";export{c as Highlight,a as SilhouetteHighlight,b as SurfaceHighlight};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var L=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var $=(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 U(e))!X.call(n,r)&&r!==t&&L(n,r,{get:()=>e[r],enumerable:!(i=q(e,r))||i.enumerable});return n};var J=n=>K(L({},"__esModule",{value:!0}),n);var Q={};$(Q,{Collection:()=>y,Highlight:()=>C,HybridTerrainProvider:()=>A,TerrainArea:()=>g,TerrainAreaCollection:()=>p,TerrainVisualizer:()=>v,cloneViewer:()=>k,computeRectangle:()=>w,isGetterOnly:()=>P,syncCamera:()=>R});module.exports=J(Q);var _=require("cesium");var c=require("cesium");var v=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",c.Color.RED],["default",c.Color.BLUE],["fallback",c.Color.GRAY],["grid",c.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new y({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(n.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new c.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:c.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(l=>{this._collection.add(l.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(c.Rectangle.northwest(e),t),o=i.positionToTileXY(c.Rectangle.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],l=Math.min(e.end.x-e.start.x+1,100),s=Math.min(e.end.y-e.start.y+1,100);for(let h=e.start.x;h<e.start.x+l;h++)for(let m=e.start.y;m<e.start.y+s;m++)try{let f=this._createTileEntity(h,m,t,i);f&&r.push({entity:f})}catch(f){console.warn(`Error creating tile (${h}, ${m}, ${t}):`,f)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let l=this._getTileColor(e,t,i),s=n.createRectangle(o,l.withAlpha(.3));return s.properties?.addProperty("tileX",e),s.properties?.addProperty("tileY",t),s.properties?.addProperty("tileLevel",i),s}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||c.Color.TRANSPARENT;for(let r of this._terrainProvider.terrainAreas)if(r.contains(e,t,i))return r.isCustom?this._colors.get("custom")||c.Color.RED:this._colors.get("default")||c.Color.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||c.Color.BLUE:this._colors.get("fallback")||c.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new c.Entity({rectangle:{coordinates:r,material:o,heightReference:c.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,l){let s=l?.tag||"terrain_area_visualization",h=l?.color||c.Color.RED,m=l?.maxTilesToShow||100,f=l?.show??!0,E=l?.alpha||.7,I=l?.tileAlpha||.2,S=new y({collection:o.entities,tag:s}),{rectangle:B}=r;if(S.add(i.createRectangle(B,h.withAlpha(E)),s),f&&r.tileRanges.size>0){let{tilingScheme:Y}=r.terrainProvider,O=0;r.tileRanges.forEach((x,j)=>{for(let V=x.start.x;V<=x.end.x&&O<m;V++)for(let M=x.start.y;M<=x.end.y&&O<m;M++){let W=Y.tileXYToRectangle(V,M,j);S.add(e(W,h.withAlpha(I)),`${s}_tile`),O++}})}return S}i.visualize=t})(v||={});function P(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var G=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache(){this._valuesCache=null}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})),e}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)){let r=this.collection.remove(e);return r&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),r}if(Array.isArray(e)){if(e.length===0)return!1;let r=!1;for(let o of e)this.remove(o)&&(r=!0);return r}let t=this.get(e);if(t.length===0)return!1;let i=!1;for(let r of t)this.remove(r)&&(i=!0);return i}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof _.EntityCollection)return this.collection.values;{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));return e}}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,_.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,_.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,_.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(P(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)}},y=G;var d=require("cesium");var u=require("cesium"),T=class{_color=u.Color.RED;_silhouette;_composite;_stages;_entity;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=u.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=u.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}show(e,t){if(!(!(0,u.defined)(e)||this._silhouette.selected[0]===e))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)}}hide(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new u.ConstantProperty(u.Color.TRANSPARENT),this._entity=void 0)}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite)}get color(){return this._color}set color(e){this._color=e}};var a=require("cesium"),b=class{_color=a.Color.RED;_entity;_entities;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new a.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}show(e,t){if(!(!(0,a.defined)(e)||!this._entity)){this._clearGeometries();try{if(e instanceof a.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof a.GroundPrimitive)this._update(e,t);else return;return this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i);return}}}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof a.Entity){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let r;i.positions.length>0&&!a.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new a.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new a.PolygonGraphics({hierarchy:i,material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||a.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let r=e.polyline.width?.getValue();this._entity.polyline=new a.PolylineGraphics({positions:i,material:t.color,width:r+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let r=[a.Cartesian3.fromRadians(i.west,i.north),a.Cartesian3.fromRadians(i.east,i.north),a.Cartesian3.fromRadians(i.east,i.south),a.Cartesian3.fromRadians(i.west,i.south),a.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new a.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new a.RectangleGraphics({coordinates:i,material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND}))}}else if(e instanceof a.GroundPrimitive){let i=e.geometryInstances,r=Array.isArray(i)?i[0]:i;if(!r.geometry.attributes.position)return;let o=r.geometry.attributes.position.values,l=[];for(let s=0;s<o.length;s+=3)l.push(new a.Cartesian3(o[s],o[s+1],o[s+2]));t.outline?this._entity.polyline=new a.PolylineGraphics({positions:l,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new a.PolygonGraphics({hierarchy:new a.PolygonHierarchy(l),material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND,classificationType:a.ClassificationType.BOTH})}}hide(){this._entity&&(this._entity.show=!1)}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity)}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}};var C=class n{static instances=new WeakMap;_surface;_silhouette;_color=d.Color.RED;constructor(e){this._surface=new b(e),this._silhouette=new T(e),this._surface.color=this._color,this._silhouette.color=this._color}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,i=n.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),n.instances.delete(t))}show(e,t={color:this._color}){this.hide();let i=this._getObject(e);if((0,d.defined)(i))return i instanceof d.Cesium3DTileFeature?this._silhouette.show(i,t):i instanceof d.Entity&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if((0,d.defined)(e)){if(e instanceof d.Entity||e instanceof d.Cesium3DTileFeature||e instanceof d.GroundPrimitive)return e;if(e.id instanceof d.Entity)return e.id;if(e.primitive instanceof d.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}};var F=require("cesium");var N=require("cesium");var H=require("cesium");function w(n,e){if(e.size===0)return new H.Rectangle;let t=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY,l=Array.from(e.keys()),s=Math.min(...l),h=e.get(s);if(h){let{start:m,end:f}=h,E=n.tileXYToRectangle(m.x,m.y,s),I=n.tileXYToRectangle(f.x,f.y,s);t=Math.min(E.west,t),i=Math.min(I.south,i),r=Math.max(I.east,r),o=Math.max(E.north,o)}return new H.Rectangle(t,i,r,o)}var g=class{_terrainProvider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(e){this._terrainProvider=e.terrainProvider,this._tileRanges=e.tileRanges,this._credit=e.credit||"custom",this._isCustom=e.isCustom!==void 0?e.isCustom:!0,this._rectangle=w(e.terrainProvider.tilingScheme,e.tileRanges),e.tileRanges.forEach((t,i)=>{this._terrainProvider.availability?.addAvailableTileRange(i,t.start.x,t.start.y,t.end.x,t.end.y)}),this._ready=!0}contains(e,t,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let r=this._tileRanges.get(i);return e>=r.start.x&&e<=r.end.x&&t>=r.start.y&&t<=r.end.y}requestTileGeometry(e,t,i,r){if(!(!this._ready||!this.contains(e,t,i)))return this._terrainProvider.requestTileGeometry(e,t,i,r)}getTileDataAvailable(e,t,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let r=this._tileRanges.get(i);return e>=r.start.x&&e<=r.end.x&&t>=r.start.y&&t<=r.end.y}get isCustom(){return this._isCustom}get credit(){return this._credit}get terrainProvider(){return this._terrainProvider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(e=>{async function n(t,i,r){let o=r?.credit||"custom",l=await N.CesiumTerrainProvider.fromUrl(t,{...r,credit:o});return new e({terrainProvider:l,tileRanges:i,credit:o})}e.fromUrl=n})(g||={});var p=class extends Array{add(e){if(Array.isArray(e)){for(let i of e)this.add(i);return this.length}let t;return e instanceof g?t=e:t=new g(e),this.push(t)}remove(e){if(Array.isArray(e))return e.forEach(i=>this.remove(i)),this;let t=this.indexOf(e);return t>=0&&this.splice(t,1),this}removeAll(){this.length=0}};var A=class{_terrainAreas=new p;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._terrainProvider=e.terrainProvider,this._fallbackProvider=e.fallbackProvider||new F.EllipsoidTerrainProvider,this._tilingScheme=e.terrainProvider.tilingScheme,this._terrainAreas=new p(...e.terrainAreas),this._availability=e.terrainProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get terrainAreas(){return[...this._terrainAreas]}get defaultProvider(){return this._terrainProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._terrainProvider?.credit}get errorEvent(){return this._terrainProvider.errorEvent}get hasWaterMask(){return this._terrainProvider.hasWaterMask}get hasVertexNormals(){return this._terrainProvider.hasVertexNormals}loadTileDataAvailability(e,t,i){return this._terrainProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){return this._terrainProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,i,r){if(this._ready){for(let o of this._terrainAreas)if(o.contains(e,t,i))return o.requestTileGeometry(e,t,i,r);return this._terrainProvider.getTileDataAvailable(e,t,i)?this._terrainProvider.requestTileGeometry(e,t,i,r):this._fallbackProvider.requestTileGeometry(e,t,i,r)}}getTileDataAvailable(e,t,i){for(let r of this._terrainAreas)if(r.contains(e,t,i))return r.getTileDataAvailable(e,t,i);return this._terrainProvider.getTileDataAvailable(e,t,i)}};var z=require("cesium");var D=require("cesium");function R(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 k(n,e,t){let i={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},r=new z.Viewer(e,{...i,...t});R(n,r);let o=n.imageryLayers;r.imageryLayers.removeAll();for(let h=0;h<o.length;h++){let m=o.get(h);r.imageryLayers.addImageryProvider(m.imageryProvider,h)}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 l=n.scene.screenSpaceCameraController.tiltEventTypes;l&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(l)?[...l]:l);let s=n.scene.screenSpaceCameraController.zoomEventTypes;return s&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(s)?[...s]:s),r}
1
+ "use strict";var H=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var $=(n,e)=>{for(var t in e)H(n,t,{get:e[t],enumerable:!0})},K=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of U(e))!X.call(n,r)&&r!==t&&H(n,r,{get:()=>e[r],enumerable:!(i=W(e,r))||i.enumerable});return n};var J=n=>K(H({},"__esModule",{value:!0}),n);var Q={};$(Q,{Collection:()=>C,Highlight:()=>b,HybridTerrainProvider:()=>E,SilhouetteHighlight:()=>_,SurfaceHighlight:()=>y,TerrainArea:()=>v,TerrainAreaCollection:()=>p,TerrainVisualizer:()=>T,cloneViewer:()=>k,computeRectangle:()=>w,isGetterOnly:()=>P,syncCamera:()=>A});module.exports=J(Q);var m=require("cesium");var h=require("cesium");var T=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",h.Color.RED],["default",h.Color.BLUE],["fallback",h.Color.GRAY],["grid",h.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new C({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(n.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new h.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:h.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(l=>{this._collection.add(l.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(h.Rectangle.northwest(e),t),a=i.positionToTileXY(h.Rectangle.southeast(e),t);if(!r||!a)throw new Error("Failed to calculate tile bounds");return{start:r,end:a}}_generateVisibleTiles(e,t,i){let r=[],l=Math.min(e.end.x-e.start.x+1,100),s=Math.min(e.end.y-e.start.y+1,100);for(let d=e.start.x;d<e.start.x+l;d++)for(let g=e.start.y;g<e.start.y+s;g++)try{let f=this._createTileEntity(d,g,t,i);f&&r.push({entity:f})}catch(f){console.warn(`Error creating tile (${d}, ${g}, ${t}):`,f)}return r}_createTileEntity(e,t,i,r){let a=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(a))return null;let l=this._getTileColor(e,t,i),s=n.createRectangle(a,l.withAlpha(.3));return s.properties?.addProperty("tileX",e),s.properties?.addProperty("tileY",t),s.properties?.addProperty("tileLevel",i),s}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||h.Color.TRANSPARENT;for(let r of this._terrainProvider.terrainAreas)if(r.contains(e,t,i))return r.isCustom?this._colors.get("custom")||h.Color.RED:this._colors.get("default")||h.Color.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||h.Color.BLUE:this._colors.get("fallback")||h.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){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,a){return new h.Entity({rectangle:{coordinates:r,material:a,heightReference:h.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,a,l){let s=l?.tag||"terrain_area_visualization",d=l?.color||h.Color.RED,g=l?.maxTilesToShow||100,f=l?.show??!0,R=l?.alpha||.7,O=l?.tileAlpha||.2,I=new C({collection:a.entities,tag:s}),{rectangle:q}=r;if(I.add(i.createRectangle(q,d.withAlpha(R)),s),f&&r.tileRanges.size>0){let{tilingScheme:z}=r.terrainProvider,x=0;r.tileRanges.forEach((S,B)=>{for(let L=S.start.x;L<=S.end.x&&x<g;L++)for(let M=S.start.y;M<=S.end.y&&x<g;M++){let Y=z.tileXYToRectangle(L,M,B);I.add(e(Y,d.withAlpha(O)),`${s}_tile`),x++}})}return I}i.visualize=t})(T||={});function P(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 V=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(a=>a(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 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)))}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof 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(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,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 r=this.get(i);for(let a of r)if(e in a&&typeof a[e]!="function"){if(P(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((r,a)=>e(r,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)}},C=V;var u=require("cesium");var c=require("cesium"),_=class{_color=c.Color.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=c.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=c.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}show(e,t){if((0,c.defined)(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{if(e instanceof c.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 c.ConstantProperty(t?.width||2),e.model.silhouetteColor=new c.ConstantProperty(t?.color||this._color)}this._currentObject=e,this._currentOptions=t?{...t}:void 0}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0}}}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&c.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 c.ConstantProperty(c.Color.TRANSPARENT),this._entity.model.silhouetteSize=new c.ConstantProperty(0),this._entity=void 0)}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}};var o=require("cesium"),y=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}))}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}}}_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 r;i.positions.length>0&&!o.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new o.PolylineGraphics({positions:r,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 r=e.polyline.width?.getValue();this._entity.polyline=new o.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=[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:r,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,r=Array.isArray(i)?i[0]:i;if(!r.geometry.attributes.position)return;let a=r.geometry.attributes.position.values,l=[];for(let s=0;s<a.length;s+=3)l.push(new o.Cartesian3(a[s],a[s+1],a[s+2]));t.outline?this._entity.polyline=new o.PolylineGraphics({positions:l,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new o.PolygonGraphics({hierarchy:new o.PolygonHierarchy(l),material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND,classificationType:o.ClassificationType.BOTH})}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}};var b=class n{static instances=new WeakMap;_surface;_silhouette;_color=u.Color.RED;constructor(e){this._surface=new y(e),this._silhouette=new _(e),this._surface.color=this._color,this._silhouette.color=this._color}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,i=n.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),n.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if((0,u.defined)(i))return i instanceof u.Cesium3DTileFeature?this._silhouette.show(i,t):i instanceof u.Entity&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if((0,u.defined)(e)){if(e instanceof u.Entity||e instanceof u.Cesium3DTileFeature||e instanceof u.GroundPrimitive)return e;if(e.id instanceof u.Entity)return e.id;if(e.primitive instanceof u.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}};var N=require("cesium");var F=require("cesium");var G=require("cesium");function w(n,e){if(e.size===0)return new G.Rectangle;let t=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY,l=Array.from(e.keys()),s=Math.min(...l),d=e.get(s);if(d){let{start:g,end:f}=d,R=n.tileXYToRectangle(g.x,g.y,s),O=n.tileXYToRectangle(f.x,f.y,s);t=Math.min(R.west,t),i=Math.min(O.south,i),r=Math.max(O.east,r),a=Math.max(R.north,a)}return new G.Rectangle(t,i,r,a)}var v=class{_terrainProvider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(e){this._terrainProvider=e.terrainProvider,this._tileRanges=e.tileRanges,this._credit=e.credit||"custom",this._isCustom=e.isCustom!==void 0?e.isCustom:!0,this._rectangle=w(e.terrainProvider.tilingScheme,e.tileRanges),e.tileRanges.forEach((t,i)=>{this._terrainProvider.availability?.addAvailableTileRange(i,t.start.x,t.start.y,t.end.x,t.end.y)}),this._ready=!0}contains(e,t,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let r=this._tileRanges.get(i);return e>=r.start.x&&e<=r.end.x&&t>=r.start.y&&t<=r.end.y}requestTileGeometry(e,t,i,r){if(!(!this._ready||!this.contains(e,t,i)))return this._terrainProvider.requestTileGeometry(e,t,i,r)}getTileDataAvailable(e,t,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let r=this._tileRanges.get(i);return e>=r.start.x&&e<=r.end.x&&t>=r.start.y&&t<=r.end.y}get isCustom(){return this._isCustom}get credit(){return this._credit}get terrainProvider(){return this._terrainProvider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(e=>{async function n(t,i,r){let a=r?.credit||"custom",l=await F.CesiumTerrainProvider.fromUrl(t,{...r,credit:a});return new e({terrainProvider:l,tileRanges:i,credit:a})}e.fromUrl=n})(v||={});var p=class extends Array{add(e){if(Array.isArray(e)){for(let i of e)this.add(i);return this}let t;return e instanceof v?t=e:t=new v(e),this.push(t),this}remove(e){if(Array.isArray(e))return e.forEach(i=>this.remove(i)),this;let t=this.indexOf(e);return t>=0&&this.splice(t,1),this}removeAll(){this.length=0}};var E=class{_terrainAreas=new p;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._terrainProvider=e.terrainProvider,this._fallbackProvider=e.fallbackProvider||new N.EllipsoidTerrainProvider,this._tilingScheme=e.terrainProvider.tilingScheme,this._terrainAreas=new p(...e.terrainAreas),this._availability=e.terrainProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get terrainAreas(){return[...this._terrainAreas]}get defaultProvider(){return this._terrainProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._terrainProvider?.credit}get errorEvent(){return this._terrainProvider.errorEvent}get hasWaterMask(){return this._terrainProvider.hasWaterMask}get hasVertexNormals(){return this._terrainProvider.hasVertexNormals}loadTileDataAvailability(e,t,i){return this._terrainProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){return this._terrainProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,i,r){if(this._ready){for(let a of this._terrainAreas)if(a.contains(e,t,i))return a.requestTileGeometry(e,t,i,r);return this._terrainProvider.getTileDataAvailable(e,t,i)?this._terrainProvider.requestTileGeometry(e,t,i,r):this._fallbackProvider.requestTileGeometry(e,t,i,r)}}getTileDataAvailable(e,t,i){for(let r of this._terrainAreas)if(r.contains(e,t,i))return r.getTileDataAvailable(e,t,i);return this._terrainProvider.getTileDataAvailable(e,t,i)}};var j=require("cesium");var D=require("cesium");function A(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 k(n,e,t){let i={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},r=new j.Viewer(e,{...i,...t});A(n,r);let a=n.imageryLayers;r.imageryLayers.removeAll();for(let d=0;d<a.length;d++){let g=a.get(d);r.imageryLayers.addImageryProvider(g.imageryProvider,d)}r.clock.startTime=n.clock.startTime.clone(),r.clock.stopTime=n.clock.stopTime.clone(),r.clock.currentTime=n.clock.currentTime.clone(),r.clock.multiplier=n.clock.multiplier,r.clock.clockStep=n.clock.clockStep,r.clock.clockRange=n.clock.clockRange,r.clock.shouldAnimate=n.clock.shouldAnimate,r.scene.globe.enableLighting=n.scene.globe.enableLighting,r.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,r.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let l=n.scene.screenSpaceCameraController.tiltEventTypes;l&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(l)?[...l]:l);let s=n.scene.screenSpaceCameraController.zoomEventTypes;return s&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(s)?[...s]:s),r}
package/dist/index.d.cts CHANGED
@@ -1,100 +1,7 @@
1
1
  export { CesiumCollection, CesiumCollectionItem, Collection, CollectionEventType, EventHandler, NonFunction, Tag, WithTag } from './collection/index.cjs';
2
- import { Entity, Cesium3DTileFeature, GroundPrimitive, Primitive, Model, Cesium3DTileset, Color, Viewer } from 'cesium';
2
+ export { Highlight, HighlightOptions, IHighlight, Picked, PickedObject, SilhouetteHighlight, SurfaceHighlight } from './highlight/index.cjs';
3
3
  export { H as HybridTerrainProvider, T as TerrainArea, a as TileRange } from './hybrid-terrain-provider-C4b9z5pv.cjs';
4
4
  export { TerrainAreaCollection, computeRectangle } from './terrain/index.cjs';
5
5
  export { TerrainVisualizer, isGetterOnly } from './utils/index.cjs';
6
6
  export { cloneViewer, syncCamera } from './viewer/index.cjs';
7
-
8
- interface IHighlight {
9
- show(object: any, options?: HighlightOptions): void;
10
- hide(): void;
11
- destroy(): void;
12
- color: Color;
13
- }
14
- interface HighlightOptions {
15
- /** Color of the highlight */
16
- color?: Color;
17
- /** To apply outline style for the highlight */
18
- outline?: boolean;
19
- /** Outline width */
20
- width?: number;
21
- }
22
- type PickedObject = {
23
- id?: Entity;
24
- primitive?: Primitive | GroundPrimitive | Model | Cesium3DTileset;
25
- tileset?: Cesium3DTileset;
26
- detail?: {
27
- model?: Model;
28
- };
29
- };
30
- type Picked = Entity | Cesium3DTileFeature | GroundPrimitive | PickedObject;
31
-
32
- /**
33
- * @class
34
- * Lightweight multiton highlight manager for Cesium using flyweight pattern.
35
- *
36
- * @example
37
- * ```
38
- * // Setup
39
- * const viewer1 = new Viewer('cesiumContainer1');
40
- * const viewer2 = new Viewer('cesiumContainer2');
41
- *
42
- * const highlighter1 = Highlight.getInstance(viewer1);
43
- * const highlighter2 = Highlight.getInstance(viewer2);
44
- *
45
- * // This highlight only affects viewer1
46
- * highlighter1.show(someEntity, { color: Color.RED });
47
- *
48
- * // This highlight only affects viewer2
49
- * highlighter2.show(someEntity, { color: Color.BLUE });
50
- *
51
- * // When done with viewers
52
- * Highlight.releaseInstance(viewer1);
53
- * Highlight.releaseInstance(viewer2);
54
- * viewer1.destroy();
55
- * viewer2.destroy();
56
- * ```
57
- */
58
- declare class Highlight {
59
- private static instances;
60
- private _surface;
61
- private _silhouette;
62
- private _color;
63
- /**
64
- * Creates a new `Highlight` instance.
65
- * @private Use {@link getInstance `Highlight.getInstance()`}
66
- * @param viewer A viewer to create highlight entity in
67
- */
68
- private constructor();
69
- /**
70
- * Gets or creates highlight instance from a viewer.
71
- * @param viewer The viewer to get or create a new instance from.
72
- */
73
- static getInstance(viewer: Viewer): Highlight;
74
- /**
75
- * Releases the highlight instance associated with a viewer.
76
- * @param viewer The viewer whose highlight instance should be released.
77
- */
78
- static releaseInstance(viewer: Viewer): void;
79
- /**
80
- * Highlights a picked object or a direct instance.
81
- * @param picked The result of `Scene.pick()` or direct instance to be highlighted.
82
- * @param options Optional style for the highlight.
83
- * @see {@link HighlightOptions}
84
- */
85
- show(picked: Picked, options?: HighlightOptions): void | Entity;
86
- private _getObject;
87
- /**
88
- * Clears the current highlight effects.
89
- */
90
- hide(): void;
91
- /** Gets the highlight color. */
92
- get color(): Color;
93
- /**
94
- * Sets the highlight color.
95
- * @param color The new color for highlights
96
- */
97
- set color(color: Color);
98
- }
99
-
100
- export { Highlight, type HighlightOptions, type IHighlight, type Picked, type PickedObject };
7
+ import 'cesium';
package/dist/index.d.ts CHANGED
@@ -1,100 +1,7 @@
1
1
  export { CesiumCollection, CesiumCollectionItem, Collection, CollectionEventType, EventHandler, NonFunction, Tag, WithTag } from './collection/index.js';
2
- import { Entity, Cesium3DTileFeature, GroundPrimitive, Primitive, Model, Cesium3DTileset, Color, Viewer } from 'cesium';
2
+ export { Highlight, HighlightOptions, IHighlight, Picked, PickedObject, SilhouetteHighlight, SurfaceHighlight } from './highlight/index.js';
3
3
  export { H as HybridTerrainProvider, T as TerrainArea, a as TileRange } from './hybrid-terrain-provider-C4b9z5pv.js';
4
4
  export { TerrainAreaCollection, computeRectangle } from './terrain/index.js';
5
5
  export { TerrainVisualizer, isGetterOnly } from './utils/index.js';
6
6
  export { cloneViewer, syncCamera } from './viewer/index.js';
7
-
8
- interface IHighlight {
9
- show(object: any, options?: HighlightOptions): void;
10
- hide(): void;
11
- destroy(): void;
12
- color: Color;
13
- }
14
- interface HighlightOptions {
15
- /** Color of the highlight */
16
- color?: Color;
17
- /** To apply outline style for the highlight */
18
- outline?: boolean;
19
- /** Outline width */
20
- width?: number;
21
- }
22
- type PickedObject = {
23
- id?: Entity;
24
- primitive?: Primitive | GroundPrimitive | Model | Cesium3DTileset;
25
- tileset?: Cesium3DTileset;
26
- detail?: {
27
- model?: Model;
28
- };
29
- };
30
- type Picked = Entity | Cesium3DTileFeature | GroundPrimitive | PickedObject;
31
-
32
- /**
33
- * @class
34
- * Lightweight multiton highlight manager for Cesium using flyweight pattern.
35
- *
36
- * @example
37
- * ```
38
- * // Setup
39
- * const viewer1 = new Viewer('cesiumContainer1');
40
- * const viewer2 = new Viewer('cesiumContainer2');
41
- *
42
- * const highlighter1 = Highlight.getInstance(viewer1);
43
- * const highlighter2 = Highlight.getInstance(viewer2);
44
- *
45
- * // This highlight only affects viewer1
46
- * highlighter1.show(someEntity, { color: Color.RED });
47
- *
48
- * // This highlight only affects viewer2
49
- * highlighter2.show(someEntity, { color: Color.BLUE });
50
- *
51
- * // When done with viewers
52
- * Highlight.releaseInstance(viewer1);
53
- * Highlight.releaseInstance(viewer2);
54
- * viewer1.destroy();
55
- * viewer2.destroy();
56
- * ```
57
- */
58
- declare class Highlight {
59
- private static instances;
60
- private _surface;
61
- private _silhouette;
62
- private _color;
63
- /**
64
- * Creates a new `Highlight` instance.
65
- * @private Use {@link getInstance `Highlight.getInstance()`}
66
- * @param viewer A viewer to create highlight entity in
67
- */
68
- private constructor();
69
- /**
70
- * Gets or creates highlight instance from a viewer.
71
- * @param viewer The viewer to get or create a new instance from.
72
- */
73
- static getInstance(viewer: Viewer): Highlight;
74
- /**
75
- * Releases the highlight instance associated with a viewer.
76
- * @param viewer The viewer whose highlight instance should be released.
77
- */
78
- static releaseInstance(viewer: Viewer): void;
79
- /**
80
- * Highlights a picked object or a direct instance.
81
- * @param picked The result of `Scene.pick()` or direct instance to be highlighted.
82
- * @param options Optional style for the highlight.
83
- * @see {@link HighlightOptions}
84
- */
85
- show(picked: Picked, options?: HighlightOptions): void | Entity;
86
- private _getObject;
87
- /**
88
- * Clears the current highlight effects.
89
- */
90
- hide(): void;
91
- /** Gets the highlight color. */
92
- get color(): Color;
93
- /**
94
- * Sets the highlight color.
95
- * @param color The new color for highlights
96
- */
97
- set color(color: Color);
98
- }
99
-
100
- export { Highlight, type HighlightOptions, type IHighlight, type Picked, type PickedObject };
7
+ import 'cesium';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-RXMNSDKR.js";import{a as R,b as S,c as V,d as D}from"./chunk-D2H7O3WV.js";import{a as x,b as A}from"./chunk-2JNRK7SN.js";import{a as E,b as O,c as G}from"./chunk-YHYFSR66.js";import{Cesium3DTileFeature as P,Color as z,defined as H,Entity as y,GroundPrimitive as T}from"cesium";import{Cesium3DTileFeature as I,Color as _,ConstantProperty as p,defined as F,PostProcessStageLibrary as m}from"cesium";var n=class{_color=_.RED;_silhouette;_composite;_stages;_entity;constructor(t){this._stages=t.scene.postProcessStages,this._silhouette=m.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=m.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}show(t,i){if(!(!F(t)||this._silhouette.selected[0]===t))if(t instanceof I)this._silhouette.uniforms.color=i?.color||this._color,this._silhouette.selected.push(t);else{if(!t.model)return;this._entity=t,t.model.silhouetteSize=new p(i?.width||2),t.model.silhouetteColor=new p(i?.color||this._color)}}hide(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new p(_.TRANSPARENT),this._entity=void 0)}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite)}get color(){return this._color}set color(t){this._color=t}};import{Cartesian3 as r,ClassificationType as w,Color as M,defined as N,Entity as f,GroundPrimitive as v,HeightReference as d,PolygonGraphics as C,PolygonHierarchy as L,PolylineGraphics as u,RectangleGraphics as U}from"cesium";var l=class{_color=M.RED;_entity;_entities;constructor(t){this._entities=t.entities,this._entity=this._entities.add(new f({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}show(t,i){if(!(!N(t)||!this._entity)){this._clearGeometries();try{if(t instanceof f&&(t.polygon||t.polyline||t.rectangle))this._update(t,i);else if(t instanceof v)this._update(t,i);else return;return this._entity.show=!0,this._entity}catch(e){console.error("Failed to highlight object:",e);return}}}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(t,i={color:this._color,outline:!1,width:2}){if(t instanceof f){if(t.polygon)if(i.outline){let e=t.polygon.hierarchy?.getValue();if(e&&e.positions){let o;e.positions.length>0&&!r.equals(e.positions[0],e.positions[e.positions.length-1])?o=[...e.positions,e.positions[0]]:o=e.positions,this._entity.polyline=new u({positions:o,material:i.color,width:i.width||2,clampToGround:!0})}}else{let e=t.polygon.hierarchy?.getValue();e&&(this._entity.polygon=new C({hierarchy:e,material:i.color,heightReference:d.CLAMP_TO_GROUND,classificationType:t.polygon.classificationType?.getValue()||w.BOTH}))}else if(t.polyline){let e=t.polyline.positions?.getValue();if(e){let o=t.polyline.width?.getValue();this._entity.polyline=new u({positions:e,material:i.color,width:o+(i.width||2),clampToGround:!0})}}else if(t.rectangle)if(i.outline){let e=t.rectangle.coordinates?.getValue();if(e){let o=[r.fromRadians(e.west,e.north),r.fromRadians(e.east,e.north),r.fromRadians(e.east,e.south),r.fromRadians(e.west,e.south),r.fromRadians(e.west,e.north)];this._entity.polyline=new u({positions:o,material:i.color,width:i.width||2,clampToGround:!0})}}else{let e=t.rectangle.coordinates?.getValue();e&&(this._entity.rectangle=new U({coordinates:e,material:i.color,heightReference:d.CLAMP_TO_GROUND}))}}else if(t instanceof v){let e=t.geometryInstances,o=Array.isArray(e)?e[0]:e;if(!o.geometry.attributes.position)return;let c=o.geometry.attributes.position.values,g=[];for(let h=0;h<c.length;h+=3)g.push(new r(c[h],c[h+1],c[h+2]));i.outline?this._entity.polyline=new u({positions:g,material:i.color,width:i.width||2,clampToGround:!0}):this._entity.polygon=new C({hierarchy:new L(g),material:i.color,heightReference:d.CLAMP_TO_GROUND,classificationType:w.BOTH})}}hide(){this._entity&&(this._entity.show=!1)}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity)}get color(){return this._color}set color(t){this._color=t}get entity(){return this._entity}};var a=class s{static instances=new WeakMap;_surface;_silhouette;_color=z.RED;constructor(t){this._surface=new l(t),this._silhouette=new n(t),this._surface.color=this._color,this._silhouette.color=this._color}static getInstance(t){let i=t.container;return s.instances.has(i)||s.instances.set(i,new s(t)),s.instances.get(i)}static releaseInstance(t){let i=t.container,e=s.instances.get(i);e&&(e.hide(),e._surface&&e._surface.destroy(),e._silhouette&&e._silhouette.destroy(),s.instances.delete(i))}show(t,i={color:this._color}){this.hide();let e=this._getObject(t);if(H(e))return e instanceof P?this._silhouette.show(e,i):e instanceof y&&e.model?this._silhouette.show(e,i):this._surface.show(e,i)}_getObject(t){if(H(t)){if(t instanceof y||t instanceof P||t instanceof T)return t;if(t.id instanceof y)return t.id;if(t.primitive instanceof T)return t.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}get color(){return this._color}set color(t){this._color=t,this._surface.color=t,this._silhouette.color=t}};export{G as Collection,a as Highlight,D as HybridTerrainProvider,S as TerrainArea,V as TerrainAreaCollection,E as TerrainVisualizer,A as cloneViewer,R as computeRectangle,O as isGetterOnly,x as syncCamera};
1
+ import"./chunk-RXMNSDKR.js";import{a as i,b as o,c as l}from"./chunk-VMZ2PVXH.js";import{a as p,b as m,c as n,d as a}from"./chunk-4EI5BBVR.js";import{a as r,b as e,c as t}from"./chunk-ZV7FKRP6.js";import{a as h,b as c}from"./chunk-2JNRK7SN.js";export{t as Collection,l as Highlight,a as HybridTerrainProvider,i as SilhouetteHighlight,o as SurfaceHighlight,m as TerrainArea,n as TerrainAreaCollection,r as TerrainVisualizer,c as cloneViewer,p as computeRectangle,e as isGetterOnly,h as syncCamera};
@@ -1 +1 @@
1
- "use strict";var c=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var R=(a,r)=>{for(var e in r)c(a,e,{get:r[e],enumerable:!0})},C=(a,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of p(r))!y.call(a,t)&&t!==e&&c(a,t,{get:()=>r[t],enumerable:!(i=A(r,t))||i.enumerable});return a};var x=a=>C(c({},"__esModule",{value:!0}),a);var I={};R(I,{HybridTerrainProvider:()=>d,TerrainArea:()=>o,TerrainAreaCollection:()=>s,computeRectangle:()=>u});module.exports=x(I);var P=require("cesium");var _=require("cesium");var h=require("cesium");function u(a,r){if(r.size===0)return new h.Rectangle;let e=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY,m=Array.from(r.keys()),l=Math.min(...m),v=r.get(l);if(v){let{start:T,end:g}=v,b=a.tileXYToRectangle(T.x,T.y,l),f=a.tileXYToRectangle(g.x,g.y,l);e=Math.min(b.west,e),i=Math.min(f.south,i),t=Math.max(f.east,t),n=Math.max(b.north,n)}return new h.Rectangle(e,i,t,n)}var o=class{_terrainProvider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(r){this._terrainProvider=r.terrainProvider,this._tileRanges=r.tileRanges,this._credit=r.credit||"custom",this._isCustom=r.isCustom!==void 0?r.isCustom:!0,this._rectangle=u(r.terrainProvider.tilingScheme,r.tileRanges),r.tileRanges.forEach((e,i)=>{this._terrainProvider.availability?.addAvailableTileRange(i,e.start.x,e.start.y,e.end.x,e.end.y)}),this._ready=!0}contains(r,e,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let t=this._tileRanges.get(i);return r>=t.start.x&&r<=t.end.x&&e>=t.start.y&&e<=t.end.y}requestTileGeometry(r,e,i,t){if(!(!this._ready||!this.contains(r,e,i)))return this._terrainProvider.requestTileGeometry(r,e,i,t)}getTileDataAvailable(r,e,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let t=this._tileRanges.get(i);return r>=t.start.x&&r<=t.end.x&&e>=t.start.y&&e<=t.end.y}get isCustom(){return this._isCustom}get credit(){return this._credit}get terrainProvider(){return this._terrainProvider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(r=>{async function a(e,i,t){let n=t?.credit||"custom",m=await _.CesiumTerrainProvider.fromUrl(e,{...t,credit:n});return new r({terrainProvider:m,tileRanges:i,credit:n})}r.fromUrl=a})(o||={});var s=class extends Array{add(r){if(Array.isArray(r)){for(let i of r)this.add(i);return this.length}let e;return r instanceof o?e=r:e=new o(r),this.push(e)}remove(r){if(Array.isArray(r))return r.forEach(i=>this.remove(i)),this;let e=this.indexOf(r);return e>=0&&this.splice(e,1),this}removeAll(){this.length=0}};var d=class{_terrainAreas=new s;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(r){this._terrainProvider=r.terrainProvider,this._fallbackProvider=r.fallbackProvider||new P.EllipsoidTerrainProvider,this._tilingScheme=r.terrainProvider.tilingScheme,this._terrainAreas=new s(...r.terrainAreas),this._availability=r.terrainProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get terrainAreas(){return[...this._terrainAreas]}get defaultProvider(){return this._terrainProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._terrainProvider?.credit}get errorEvent(){return this._terrainProvider.errorEvent}get hasWaterMask(){return this._terrainProvider.hasWaterMask}get hasVertexNormals(){return this._terrainProvider.hasVertexNormals}loadTileDataAvailability(r,e,i){return this._terrainProvider.loadTileDataAvailability(r,e,i)}getLevelMaximumGeometricError(r){return this._terrainProvider.getLevelMaximumGeometricError(r)}requestTileGeometry(r,e,i,t){if(this._ready){for(let n of this._terrainAreas)if(n.contains(r,e,i))return n.requestTileGeometry(r,e,i,t);return this._terrainProvider.getTileDataAvailable(r,e,i)?this._terrainProvider.requestTileGeometry(r,e,i,t):this._fallbackProvider.requestTileGeometry(r,e,i,t)}}getTileDataAvailable(r,e,i){for(let t of this._terrainAreas)if(t.contains(r,e,i))return t.getTileDataAvailable(r,e,i);return this._terrainProvider.getTileDataAvailable(r,e,i)}};
1
+ "use strict";var c=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var R=(a,r)=>{for(var e in r)c(a,e,{get:r[e],enumerable:!0})},C=(a,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of p(r))!y.call(a,t)&&t!==e&&c(a,t,{get:()=>r[t],enumerable:!(i=A(r,t))||i.enumerable});return a};var x=a=>C(c({},"__esModule",{value:!0}),a);var I={};R(I,{HybridTerrainProvider:()=>u,TerrainArea:()=>o,TerrainAreaCollection:()=>s,computeRectangle:()=>d});module.exports=x(I);var P=require("cesium");var _=require("cesium");var h=require("cesium");function d(a,r){if(r.size===0)return new h.Rectangle;let e=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY,m=Array.from(r.keys()),l=Math.min(...m),v=r.get(l);if(v){let{start:T,end:g}=v,f=a.tileXYToRectangle(T.x,T.y,l),b=a.tileXYToRectangle(g.x,g.y,l);e=Math.min(f.west,e),i=Math.min(b.south,i),t=Math.max(b.east,t),n=Math.max(f.north,n)}return new h.Rectangle(e,i,t,n)}var o=class{_terrainProvider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(r){this._terrainProvider=r.terrainProvider,this._tileRanges=r.tileRanges,this._credit=r.credit||"custom",this._isCustom=r.isCustom!==void 0?r.isCustom:!0,this._rectangle=d(r.terrainProvider.tilingScheme,r.tileRanges),r.tileRanges.forEach((e,i)=>{this._terrainProvider.availability?.addAvailableTileRange(i,e.start.x,e.start.y,e.end.x,e.end.y)}),this._ready=!0}contains(r,e,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let t=this._tileRanges.get(i);return r>=t.start.x&&r<=t.end.x&&e>=t.start.y&&e<=t.end.y}requestTileGeometry(r,e,i,t){if(!(!this._ready||!this.contains(r,e,i)))return this._terrainProvider.requestTileGeometry(r,e,i,t)}getTileDataAvailable(r,e,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let t=this._tileRanges.get(i);return r>=t.start.x&&r<=t.end.x&&e>=t.start.y&&e<=t.end.y}get isCustom(){return this._isCustom}get credit(){return this._credit}get terrainProvider(){return this._terrainProvider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(r=>{async function a(e,i,t){let n=t?.credit||"custom",m=await _.CesiumTerrainProvider.fromUrl(e,{...t,credit:n});return new r({terrainProvider:m,tileRanges:i,credit:n})}r.fromUrl=a})(o||={});var s=class extends Array{add(r){if(Array.isArray(r)){for(let i of r)this.add(i);return this}let e;return r instanceof o?e=r:e=new o(r),this.push(e),this}remove(r){if(Array.isArray(r))return r.forEach(i=>this.remove(i)),this;let e=this.indexOf(r);return e>=0&&this.splice(e,1),this}removeAll(){this.length=0}};var u=class{_terrainAreas=new s;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(r){this._terrainProvider=r.terrainProvider,this._fallbackProvider=r.fallbackProvider||new P.EllipsoidTerrainProvider,this._tilingScheme=r.terrainProvider.tilingScheme,this._terrainAreas=new s(...r.terrainAreas),this._availability=r.terrainProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get terrainAreas(){return[...this._terrainAreas]}get defaultProvider(){return this._terrainProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._terrainProvider?.credit}get errorEvent(){return this._terrainProvider.errorEvent}get hasWaterMask(){return this._terrainProvider.hasWaterMask}get hasVertexNormals(){return this._terrainProvider.hasVertexNormals}loadTileDataAvailability(r,e,i){return this._terrainProvider.loadTileDataAvailability(r,e,i)}getLevelMaximumGeometricError(r){return this._terrainProvider.getLevelMaximumGeometricError(r)}requestTileGeometry(r,e,i,t){if(this._ready){for(let n of this._terrainAreas)if(n.contains(r,e,i))return n.requestTileGeometry(r,e,i,t);return this._terrainProvider.getTileDataAvailable(r,e,i)?this._terrainProvider.requestTileGeometry(r,e,i,t):this._fallbackProvider.requestTileGeometry(r,e,i,t)}}getTileDataAvailable(r,e,i){for(let t of this._terrainAreas)if(t.contains(r,e,i))return t.getTileDataAvailable(r,e,i);return this._terrainProvider.getTileDataAvailable(r,e,i)}};
@@ -20,13 +20,13 @@ declare class TerrainAreaCollection extends Array<TerrainArea> {
20
20
  * @param area A TerrainArea instance or constructor options
21
21
  * @returns The index of the added item
22
22
  */
23
- add(area: TerrainArea | TerrainArea.ConstructorOptions): number;
23
+ add(area: TerrainArea | TerrainArea.ConstructorOptions): this;
24
24
  /**
25
25
  * Adds terrain areas to the collection.
26
26
  * @param areas An array of TerrainArea instance or constructor options
27
27
  * @returns The index of the added item
28
28
  */
29
- add(areas: (TerrainArea | TerrainArea.ConstructorOptions)[]): number;
29
+ add(areas: (TerrainArea | TerrainArea.ConstructorOptions)[]): this;
30
30
  /**
31
31
  * Removes a terrain area from the collection.
32
32
  * @param area The terrain area to remove.
@@ -20,13 +20,13 @@ declare class TerrainAreaCollection extends Array<TerrainArea> {
20
20
  * @param area A TerrainArea instance or constructor options
21
21
  * @returns The index of the added item
22
22
  */
23
- add(area: TerrainArea | TerrainArea.ConstructorOptions): number;
23
+ add(area: TerrainArea | TerrainArea.ConstructorOptions): this;
24
24
  /**
25
25
  * Adds terrain areas to the collection.
26
26
  * @param areas An array of TerrainArea instance or constructor options
27
27
  * @returns The index of the added item
28
28
  */
29
- add(areas: (TerrainArea | TerrainArea.ConstructorOptions)[]): number;
29
+ add(areas: (TerrainArea | TerrainArea.ConstructorOptions)[]): this;
30
30
  /**
31
31
  * Removes a terrain area from the collection.
32
32
  * @param area The terrain area to remove.
@@ -1 +1 @@
1
- import{a,b,c,d}from"../chunk-D2H7O3WV.js";export{d as HybridTerrainProvider,b as TerrainArea,c as TerrainAreaCollection,a as computeRectangle};
1
+ import{a,b,c,d}from"../chunk-4EI5BBVR.js";export{d as HybridTerrainProvider,b as TerrainArea,c as TerrainAreaCollection,a as computeRectangle};