@juun-roh/cesium-utils 0.3.1 → 0.3.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/README.md +7 -4
- package/dist/{chunk-O27H72YO.js → chunk-EGWUHR3C.js} +1 -1
- package/dist/chunk-PSCNWZUR.js +1 -0
- package/dist/collection/index.cjs +1 -1
- package/dist/collection/index.d.cts +1 -1
- package/dist/collection/index.d.ts +1 -1
- package/dist/collection/index.js +1 -1
- package/dist/dev/index.cjs +1 -1
- package/dist/dev/index.d.cts +3 -3
- package/dist/dev/index.d.ts +3 -3
- package/dist/dev/index.js +1 -1
- package/dist/experimental/index.cjs +1 -1
- package/dist/experimental/index.d.cts +8 -5
- package/dist/experimental/index.d.ts +8 -5
- package/dist/experimental/index.js +1 -1
- package/dist/highlight/index.cjs +1 -1
- package/dist/highlight/index.d.cts +32 -32
- package/dist/highlight/index.d.ts +32 -32
- package/dist/highlight/index.js +1 -1
- package/dist/{hybrid-terrain-provider-CzdhZJyg.d.cts → hybrid-terrain-provider-C2iCeaf-.d.cts} +5 -17
- package/dist/{hybrid-terrain-provider-CzdhZJyg.d.ts → hybrid-terrain-provider-C2iCeaf-.d.ts} +5 -17
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/terrain/index.d.cts +1 -1
- package/dist/terrain/index.d.ts +1 -1
- package/package.json +13 -13
- package/dist/chunk-RZ3PTU3G.js +0 -1
- package/dist/{index-Bfd24d9-.d.cts → index-iIlou-Sq.d.cts} +59 -59
- package/dist/{index-Bfd24d9-.d.ts → index-iIlou-Sq.d.ts} +59 -59
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Viewer, Entity,
|
|
1
|
+
import { Color, Viewer, Entity, Primitive, GroundPrimitive, Model, Cesium3DTileset, Cesium3DTileFeature } from 'cesium';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @class
|
|
@@ -37,6 +37,13 @@ declare class Highlight {
|
|
|
37
37
|
* @param viewer A viewer to create highlight entity in
|
|
38
38
|
*/
|
|
39
39
|
private constructor();
|
|
40
|
+
/** Gets the highlight color. */
|
|
41
|
+
get color(): Color;
|
|
42
|
+
/**
|
|
43
|
+
* Sets the highlight color.
|
|
44
|
+
* @param color The new color for highlights
|
|
45
|
+
*/
|
|
46
|
+
set color(color: Color);
|
|
40
47
|
/**
|
|
41
48
|
* Gets or creates highlight instance from a viewer.
|
|
42
49
|
* @param viewer The viewer to get or create a new instance from.
|
|
@@ -59,13 +66,6 @@ declare class Highlight {
|
|
|
59
66
|
* Clears the current highlight effects.
|
|
60
67
|
*/
|
|
61
68
|
hide(): void;
|
|
62
|
-
/** Gets the highlight color. */
|
|
63
|
-
get color(): Color;
|
|
64
|
-
/**
|
|
65
|
-
* Sets the highlight color.
|
|
66
|
-
* @param color The new color for highlights
|
|
67
|
-
*/
|
|
68
|
-
set color(color: Color);
|
|
69
69
|
}
|
|
70
70
|
declare namespace Highlight {
|
|
71
71
|
export interface Base {
|
|
@@ -129,6 +129,12 @@ declare class SilhouetteHighlight implements Highlight.Base {
|
|
|
129
129
|
* @param viewer A viewer to create highlight silhouette in
|
|
130
130
|
*/
|
|
131
131
|
constructor(viewer: Viewer);
|
|
132
|
+
/** Gets the highlight color. */
|
|
133
|
+
get color(): Color;
|
|
134
|
+
/** Sets the highlight color. */
|
|
135
|
+
set color(color: Color);
|
|
136
|
+
/** Gets the currently highlighted object */
|
|
137
|
+
get currentObject(): Cesium3DTileFeature | Entity | undefined;
|
|
132
138
|
/**
|
|
133
139
|
* Highlights a picked `Cesium3DTileset` by updating silhouette composite.
|
|
134
140
|
* @param object The object to be highlighted.
|
|
@@ -141,6 +147,10 @@ declare class SilhouetteHighlight implements Highlight.Base {
|
|
|
141
147
|
* @param options Optional style for the highlight.
|
|
142
148
|
*/
|
|
143
149
|
show(object: Entity, options?: Highlight.Options): void;
|
|
150
|
+
/** Clears the current highlight */
|
|
151
|
+
hide(): void;
|
|
152
|
+
/** Clean up the instances */
|
|
153
|
+
destroy(): void;
|
|
144
154
|
/**
|
|
145
155
|
* Compares two Highlight.Options objects for equality
|
|
146
156
|
* @private
|
|
@@ -151,16 +161,6 @@ declare class SilhouetteHighlight implements Highlight.Base {
|
|
|
151
161
|
* @private
|
|
152
162
|
*/
|
|
153
163
|
private _clearHighlights;
|
|
154
|
-
/** Clears the current highlight */
|
|
155
|
-
hide(): void;
|
|
156
|
-
/** Clean up the instances */
|
|
157
|
-
destroy(): void;
|
|
158
|
-
/** Gets the highlight color. */
|
|
159
|
-
get color(): Color;
|
|
160
|
-
/** Sets the highlight color. */
|
|
161
|
-
set color(color: Color);
|
|
162
|
-
/** Gets the currently highlighted object */
|
|
163
|
-
get currentObject(): Cesium3DTileFeature | Entity | undefined;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
/**
|
|
@@ -204,6 +204,14 @@ declare class SurfaceHighlight implements Highlight.Base {
|
|
|
204
204
|
* @param viewer A viewer to create highlight entity in
|
|
205
205
|
*/
|
|
206
206
|
constructor(viewer: Viewer);
|
|
207
|
+
/** Gets the highlight color. */
|
|
208
|
+
get color(): Color;
|
|
209
|
+
/** Sets the highlight color. */
|
|
210
|
+
set color(color: Color);
|
|
211
|
+
/** Gets the highlight entity */
|
|
212
|
+
get entity(): Entity;
|
|
213
|
+
/** Gets the currently highlighted object */
|
|
214
|
+
get currentObject(): Entity | GroundPrimitive | undefined;
|
|
207
215
|
/**
|
|
208
216
|
* Highlights a picked object by updating the reusable entity
|
|
209
217
|
* @param object The object to be highlighted.
|
|
@@ -211,6 +219,12 @@ declare class SurfaceHighlight implements Highlight.Base {
|
|
|
211
219
|
* @see {@link Highlight.Options}
|
|
212
220
|
*/
|
|
213
221
|
show(object: Entity | GroundPrimitive, options?: Highlight.Options): Entity | undefined;
|
|
222
|
+
/**
|
|
223
|
+
* Clears the current highlight
|
|
224
|
+
*/
|
|
225
|
+
hide(): void;
|
|
226
|
+
/** Clean up the instances */
|
|
227
|
+
destroy(): void;
|
|
214
228
|
/**
|
|
215
229
|
* Compares two Highlight.Options objects for equality
|
|
216
230
|
* @private
|
|
@@ -226,20 +240,6 @@ declare class SurfaceHighlight implements Highlight.Base {
|
|
|
226
240
|
* @private
|
|
227
241
|
*/
|
|
228
242
|
private _update;
|
|
229
|
-
/**
|
|
230
|
-
* Clears the current highlight
|
|
231
|
-
*/
|
|
232
|
-
hide(): void;
|
|
233
|
-
/** Clean up the instances */
|
|
234
|
-
destroy(): void;
|
|
235
|
-
/** Gets the highlight color. */
|
|
236
|
-
get color(): Color;
|
|
237
|
-
/** Sets the highlight color. */
|
|
238
|
-
set color(color: Color);
|
|
239
|
-
/** Gets the highlight entity */
|
|
240
|
-
get entity(): Entity;
|
|
241
|
-
/** Gets the currently highlighted object */
|
|
242
|
-
get currentObject(): Entity | GroundPrimitive | undefined;
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
export { Highlight, SilhouetteHighlight, SurfaceHighlight };
|
package/dist/highlight/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c}from"../chunk-
|
|
1
|
+
import{a,b,c}from"../chunk-PSCNWZUR.js";export{c as Highlight,a as SilhouetteHighlight,b as SurfaceHighlight};
|
package/dist/{hybrid-terrain-provider-CzdhZJyg.d.cts → hybrid-terrain-provider-C2iCeaf-.d.cts}
RENAMED
|
@@ -8,28 +8,16 @@ import { TerrainProvider, TilingScheme, TileAvailability, Credit, Request, Terra
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ``` typescript
|
|
11
|
-
* //
|
|
12
|
-
* const
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* provider: customProvider,
|
|
16
|
-
* bounds: Rectangle.fromDegrees(-120, 30, -100, 50),
|
|
17
|
-
* levels: [10, 15] // optional
|
|
18
|
-
* }
|
|
19
|
-
* ],
|
|
20
|
-
* defaultProvider: worldTerrain
|
|
21
|
-
* });
|
|
22
|
-
*
|
|
23
|
-
* // Or tile-coordinate based for precise control (multiple levels)
|
|
24
|
-
* const tileRanges = new Map();
|
|
25
|
-
* tileRanges.set(15, { x: [55852, 55871], y: [9556, 9575] });
|
|
26
|
-
* tileRanges.set(16, { x: [111704, 111742], y: [19112, 19150] });
|
|
11
|
+
* // Tile-coordinate based for precise control (multiple levels)
|
|
12
|
+
* const customTiles: TerrainTiles = new Map();
|
|
13
|
+
* customTiles.set(15, { x: [55852, 55871], y: [9556, 9575] });
|
|
14
|
+
* customTiles.set(16, { x: [111704, 111742], y: [19112, 19150] });
|
|
27
15
|
*
|
|
28
16
|
* const hybridTerrain = new HybridTerrainProvider({
|
|
29
17
|
* regions: [
|
|
30
18
|
* {
|
|
31
19
|
* provider: customProvider,
|
|
32
|
-
* tiles:
|
|
20
|
+
* tiles: customTiles,
|
|
33
21
|
* }
|
|
34
22
|
* ],
|
|
35
23
|
* defaultProvider: worldTerrain
|
package/dist/{hybrid-terrain-provider-CzdhZJyg.d.ts → hybrid-terrain-provider-C2iCeaf-.d.ts}
RENAMED
|
@@ -8,28 +8,16 @@ import { TerrainProvider, TilingScheme, TileAvailability, Credit, Request, Terra
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ``` typescript
|
|
11
|
-
* //
|
|
12
|
-
* const
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* provider: customProvider,
|
|
16
|
-
* bounds: Rectangle.fromDegrees(-120, 30, -100, 50),
|
|
17
|
-
* levels: [10, 15] // optional
|
|
18
|
-
* }
|
|
19
|
-
* ],
|
|
20
|
-
* defaultProvider: worldTerrain
|
|
21
|
-
* });
|
|
22
|
-
*
|
|
23
|
-
* // Or tile-coordinate based for precise control (multiple levels)
|
|
24
|
-
* const tileRanges = new Map();
|
|
25
|
-
* tileRanges.set(15, { x: [55852, 55871], y: [9556, 9575] });
|
|
26
|
-
* tileRanges.set(16, { x: [111704, 111742], y: [19112, 19150] });
|
|
11
|
+
* // Tile-coordinate based for precise control (multiple levels)
|
|
12
|
+
* const customTiles: TerrainTiles = new Map();
|
|
13
|
+
* customTiles.set(15, { x: [55852, 55871], y: [9556, 9575] });
|
|
14
|
+
* customTiles.set(16, { x: [111704, 111742], y: [19112, 19150] });
|
|
27
15
|
*
|
|
28
16
|
* const hybridTerrain = new HybridTerrainProvider({
|
|
29
17
|
* regions: [
|
|
30
18
|
* {
|
|
31
19
|
* provider: customProvider,
|
|
32
|
-
* tiles:
|
|
20
|
+
* tiles: customTiles,
|
|
33
21
|
* }
|
|
34
22
|
* ],
|
|
35
23
|
* defaultProvider: worldTerrain
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var L=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var K=(n,e)=>{for(var t in e)L(n,t,{get:e[t],enumerable:!0})},X=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Y(e))!U.call(n,r)&&r!==t&&L(n,r,{get:()=>e[r],enumerable:!(i=$(e,r))||i.enumerable});return n};var J=n=>X(L({},"__esModule",{value:!0}),n);var Q={};K(Q,{Collection:()=>_,Highlight:()=>M,HybridTerrainProvider:()=>D,SilhouetteHighlight:()=>p,SurfaceHighlight:()=>y,cloneViewer:()=>G,syncCamera:()=>O});module.exports=J(Q);var v=require("cesium");var B;(l=>{let n=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(c,u={}){if(!e)return;let{once:g=!0,prefix:C="[DEPRECATED]",includeStack:T=!0,removeInVersion:b}=u;if(g&&n.has(c))return;let P=`${C} ${c}`;b&&(P+=` This feature will be removed in ${b}.`),typeof console<"u"&&console.warn&&(T?(console.warn(P),console.trace("Deprecation stack trace:")):console.warn(P)),g&&n.add(c)}l.warn=t;function i(c,u,g={}){let C=((...T)=>(t(u,g),c(...T)));return Object.defineProperty(C,"name",{value:c.name,configurable:!0}),C}l.deprecate=i;function r(){n.clear()}l.clear=r;function o(){return n.size}l.getWarningCount=o;function s(c){return n.has(c)}l.hasShown=s})(B||={});var j=B;var h=require("cesium");var w=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 _({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(n.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new h.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:h.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(s=>{this._collection.add(s.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(h.Rectangle.northwest(e),t),o=i.positionToTileXY(h.Rectangle.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],s=Math.min(e.end.x-e.start.x+1,100),l=Math.min(e.end.y-e.start.y+1,100);for(let c=e.start.x;c<e.start.x+s;c++)for(let u=e.start.y;u<e.start.y+l;u++)try{let g=this._createTileEntity(c,u,t,i);g&&r.push({entity:g})}catch(g){console.warn(`Error creating tile (${c}, ${u}, ${t}):`,g)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let s=this._getTileColor(e,t,i),l=n.createRectangle(o,s.withAlpha(.3));return l.properties?.addProperty("tileX",e),l.properties?.addProperty("tileY",t),l.properties?.addProperty("tileLevel",i),l}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||h.Color.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||h.Color.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||h.Color.BLUE:this._colors.get("fallback")||h.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){this._viewer.camera.flyTo({destination:e,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new h.Entity({rectangle:{coordinates:r,material:o,heightReference:h.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,s){let l=s?.tag||"terrain_region_visualization",c=s?.color||h.Color.RED,u=s?.maxTilesToShow||100,g=s?.show??!0,C=s?.alpha||.7,T=s?.tileAlpha||.2,b=new _({collection:o.entities,tag:l});if(g&&r.tiles&&r.tiles.size>0){let P=r.provider.tilingScheme,x=0;r.tiles.forEach((f,z)=>{let k=Array.isArray(f.x)?f.x:[f.x,f.x],F=Array.isArray(f.y)?f.y:[f.y,f.y];for(let S=k[0];S<=k[1]&&x<u;S++)for(let R=F[0];R<=F[1]&&x<u;R++){let q=P.tileXYToRectangle(S,R,z);b.add(e(q,c.withAlpha(T)),`${l}_tile`),x++}})}return b}i.visualize=t})(w||={});function A(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var de=j.deprecate;var I=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}_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 v.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof v.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 v.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 v.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 v.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,v.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,v.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,v.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r)if(e in o&&typeof o[e]!="function"){if(A(o,e))throw Error(`Cannot set read-only property '${String(e)}' on ${o.constructor.name}`);o[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,o)=>e(r,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},_=I;var m=require("cesium");var d=require("cesium"),p=class{_color=d.Color.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;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._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{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)}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&&d.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 d.ConstantProperty(d.Color.TRANSPARENT),this._entity.model.silhouetteSize=new d.ConstantProperty(0),this._entity=void 0)}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}};var a=require("cesium"),y=class{_color=a.Color.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new a.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}show(e,t){if(!(!(0,a.defined)(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof a.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof a.GroundPrimitive)this._update(e,t);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=e,this._currentOptions=t?{...t}:void 0,this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0;return}}}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&a.Color.equals(e.color||this._color,t.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof a.Entity){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let r;i.positions.length>0&&!a.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new a.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new a.PolygonGraphics({hierarchy:i,material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||a.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let r=e.polyline.width?.getValue();this._entity.polyline=new a.PolylineGraphics({positions:i,material:t.color,width:r+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let r=[a.Cartesian3.fromRadians(i.west,i.north),a.Cartesian3.fromRadians(i.east,i.north),a.Cartesian3.fromRadians(i.east,i.south),a.Cartesian3.fromRadians(i.west,i.south),a.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new a.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new a.RectangleGraphics({coordinates:i,material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND}))}}else if(e instanceof a.GroundPrimitive){let i=e.geometryInstances,r=Array.isArray(i)?i[0]:i;if(!r.geometry.attributes.position)return;let o=r.geometry.attributes.position.values,s=[];for(let l=0;l<o.length;l+=3)s.push(new a.Cartesian3(o[l],o[l+1],o[l+2]));t.outline?this._entity.polyline=new a.PolylineGraphics({positions:s,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new a.PolygonGraphics({hierarchy:new a.PolygonHierarchy(s),material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND,classificationType:a.ClassificationType.BOTH})}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}};var H=class n{static instances=new WeakMap;_surface;_silhouette;_color=m.Color.RED;constructor(e){this._surface=new y(e),this._silhouette=new p(e),this._surface.color=this._color,this._silhouette.color=this._color}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,i=n.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),n.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if((0,m.defined)(i))return i instanceof m.Cesium3DTileFeature?this._silhouette.show(i,t):i instanceof m.Entity&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if((0,m.defined)(e)){if(e instanceof m.Entity||e instanceof m.Cesium3DTileFeature||e instanceof m.GroundPrimitive)return e;if(e.id instanceof m.Entity)return e.id;if(e.primitive instanceof m.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}},M=H;var N=require("cesium"),E=class{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new N.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,t,i){return this._defaultProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,i,r){if(this._ready){for(let o of this._regions)if(this._regionContains(o,e,t,i))return o.provider.requestTileGeometry(e,t,i,r);return this._defaultProvider.getTileDataAvailable(e,t,i)?this._defaultProvider.requestTileGeometry(e,t,i,r):this._fallbackProvider.requestTileGeometry(e,t,i,r)}}getTileDataAvailable(e,t,i){for(let r of this._regions)if(this._regionContains(r,e,t,i)&&r.provider.getTileDataAvailable(e,t,i))return!0;return this._defaultProvider.getTileDataAvailable(e,t,i)}_regionContains(e,t,i,r){if(e.levels&&!e.levels.includes(r))return!1;if(e.tiles){let o=e.tiles.get(r);if(!o)return!1;let[s,l]=Array.isArray(o.x)?o.x:[o.x,o.x],[c,u]=Array.isArray(o.y)?o.y:[o.y,o.y];return t>=s&&t<=l&&i>=c&&i<=u}return!1}};(e=>{function n(t,i,r){return new e({regions:t.map(o=>({...o})),defaultProvider:i,fallbackProvider:r})}e.fromTileRanges=n})(E||={});var D=E;var W=require("cesium");var V=require("cesium");function O(n,e){if((0,V.defined)(n)&&(0,V.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 G(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 W.Viewer(e,{...i,...t});O(n,r);let o=n.imageryLayers;r.imageryLayers.removeAll();for(let c=0;c<o.length;c++){let u=o.get(c);r.imageryLayers.addImageryProvider(u.imageryProvider,c)}r.clock.startTime=n.clock.startTime.clone(),r.clock.stopTime=n.clock.stopTime.clone(),r.clock.currentTime=n.clock.currentTime.clone(),r.clock.multiplier=n.clock.multiplier,r.clock.clockStep=n.clock.clockStep,r.clock.clockRange=n.clock.clockRange,r.clock.shouldAnimate=n.clock.shouldAnimate,r.scene.globe.enableLighting=n.scene.globe.enableLighting,r.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,r.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let s=n.scene.screenSpaceCameraController.tiltEventTypes;s&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(s)?[...s]:s);let l=n.scene.screenSpaceCameraController.zoomEventTypes;return l&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(l)?[...l]:l),r}
|
|
1
|
+
"use strict";var L=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var K=(n,e)=>{for(var t in e)L(n,t,{get:e[t],enumerable:!0})},X=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Y(e))!U.call(n,r)&&r!==t&&L(n,r,{get:()=>e[r],enumerable:!(i=$(e,r))||i.enumerable});return n};var J=n=>X(L({},"__esModule",{value:!0}),n);var Q={};K(Q,{Collection:()=>_,Highlight:()=>M,HybridTerrainProvider:()=>D,SilhouetteHighlight:()=>p,SurfaceHighlight:()=>y,cloneViewer:()=>G,syncCamera:()=>x});module.exports=J(Q);var v=require("cesium");var j;(l=>{let n=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(c,u={}){if(!e)return;let{once:g=!0,prefix:C="[DEPRECATED]",includeStack:T=!0,removeInVersion:b}=u;if(g&&n.has(c))return;let P=`${C} ${c}`;b&&(P+=` This feature will be removed in ${b}.`),typeof console<"u"&&console.warn&&(T?(console.warn(P),console.trace("Deprecation stack trace:")):console.warn(P)),g&&n.add(c)}l.warn=t;function i(c,u,g={}){let C=((...T)=>(t(u,g),c(...T)));return Object.defineProperty(C,"name",{value:c.name,configurable:!0}),C}l.deprecate=i;function r(){n.clear()}l.clear=r;function o(){return n.size}l.getWarningCount=o;function a(c){return n.has(c)}l.hasShown=a})(j||={});var B=j;var h=require("cesium");var w=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 _({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(a=>{this._collection.add(a.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(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=[],a=Math.min(e.end.x-e.start.x+1,100),l=Math.min(e.end.y-e.start.y+1,100);for(let c=e.start.x;c<e.start.x+a;c++)for(let u=e.start.y;u<e.start.y+l;u++)try{let g=this._createTileEntity(c,u,t,i);g&&r.push({entity:g})}catch(g){console.warn(`Error creating tile (${c}, ${u}, ${t}):`,g)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let a=this._getTileColor(e,t,i),l=n.createRectangle(o,a.withAlpha(.3));return l.properties?.addProperty("tileX",e),l.properties?.addProperty("tileY",t),l.properties?.addProperty("tileLevel",i),l}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||h.Color.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||h.Color.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||h.Color.BLUE:this._colors.get("fallback")||h.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){this._viewer.camera.flyTo({destination:e,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new h.Entity({rectangle:{coordinates:r,material:o,heightReference:h.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,a){let l=a?.tag||"terrain_region_visualization",c=a?.color||h.Color.RED,u=a?.maxTilesToShow||100,g=a?.show??!0,C=a?.alpha||.7,T=a?.tileAlpha||.2,b=new _({collection:o.entities,tag:l});if(g&&r.tiles&&r.tiles.size>0){let P=r.provider.tilingScheme,O=0;r.tiles.forEach((f,z)=>{let k=Array.isArray(f.x)?f.x:[f.x,f.x],F=Array.isArray(f.y)?f.y:[f.y,f.y];for(let S=k[0];S<=k[1]&&O<u;S++)for(let R=F[0];R<=F[1]&&O<u;R++){let q=P.tileXYToRectangle(S,R,z);b.add(e(q,c.withAlpha(T)),`${l}_tile`),O++}})}return b}i.visualize=t})(w||={});function A(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var de=B.deprecate;var I=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof v.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get tags(){return Array.from(this._tagMap.keys())}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,v.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,v.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,v.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r)if(e in o&&typeof o[e]!="function"){if(A(o,e))throw Error(`Cannot set read-only property '${String(e)}' on ${o.constructor.name}`);o[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,o)=>e(r,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof v.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof v.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 v.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 v.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)))}},_=I;var m=require("cesium");var d=require("cesium"),p=class{_color=d.Color.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;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)}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}show(e,t){if((0,d.defined)(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{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)}this._currentObject=e,this._currentOptions=t?{...t}:void 0}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0}}}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&d.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 d.ConstantProperty(d.Color.TRANSPARENT),this._entity.model.silhouetteSize=new d.ConstantProperty(0),this._entity=void 0)}};var s=require("cesium"),y=class{_color=s.Color.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new s.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}show(e,t){if(!(!(0,s.defined)(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof s.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof s.GroundPrimitive)this._update(e,t);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=e,this._currentOptions=t?{...t}:void 0,this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0;return}}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&s.Color.equals(e.color||this._color,t.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof s.Entity){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let r;i.positions.length>0&&!s.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new s.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new s.PolygonGraphics({hierarchy:i,material:t.color,heightReference:s.HeightReference.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||s.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let r=e.polyline.width?.getValue();this._entity.polyline=new s.PolylineGraphics({positions:i,material:t.color,width:r+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let r=[s.Cartesian3.fromRadians(i.west,i.north),s.Cartesian3.fromRadians(i.east,i.north),s.Cartesian3.fromRadians(i.east,i.south),s.Cartesian3.fromRadians(i.west,i.south),s.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new s.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new s.RectangleGraphics({coordinates:i,material:t.color,heightReference:s.HeightReference.CLAMP_TO_GROUND}))}}else if(e instanceof s.GroundPrimitive){let i=e.geometryInstances,r=Array.isArray(i)?i[0]:i;if(!r.geometry.attributes.position)return;let o=r.geometry.attributes.position.values,a=[];for(let l=0;l<o.length;l+=3)a.push(new s.Cartesian3(o[l],o[l+1],o[l+2]));t.outline?this._entity.polyline=new s.PolylineGraphics({positions:a,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new s.PolygonGraphics({hierarchy:new s.PolygonHierarchy(a),material:t.color,heightReference:s.HeightReference.CLAMP_TO_GROUND,classificationType:s.ClassificationType.BOTH})}}};var H=class n{static instances=new WeakMap;_surface;_silhouette;_color=m.Color.RED;constructor(e){this._surface=new y(e),this._silhouette=new p(e),this._surface.color=this._color,this._silhouette.color=this._color}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,i=n.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),n.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if((0,m.defined)(i))return i instanceof m.Cesium3DTileFeature?this._silhouette.show(i,t):i instanceof m.Entity&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if((0,m.defined)(e)){if(e instanceof m.Entity||e instanceof m.Cesium3DTileFeature||e instanceof m.GroundPrimitive)return e;if(e.id instanceof m.Entity)return e.id;if(e.primitive instanceof m.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}},M=H;var N=require("cesium"),E=class{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new N.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,t,i){return this._defaultProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,i,r){if(this._ready){for(let o of this._regions)if(this._regionContains(o,e,t,i))return o.provider.requestTileGeometry(e,t,i,r);return this._defaultProvider.getTileDataAvailable(e,t,i)?this._defaultProvider.requestTileGeometry(e,t,i,r):this._fallbackProvider.requestTileGeometry(e,t,i,r)}}getTileDataAvailable(e,t,i){for(let r of this._regions)if(this._regionContains(r,e,t,i)&&r.provider.getTileDataAvailable(e,t,i))return!0;return this._defaultProvider.getTileDataAvailable(e,t,i)}_regionContains(e,t,i,r){if(e.levels&&!e.levels.includes(r))return!1;if(e.tiles){let o=e.tiles.get(r);if(!o)return!1;let[a,l]=Array.isArray(o.x)?o.x:[o.x,o.x],[c,u]=Array.isArray(o.y)?o.y:[o.y,o.y];return t>=a&&t<=l&&i>=c&&i<=u}return!1}};(e=>{function n(t,i,r){return new e({regions:t.map(o=>({...o})),defaultProvider:i,fallbackProvider:r})}e.fromTileRanges=n})(E||={});var D=E;var W=require("cesium");var V=require("cesium");function x(n,e){if((0,V.defined)(n)&&(0,V.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 G(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 W.Viewer(e,{...i,...t});x(n,r);let o=n.imageryLayers;r.imageryLayers.removeAll();for(let c=0;c<o.length;c++){let u=o.get(c);r.imageryLayers.addImageryProvider(u.imageryProvider,c)}r.clock.startTime=n.clock.startTime.clone(),r.clock.stopTime=n.clock.stopTime.clone(),r.clock.currentTime=n.clock.currentTime.clone(),r.clock.multiplier=n.clock.multiplier,r.clock.clockStep=n.clock.clockStep,r.clock.clockRange=n.clock.clockRange,r.clock.shouldAnimate=n.clock.shouldAnimate,r.scene.globe.enableLighting=n.scene.globe.enableLighting,r.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,r.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let a=n.scene.screenSpaceCameraController.tiltEventTypes;a&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(a)?[...a]:a);let l=n.scene.screenSpaceCameraController.zoomEventTypes;return l&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(l)?[...l]:l),r}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { C as Collection } from './index-
|
|
1
|
+
export { C as Collection } from './index-iIlou-Sq.cjs';
|
|
2
2
|
export { Highlight, SilhouetteHighlight, SurfaceHighlight } from './highlight/index.cjs';
|
|
3
|
-
export {
|
|
3
|
+
export { TerrainOptions, TerrainRegion, TerrainTiles } from './terrain/index.cjs';
|
|
4
4
|
export { cloneViewer, syncCamera } from './viewer/index.cjs';
|
|
5
|
+
export { H as HybridTerrainProvider } from './hybrid-terrain-provider-C2iCeaf-.cjs';
|
|
5
6
|
import 'cesium';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { C as Collection } from './index-
|
|
1
|
+
export { C as Collection } from './index-iIlou-Sq.js';
|
|
2
2
|
export { Highlight, SilhouetteHighlight, SurfaceHighlight } from './highlight/index.js';
|
|
3
|
-
export {
|
|
3
|
+
export { TerrainOptions, TerrainRegion, TerrainTiles } from './terrain/index.js';
|
|
4
4
|
export { cloneViewer, syncCamera } from './viewer/index.js';
|
|
5
|
+
export { H as HybridTerrainProvider } from './hybrid-terrain-provider-C2iCeaf-.js';
|
|
5
6
|
import 'cesium';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-RXMNSDKR.js";import{e as r}from"./chunk-
|
|
1
|
+
import"./chunk-RXMNSDKR.js";import{e as r}from"./chunk-EGWUHR3C.js";import{a as e,b as i,c as o}from"./chunk-PSCNWZUR.js";import{a as t}from"./chunk-6I4THOWX.js";import{a as p,b as m}from"./chunk-Z2COOTT4.js";export{r as Collection,o as Highlight,t as HybridTerrainProvider,e as SilhouetteHighlight,i as SurfaceHighlight,m as cloneViewer,p as syncCamera};
|
package/dist/terrain/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-
|
|
1
|
+
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-C2iCeaf-.cjs';
|
|
2
2
|
import 'cesium';
|
|
3
3
|
|
|
4
4
|
type TerrainTiles = NonNullable<HybridTerrainProvider.TerrainRegion["tiles"]>;
|
package/dist/terrain/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-
|
|
1
|
+
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-C2iCeaf-.js';
|
|
2
2
|
import 'cesium';
|
|
3
3
|
|
|
4
4
|
type TerrainTiles = NonNullable<HybridTerrainProvider.TerrainRegion["tiles"]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juun-roh/cesium-utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Solve common Cesium.js challenges: combine multiple terrain sources, tag and filter entity collections, and add visual highlights.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cesium",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"node": ">=20.0.0"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"cesium": "^1.
|
|
84
|
+
"cesium": "^1.133.0"
|
|
85
85
|
},
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public"
|
|
@@ -92,30 +92,30 @@
|
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
|
-
"@changesets/cli": "^2.29.
|
|
95
|
+
"@changesets/cli": "^2.29.7",
|
|
96
96
|
"@commitlint/cli": "^19.8.1",
|
|
97
97
|
"@commitlint/config-conventional": "^19.8.1",
|
|
98
98
|
"@commitlint/cz-commitlint": "^19.8.1",
|
|
99
99
|
"@commitlint/format": "^19.8.1",
|
|
100
100
|
"@commitlint/types": "^19.8.1",
|
|
101
|
-
"@eslint/js": "^9.
|
|
102
|
-
"@types/node": "^24.
|
|
103
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
104
|
-
"@typescript-eslint/parser": "^8.
|
|
101
|
+
"@eslint/js": "^9.36.0",
|
|
102
|
+
"@types/node": "^24.5.2",
|
|
103
|
+
"@typescript-eslint/eslint-plugin": "^8.44.0",
|
|
104
|
+
"@typescript-eslint/parser": "^8.44.0",
|
|
105
105
|
"@vitest/coverage-v8": "^3.2.4",
|
|
106
|
-
"cesium": "^1.
|
|
107
|
-
"eslint": "^9.
|
|
108
|
-
"eslint-plugin-jsdoc": "^
|
|
106
|
+
"cesium": "^1.133.1",
|
|
107
|
+
"eslint": "^9.36.0",
|
|
108
|
+
"eslint-plugin-jsdoc": "^60.1.0",
|
|
109
109
|
"eslint-plugin-prettier": "^5.5.4",
|
|
110
110
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
111
111
|
"eslint-plugin-unused-imports": "^4.2.0",
|
|
112
112
|
"husky": "^9.1.7",
|
|
113
|
-
"jsdom": "^
|
|
113
|
+
"jsdom": "^27.0.0",
|
|
114
114
|
"rimraf": "^6.0.1",
|
|
115
115
|
"tsup": "^8.5.0",
|
|
116
|
-
"typedoc": "^0.28.
|
|
116
|
+
"typedoc": "^0.28.13",
|
|
117
117
|
"typescript": "^5.9.2",
|
|
118
|
-
"vite": "^7.1.
|
|
118
|
+
"vite": "^7.1.6",
|
|
119
119
|
"vitest": "^3.2.4"
|
|
120
120
|
},
|
|
121
121
|
"scripts": {
|
package/dist/chunk-RZ3PTU3G.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Cesium3DTileFeature as P,Color as R,defined as H,Entity as p,GroundPrimitive as E}from"cesium";import{Cesium3DTileFeature as T,Color as f,ConstantProperty as u,defined as G,PostProcessStageLibrary as m}from"cesium";var s=class{_color=f.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;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(G(t)&&!(this._currentObject===t&&this._optionsEqual(this._currentOptions,i))){this._clearHighlights();try{if(t instanceof T)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 u(i?.width||2),t.model.silhouetteColor=new u(i?.color||this._color)}this._currentObject=t,this._currentOptions=i?{...i}:void 0}catch(e){console.error("Failed to highlight object:",e),this._currentObject=void 0,this._currentOptions=void 0}}}_optionsEqual(t,i){return!t&&!i?!0:!t||!i?!1:t.outline===i.outline&&t.width===i.width&&f.equals(t.color||this._color,i.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new u(f.TRANSPARENT),this._entity.model.silhouetteSize=new u(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(t){this._color=t}get currentObject(){return this._currentObject}};import{Cartesian3 as o,ClassificationType as v,Color as O,defined as S,Entity as g,GroundPrimitive as w,HeightReference as _,PolygonGraphics as C,PolygonHierarchy as b,PolylineGraphics as a,RectangleGraphics as D}from"cesium";var l=class{_color=O.RED;_entity;_entities;_currentObject;_currentOptions;constructor(t){this._entities=t.entities,this._entity=this._entities.add(new g({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}show(t,i){if(!(!S(t)||!this._entity)){if(this._currentObject===t&&this._optionsEqual(this._currentOptions,i))return this._entity;this._clearGeometries();try{if(t instanceof g&&(t.polygon||t.polyline||t.rectangle))this._update(t,i);else if(t instanceof w)this._update(t,i);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=t,this._currentOptions=i?{...i}:void 0,this._entity.show=!0,this._entity}catch(e){console.error("Failed to highlight object:",e),this._currentObject=void 0,this._currentOptions=void 0;return}}}_optionsEqual(t,i){return!t&&!i?!0:!t||!i?!1:t.outline===i.outline&&t.width===i.width&&O.equals(t.color||this._color,i.color||this._color)}_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 g){if(t.polygon)if(i.outline){let e=t.polygon.hierarchy?.getValue();if(e&&e.positions){let r;e.positions.length>0&&!o.equals(e.positions[0],e.positions[e.positions.length-1])?r=[...e.positions,e.positions[0]]:r=e.positions,this._entity.polyline=new a({positions:r,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:_.CLAMP_TO_GROUND,classificationType:t.polygon.classificationType?.getValue()||v.BOTH}))}else if(t.polyline){let e=t.polyline.positions?.getValue();if(e){let r=t.polyline.width?.getValue();this._entity.polyline=new a({positions:e,material:i.color,width:r+(i.width||2),clampToGround:!0})}}else if(t.rectangle)if(i.outline){let e=t.rectangle.coordinates?.getValue();if(e){let r=[o.fromRadians(e.west,e.north),o.fromRadians(e.east,e.north),o.fromRadians(e.east,e.south),o.fromRadians(e.west,e.south),o.fromRadians(e.west,e.north)];this._entity.polyline=new a({positions:r,material:i.color,width:i.width||2,clampToGround:!0})}}else{let e=t.rectangle.coordinates?.getValue();e&&(this._entity.rectangle=new D({coordinates:e,material:i.color,heightReference:_.CLAMP_TO_GROUND}))}}else if(t instanceof w){let e=t.geometryInstances,r=Array.isArray(e)?e[0]:e;if(!r.geometry.attributes.position)return;let c=r.geometry.attributes.position.values,d=[];for(let h=0;h<c.length;h+=3)d.push(new o(c[h],c[h+1],c[h+2]));i.outline?this._entity.polyline=new a({positions:d,material:i.color,width:i.width||2,clampToGround:!0}):this._entity.polygon=new C({hierarchy:new b(d),material:i.color,heightReference:_.CLAMP_TO_GROUND,classificationType:v.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(t){this._color=t}get entity(){return this._entity}get currentObject(){return this._currentObject}};var y=class n{static instances=new WeakMap;_surface;_silhouette;_color=R.RED;constructor(t){this._surface=new l(t),this._silhouette=new s(t),this._surface.color=this._color,this._silhouette.color=this._color}static getInstance(t){let i=t.container;return n.instances.has(i)||n.instances.set(i,new n(t)),n.instances.get(i)}static releaseInstance(t){let i=t.container,e=n.instances.get(i);e&&(e.hide(),e._surface&&e._surface.destroy(),e._silhouette&&e._silhouette.destroy(),n.instances.delete(i))}show(t,i={color:this._color}){let e=this._getObject(t);if(H(e))return e instanceof P?this._silhouette.show(e,i):e instanceof p&&e.model?this._silhouette.show(e,i):this._surface.show(e,i)}_getObject(t){if(H(t)){if(t instanceof p||t instanceof P||t instanceof E)return t;if(t.id instanceof p)return t.id;if(t.primitive instanceof E)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}},V=y;export{s as a,l as b,V as c};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { DataSourceCollection, EntityCollection, ImageryLayerCollection, PrimitiveCollection, Billboard, Cesium3DTileset, GroundPrimitive, Label, PointPrimitive, Polyline, Primitive, DataSource, Entity, ImageryLayer } from 'cesium';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Runtime type validator to identify the non-function property.
|
|
5
|
+
*/
|
|
6
|
+
type NonFunction<T> = {
|
|
7
|
+
[K in keyof T]: T[K] extends Function ? never : K;
|
|
8
|
+
}[keyof T];
|
|
3
9
|
/**
|
|
4
10
|
* Examine the property descriptors at runtime
|
|
5
11
|
* to detect properties that only have getters.
|
|
@@ -8,12 +14,6 @@ import { DataSourceCollection, EntityCollection, ImageryLayerCollection, Primiti
|
|
|
8
14
|
* @param k The key value of the property.
|
|
9
15
|
*/
|
|
10
16
|
declare function isGetterOnly(o: object, k: string | number | symbol): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Runtime type validator to identify the non-function property.
|
|
13
|
-
*/
|
|
14
|
-
type NonFunction<T> = {
|
|
15
|
-
[K in keyof T]: T[K] extends Function ? never : K;
|
|
16
|
-
}[keyof T];
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* @class
|
|
@@ -171,44 +171,29 @@ declare class Collection<C extends Collection.Base, I extends Collection.ItemFor
|
|
|
171
171
|
*/
|
|
172
172
|
[Symbol.iterator](): Iterator<I>;
|
|
173
173
|
/**
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
* @private
|
|
177
|
-
* @param type - The event type
|
|
178
|
-
* @param data - Additional event data
|
|
179
|
-
*/
|
|
180
|
-
private _emit;
|
|
181
|
-
/**
|
|
182
|
-
* Adds an item to the internal tag map for quick lookups.
|
|
183
|
-
*
|
|
184
|
-
* @private
|
|
185
|
-
* @param item - The item to add
|
|
186
|
-
* @param tag - The tag to associate with the item
|
|
187
|
-
*/
|
|
188
|
-
private _addToTagMap;
|
|
189
|
-
/**
|
|
190
|
-
* Removes an item from the internal tag map.
|
|
174
|
+
* Gets all item instances in the collection.
|
|
175
|
+
* This array should not be modified directly.
|
|
191
176
|
*
|
|
192
|
-
* @
|
|
193
|
-
* @param item - The item to remove
|
|
177
|
+
* @returns An array of all items in the collection
|
|
194
178
|
*/
|
|
195
|
-
|
|
179
|
+
get values(): I[];
|
|
196
180
|
/**
|
|
197
|
-
*
|
|
181
|
+
* Gets the number of items in the collection.
|
|
198
182
|
*
|
|
199
|
-
* @
|
|
183
|
+
* @returns The item count
|
|
200
184
|
*/
|
|
201
|
-
|
|
185
|
+
get length(): number;
|
|
202
186
|
/**
|
|
203
|
-
*
|
|
187
|
+
* Gets all unique tags currently in use in the collection.
|
|
204
188
|
*
|
|
205
|
-
* @
|
|
206
|
-
* @param collection - The Cesium collection to monitor for changes
|
|
189
|
+
* @returns An array of all unique tags
|
|
207
190
|
*
|
|
208
|
-
* @
|
|
209
|
-
*
|
|
191
|
+
* @example
|
|
192
|
+
* // Get all tags
|
|
193
|
+
* const tags = collection.tags;
|
|
194
|
+
* console.log(`Collection has these tags: ${tags.join(', ')}`);
|
|
210
195
|
*/
|
|
211
|
-
|
|
196
|
+
get tags(): Collection.Tag[];
|
|
212
197
|
/**
|
|
213
198
|
* Registers an event listener for collection events.
|
|
214
199
|
*
|
|
@@ -300,19 +285,6 @@ declare class Collection<C extends Collection.Base, I extends Collection.ItemFor
|
|
|
300
285
|
* The Collection instance should not be used after calling this method.
|
|
301
286
|
*/
|
|
302
287
|
destroy(): void;
|
|
303
|
-
/**
|
|
304
|
-
* Gets all item instances in the collection.
|
|
305
|
-
* This array should not be modified directly.
|
|
306
|
-
*
|
|
307
|
-
* @returns An array of all items in the collection
|
|
308
|
-
*/
|
|
309
|
-
get values(): I[];
|
|
310
|
-
/**
|
|
311
|
-
* Gets the number of items in the collection.
|
|
312
|
-
*
|
|
313
|
-
* @returns The item count
|
|
314
|
-
*/
|
|
315
|
-
get length(): number;
|
|
316
288
|
/**
|
|
317
289
|
* Gets all items with the specified tag from the collection.
|
|
318
290
|
* Uses an optimized internal map for faster lookups.
|
|
@@ -337,17 +309,6 @@ declare class Collection<C extends Collection.Base, I extends Collection.ItemFor
|
|
|
337
309
|
* const firstBuilding = collection.first('buildings');
|
|
338
310
|
*/
|
|
339
311
|
first(by: Collection.Tag): I | undefined;
|
|
340
|
-
/**
|
|
341
|
-
* Gets all unique tags currently in use in the collection.
|
|
342
|
-
*
|
|
343
|
-
* @returns An array of all unique tags
|
|
344
|
-
*
|
|
345
|
-
* @example
|
|
346
|
-
* // Get all tags
|
|
347
|
-
* const tags = collection.tags;
|
|
348
|
-
* console.log(`Collection has these tags: ${tags.join(', ')}`);
|
|
349
|
-
*/
|
|
350
|
-
get tags(): Collection.Tag[];
|
|
351
312
|
/**
|
|
352
313
|
* Updates the tag for all items with the specified tag.
|
|
353
314
|
*
|
|
@@ -482,6 +443,45 @@ declare class Collection<C extends Collection.Base, I extends Collection.ItemFor
|
|
|
482
443
|
* );
|
|
483
444
|
*/
|
|
484
445
|
find(predicate: (value: I) => boolean, by?: Collection.Tag): I | undefined;
|
|
446
|
+
/**
|
|
447
|
+
* Emits an event to all registered listeners.
|
|
448
|
+
*
|
|
449
|
+
* @private
|
|
450
|
+
* @param type - The event type
|
|
451
|
+
* @param data - Additional event data
|
|
452
|
+
*/
|
|
453
|
+
private _emit;
|
|
454
|
+
/**
|
|
455
|
+
* Adds an item to the internal tag map for quick lookups.
|
|
456
|
+
*
|
|
457
|
+
* @private
|
|
458
|
+
* @param item - The item to add
|
|
459
|
+
* @param tag - The tag to associate with the item
|
|
460
|
+
*/
|
|
461
|
+
private _addToTagMap;
|
|
462
|
+
/**
|
|
463
|
+
* Removes an item from the internal tag map.
|
|
464
|
+
*
|
|
465
|
+
* @private
|
|
466
|
+
* @param item - The item to remove
|
|
467
|
+
*/
|
|
468
|
+
private _removeFromTagMap;
|
|
469
|
+
/**
|
|
470
|
+
* Invalidates the values cache when collection changes.
|
|
471
|
+
*
|
|
472
|
+
* @private
|
|
473
|
+
*/
|
|
474
|
+
private _invalidateCache;
|
|
475
|
+
/**
|
|
476
|
+
* Sets up automatic cache invalidation by registering event listeners on the underlying Cesium collection.
|
|
477
|
+
*
|
|
478
|
+
* @private
|
|
479
|
+
* @param collection - The Cesium collection to monitor for changes
|
|
480
|
+
*
|
|
481
|
+
* @see {@link destroy} For cleanup of event listeners
|
|
482
|
+
* @see {@link _invalidateCache} For the actual cache invalidation logic
|
|
483
|
+
*/
|
|
484
|
+
private _setupCacheInvalidator;
|
|
485
485
|
}
|
|
486
486
|
/**
|
|
487
487
|
* @namespace
|