@juun-roh/cesium-utils 0.2.7 → 0.3.1

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 CHANGED
@@ -106,6 +106,17 @@ Additional utilities for advanced usage:
106
106
  import { Deprecate, TerrainVisualizer, isGetterOnly } from "@juun-roh/cesium-utils/dev";
107
107
  ```
108
108
 
109
+ ### Experimental Features
110
+
111
+ ⚠️ **Warning**: Experimental features use Cesium's internal APIs and may break in future versions.
112
+
113
+ ```typescript
114
+ import Sunlight from "@juun-roh/cesium-utils/experimental/sunlight";
115
+
116
+ const sunlight = new Sunlight(viewer);
117
+ const result = sunlight.analyze(point, JulianDate.now());
118
+ ```
119
+
109
120
  ## License
110
121
 
111
122
  MIT © Juun
@@ -0,0 +1 @@
1
+ import{EllipsoidTerrainProvider as v}from"cesium";var n=class{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(r){this._defaultProvider=r.defaultProvider,this._fallbackProvider=r.fallbackProvider||new v,this._tilingScheme=r.defaultProvider.tilingScheme,this._regions=r.regions||[],this._availability=r.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(r,e,i){return this._defaultProvider.loadTileDataAvailability(r,e,i)}getLevelMaximumGeometricError(r){return this._defaultProvider.getLevelMaximumGeometricError(r)}requestTileGeometry(r,e,i,t){if(this._ready){for(let a of this._regions)if(this._regionContains(a,r,e,i))return a.provider.requestTileGeometry(r,e,i,t);return this._defaultProvider.getTileDataAvailable(r,e,i)?this._defaultProvider.requestTileGeometry(r,e,i,t):this._fallbackProvider.requestTileGeometry(r,e,i,t)}}getTileDataAvailable(r,e,i){for(let t of this._regions)if(this._regionContains(t,r,e,i)&&t.provider.getTileDataAvailable(r,e,i))return!0;return this._defaultProvider.getTileDataAvailable(r,e,i)}_regionContains(r,e,i,t){if(r.levels&&!r.levels.includes(t))return!1;if(r.tiles){let a=r.tiles.get(t);if(!a)return!1;let[l,d]=Array.isArray(a.x)?a.x:[a.x,a.x],[u,s]=Array.isArray(a.y)?a.y:[a.y,a.y];return e>=l&&e<=d&&i>=u&&i<=s}return!1}};(r=>{function o(e,i,t){return new r({regions:e.map(a=>({...a})),defaultProvider:i,fallbackProvider:t})}r.fromTileRanges=o})(n||={});var b=n;export{b as a};
@@ -0,0 +1 @@
1
+ var I;(h=>{let o=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(a,l={}){if(!e)return;let{once:c=!0,prefix:u="[DEPRECATED]",includeStack:m=!0,removeInVersion:g}=l;if(c&&o.has(a))return;let p=`${u} ${a}`;g&&(p+=` This feature will be removed in ${g}.`),typeof console<"u"&&console.warn&&(m?(console.warn(p),console.trace("Deprecation stack trace:")):console.warn(p)),c&&o.add(a)}h.warn=t;function i(a,l,c={}){let u=((...m)=>(t(l,c),a(...m)));return Object.defineProperty(u,"name",{value:a.name,configurable:!0}),u}h.deprecate=i;function r(){o.clear()}h.clear=r;function n(){return o.size}h.getWarningCount=n;function s(a){return o.has(a)}h.hasShown=s})(I||={});var P=I;import{Color as d,Entity as V,HeightReference as N,Rectangle as R,TileCoordinatesImageryProvider as j}from"cesium";import{DataSourceCollection as O,defined as T,EntityCollection as S,ImageryLayerCollection as F,PrimitiveCollection as D}from"cesium";var b=class o{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(n=>n(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[o.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof S?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof D?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof O?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof F&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,o.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof S)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,o.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)T(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)T(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)T(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let n of r)if(e in n&&typeof n[e]!="function"){if(E(n,e))throw Error(`Cannot set read-only property '${String(e)}' on ${n.constructor.name}`);n[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,n)=>e(r,n))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},w=b;var f=class o{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",d.RED],["default",d.BLUE],["fallback",d.GRAY],["grid",d.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new w({collection:e.entities,tag:o.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(o.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new j({tilingScheme:this._terrainProvider.tilingScheme,color:d.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(s=>{this._collection.add(s.entity,o.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(R.northwest(e),t),n=i.positionToTileXY(R.southeast(e),t);if(!r||!n)throw new Error("Failed to calculate tile bounds");return{start:r,end:n}}_generateVisibleTiles(e,t,i){let r=[],s=Math.min(e.end.x-e.start.x+1,100),h=Math.min(e.end.y-e.start.y+1,100);for(let a=e.start.x;a<e.start.x+s;a++)for(let l=e.start.y;l<e.start.y+h;l++)try{let c=this._createTileEntity(a,l,t,i);c&&r.push({entity:c})}catch(c){console.warn(`Error creating tile (${a}, ${l}, ${t}):`,c)}return r}_createTileEntity(e,t,i,r){let n=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(n))return null;let s=this._getTileColor(e,t,i),h=o.createRectangle(n,s.withAlpha(.3));return h.properties?.addProperty("tileX",e),h.properties?.addProperty("tileY",t),h.properties?.addProperty("tileLevel",i),h}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||d.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||d.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||d.BLUE:this._colors.get("fallback")||d.GRAY}hide(){this._collection.remove(o.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){this._viewer.camera.flyTo({destination:e,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,n){return new V({rectangle:{coordinates:r,material:n,heightReference:N.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,n,s){let h=s?.tag||"terrain_region_visualization",a=s?.color||d.RED,l=s?.maxTilesToShow||100,c=s?.show??!0,u=s?.alpha||.7,m=s?.tileAlpha||.2,g=new w({collection:n.entities,tag:h});if(c&&r.tiles&&r.tiles.size>0){let p=r.provider.tilingScheme,y=0;r.tiles.forEach((v,A)=>{let L=Array.isArray(v.x)?v.x:[v.x,v.x],x=Array.isArray(v.y)?v.y:[v.y,v.y];for(let C=L[0];C<=L[1]&&y<l;C++)for(let _=x[0];_<=x[1]&&y<l;_++){let M=p.tileXYToRectangle(C,_,A);g.add(e(M,a.withAlpha(m)),`${h}_tile`),y++}})}return g}i.visualize=t})(f||={});function E(o,e){let t=!1,i=Object.getOwnPropertyDescriptor(o,e);if(!i){let r=Object.getPrototypeOf(o);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var ee=P.deprecate;export{P as a,f as b,E as c,ee as d,w as e};
@@ -1 +1 @@
1
- "use strict";var E=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var D=(n,e)=>{for(var t in e)E(n,t,{get:e[t],enumerable:!0})},V=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of O(e))!F.call(n,r)&&r!==t&&E(n,r,{get:()=>e[r],enumerable:!(i=M(e,r))||i.enumerable});return n};var N=n=>V(E({},"__esModule",{value:!0}),n);var j={};D(j,{Collection:()=>C});module.exports=N(j);var c=require("cesium");var P;(h=>{let n=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(s,d={}){if(!e)return;let{once:v=!0,prefix:m="[DEPRECATED]",includeStack:p=!0,removeInVersion:g}=d;if(v&&n.has(s))return;let f=`${m} ${s}`;g&&(f+=` This feature will be removed in ${g}.`),typeof console<"u"&&console.warn&&(p?(console.warn(f),console.trace("Deprecation stack trace:")):console.warn(f)),v&&n.add(s)}h.warn=t;function i(s,d,v={}){let m=((...p)=>(t(d,v),s(...p)));return Object.defineProperty(m,"name",{value:s.name,configurable:!0}),m}h.deprecate=i;function r(){n.clear()}h.clear=r;function o(){return n.size}h.getWarningCount=o;function l(s){return n.has(s)}h.hasShown=l})(P||={});var S=P;var a=require("cesium");var y=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",a.Color.RED],["default",a.Color.BLUE],["fallback",a.Color.GRAY],["grid",a.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 a.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:a.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(a.Rectangle.northwest(e),t),o=i.positionToTileXY(a.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),h=Math.min(e.end.y-e.start.y+1,100);for(let s=e.start.x;s<e.start.x+l;s++)for(let d=e.start.y;d<e.start.y+h;d++)try{let v=this._createTileEntity(s,d,t,i);v&&r.push({entity:v})}catch(v){console.warn(`Error creating tile (${s}, ${d}, ${t}):`,v)}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),h=n.createRectangle(o,l.withAlpha(.3));return h.properties?.addProperty("tileX",e),h.properties?.addProperty("tileY",t),h.properties?.addProperty("tileLevel",i),h}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||a.Color.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||a.Color.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||a.Color.BLUE:this._colors.get("fallback")||a.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 a.Entity({rectangle:{coordinates:r,material:o,heightReference:a.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,l){let h=l?.tag||"terrain_region_visualization",s=l?.color||a.Color.RED,d=l?.maxTilesToShow||100,v=l?.show??!0,m=l?.alpha||.7,p=l?.tileAlpha||.2,g=new C({collection:o.entities,tag:h});if(r.bounds&&g.add(i.createRectangle(r.bounds,s.withAlpha(m)),h),v&&r.tiles&&r.tiles.size>0){let f=r.provider.tilingScheme,_=0;r.tiles.forEach((u,R)=>{let x=Array.isArray(u.x)?u.x:[u.x,u.x],I=Array.isArray(u.y)?u.y:[u.y,u.y];for(let T=x[0];T<=x[1]&&_<d;T++)for(let b=I[0];b<=I[1]&&_<d;b++){let A=f.tileXYToRectangle(T,b,R);g.add(e(A,s.withAlpha(p)),`${h}_tile`),_++}})}return g}i.visualize=t})(y||={});function w(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 J=S.deprecate;var L=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 c.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof c.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 c.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 c.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 c.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,c.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,c.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,c.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(w(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=L;
1
+ "use strict";var E=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var D=(n,e)=>{for(var t in e)E(n,t,{get:e[t],enumerable:!0})},V=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of O(e))!F.call(n,r)&&r!==t&&E(n,r,{get:()=>e[r],enumerable:!(i=M(e,r))||i.enumerable});return n};var N=n=>V(E({},"__esModule",{value:!0}),n);var j={};D(j,{Collection:()=>C});module.exports=N(j);var c=require("cesium");var P;(v=>{let n=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(s,h={}){if(!e)return;let{once:d=!0,prefix:m="[DEPRECATED]",includeStack:g=!0,removeInVersion:p}=h;if(d&&n.has(s))return;let f=`${m} ${s}`;p&&(f+=` This feature will be removed in ${p}.`),typeof console<"u"&&console.warn&&(g?(console.warn(f),console.trace("Deprecation stack trace:")):console.warn(f)),d&&n.add(s)}v.warn=t;function i(s,h,d={}){let m=((...g)=>(t(h,d),s(...g)));return Object.defineProperty(m,"name",{value:s.name,configurable:!0}),m}v.deprecate=i;function r(){n.clear()}v.clear=r;function o(){return n.size}v.getWarningCount=o;function l(s){return n.has(s)}v.hasShown=l})(P||={});var S=P;var a=require("cesium");var y=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",a.Color.RED],["default",a.Color.BLUE],["fallback",a.Color.GRAY],["grid",a.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 a.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:a.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(a.Rectangle.northwest(e),t),o=i.positionToTileXY(a.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),v=Math.min(e.end.y-e.start.y+1,100);for(let s=e.start.x;s<e.start.x+l;s++)for(let h=e.start.y;h<e.start.y+v;h++)try{let d=this._createTileEntity(s,h,t,i);d&&r.push({entity:d})}catch(d){console.warn(`Error creating tile (${s}, ${h}, ${t}):`,d)}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),v=n.createRectangle(o,l.withAlpha(.3));return v.properties?.addProperty("tileX",e),v.properties?.addProperty("tileY",t),v.properties?.addProperty("tileLevel",i),v}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||a.Color.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||a.Color.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||a.Color.BLUE:this._colors.get("fallback")||a.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 a.Entity({rectangle:{coordinates:r,material:o,heightReference:a.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,l){let v=l?.tag||"terrain_region_visualization",s=l?.color||a.Color.RED,h=l?.maxTilesToShow||100,d=l?.show??!0,m=l?.alpha||.7,g=l?.tileAlpha||.2,p=new C({collection:o.entities,tag:v});if(d&&r.tiles&&r.tiles.size>0){let f=r.provider.tilingScheme,_=0;r.tiles.forEach((u,R)=>{let x=Array.isArray(u.x)?u.x:[u.x,u.x],I=Array.isArray(u.y)?u.y:[u.y,u.y];for(let T=x[0];T<=x[1]&&_<h;T++)for(let b=I[0];b<=I[1]&&_<h;b++){let A=f.tileXYToRectangle(T,b,R);p.add(e(A,s.withAlpha(g)),`${v}_tile`),_++}})}return p}i.visualize=t})(y||={});function w(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 J=S.deprecate;var L=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 c.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof c.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 c.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 c.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 c.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,c.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,c.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,c.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(w(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=L;
@@ -1 +1 @@
1
- import"../chunk-RXMNSDKR.js";import{d as a}from"../chunk-OUTUX3ZP.js";import"../chunk-TC3IX3JL.js";export{a as Collection};
1
+ import"../chunk-RXMNSDKR.js";import{e as a}from"../chunk-O27H72YO.js";export{a as Collection};
@@ -1 +1 @@
1
- "use strict";var E=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var D=(n,e)=>{for(var t in e)E(n,t,{get:e[t],enumerable:!0})},V=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of O(e))!F.call(n,r)&&r!==t&&E(n,r,{get:()=>e[r],enumerable:!(i=M(e,r))||i.enumerable});return n};var N=n=>V(E({},"__esModule",{value:!0}),n);var G={};D(G,{Deprecate:()=>w,TerrainVisualizer:()=>p,deprecate:()=>j,isGetterOnly:()=>C});module.exports=N(G);var S;(h=>{let n=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(s,d={}){if(!e)return;let{once:v=!0,prefix:m="[DEPRECATED]",includeStack:f=!0,removeInVersion:g}=d;if(v&&n.has(s))return;let y=`${m} ${s}`;g&&(y+=` This feature will be removed in ${g}.`),typeof console<"u"&&console.warn&&(f?(console.warn(y),console.trace("Deprecation stack trace:")):console.warn(y)),v&&n.add(s)}h.warn=t;function i(s,d,v={}){let m=((...f)=>(t(d,v),s(...f)));return Object.defineProperty(m,"name",{value:s.name,configurable:!0}),m}h.deprecate=i;function r(){n.clear()}h.clear=r;function o(){return n.size}h.getWarningCount=o;function l(s){return n.has(s)}h.hasShown=l})(S||={});var w=S;var a=require("cesium");var c=require("cesium");var L=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 c.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof c.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 c.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 c.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 c.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,c.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,c.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,c.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(C(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)}},x=L;var p=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",a.Color.RED],["default",a.Color.BLUE],["fallback",a.Color.GRAY],["grid",a.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new x({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 a.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:a.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(a.Rectangle.northwest(e),t),o=i.positionToTileXY(a.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),h=Math.min(e.end.y-e.start.y+1,100);for(let s=e.start.x;s<e.start.x+l;s++)for(let d=e.start.y;d<e.start.y+h;d++)try{let v=this._createTileEntity(s,d,t,i);v&&r.push({entity:v})}catch(v){console.warn(`Error creating tile (${s}, ${d}, ${t}):`,v)}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),h=n.createRectangle(o,l.withAlpha(.3));return h.properties?.addProperty("tileX",e),h.properties?.addProperty("tileY",t),h.properties?.addProperty("tileLevel",i),h}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||a.Color.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||a.Color.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||a.Color.BLUE:this._colors.get("fallback")||a.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 a.Entity({rectangle:{coordinates:r,material:o,heightReference:a.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,l){let h=l?.tag||"terrain_region_visualization",s=l?.color||a.Color.RED,d=l?.maxTilesToShow||100,v=l?.show??!0,m=l?.alpha||.7,f=l?.tileAlpha||.2,g=new x({collection:o.entities,tag:h});if(r.bounds&&g.add(i.createRectangle(r.bounds,s.withAlpha(m)),h),v&&r.tiles&&r.tiles.size>0){let y=r.provider.tilingScheme,_=0;r.tiles.forEach((u,R)=>{let I=Array.isArray(u.x)?u.x:[u.x,u.x],P=Array.isArray(u.y)?u.y:[u.y,u.y];for(let T=I[0];T<=I[1]&&_<d;T++)for(let b=P[0];b<=P[1]&&_<d;b++){let A=y.tileXYToRectangle(T,b,R);g.add(e(A,s.withAlpha(f)),`${h}_tile`),_++}})}return g}i.visualize=t})(p||={});function C(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 j=w.deprecate;
1
+ "use strict";var E=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var D=(n,e)=>{for(var t in e)E(n,t,{get:e[t],enumerable:!0})},V=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of O(e))!F.call(n,r)&&r!==t&&E(n,r,{get:()=>e[r],enumerable:!(i=M(e,r))||i.enumerable});return n};var N=n=>V(E({},"__esModule",{value:!0}),n);var G={};D(G,{Deprecate:()=>w,TerrainVisualizer:()=>m,deprecate:()=>j,isGetterOnly:()=>C});module.exports=N(G);var S;(v=>{let n=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(s,h={}){if(!e)return;let{once:d=!0,prefix:g="[DEPRECATED]",includeStack:p=!0,removeInVersion:f}=h;if(d&&n.has(s))return;let y=`${g} ${s}`;f&&(y+=` This feature will be removed in ${f}.`),typeof console<"u"&&console.warn&&(p?(console.warn(y),console.trace("Deprecation stack trace:")):console.warn(y)),d&&n.add(s)}v.warn=t;function i(s,h,d={}){let g=((...p)=>(t(h,d),s(...p)));return Object.defineProperty(g,"name",{value:s.name,configurable:!0}),g}v.deprecate=i;function r(){n.clear()}v.clear=r;function o(){return n.size}v.getWarningCount=o;function l(s){return n.has(s)}v.hasShown=l})(S||={});var w=S;var a=require("cesium");var c=require("cesium");var L=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 c.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof c.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 c.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 c.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 c.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,c.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,c.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,c.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(C(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)}},x=L;var m=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",a.Color.RED],["default",a.Color.BLUE],["fallback",a.Color.GRAY],["grid",a.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new x({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 a.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:a.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(a.Rectangle.northwest(e),t),o=i.positionToTileXY(a.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),v=Math.min(e.end.y-e.start.y+1,100);for(let s=e.start.x;s<e.start.x+l;s++)for(let h=e.start.y;h<e.start.y+v;h++)try{let d=this._createTileEntity(s,h,t,i);d&&r.push({entity:d})}catch(d){console.warn(`Error creating tile (${s}, ${h}, ${t}):`,d)}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),v=n.createRectangle(o,l.withAlpha(.3));return v.properties?.addProperty("tileX",e),v.properties?.addProperty("tileY",t),v.properties?.addProperty("tileLevel",i),v}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||a.Color.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||a.Color.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||a.Color.BLUE:this._colors.get("fallback")||a.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 a.Entity({rectangle:{coordinates:r,material:o,heightReference:a.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,l){let v=l?.tag||"terrain_region_visualization",s=l?.color||a.Color.RED,h=l?.maxTilesToShow||100,d=l?.show??!0,g=l?.alpha||.7,p=l?.tileAlpha||.2,f=new x({collection:o.entities,tag:v});if(d&&r.tiles&&r.tiles.size>0){let y=r.provider.tilingScheme,_=0;r.tiles.forEach((u,R)=>{let I=Array.isArray(u.x)?u.x:[u.x,u.x],P=Array.isArray(u.y)?u.y:[u.y,u.y];for(let T=I[0];T<=I[1]&&_<h;T++)for(let b=P[0];b<=P[1]&&_<h;b++){let A=y.tileXYToRectangle(T,b,R);f.add(e(A,s.withAlpha(p)),`${v}_tile`),_++}})}return f}i.visualize=t})(m||={});function C(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 j=w.deprecate;
@@ -1,7 +1,7 @@
1
1
  import { Viewer, Color, Rectangle, EntityCollection, Entity } from 'cesium';
2
2
  import { C as Collection } from '../index-Bfd24d9-.cjs';
3
3
  export { N as NonFunction, i as isGetterOnly } from '../index-Bfd24d9-.cjs';
4
- import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-C2V-igd9.cjs';
4
+ import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-CzdhZJyg.cjs';
5
5
 
6
6
  /**
7
7
  * Utility for managing deprecation warnings in the cesium-utils library.
@@ -1,7 +1,7 @@
1
1
  import { Viewer, Color, Rectangle, EntityCollection, Entity } from 'cesium';
2
2
  import { C as Collection } from '../index-Bfd24d9-.js';
3
3
  export { N as NonFunction, i as isGetterOnly } from '../index-Bfd24d9-.js';
4
- import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-C2V-igd9.js';
4
+ import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-CzdhZJyg.js';
5
5
 
6
6
  /**
7
7
  * Utility for managing deprecation warnings in the cesium-utils library.
package/dist/dev/index.js CHANGED
@@ -1 +1 @@
1
- import{a as b,b as c,c as d}from"../chunk-OUTUX3ZP.js";import{a}from"../chunk-TC3IX3JL.js";export{a as Deprecate,b as TerrainVisualizer,d as deprecate,c as isGetterOnly};
1
+ import{a,b,c,d}from"../chunk-O27H72YO.js";export{a as Deprecate,b as TerrainVisualizer,d as deprecate,c as isGetterOnly};
@@ -0,0 +1 @@
1
+ "use strict";var y=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var S=(r,t)=>{for(var e in t)y(r,e,{get:t[e],enumerable:!0})},C=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of b(t))!m.call(r,s)&&s!==e&&y(r,s,{get:()=>t[s],enumerable:!(i=v(t,s))||i.enumerable});return r};var E=r=>C(y({},"__esModule",{value:!0}),r);var f={};S(f,{Sunlight:()=>_});module.exports=E(f);var a=require("cesium"),n=require("cesium"),g=class{_sunPositionWC;_sunDirectionWC;_viewer;_analyzing=!1;_pointEntityId;_debugEntityIds=[];constructor(t){let{sunPositionWC:e,sunDirectionWC:i}=t.scene.context.uniformState;this._sunPositionWC=e,this._sunDirectionWC=i,this._viewer=t}get sunPositionWC(){return this._sunPositionWC}get sunDirectionWC(){return this._sunDirectionWC}get isAnalyzing(){return this._analyzing}getVirtualSunPosition(t,e=1e3){let i=n.Cartesian3.normalize(n.Cartesian3.subtract(this._sunPositionWC,t,new n.Cartesian3),new n.Cartesian3);return n.Cartesian3.multiplyByScalar(i,e,i),n.Cartesian3.add(t,i,new n.Cartesian3)}analyze(t,e,i){let s=[],c=!this._analyzing,p=c?this._viewer.clock.currentTime.clone():void 0;c&&(this._viewer.entities.add(this._createPointEntity(t,i?.debugShowPoints,i?.errorBoundary)),this._analyzing=!0);try{if(e instanceof n.JulianDate){this._viewer.clock.currentTime=e,this._viewer.scene.render();let d=new a.Ray(this.getVirtualSunPosition(t),this._sunDirectionWC);if(i?.debugShowRays){let l=new a.Entity({polyline:{positions:[this.getVirtualSunPosition(t),t],width:10,material:a.Color.YELLOW.withAlpha(.5)}});this._debugEntityIds.push(l.id),this._viewer.entities.add(l)}let u=this._viewer.scene.picking,{object:h,position:o}=u.pickFromRay(u,this._viewer.scene,d,[...this._debugEntityIds.map(l=>this._viewer.entities.getById(l)).filter(Boolean),...i?.objectsToExclude??[]]),w=h instanceof a.Entity&&h.id===this._pointEntityId;if(i?.debugShowPoints&&o){let l=new a.Entity({point:{show:!0,pixelSize:5},position:o});this._debugEntityIds.push(l.id),this._viewer.entities.add(l)}return{timestamp:e.toString(),result:w}}else{let{start:d,end:u,step:h}=e,o=d.clone();for(;n.JulianDate.compare(o,u)<=0;)s.push(this.analyze(t,o,i)),n.JulianDate.addSeconds(o,h,o)}}finally{c&&p&&(this._viewer.clock.currentTime=p,this._viewer.scene.render(),this._analyzing=!1,this._pointEntityId&&!i?.debugShowPoints&&this._viewer.entities.removeById(this._pointEntityId))}return s}_createPointEntity(t,e,i){let s=new a.Entity({point:{show:e,pixelSize:i??5},position:t});return this._pointEntityId=s.id,s}clear(){this._debugEntityIds.forEach(t=>this._viewer.entities.removeById(t)),this._debugEntityIds=[],this._pointEntityId&&this._viewer.entities.removeById(this._pointEntityId)}},_=g;
@@ -0,0 +1,92 @@
1
+ import { Viewer, Cartesian3, JulianDate } from 'cesium';
2
+
3
+ /**
4
+ * @since Cesium 1.132.0
5
+ * @experimental
6
+ * Point sunlight analysis utility for shadow calculations.
7
+ *
8
+ * ⚠️ **Warning**: This is an experimental feature that uses Cesium's internal APIs.
9
+ * The API may change or break in future versions of Cesium or cesium-utils.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const sunlight = new Sunlight(viewer);
14
+ * sunlight.analyze(point, JulianDate.now());
15
+ * ```
16
+ */
17
+ declare class Sunlight {
18
+ private _sunPositionWC;
19
+ private _sunDirectionWC;
20
+ private _viewer;
21
+ private _analyzing;
22
+ private _pointEntityId?;
23
+ private _debugEntityIds;
24
+ constructor(viewer: Viewer);
25
+ /** The sun position in 3D world coordinates at the current scene time. */
26
+ get sunPositionWC(): Cartesian3;
27
+ /** A normalized vector to the sun in 3D world coordinates at the current scene time. */
28
+ get sunDirectionWC(): Cartesian3;
29
+ /** Whether sunlight analysis is currently in progress. */
30
+ get isAnalyzing(): boolean;
31
+ /**
32
+ * Gets a virtual position of the sun to reduce calculation overhead.
33
+ *
34
+ * @param from target point to start from
35
+ * @param radius virtual distance between target point and the sun. Defaults to 1000 (1km)
36
+ */
37
+ getVirtualSunPosition(from: Cartesian3, radius?: number): Cartesian3;
38
+ /**
39
+ * Analyze the sunlight acceptance from a given point at a given time.
40
+ * @param from target point to analyze
41
+ * @param at time to analyze
42
+ * @param options {@link Sunlight.AnalyzeOptions}
43
+ */
44
+ analyze(from: Cartesian3, at: JulianDate, options?: Sunlight.AnalyzeOptions): Sunlight.AnalysisResult;
45
+ /**
46
+ * Analyze the sunlight acceptance from a given point at a given time range.
47
+ * @param from target point to analyze
48
+ * @param range time range to analyze
49
+ * @param options {@link Sunlight.AnalyzeOptions}
50
+ */
51
+ analyze(from: Cartesian3, range: Sunlight.TimeRange, options?: Sunlight.AnalyzeOptions): Sunlight.AnalysisResult[];
52
+ /**
53
+ * Create a point entity for collision detection
54
+ * @param at where to create the entity
55
+ * @param show whether to show point entity
56
+ * @param errorBoundary size of the point entity for error tolerance
57
+ */
58
+ private _createPointEntity;
59
+ /**
60
+ * Remove all instances created for debug purpose
61
+ */
62
+ clear(): void;
63
+ }
64
+ declare namespace Sunlight {
65
+ /** for time-range analysis */
66
+ interface TimeRange {
67
+ /** When to start analysis */
68
+ start: JulianDate;
69
+ /** When to end analysis */
70
+ end: JulianDate;
71
+ /** Step interval (seconds) inside the range */
72
+ step: number;
73
+ }
74
+ interface AnalyzeOptions {
75
+ /** List of objects to exclude from ray pick */
76
+ objectsToExclude?: any[];
77
+ /** size of the point entity for error tolerance */
78
+ errorBoundary?: number;
79
+ /** Whether to show sunlight paths, NOT IMPLEMENTED YET */
80
+ debugShowRays?: boolean;
81
+ /** Whether to show points */
82
+ debugShowPoints?: boolean;
83
+ }
84
+ interface AnalysisResult {
85
+ /** ISO time string */
86
+ timestamp: string;
87
+ /** Whether the sunlight has reached */
88
+ result: boolean;
89
+ }
90
+ }
91
+
92
+ export { Sunlight };
@@ -0,0 +1,92 @@
1
+ import { Viewer, Cartesian3, JulianDate } from 'cesium';
2
+
3
+ /**
4
+ * @since Cesium 1.132.0
5
+ * @experimental
6
+ * Point sunlight analysis utility for shadow calculations.
7
+ *
8
+ * ⚠️ **Warning**: This is an experimental feature that uses Cesium's internal APIs.
9
+ * The API may change or break in future versions of Cesium or cesium-utils.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const sunlight = new Sunlight(viewer);
14
+ * sunlight.analyze(point, JulianDate.now());
15
+ * ```
16
+ */
17
+ declare class Sunlight {
18
+ private _sunPositionWC;
19
+ private _sunDirectionWC;
20
+ private _viewer;
21
+ private _analyzing;
22
+ private _pointEntityId?;
23
+ private _debugEntityIds;
24
+ constructor(viewer: Viewer);
25
+ /** The sun position in 3D world coordinates at the current scene time. */
26
+ get sunPositionWC(): Cartesian3;
27
+ /** A normalized vector to the sun in 3D world coordinates at the current scene time. */
28
+ get sunDirectionWC(): Cartesian3;
29
+ /** Whether sunlight analysis is currently in progress. */
30
+ get isAnalyzing(): boolean;
31
+ /**
32
+ * Gets a virtual position of the sun to reduce calculation overhead.
33
+ *
34
+ * @param from target point to start from
35
+ * @param radius virtual distance between target point and the sun. Defaults to 1000 (1km)
36
+ */
37
+ getVirtualSunPosition(from: Cartesian3, radius?: number): Cartesian3;
38
+ /**
39
+ * Analyze the sunlight acceptance from a given point at a given time.
40
+ * @param from target point to analyze
41
+ * @param at time to analyze
42
+ * @param options {@link Sunlight.AnalyzeOptions}
43
+ */
44
+ analyze(from: Cartesian3, at: JulianDate, options?: Sunlight.AnalyzeOptions): Sunlight.AnalysisResult;
45
+ /**
46
+ * Analyze the sunlight acceptance from a given point at a given time range.
47
+ * @param from target point to analyze
48
+ * @param range time range to analyze
49
+ * @param options {@link Sunlight.AnalyzeOptions}
50
+ */
51
+ analyze(from: Cartesian3, range: Sunlight.TimeRange, options?: Sunlight.AnalyzeOptions): Sunlight.AnalysisResult[];
52
+ /**
53
+ * Create a point entity for collision detection
54
+ * @param at where to create the entity
55
+ * @param show whether to show point entity
56
+ * @param errorBoundary size of the point entity for error tolerance
57
+ */
58
+ private _createPointEntity;
59
+ /**
60
+ * Remove all instances created for debug purpose
61
+ */
62
+ clear(): void;
63
+ }
64
+ declare namespace Sunlight {
65
+ /** for time-range analysis */
66
+ interface TimeRange {
67
+ /** When to start analysis */
68
+ start: JulianDate;
69
+ /** When to end analysis */
70
+ end: JulianDate;
71
+ /** Step interval (seconds) inside the range */
72
+ step: number;
73
+ }
74
+ interface AnalyzeOptions {
75
+ /** List of objects to exclude from ray pick */
76
+ objectsToExclude?: any[];
77
+ /** size of the point entity for error tolerance */
78
+ errorBoundary?: number;
79
+ /** Whether to show sunlight paths, NOT IMPLEMENTED YET */
80
+ debugShowRays?: boolean;
81
+ /** Whether to show points */
82
+ debugShowPoints?: boolean;
83
+ }
84
+ interface AnalysisResult {
85
+ /** ISO time string */
86
+ timestamp: string;
87
+ /** Whether the sunlight has reached */
88
+ result: boolean;
89
+ }
90
+ }
91
+
92
+ export { Sunlight };
@@ -0,0 +1 @@
1
+ import{Color as _,Entity as u,Ray as w}from"cesium";import{Cartesian3 as a,JulianDate as d}from"cesium";var y=class{_sunPositionWC;_sunDirectionWC;_viewer;_analyzing=!1;_pointEntityId;_debugEntityIds=[];constructor(t){let{sunPositionWC:e,sunDirectionWC:i}=t.scene.context.uniformState;this._sunPositionWC=e,this._sunDirectionWC=i,this._viewer=t}get sunPositionWC(){return this._sunPositionWC}get sunDirectionWC(){return this._sunDirectionWC}get isAnalyzing(){return this._analyzing}getVirtualSunPosition(t,e=1e3){let i=a.normalize(a.subtract(this._sunPositionWC,t,new a),new a);return a.multiplyByScalar(i,e,i),a.add(t,i,new a)}analyze(t,e,i){let r=[],h=!this._analyzing,g=h?this._viewer.clock.currentTime.clone():void 0;h&&(this._viewer.entities.add(this._createPointEntity(t,i?.debugShowPoints,i?.errorBoundary)),this._analyzing=!0);try{if(e instanceof d){this._viewer.clock.currentTime=e,this._viewer.scene.render();let c=new w(this.getVirtualSunPosition(t),this._sunDirectionWC);if(i?.debugShowRays){let s=new u({polyline:{positions:[this.getVirtualSunPosition(t),t],width:10,material:_.YELLOW.withAlpha(.5)}});this._debugEntityIds.push(s.id),this._viewer.entities.add(s)}let o=this._viewer.scene.picking,{object:l,position:n}=o.pickFromRay(o,this._viewer.scene,c,[...this._debugEntityIds.map(s=>this._viewer.entities.getById(s)).filter(Boolean),...i?.objectsToExclude??[]]),p=l instanceof u&&l.id===this._pointEntityId;if(i?.debugShowPoints&&n){let s=new u({point:{show:!0,pixelSize:5},position:n});this._debugEntityIds.push(s.id),this._viewer.entities.add(s)}return{timestamp:e.toString(),result:p}}else{let{start:c,end:o,step:l}=e,n=c.clone();for(;d.compare(n,o)<=0;)r.push(this.analyze(t,n,i)),d.addSeconds(n,l,n)}}finally{h&&g&&(this._viewer.clock.currentTime=g,this._viewer.scene.render(),this._analyzing=!1,this._pointEntityId&&!i?.debugShowPoints&&this._viewer.entities.removeById(this._pointEntityId))}return r}_createPointEntity(t,e,i){let r=new u({point:{show:e,pixelSize:i??5},position:t});return this._pointEntityId=r.id,r}clear(){this._debugEntityIds.forEach(t=>this._viewer.entities.removeById(t)),this._debugEntityIds=[],this._pointEntityId&&this._viewer.entities.removeById(this._pointEntityId)}},v=y;export{v as Sunlight};
@@ -1,4 +1,4 @@
1
- import { TerrainProvider, TilingScheme, TileAvailability, Credit, Request, TerrainData, Rectangle } from 'cesium';
1
+ import { TerrainProvider, TilingScheme, TileAvailability, Credit, Request, TerrainData } from 'cesium';
2
2
 
3
3
  /**
4
4
  * @class
@@ -150,8 +150,6 @@ declare namespace HybridTerrainProvider {
150
150
  interface TerrainRegion {
151
151
  /** The terrain provider for this region. */
152
152
  provider: TerrainProvider;
153
- /** Rectangle-based geographic bounds (simpler). */
154
- bounds?: Rectangle;
155
153
  /**
156
154
  * Tile-coordinate based bounds (precise control).
157
155
  * Map of level to tile coordinate ranges for that level.
@@ -165,17 +163,6 @@ declare namespace HybridTerrainProvider {
165
163
  /** Optional level constraints. If specified, region only applies to these levels. */
166
164
  levels?: number[];
167
165
  }
168
- /**
169
- * Creates a HybridTerrainProvider from rectangle-based regions.
170
- * @param regions Array of regions with rectangle bounds
171
- * @param defaultProvider Default terrain provider
172
- * @param fallbackProvider Optional fallback provider
173
- */
174
- function fromRectangles(regions: Array<{
175
- provider: TerrainProvider;
176
- bounds: Rectangle;
177
- levels?: number[];
178
- }>, defaultProvider: TerrainProvider, fallbackProvider?: TerrainProvider): HybridTerrainProvider;
179
166
  /**
180
167
  * Creates a HybridTerrainProvider from tile-coordinate based regions.
181
168
  * @param regions Array of regions with tile-coordinate bounds
@@ -190,13 +177,6 @@ declare namespace HybridTerrainProvider {
190
177
  }>;
191
178
  levels?: number[];
192
179
  }>, defaultProvider: TerrainProvider, fallbackProvider?: TerrainProvider): HybridTerrainProvider;
193
- /**
194
- * @deprecated Use Rectangle.fromDegrees() instead. This method is maintained for backward compatibility.
195
- * Calculates a bounding rectangle that encompasses all the specified tile ranges.
196
- * @param tilingScheme The tiling scheme to use for calculation.
197
- * @param from Tile ranges to calculate from.
198
- */
199
- function computeRectangle(tilingScheme: TilingScheme, from: Map<number, any>): Rectangle;
200
180
  }
201
181
 
202
182
  export { HybridTerrainProvider as H };
@@ -1,4 +1,4 @@
1
- import { TerrainProvider, TilingScheme, TileAvailability, Credit, Request, TerrainData, Rectangle } from 'cesium';
1
+ import { TerrainProvider, TilingScheme, TileAvailability, Credit, Request, TerrainData } from 'cesium';
2
2
 
3
3
  /**
4
4
  * @class
@@ -150,8 +150,6 @@ declare namespace HybridTerrainProvider {
150
150
  interface TerrainRegion {
151
151
  /** The terrain provider for this region. */
152
152
  provider: TerrainProvider;
153
- /** Rectangle-based geographic bounds (simpler). */
154
- bounds?: Rectangle;
155
153
  /**
156
154
  * Tile-coordinate based bounds (precise control).
157
155
  * Map of level to tile coordinate ranges for that level.
@@ -165,17 +163,6 @@ declare namespace HybridTerrainProvider {
165
163
  /** Optional level constraints. If specified, region only applies to these levels. */
166
164
  levels?: number[];
167
165
  }
168
- /**
169
- * Creates a HybridTerrainProvider from rectangle-based regions.
170
- * @param regions Array of regions with rectangle bounds
171
- * @param defaultProvider Default terrain provider
172
- * @param fallbackProvider Optional fallback provider
173
- */
174
- function fromRectangles(regions: Array<{
175
- provider: TerrainProvider;
176
- bounds: Rectangle;
177
- levels?: number[];
178
- }>, defaultProvider: TerrainProvider, fallbackProvider?: TerrainProvider): HybridTerrainProvider;
179
166
  /**
180
167
  * Creates a HybridTerrainProvider from tile-coordinate based regions.
181
168
  * @param regions Array of regions with tile-coordinate bounds
@@ -190,13 +177,6 @@ declare namespace HybridTerrainProvider {
190
177
  }>;
191
178
  levels?: number[];
192
179
  }>, defaultProvider: TerrainProvider, fallbackProvider?: TerrainProvider): HybridTerrainProvider;
193
- /**
194
- * @deprecated Use Rectangle.fromDegrees() instead. This method is maintained for backward compatibility.
195
- * Calculates a bounding rectangle that encompasses all the specified tile ranges.
196
- * @param tilingScheme The tiling scheme to use for calculation.
197
- * @param from Tile ranges to calculate from.
198
- */
199
- function computeRectangle(tilingScheme: TilingScheme, from: Map<number, any>): Rectangle;
200
180
  }
201
181
 
202
182
  export { HybridTerrainProvider as H };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var L=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var X=(n,e)=>{for(var t in e)L(n,t,{get:e[t],enumerable:!0})},K=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of $(e))!U.call(n,r)&&r!==t&&L(n,r,{get:()=>e[r],enumerable:!(i=q(e,r))||i.enumerable});return n};var J=n=>K(L({},"__esModule",{value:!0}),n);var Q={};X(Q,{Collection:()=>w,Highlight:()=>V,HybridTerrainProvider:()=>G,SilhouetteHighlight:()=>C,SurfaceHighlight:()=>b,cloneViewer:()=>F,syncCamera:()=>R});module.exports=J(Q);var g=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,d={}){if(!e)return;let{once:v=!0,prefix:p="[DEPRECATED]",includeStack:_=!0,removeInVersion:y}=d;if(v&&n.has(c))return;let T=`${p} ${c}`;y&&(T+=` This feature will be removed in ${y}.`),typeof console<"u"&&console.warn&&(_?(console.warn(T),console.trace("Deprecation stack trace:")):console.warn(T)),v&&n.add(c)}l.warn=t;function i(c,d,v={}){let p=((..._)=>(t(d,v),c(..._)));return Object.defineProperty(p,"name",{value:c.name,configurable:!0}),p}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})(j||={});var S=j;var h=require("cesium");var x=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 w({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 d=e.start.y;d<e.start.y+l;d++)try{let v=this._createTileEntity(c,d,t,i);v&&r.push({entity:v})}catch(v){console.warn(`Error creating tile (${c}, ${d}, ${t}):`,v)}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,d=s?.maxTilesToShow||100,v=s?.show??!0,p=s?.alpha||.7,_=s?.tileAlpha||.2,y=new w({collection:o.entities,tag:l});if(r.bounds&&y.add(i.createRectangle(r.bounds,c.withAlpha(p)),l),v&&r.tiles&&r.tiles.size>0){let T=r.provider.tilingScheme,P=0;r.tiles.forEach((f,W)=>{let N=Array.isArray(f.x)?f.x:[f.x,f.x],B=Array.isArray(f.y)?f.y:[f.y,f.y];for(let I=N[0];I<=N[1]&&P<d;I++)for(let A=B[0];A<=B[1]&&P<d;A++){let Y=T.tileXYToRectangle(I,A,W);y.add(e(Y,c.withAlpha(_)),`${l}_tile`),P++}})}return y}i.visualize=t})(x||={});function H(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=S.deprecate;var M=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 g.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof g.PrimitiveCollection?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof g.DataSourceCollection?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof g.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}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 g.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get(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,g.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,g.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,g.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r)if(e in o&&typeof o[e]!="function"){if(H(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)}},w=M;var m=require("cesium");var u=require("cesium"),C=class{_color=u.Color.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=u.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=u.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}show(e,t){if((0,u.defined)(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{if(e instanceof u.Cesium3DTileFeature)this._silhouette.uniforms.color=t?.color||this._color,this._silhouette.selected.push(e);else{if(!e.model)return;this._entity=e,e.model.silhouetteSize=new u.ConstantProperty(t?.width||2),e.model.silhouetteColor=new u.ConstantProperty(t?.color||this._color)}this._currentObject=e,this._currentOptions=t?{...t}:void 0}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0}}}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&u.Color.equals(e.color||this._color,t.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new u.ConstantProperty(u.Color.TRANSPARENT),this._entity.model.silhouetteSize=new u.ConstantProperty(0),this._entity=void 0)}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"),b=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 D=class n{static instances=new WeakMap;_surface;_silhouette;_color=m.Color.RED;constructor(e){this._surface=new b(e),this._silhouette=new C(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}},V=D;var E=require("cesium");var O=class{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new E.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,d]=Array.isArray(o.y)?o.y:[o.y,o.y];return t>=s&&t<=l&&i>=c&&i<=d}if(e.bounds){let o=this._tilingScheme.tileXYToRectangle(t,i,r);return E.Rectangle.intersection(o,e.bounds)!==void 0}return!1}};(i=>{function n(r,o,s){return new i({regions:r.map(l=>({...l})),defaultProvider:o,fallbackProvider:s})}i.fromRectangles=n;function e(r,o,s){return new i({regions:r.map(l=>({...l})),defaultProvider:o,fallbackProvider:s})}i.fromTileRanges=e;function t(r,o){if(S.warn("computeRectangle() is deprecated. Use Rectangle.fromDegrees() instead.",{removeInVersion:"v0.3.0"}),o.size===0)return new E.Rectangle;let s=Number.POSITIVE_INFINITY,l=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,d=Number.NEGATIVE_INFINITY,v=Array.from(o.keys()),p=Math.min(...v),_=o.get(p);if(_){let{start:y,end:T}=_,P=r.tileXYToRectangle(y.x,y.y,p),f=r.tileXYToRectangle(T.x,T.y,p);s=Math.min(P.west,s),l=Math.min(f.south,l),c=Math.max(f.east,c),d=Math.max(P.north,d)}return new E.Rectangle(s,l,c,d)}i.computeRectangle=t})(O||={});var G=O;var z=require("cesium");var k=require("cesium");function R(n,e){if((0,k.defined)(n)&&(0,k.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 F(n,e,t){let i={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},r=new z.Viewer(e,{...i,...t});R(n,r);let o=n.imageryLayers;r.imageryLayers.removeAll();for(let c=0;c<o.length;c++){let d=o.get(c);r.imageryLayers.addImageryProvider(d.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:()=>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}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { C as Collection } from './index-Bfd24d9-.cjs';
2
2
  export { Highlight, SilhouetteHighlight, SurfaceHighlight } from './highlight/index.cjs';
3
- export { H as HybridTerrainProvider } from './hybrid-terrain-provider-C2V-igd9.cjs';
3
+ export { H as HybridTerrainProvider } from './hybrid-terrain-provider-CzdhZJyg.cjs';
4
4
  export { cloneViewer, syncCamera } from './viewer/index.cjs';
5
5
  import 'cesium';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { C as Collection } from './index-Bfd24d9-.js';
2
2
  export { Highlight, SilhouetteHighlight, SurfaceHighlight } from './highlight/index.js';
3
- export { H as HybridTerrainProvider } from './hybrid-terrain-provider-C2V-igd9.js';
3
+ export { H as HybridTerrainProvider } from './hybrid-terrain-provider-CzdhZJyg.js';
4
4
  export { cloneViewer, syncCamera } from './viewer/index.js';
5
5
  import 'cesium';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-RXMNSDKR.js";import{d as r}from"./chunk-OUTUX3ZP.js";import{a as i,b as o,c as e}from"./chunk-RZ3PTU3G.js";import{a as t}from"./chunk-WVFPGF7U.js";import"./chunk-TC3IX3JL.js";import{a as m,b as h}from"./chunk-Z2COOTT4.js";export{r as Collection,e as Highlight,t as HybridTerrainProvider,i as SilhouetteHighlight,o as SurfaceHighlight,h as cloneViewer,m as syncCamera};
1
+ import"./chunk-RXMNSDKR.js";import{e as r}from"./chunk-O27H72YO.js";import{a as i,b as o,c as e}from"./chunk-RZ3PTU3G.js";import{a as t}from"./chunk-6I4THOWX.js";import{a as m,b as h}from"./chunk-Z2COOTT4.js";export{r as Collection,e as Highlight,t as HybridTerrainProvider,i as SilhouetteHighlight,o as SurfaceHighlight,h as cloneViewer,m as syncCamera};
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var A=(a,e)=>{for(var t in e)g(a,t,{get:e[t],enumerable:!0})},N=(a,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of R(e))!I.call(a,r)&&r!==t&&g(a,r,{get:()=>e[r],enumerable:!(n=x(e,r))||n.enumerable});return a};var w=a=>N(g({},"__esModule",{value:!0}),a);var E={};A(E,{HybridTerrainProvider:()=>_});module.exports=w(E);var b=require("cesium");var h;(s=>{let a=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(o,u={}){if(!e)return;let{once:c=!0,prefix:d="[DEPRECATED]",includeStack:m=!0,removeInVersion:f}=u;if(c&&a.has(o))return;let v=`${d} ${o}`;f&&(v+=` This feature will be removed in ${f}.`),typeof console<"u"&&console.warn&&(m?(console.warn(v),console.trace("Deprecation stack trace:")):console.warn(v)),c&&a.add(o)}s.warn=t;function n(o,u,c={}){let d=((...m)=>(t(u,c),o(...m)));return Object.defineProperty(d,"name",{value:o.name,configurable:!0}),d}s.deprecate=n;function r(){a.clear()}s.clear=r;function i(){return a.size}s.getWarningCount=i;function l(o){return a.has(o)}s.hasShown=l})(h||={});var y=h;var T=class{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new b.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,t,n){return this._defaultProvider.loadTileDataAvailability(e,t,n)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,n,r){if(this._ready){for(let i of this._regions)if(this._regionContains(i,e,t,n))return i.provider.requestTileGeometry(e,t,n,r);return this._defaultProvider.getTileDataAvailable(e,t,n)?this._defaultProvider.requestTileGeometry(e,t,n,r):this._fallbackProvider.requestTileGeometry(e,t,n,r)}}getTileDataAvailable(e,t,n){for(let r of this._regions)if(this._regionContains(r,e,t,n)&&r.provider.getTileDataAvailable(e,t,n))return!0;return this._defaultProvider.getTileDataAvailable(e,t,n)}_regionContains(e,t,n,r){if(e.levels&&!e.levels.includes(r))return!1;if(e.tiles){let i=e.tiles.get(r);if(!i)return!1;let[l,s]=Array.isArray(i.x)?i.x:[i.x,i.x],[o,u]=Array.isArray(i.y)?i.y:[i.y,i.y];return t>=l&&t<=s&&n>=o&&n<=u}if(e.bounds){let i=this._tilingScheme.tileXYToRectangle(t,n,r);return b.Rectangle.intersection(i,e.bounds)!==void 0}return!1}};(n=>{function a(r,i,l){return new n({regions:r.map(s=>({...s})),defaultProvider:i,fallbackProvider:l})}n.fromRectangles=a;function e(r,i,l){return new n({regions:r.map(s=>({...s})),defaultProvider:i,fallbackProvider:l})}n.fromTileRanges=e;function t(r,i){if(y.warn("computeRectangle() is deprecated. Use Rectangle.fromDegrees() instead.",{removeInVersion:"v0.3.0"}),i.size===0)return new b.Rectangle;let l=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,u=Number.NEGATIVE_INFINITY,c=Array.from(i.keys()),d=Math.min(...c),m=i.get(d);if(m){let{start:f,end:v}=m,p=r.tileXYToRectangle(f.x,f.y,d),P=r.tileXYToRectangle(v.x,v.y,d);l=Math.min(p.west,l),s=Math.min(P.south,s),o=Math.max(P.east,o),u=Math.max(p.north,u)}return new b.Rectangle(l,s,o,u)}n.computeRectangle=t})(T||={});var _=T;
1
+ "use strict";var l=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var g=(n,r)=>{for(var e in r)l(n,e,{get:r[e],enumerable:!0})},h=(n,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of T(r))!P.call(n,a)&&a!==e&&l(n,a,{get:()=>r[a],enumerable:!(i=f(r,a))||i.enumerable});return n};var y=n=>h(l({},"__esModule",{value:!0}),n);var c={};g(c,{HybridTerrainProvider:()=>u});module.exports=y(c);var d=require("cesium"),o=class{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(r){this._defaultProvider=r.defaultProvider,this._fallbackProvider=r.fallbackProvider||new d.EllipsoidTerrainProvider,this._tilingScheme=r.defaultProvider.tilingScheme,this._regions=r.regions||[],this._availability=r.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(r,e,i){return this._defaultProvider.loadTileDataAvailability(r,e,i)}getLevelMaximumGeometricError(r){return this._defaultProvider.getLevelMaximumGeometricError(r)}requestTileGeometry(r,e,i,a){if(this._ready){for(let t of this._regions)if(this._regionContains(t,r,e,i))return t.provider.requestTileGeometry(r,e,i,a);return this._defaultProvider.getTileDataAvailable(r,e,i)?this._defaultProvider.requestTileGeometry(r,e,i,a):this._fallbackProvider.requestTileGeometry(r,e,i,a)}}getTileDataAvailable(r,e,i){for(let a of this._regions)if(this._regionContains(a,r,e,i)&&a.provider.getTileDataAvailable(r,e,i))return!0;return this._defaultProvider.getTileDataAvailable(r,e,i)}_regionContains(r,e,i,a){if(r.levels&&!r.levels.includes(a))return!1;if(r.tiles){let t=r.tiles.get(a);if(!t)return!1;let[s,v]=Array.isArray(t.x)?t.x:[t.x,t.x],[b,m]=Array.isArray(t.y)?t.y:[t.y,t.y];return e>=s&&e<=v&&i>=b&&i<=m}return!1}};(r=>{function n(e,i,a){return new r({regions:e.map(t=>({...t})),defaultProvider:i,fallbackProvider:a})}r.fromTileRanges=n})(o||={});var u=o;
@@ -1,4 +1,4 @@
1
- import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-C2V-igd9.cjs';
1
+ import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-CzdhZJyg.cjs';
2
2
  import 'cesium';
3
3
 
4
4
  type TerrainTiles = NonNullable<HybridTerrainProvider.TerrainRegion["tiles"]>;
@@ -1,4 +1,4 @@
1
- import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-C2V-igd9.js';
1
+ import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-CzdhZJyg.js';
2
2
  import 'cesium';
3
3
 
4
4
  type TerrainTiles = NonNullable<HybridTerrainProvider.TerrainRegion["tiles"]>;
@@ -1 +1 @@
1
- import{a}from"../chunk-WVFPGF7U.js";import"../chunk-TC3IX3JL.js";export{a as HybridTerrainProvider};
1
+ import{a}from"../chunk-6I4THOWX.js";export{a as HybridTerrainProvider};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juun-roh/cesium-utils",
3
- "version": "0.2.7",
3
+ "version": "0.3.1",
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",
@@ -66,6 +66,11 @@
66
66
  "import": "./dist/dev/index.js",
67
67
  "require": "./dist/dev/index.cjs"
68
68
  },
69
+ "./experimental": {
70
+ "types": "./dist/experimental/index.d.ts",
71
+ "import": "./dist/experimental/index.js",
72
+ "require": "./dist/experimental/index.cjs"
73
+ },
69
74
  "./viewer": {
70
75
  "types": "./dist/viewer/index.d.ts",
71
76
  "import": "./dist/viewer/index.js",
@@ -93,24 +98,24 @@
93
98
  "@commitlint/cz-commitlint": "^19.8.1",
94
99
  "@commitlint/format": "^19.8.1",
95
100
  "@commitlint/types": "^19.8.1",
96
- "@eslint/js": "^9.33.0",
101
+ "@eslint/js": "^9.34.0",
97
102
  "@types/node": "^24.3.0",
98
- "@typescript-eslint/eslint-plugin": "^8.39.1",
99
- "@typescript-eslint/parser": "^8.39.1",
103
+ "@typescript-eslint/eslint-plugin": "^8.40.0",
104
+ "@typescript-eslint/parser": "^8.40.0",
100
105
  "@vitest/coverage-v8": "^3.2.4",
101
106
  "cesium": "^1.132.0",
102
- "eslint": "^9.33.0",
103
- "eslint-plugin-jsdoc": "^54.1.0",
107
+ "eslint": "^9.34.0",
108
+ "eslint-plugin-jsdoc": "^54.1.1",
104
109
  "eslint-plugin-prettier": "^5.5.4",
105
110
  "eslint-plugin-simple-import-sort": "^12.1.1",
106
- "eslint-plugin-unused-imports": "^4.1.4",
111
+ "eslint-plugin-unused-imports": "^4.2.0",
107
112
  "husky": "^9.1.7",
108
113
  "jsdom": "^26.1.0",
109
114
  "rimraf": "^6.0.1",
110
115
  "tsup": "^8.5.0",
111
116
  "typedoc": "^0.28.10",
112
117
  "typescript": "^5.9.2",
113
- "vite": "^7.1.2",
118
+ "vite": "^7.1.3",
114
119
  "vitest": "^3.2.4"
115
120
  },
116
121
  "scripts": {
@@ -1 +0,0 @@
1
- import{a as L}from"./chunk-TC3IX3JL.js";import{Color as l,Entity as D,HeightReference as V,Rectangle as I,TileCoordinatesImageryProvider as j}from"cesium";import{DataSourceCollection as M,defined as f,EntityCollection as w,ImageryLayerCollection as O,PrimitiveCollection as F}from"cesium";var C=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 w?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof F?(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?(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 O&&(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 w)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)f(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)f(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)f(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(_(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)}},T=C;var u=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",l.RED],["default",l.BLUE],["fallback",l.GRAY],["grid",l.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new T({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 j({tilingScheme:this._terrainProvider.tilingScheme,color:l.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(I.northwest(e),t),o=i.positionToTileXY(I.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),s=Math.min(e.end.y-e.start.y+1,100);for(let h=e.start.x;h<e.start.x+a;h++)for(let d=e.start.y;d<e.start.y+s;d++)try{let v=this._createTileEntity(h,d,t,i);v&&r.push({entity:v})}catch(v){console.warn(`Error creating tile (${h}, ${d}, ${t}):`,v)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let a=this._getTileColor(e,t,i),s=n.createRectangle(o,a.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")||l.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||l.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||l.BLUE:this._colors.get("fallback")||l.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 D({rectangle:{coordinates:r,material:o,heightReference:V.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,a){let s=a?.tag||"terrain_region_visualization",h=a?.color||l.RED,d=a?.maxTilesToShow||100,v=a?.show??!0,P=a?.alpha||.7,x=a?.tileAlpha||.2,m=new T({collection:o.entities,tag:s});if(r.bounds&&m.add(i.createRectangle(r.bounds,h.withAlpha(P)),s),v&&r.tiles&&r.tiles.size>0){let R=r.provider.tilingScheme,g=0;r.tiles.forEach((c,S)=>{let b=Array.isArray(c.x)?c.x:[c.x,c.x],E=Array.isArray(c.y)?c.y:[c.y,c.y];for(let p=b[0];p<=b[1]&&g<d;p++)for(let y=E[0];y<=E[1]&&g<d;y++){let A=R.tileXYToRectangle(p,y,S);m.add(e(A,h.withAlpha(x)),`${s}_tile`),g++}})}return m}i.visualize=t})(u||={});function _(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 Q=L.deprecate;export{u as a,_ as b,Q as c,T as d};
@@ -1 +0,0 @@
1
- var c;(w=>{let n=new Set,u=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function f(e,o={}){if(!u)return;let{once:r=!0,prefix:t="[DEPRECATED]",includeStack:i=!0,removeInVersion:s}=o;if(r&&n.has(e))return;let a=`${t} ${e}`;s&&(a+=` This feature will be removed in ${s}.`),typeof console<"u"&&console.warn&&(i?(console.warn(a),console.trace("Deprecation stack trace:")):console.warn(a)),r&&n.add(e)}w.warn=f;function l(e,o,r={}){let t=((...i)=>(f(o,r),e(...i)));return Object.defineProperty(t,"name",{value:e.name,configurable:!0}),t}w.deprecate=l;function p(){n.clear()}w.clear=p;function d(){return n.size}w.getWarningCount=d;function g(e){return n.has(e)}w.hasShown=g})(c||={});var x=c;export{x as a};
@@ -1 +0,0 @@
1
- import{a as g}from"./chunk-TC3IX3JL.js";import{EllipsoidTerrainProvider as y,Rectangle as m}from"cesium";var d=class{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new y,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,n,i){return this._defaultProvider.loadTileDataAvailability(e,n,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,n,i,t){if(this._ready){for(let r of this._regions)if(this._regionContains(r,e,n,i))return r.provider.requestTileGeometry(e,n,i,t);return this._defaultProvider.getTileDataAvailable(e,n,i)?this._defaultProvider.requestTileGeometry(e,n,i,t):this._fallbackProvider.requestTileGeometry(e,n,i,t)}}getTileDataAvailable(e,n,i){for(let t of this._regions)if(this._regionContains(t,e,n,i)&&t.provider.getTileDataAvailable(e,n,i))return!0;return this._defaultProvider.getTileDataAvailable(e,n,i)}_regionContains(e,n,i,t){if(e.levels&&!e.levels.includes(t))return!1;if(e.tiles){let r=e.tiles.get(t);if(!r)return!1;let[a,o]=Array.isArray(r.x)?r.x:[r.x,r.x],[l,s]=Array.isArray(r.y)?r.y:[r.y,r.y];return n>=a&&n<=o&&i>=l&&i<=s}if(e.bounds){let r=this._tilingScheme.tileXYToRectangle(n,i,t);return m.intersection(r,e.bounds)!==void 0}return!1}};(i=>{function P(t,r,a){return new i({regions:t.map(o=>({...o})),defaultProvider:r,fallbackProvider:a})}i.fromRectangles=P;function e(t,r,a){return new i({regions:t.map(o=>({...o})),defaultProvider:r,fallbackProvider:a})}i.fromTileRanges=e;function n(t,r){if(g.warn("computeRectangle() is deprecated. Use Rectangle.fromDegrees() instead.",{removeInVersion:"v0.3.0"}),r.size===0)return new m;let a=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY,h=Array.from(r.keys()),u=Math.min(...h),v=r.get(u);if(v){let{start:b,end:T}=v,c=t.tileXYToRectangle(b.x,b.y,u),f=t.tileXYToRectangle(T.x,T.y,u);a=Math.min(c.west,a),o=Math.min(f.south,o),l=Math.max(f.east,l),s=Math.max(c.north,s)}return new m(a,o,l,s)}i.computeRectangle=n})(d||={});var p=d;export{p as a};