@juun-roh/cesium-utils 0.1.2 → 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.
- package/dist/chunk-4EI5BBVR.js +1 -0
- package/dist/chunk-VMZ2PVXH.js +1 -0
- package/dist/chunk-ZV7FKRP6.js +1 -0
- package/dist/collection/index.cjs +1 -1
- package/dist/collection/index.d.cts +11 -11
- package/dist/collection/index.d.ts +11 -11
- package/dist/collection/index.js +1 -1
- package/dist/highlight/index.cjs +1 -0
- package/dist/highlight/index.d.cts +243 -0
- package/dist/highlight/index.d.ts +243 -0
- package/dist/highlight/index.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -220
- package/dist/index.d.ts +2 -220
- package/dist/index.js +1 -1
- package/dist/terrain/index.cjs +1 -1
- package/dist/terrain/index.d.cts +2 -2
- package/dist/terrain/index.d.ts +2 -2
- package/dist/terrain/index.js +1 -1
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +9 -9
- package/dist/chunk-D2H7O3WV.js +0 -1
- package/dist/chunk-I53ZQ7WC.js +0 -1
|
@@ -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 V=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var $=(n,e)=>{for(var t in e)V(n,t,{get:e[t],enumerable:!0})},K=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of U(e))!X.call(n,r)&&r!==t&&V(n,r,{get:()=>e[r],enumerable:!(i=q(e,r))||i.enumerable});return n};var J=n=>K(V({},"__esModule",{value:!0}),n);var Q={};$(Q,{Collection:()=>C,Highlight:()=>b,HybridTerrainProvider:()=>A,SilhouetteHighlight:()=>_,SurfaceHighlight:()=>y,TerrainArea:()=>v,TerrainAreaCollection:()=>p,TerrainVisualizer:()=>T,cloneViewer:()=>k,computeRectangle:()=>w,isGetterOnly:()=>P,syncCamera:()=>E});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),o=i.positionToTileXY(h.Rectangle.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],l=Math.min(e.end.x-e.start.x+1,100),s=Math.min(e.end.y-e.start.y+1,100);for(let c=e.start.x;c<e.start.x+l;c++)for(let g=e.start.y;g<e.start.y+s;g++)try{let f=this._createTileEntity(c,g,t,i);f&&r.push({entity:f})}catch(f){console.warn(`Error creating tile (${c}, ${g}, ${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")||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,o){return new h.Entity({rectangle:{coordinates:r,material:o,heightReference:h.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,l){let s=l?.tag||"terrain_area_visualization",c=l?.color||h.Color.RED,g=l?.maxTilesToShow||100,f=l?.show??!0,R=l?.alpha||.7,I=l?.tileAlpha||.2,x=new C({collection:o.entities,tag:s}),{rectangle:B}=r;if(x.add(i.createRectangle(B,c.withAlpha(R)),s),f&&r.tileRanges.size>0){let{tilingScheme:Y}=r.terrainProvider,L=0;r.tileRanges.forEach((S,j)=>{for(let O=S.start.x;O<=S.end.x&&L<g;O++)for(let M=S.start.y;M<=S.end.y&&L<g;M++){let W=Y.tileXYToRectangle(O,M,j);x.add(e(W,c.withAlpha(I)),`${s}_tile`),L++}})}return x}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 H=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof 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})),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")}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 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)}},C=H;var u=require("cesium");var d=require("cesium"),_=class{_color=d.Color.RED;_silhouette;_composite;_stages;_entity;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=d.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=d.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}show(e,t){if(!(!(0,d.defined)(e)||this._silhouette.selected[0]===e))if(e instanceof d.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 d.ConstantProperty(t?.width||2),e.model.silhouetteColor=new d.ConstantProperty(t?.color||this._color)}}hide(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new d.ConstantProperty(d.Color.TRANSPARENT),this._entity.model.silhouetteSize=new d.ConstantProperty(0),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"),y=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 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}){this.hide();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 F=require("cesium");var N=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,o=Number.NEGATIVE_INFINITY,l=Array.from(e.keys()),s=Math.min(...l),c=e.get(s);if(c){let{start:g,end:f}=c,R=n.tileXYToRectangle(g.x,g.y,s),I=n.tileXYToRectangle(f.x,f.y,s);t=Math.min(R.west,t),i=Math.min(I.south,i),r=Math.max(I.east,r),o=Math.max(R.north,o)}return new G.Rectangle(t,i,r,o)}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 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})(v||={});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 v?t=e:t=new v(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 E(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});E(n,r);let o=n.imageryLayers;r.imageryLayers.removeAll();for(let c=0;c<o.length;c++){let g=o.get(c);r.imageryLayers.addImageryProvider(g.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 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,225 +1,7 @@
|
|
|
1
1
|
export { CesiumCollection, CesiumCollectionItem, Collection, CollectionEventType, EventHandler, NonFunction, Tag, WithTag } from './collection/index.cjs';
|
|
2
|
-
|
|
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
|
-
/**
|
|
101
|
-
* @class
|
|
102
|
-
* An implementation for highlighting 3D objects in Cesium.
|
|
103
|
-
*
|
|
104
|
-
* **Supported Object Types:**
|
|
105
|
-
* - `Entity` with model graphics. (adjustable outline width)
|
|
106
|
-
* - `Cesium3DTileset` instances. (fixed outline width)
|
|
107
|
-
*
|
|
108
|
-
* Currently supports outline style only.
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```typescript
|
|
112
|
-
* const viewer = new Viewer("cesiumContainer");
|
|
113
|
-
* const silhouetteHighlight = new SilhouetteHighlight(viewer);
|
|
114
|
-
*
|
|
115
|
-
* // Highlight an object
|
|
116
|
-
* const entity = viewer.entities.add(new Entity({
|
|
117
|
-
* model: new ModelGraphics(),
|
|
118
|
-
* }));
|
|
119
|
-
* silhouetteHighlight.show(entity);
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
declare class SilhouetteHighlight implements IHighlight {
|
|
123
|
-
private _color;
|
|
124
|
-
private _silhouette;
|
|
125
|
-
private _composite;
|
|
126
|
-
private _stages;
|
|
127
|
-
private _entity?;
|
|
128
|
-
/**
|
|
129
|
-
* Creates a new `Silhouette` instance.
|
|
130
|
-
* @param viewer A viewer to create highlight silhouette in
|
|
131
|
-
*/
|
|
132
|
-
constructor(viewer: Viewer);
|
|
133
|
-
/**
|
|
134
|
-
* Highlights a picked `Cesium3DTileset` by updating silhouette composite.
|
|
135
|
-
* @param object The object to be highlighted.
|
|
136
|
-
* @param options Optional style for the highlight.
|
|
137
|
-
*/
|
|
138
|
-
show(object: Cesium3DTileFeature, options?: HighlightOptions): void;
|
|
139
|
-
/**
|
|
140
|
-
* Highlights a picked `Entity` by updating the model properties.
|
|
141
|
-
* @param object The object to be highlighted.
|
|
142
|
-
* @param options Optional style for the highlight.
|
|
143
|
-
*/
|
|
144
|
-
show(object: Entity, options?: HighlightOptions): void;
|
|
145
|
-
/** Clears the current highlight */
|
|
146
|
-
hide(): void;
|
|
147
|
-
/** Clean up the instances */
|
|
148
|
-
destroy(): void;
|
|
149
|
-
/** Gets the highlight color. */
|
|
150
|
-
get color(): Color;
|
|
151
|
-
/** Sets the highlight color. */
|
|
152
|
-
set color(color: Color);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* @class
|
|
157
|
-
* A flyweight implementation for highlighting 2D surface objects in Cesium.
|
|
158
|
-
*
|
|
159
|
-
* This class provides highlighting for ground-clamped geometries (polygons, polylines, rectangles)
|
|
160
|
-
*
|
|
161
|
-
* **Supported Geometry Types:**
|
|
162
|
-
* - `Entity` with polygon, polyline, or rectangle graphics
|
|
163
|
-
* - `GroundPrimitive` instances
|
|
164
|
-
*
|
|
165
|
-
* **Highlighting Modes:**
|
|
166
|
-
* - **Fill mode** (default): Creates a filled geometry using the original shape
|
|
167
|
-
* - **Outline mode**: Creates a polyline outline of the original geometry
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* ```typescript
|
|
171
|
-
* // Basic usage
|
|
172
|
-
* const viewer = new Viewer('cesiumContainer');
|
|
173
|
-
* const surfaceHighlight = new SurfaceHighlight(viewer);
|
|
174
|
-
*
|
|
175
|
-
* // Highlight an entity with default red fill
|
|
176
|
-
* const entity = viewer.entities.add(new Entity({
|
|
177
|
-
* polygon: {
|
|
178
|
-
* hierarchy: Cartesian3.fromDegreesArray([-75, 35, -74, 35, -74, 36, -75, 36]),
|
|
179
|
-
* material: Color.BLUE
|
|
180
|
-
* }
|
|
181
|
-
* }));
|
|
182
|
-
* surfaceHighlight.show(entity);
|
|
183
|
-
* ```
|
|
184
|
-
*/
|
|
185
|
-
declare class SurfaceHighlight implements IHighlight {
|
|
186
|
-
private _color;
|
|
187
|
-
private _entity;
|
|
188
|
-
private _entities;
|
|
189
|
-
/**
|
|
190
|
-
* Creates a new `SurfaceHighlight` instance.
|
|
191
|
-
* @param viewer A viewer to create highlight entity in
|
|
192
|
-
*/
|
|
193
|
-
constructor(viewer: Viewer);
|
|
194
|
-
/**
|
|
195
|
-
* Highlights a picked object by updating the reusable entity
|
|
196
|
-
* @param object The object to be highlighted.
|
|
197
|
-
* @param options Optional style for the highlight.
|
|
198
|
-
* @see {@link HighlightOptions}
|
|
199
|
-
*/
|
|
200
|
-
show(object: Entity | GroundPrimitive, options?: HighlightOptions): Entity | undefined;
|
|
201
|
-
/**
|
|
202
|
-
* Removes all geometry properties from the highlight entity
|
|
203
|
-
* @private
|
|
204
|
-
*/
|
|
205
|
-
private _clearGeometries;
|
|
206
|
-
/**
|
|
207
|
-
* Updates the highlight entity from an Entity object
|
|
208
|
-
* @private
|
|
209
|
-
*/
|
|
210
|
-
private _update;
|
|
211
|
-
/**
|
|
212
|
-
* Clears the current highlight
|
|
213
|
-
*/
|
|
214
|
-
hide(): void;
|
|
215
|
-
/** Clean up the instances */
|
|
216
|
-
destroy(): void;
|
|
217
|
-
/** Gets the highlight color. */
|
|
218
|
-
get color(): Color;
|
|
219
|
-
/** Sets the highlight color. */
|
|
220
|
-
set color(color: Color);
|
|
221
|
-
/** Gets the highlight entity */
|
|
222
|
-
get entity(): Entity;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export { Highlight, type HighlightOptions, type IHighlight, type Picked, type PickedObject, SilhouetteHighlight, SurfaceHighlight };
|
|
7
|
+
import 'cesium';
|