@juun-roh/cesium-utils 0.0.16 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import{Color as a,Entity as A,HeightReference as M,Rectangle as C,TileCoordinatesImageryProvider as O}from"cesium";import{defined as y,EntityCollection as x}from"cesium";var T=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache(){this._valuesCache=null}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let r=this.collection.remove(e);return r&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),r}if(Array.isArray(e)){if(e.length===0)return!1;let r=!1;for(let o of e)this.remove(o)&&(r=!0);return r}let t=this.get(e);if(t.length===0)return!1;let i=!1;for(let r of t)this.remove(r)&&(i=!0);return i}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof x)return this.collection.values;{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));return e}}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)y(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)y(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)y(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)}},b=T;var u=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",a.RED],["default",a.BLUE],["fallback",a.GRAY],["grid",a.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new b({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 O({tilingScheme:this._terrainProvider.tilingScheme,color:a.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(C.northwest(e),t),o=i.positionToTileXY(C.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 h=e.start.y;h<e.start.y+l;h++)try{let d=this._createTileEntity(c,h,t,i);d&&r.push({entity:d})}catch(d){console.warn(`Error creating tile (${c}, ${h}, ${t}):`,d)}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")||a.TRANSPARENT;for(let r of this._terrainProvider.terrainAreas)if(r.contains(e,t,i))return r.isCustom?this._colors.get("custom")||a.RED:this._colors.get("default")||a.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||a.BLUE:this._colors.get("fallback")||a.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new A({rectangle:{coordinates:r,material:o,heightReference:M.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,s){let l=s?.tag||"terrain_area_visualization",c=s?.color||a.RED,h=s?.maxTilesToShow||100,d=s?.show??!0,w=s?.alpha||.7,E=s?.tileAlpha||.2,m=new b({collection:o.entities,tag:l}),{rectangle:I}=r;if(m.add(i.createRectangle(I,c.withAlpha(w)),l),d&&r.tileRanges.size>0){let{tilingScheme:R}=r.terrainProvider,v=0;r.tileRanges.forEach((g,P)=>{for(let f=g.start.x;f<=g.end.x&&v<h;f++)for(let p=g.start.y;p<=g.end.y&&v<h;p++){let L=R.tileXYToRectangle(f,p,P);m.add(e(L,c.withAlpha(E)),`${l}_tile`),v++}})}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}export{u as a,_ as b,b as c};
@@ -1 +1 @@
1
- "use strict";var _=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var O=(n,e)=>{for(var t in e)_(n,t,{get:e[t],enumerable:!0})},S=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of A(e))!M.call(n,r)&&r!==t&&_(n,r,{get:()=>e[r],enumerable:!(i=L(e,r))||i.enumerable});return n};var V=n=>S(_({},"__esModule",{value:!0}),n);var j={};O(j,{Collection:()=>g});module.exports=V(j);var u=require("cesium");var s=require("cesium");var m=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",s.Color.RED],["default",s.Color.BLUE],["fallback",s.Color.GRAY],["grid",s.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new g({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 s.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:s.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(a=>{this._collection.add(a.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(s.Rectangle.northwest(e),t),o=i.positionToTileXY(s.Rectangle.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],a=Math.min(e.end.x-e.start.x+1,100),l=Math.min(e.end.y-e.start.y+1,100);for(let c=e.start.x;c<e.start.x+a;c++)for(let h=e.start.y;h<e.start.y+l;h++)try{let d=this._createTileEntity(c,h,t,i);d&&r.push({entity:d})}catch(d){console.warn(`Error creating tile (${c}, ${h}, ${t}):`,d)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let a=this._getTileColor(e,t,i),l=n.createRectangle(o,a.withAlpha(.3));return l.properties?.addProperty("tileX",e),l.properties?.addProperty("tileY",t),l.properties?.addProperty("tileLevel",i),l}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||s.Color.TRANSPARENT;for(let r of this._terrainProvider.terrainAreas)if(r.contains(e,t,i))return r.isCustom?this._colors.get("custom")||s.Color.RED:this._colors.get("default")||s.Color.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||s.Color.BLUE:this._colors.get("fallback")||s.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new s.Entity({rectangle:{coordinates:r,material:o,heightReference:s.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,a){let l=a?.tag||"terrain_area_visualization",c=a?.color||s.Color.RED,h=a?.maxTilesToShow||100,d=a?.show??!0,w=a?.alpha||.7,E=a?.tileAlpha||.2,f=new g({collection:o.entities,tag:l}),{rectangle:I}=r;if(f.add(i.createRectangle(I,c.withAlpha(w)),l),d&&r.tileRanges.size>0){let{tilingScheme:R}=r.terrainProvider,p=0;r.tileRanges.forEach((v,P)=>{for(let y=v.start.x;y<=v.end.x&&p<h;y++)for(let T=v.start.y;T<=v.end.y&&p<h;T++){let x=R.tileXYToRectangle(y,T,P);f.add(e(x,c.withAlpha(E)),`${l}_tile`),p++}})}return f}i.visualize=t})(m||={});function b(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 C=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache(){this._valuesCache=null}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let r=this.collection.remove(e);return r&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),r}if(Array.isArray(e)){if(e.length===0)return!1;let r=!1;for(let o of e)this.remove(o)&&(r=!0);return r}let t=this.get(e);if(t.length===0)return!1;let i=!1;for(let r of t)this.remove(r)&&(i=!0);return i}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof u.EntityCollection)return this.collection.values;{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));return e}}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,u.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,u.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,u.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(b(o,e))throw Error(`setProperty(${o}, ${e}) failed; The property is readonly.`);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)}},g=C;
1
+ "use strict";var _=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var O=(n,e)=>{for(var t in e)_(n,t,{get:e[t],enumerable:!0})},S=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of A(e))!M.call(n,r)&&r!==t&&_(n,r,{get:()=>e[r],enumerable:!(i=L(e,r))||i.enumerable});return n};var V=n=>S(_({},"__esModule",{value:!0}),n);var j={};O(j,{Collection:()=>g});module.exports=V(j);var u=require("cesium");var s=require("cesium");var m=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",s.Color.RED],["default",s.Color.BLUE],["fallback",s.Color.GRAY],["grid",s.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new g({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 s.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:s.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(a=>{this._collection.add(a.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(s.Rectangle.northwest(e),t),o=i.positionToTileXY(s.Rectangle.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],a=Math.min(e.end.x-e.start.x+1,100),l=Math.min(e.end.y-e.start.y+1,100);for(let c=e.start.x;c<e.start.x+a;c++)for(let h=e.start.y;h<e.start.y+l;h++)try{let d=this._createTileEntity(c,h,t,i);d&&r.push({entity:d})}catch(d){console.warn(`Error creating tile (${c}, ${h}, ${t}):`,d)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let a=this._getTileColor(e,t,i),l=n.createRectangle(o,a.withAlpha(.3));return l.properties?.addProperty("tileX",e),l.properties?.addProperty("tileY",t),l.properties?.addProperty("tileLevel",i),l}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||s.Color.TRANSPARENT;for(let r of this._terrainProvider.terrainAreas)if(r.contains(e,t,i))return r.isCustom?this._colors.get("custom")||s.Color.RED:this._colors.get("default")||s.Color.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||s.Color.BLUE:this._colors.get("fallback")||s.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new s.Entity({rectangle:{coordinates:r,material:o,heightReference:s.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,a){let l=a?.tag||"terrain_area_visualization",c=a?.color||s.Color.RED,h=a?.maxTilesToShow||100,d=a?.show??!0,w=a?.alpha||.7,E=a?.tileAlpha||.2,f=new g({collection:o.entities,tag:l}),{rectangle:I}=r;if(f.add(i.createRectangle(I,c.withAlpha(w)),l),d&&r.tileRanges.size>0){let{tilingScheme:R}=r.terrainProvider,p=0;r.tileRanges.forEach((v,P)=>{for(let y=v.start.x;y<=v.end.x&&p<h;y++)for(let T=v.start.y;T<=v.end.y&&p<h;T++){let x=R.tileXYToRectangle(y,T,P);f.add(e(x,c.withAlpha(E)),`${l}_tile`),p++}})}return f}i.visualize=t})(m||={});function b(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 C=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache(){this._valuesCache=null}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let r=this.collection.remove(e);return r&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),r}if(Array.isArray(e)){if(e.length===0)return!1;let r=!1;for(let o of e)this.remove(o)&&(r=!0);return r}let t=this.get(e);if(t.length===0)return!1;let i=!1;for(let r of t)this.remove(r)&&(i=!0);return i}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof u.EntityCollection)return this.collection.values;{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));return e}}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,u.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,u.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,u.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(b(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)}},g=C;
@@ -396,7 +396,7 @@ declare class Collection<C extends CesiumCollection, I extends CesiumCollectionI
396
396
  * // Change color of all buildings to red
397
397
  * collection.setProperty('buildings', 'color', Color.RED);
398
398
  */
399
- setProperty<K extends NonFunction<I>, V extends Exclude<I[K], Function>>(property: K, value: V, by?: Tag): this;
399
+ setProperty<K extends NonFunction<I>>(property: K, value: I[K], by?: Tag): this;
400
400
  /**
401
401
  * Filters items in the collection based on a predicate function.
402
402
  * Optionally only filters items with a specific tag.
@@ -396,7 +396,7 @@ declare class Collection<C extends CesiumCollection, I extends CesiumCollectionI
396
396
  * // Change color of all buildings to red
397
397
  * collection.setProperty('buildings', 'color', Color.RED);
398
398
  */
399
- setProperty<K extends NonFunction<I>, V extends Exclude<I[K], Function>>(property: K, value: V, by?: Tag): this;
399
+ setProperty<K extends NonFunction<I>>(property: K, value: I[K], by?: Tag): this;
400
400
  /**
401
401
  * Filters items in the collection based on a predicate function.
402
402
  * Optionally only filters items with a specific tag.
@@ -1 +1 @@
1
- import"../chunk-RXMNSDKR.js";import{c as a}from"../chunk-XTUDPAWI.js";export{a as Collection};
1
+ import"../chunk-RXMNSDKR.js";import{c as a}from"../chunk-YHYFSR66.js";export{a as Collection};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var L=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var $=(n,e)=>{for(var t in e)L(n,t,{get:e[t],enumerable:!0})},K=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of U(e))!X.call(n,i)&&i!==t&&L(n,i,{get:()=>e[i],enumerable:!(r=j(e,i))||r.enumerable});return n};var J=n=>K(L({},"__esModule",{value:!0}),n);var Q={};$(Q,{Collection:()=>y,Highlight:()=>C,HybridTerrainProvider:()=>A,TerrainArea:()=>g,TerrainAreaCollection:()=>p,TerrainVisualizer:()=>v,cloneViewer:()=>H,computeRectangle:()=>w,isGetterOnly:()=>P,syncCamera:()=>R});module.exports=J(Q);var _=require("cesium");var h=require("cesium");var v=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 y({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([r,i])=>{this._colors.set(r,i)}),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 r=this._terrainProvider.tilingScheme;try{let i=this._calculateTileBounds(e,t,r);this._generateVisibleTiles(i,t,r).forEach(s=>{this._collection.add(s.entity,n.tag.grid)})}catch(i){console.error("Error displaying tile grid:",i)}}_calculateTileBounds(e,t,r){let i=r.positionToTileXY(h.Rectangle.northwest(e),t),o=r.positionToTileXY(h.Rectangle.southeast(e),t);if(!i||!o)throw new Error("Failed to calculate tile bounds");return{start:i,end:o}}_generateVisibleTiles(e,t,r){let i=[],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 m=e.start.y;m<e.start.y+l;m++)try{let f=this._createTileEntity(c,m,t,r);f&&i.push({entity:f})}catch(f){console.warn(`Error creating tile (${c}, ${m}, ${t}):`,f)}return i}_createTileEntity(e,t,r,i){let o=i.tileXYToRectangle(e,t,r);if(!this._isValidRectangle(o))return null;let s=this._getTileColor(e,t,r),l=n.createRectangle(o,s.withAlpha(.3));return l.properties?.addProperty("tileX",e),l.properties?.addProperty("tileY",t),l.properties?.addProperty("tileLevel",r),l}_getTileColor(e,t,r){if(!this._terrainProvider)return this._colors.get("fallback")||h.Color.TRANSPARENT;for(let i of this._terrainProvider.terrainAreas)if(i.contains(e,t,r))return i.isCustom?this._colors.get("custom")||h.Color.RED:this._colors.get("default")||h.Color.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,r)?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,r])=>{this._colors.set(t,r)}),this.update()}flyTo(e,t){let{rectangle:r}=e;this._viewer.camera.flyTo({destination:r,...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}};(r=>{r.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(i,o){return new h.Entity({rectangle:{coordinates:i,material:o,heightReference:h.HeightReference.CLAMP_TO_GROUND}})}r.createRectangle=e;function t(i,o,s){let l=s?.tag||"terrain_area_visualization",c=s?.color||h.Color.RED,m=s?.maxTilesToShow||100,f=s?.show??!0,E=s?.alpha||.7,I=s?.tileAlpha||.2,S=new y({collection:o.entities,tag:l}),{rectangle:B}=i;if(S.add(r.createRectangle(B,c.withAlpha(E)),l),f&&i.tileRanges.size>0){let{tilingScheme:Y}=i.terrainProvider,V=0;i.tileRanges.forEach((x,q)=>{for(let M=x.start.x;M<=x.end.x&&V<m;M++)for(let O=x.start.y;O<=x.end.y&&V<m;O++){let W=Y.tileXYToRectangle(M,O,q);S.add(e(W,c.withAlpha(I)),`${l}_tile`),V++}})}return S}r.visualize=t})(v||={});function P(n,e){let t=!1,r=Object.getOwnPropertyDescriptor(n,e);if(!r){let i=Object.getPrototypeOf(n);for(;i&&!r;)r=Object.getOwnPropertyDescriptor(i,e),i=Object.getPrototypeOf(i)}return r&&r.get&&!r.set&&(t=!0),t}var G=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let r=this._eventListeners.get(e);if(r){let i={type:e,...t};r.forEach(o=>o(i))}}_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],r=this._tagMap.get(t);r&&(r.delete(e),r.size===0&&this._tagMap.delete(t))}_invalidateCache(){this._valuesCache=null}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,r){return Array.isArray(e)?e.forEach(i=>{this.add(i,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,r),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let i=this.collection.remove(e);return i&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),i}if(Array.isArray(e)){if(e.length===0)return!1;let i=!1;for(let o of e)this.remove(o)&&(i=!0);return i}let t=this.get(e);if(t.length===0)return!1;let r=!1;for(let i of t)this.remove(i)&&(r=!0);return r}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof _.EntityCollection)return this.collection.values;{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));return e}}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let r=this.get(e);for(let i of r)this._removeFromTagMap(i),Object.defineProperty(i,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(i,t);return r.length>0&&this._emit("update",{items:r,tag:t}),r.length}show(e){let t=this.get(e);for(let r of t)(0,_.defined)(r.show)&&(r.show=!0);return this}hide(e){let t=this.get(e);for(let r of t)(0,_.defined)(r.show)&&(r.show=!1);return this}toggle(e){let t=this.get(e);for(let r of t)(0,_.defined)(r.show)&&(r.show=!r.show);return this}setProperty(e,t,r=this.tag){let i=this.get(r);for(let o of i)if(e in o&&typeof o[e]!="function"){if(P(o,e))throw Error(`setProperty(${o}, ${e}) failed; The property is readonly.`);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((i,o)=>e(i,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},y=G;var d=require("cesium");var u=require("cesium"),T=class{_color=u.Color.RED;_silhouette;_composite;_stages;_model;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=this._color,r){!(0,u.defined)(e)||this._silhouette.selected[0]===e||(e instanceof u.Cesium3DTileFeature?this._silhouette.selected.push(e):(this._model=e,e.silhouetteSize=new u.ConstantProperty(r?.width||2),e.silhouetteColor=new u.ConstantProperty(t)))}hide(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._model&&(this._model.silhouetteColor=new u.ConstantProperty(u.Color.TRANSPARENT),this._model=void 0)}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite)}get color(){return this._color}set color(e){this._color=e}};var a=require("cesium"),b=class{_color=a.Color.RED;_entity;_entities;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new a.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}show(e,t=this._color,r){if(!(!(0,a.defined)(e)||!this._entity)){this._clearGeometries();try{if(e instanceof a.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t,r);else if(e instanceof a.GroundPrimitive)this._update(e,t,r);else return;return this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i);return}}}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t,r={outline:!1,width:2}){if(e instanceof a.Entity){if(e.polygon)if(r.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let o;i.positions.length>0&&!a.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?o=[...i.positions,i.positions[0]]:o=i.positions,this._entity.polyline=new a.PolylineGraphics({positions:o,material:t,width:r.width||2,clampToGround:e.polygon.heightReference?.getValue()===a.HeightReference.CLAMP_TO_GROUND})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new a.PolygonGraphics({hierarchy:i,material:t,heightReference:e.polygon.heightReference?.getValue(),classificationType:e.polygon.classificationType?.getValue()||a.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let o=e.polyline.width?.getValue();this._entity.polyline=new a.PolylineGraphics({positions:i,material:t,width:o+(r.width||2),clampToGround:e.polyline.clampToGround?.getValue()})}}else if(e.rectangle)if(r.outline){let i=e.rectangle.coordinates?.getValue();if(i){let o=[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:o,material:t,width:r.width||2,clampToGround:e.rectangle.heightReference?.getValue()===a.HeightReference.CLAMP_TO_GROUND})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new a.RectangleGraphics({coordinates:i,material:t,heightReference:e.rectangle.heightReference?.getValue()}))}}else if(e instanceof a.GroundPrimitive){let i=e.geometryInstances,o=Array.isArray(i)?i[0]:i;if(!o.geometry.attributes.position)return;let s=o.geometry.attributes.position.values,l=[];for(let c=0;c<s.length;c+=3)l.push(new a.Cartesian3(s[c],s[c+1],s[c+2]));r.outline?this._entity.polyline=new a.PolylineGraphics({positions:l,material:t,width:r.width||2,clampToGround:!0}):this._entity.polygon=new a.PolygonGraphics({hierarchy:new a.PolygonHierarchy(l),material:t,heightReference:a.HeightReference.CLAMP_TO_GROUND,classificationType:a.ClassificationType.BOTH})}}hide(){this._entity&&(this._entity.show=!1)}destroy(){}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}};var C=class n{static instances=new Map;_surface;_silhouette;_color=d.Color.RED;constructor(e){this._surface=new b(e),this._silhouette=new T(e),this._surface.color=this._color,this._silhouette.color=this._color}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,r=n.instances.get(t);r&&(r.hide(),r._surface&&r._surface.destroy(),r._silhouette&&r._silhouette.destroy(),n.instances.delete(t))}show(e,t=this._color,r){let i=this._getObject(e);if((0,d.defined)(i))return i instanceof d.Cesium3DTileFeature||i instanceof d.ModelGraphics?this._silhouette.show(i,t):this._surface.show(i,t,r)}_getObject(e){if((0,d.defined)(e)){if(e instanceof d.Entity||e instanceof d.Cesium3DTileFeature||e instanceof d.GroundPrimitive)return e;if(e.id instanceof d.Entity)return e.id.model?e.id.model:e.id;if(e.primitive instanceof d.GroundPrimitive)return e.primitive;if(e instanceof d.Cesium3DTileFeature)return e}}hide(){this._surface.hide(),this._silhouette.hide()}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}};var F=require("cesium");var k=require("cesium");var D=require("cesium");function w(n,e){if(e.size===0)return new D.Rectangle;let t=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY,s=Array.from(e.keys()),l=Math.min(...s),c=e.get(l);if(c){let{start:m,end:f}=c,E=n.tileXYToRectangle(m.x,m.y,l),I=n.tileXYToRectangle(f.x,f.y,l);t=Math.min(E.west,t),r=Math.min(I.south,r),i=Math.max(I.east,i),o=Math.max(E.north,o)}return new D.Rectangle(t,r,i,o)}var g=class{_terrainProvider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(e){this._terrainProvider=e.terrainProvider,this._tileRanges=e.tileRanges,this._credit=e.credit||"custom",this._isCustom=e.isCustom!==void 0?e.isCustom:!0,this._rectangle=w(e.terrainProvider.tilingScheme,e.tileRanges),e.tileRanges.forEach((t,r)=>{this._terrainProvider.availability?.addAvailableTileRange(r,t.start.x,t.start.y,t.end.x,t.end.y)}),this._ready=!0}contains(e,t,r){if(this._tileRanges.size===0||!this._tileRanges.has(r))return!1;let i=this._tileRanges.get(r);return e>=i.start.x&&e<=i.end.x&&t>=i.start.y&&t<=i.end.y}requestTileGeometry(e,t,r,i){if(!(!this._ready||!this.contains(e,t,r)))return this._terrainProvider.requestTileGeometry(e,t,r,i)}getTileDataAvailable(e,t,r){if(this._tileRanges.size===0||!this._tileRanges.has(r))return!1;let i=this._tileRanges.get(r);return e>=i.start.x&&e<=i.end.x&&t>=i.start.y&&t<=i.end.y}get isCustom(){return this._isCustom}get credit(){return this._credit}get terrainProvider(){return this._terrainProvider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(e=>{async function n(t,r,i){let o=i?.credit||"custom",s=await k.CesiumTerrainProvider.fromUrl(t,{...i,credit:o});return new e({terrainProvider:s,tileRanges:r,credit:o})}e.fromUrl=n})(g||={});var p=class extends Array{add(e){if(Array.isArray(e)){for(let r of e)this.add(r);return this.length}let t;return e instanceof g?t=e:t=new g(e),this.push(t)}remove(e){if(Array.isArray(e))return e.forEach(r=>this.remove(r)),this;let t=this.indexOf(e);return t>=0&&this.splice(t,1),this}removeAll(){this.length=0}};var A=class{_terrainAreas=new p;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._terrainProvider=e.terrainProvider,this._fallbackProvider=e.fallbackProvider||new F.EllipsoidTerrainProvider,this._tilingScheme=e.terrainProvider.tilingScheme,this._terrainAreas=new p(...e.terrainAreas),this._availability=e.terrainProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get terrainAreas(){return[...this._terrainAreas]}get defaultProvider(){return this._terrainProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._terrainProvider?.credit}get errorEvent(){return this._terrainProvider.errorEvent}get hasWaterMask(){return this._terrainProvider.hasWaterMask}get hasVertexNormals(){return this._terrainProvider.hasVertexNormals}loadTileDataAvailability(e,t,r){return this._terrainProvider.loadTileDataAvailability(e,t,r)}getLevelMaximumGeometricError(e){return this._terrainProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,r,i){if(this._ready){for(let o of this._terrainAreas)if(o.contains(e,t,r))return o.requestTileGeometry(e,t,r,i);return this._terrainProvider.getTileDataAvailable(e,t,r)?this._terrainProvider.requestTileGeometry(e,t,r,i):this._fallbackProvider.requestTileGeometry(e,t,r,i)}}getTileDataAvailable(e,t,r){for(let i of this._terrainAreas)if(i.contains(e,t,r))return i.getTileDataAvailable(e,t,r);return this._terrainProvider.getTileDataAvailable(e,t,r)}};var z=require("cesium");var N=require("cesium");function R(n,e){if((0,N.defined)(n)&&(0,N.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 H(n,e,t){let r={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},i=new z.Viewer(e,{...r,...t});R(n,i);let o=n.imageryLayers;i.imageryLayers.removeAll();for(let c=0;c<o.length;c++){let m=o.get(c);i.imageryLayers.addImageryProvider(m.imageryProvider,c)}i.clock.startTime=n.clock.startTime.clone(),i.clock.stopTime=n.clock.stopTime.clone(),i.clock.currentTime=n.clock.currentTime.clone(),i.clock.multiplier=n.clock.multiplier,i.clock.clockStep=n.clock.clockStep,i.clock.clockRange=n.clock.clockRange,i.clock.shouldAnimate=n.clock.shouldAnimate,i.scene.globe.enableLighting=n.scene.globe.enableLighting,i.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,i.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let s=n.scene.screenSpaceCameraController.tiltEventTypes;s&&(i.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(s)?[...s]:s);let l=n.scene.screenSpaceCameraController.zoomEventTypes;return l&&(i.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(l)?[...l]:l),i}
1
+ "use strict";var L=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var $=(n,e)=>{for(var t in e)L(n,t,{get:e[t],enumerable:!0})},K=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of U(e))!X.call(n,r)&&r!==t&&L(n,r,{get:()=>e[r],enumerable:!(i=j(e,r))||i.enumerable});return n};var J=n=>K(L({},"__esModule",{value:!0}),n);var Q={};$(Q,{Collection:()=>y,Highlight:()=>C,HybridTerrainProvider:()=>A,TerrainArea:()=>g,TerrainAreaCollection:()=>p,TerrainVisualizer:()=>v,cloneViewer:()=>D,computeRectangle:()=>w,isGetterOnly:()=>P,syncCamera:()=>R});module.exports=J(Q);var _=require("cesium");var c=require("cesium");var v=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",c.Color.RED],["default",c.Color.BLUE],["fallback",c.Color.GRAY],["grid",c.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new y({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(n.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new c.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:c.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(l=>{this._collection.add(l.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(c.Rectangle.northwest(e),t),o=i.positionToTileXY(c.Rectangle.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],l=Math.min(e.end.x-e.start.x+1,100),s=Math.min(e.end.y-e.start.y+1,100);for(let h=e.start.x;h<e.start.x+l;h++)for(let m=e.start.y;m<e.start.y+s;m++)try{let f=this._createTileEntity(h,m,t,i);f&&r.push({entity:f})}catch(f){console.warn(`Error creating tile (${h}, ${m}, ${t}):`,f)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let l=this._getTileColor(e,t,i),s=n.createRectangle(o,l.withAlpha(.3));return s.properties?.addProperty("tileX",e),s.properties?.addProperty("tileY",t),s.properties?.addProperty("tileLevel",i),s}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||c.Color.TRANSPARENT;for(let r of this._terrainProvider.terrainAreas)if(r.contains(e,t,i))return r.isCustom?this._colors.get("custom")||c.Color.RED:this._colors.get("default")||c.Color.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||c.Color.BLUE:this._colors.get("fallback")||c.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new c.Entity({rectangle:{coordinates:r,material:o,heightReference:c.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,l){let s=l?.tag||"terrain_area_visualization",h=l?.color||c.Color.RED,m=l?.maxTilesToShow||100,f=l?.show??!0,E=l?.alpha||.7,I=l?.tileAlpha||.2,S=new y({collection:o.entities,tag:s}),{rectangle:B}=r;if(S.add(i.createRectangle(B,h.withAlpha(E)),s),f&&r.tileRanges.size>0){let{tilingScheme:Y}=r.terrainProvider,O=0;r.tileRanges.forEach((x,W)=>{for(let V=x.start.x;V<=x.end.x&&O<m;V++)for(let M=x.start.y;M<=x.end.y&&O<m;M++){let q=Y.tileXYToRectangle(V,M,W);S.add(e(q,h.withAlpha(I)),`${s}_tile`),O++}})}return S}i.visualize=t})(v||={});function P(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var G=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache(){this._valuesCache=null}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let r=this.collection.remove(e);return r&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),r}if(Array.isArray(e)){if(e.length===0)return!1;let r=!1;for(let o of e)this.remove(o)&&(r=!0);return r}let t=this.get(e);if(t.length===0)return!1;let i=!1;for(let r of t)this.remove(r)&&(i=!0);return i}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof _.EntityCollection)return this.collection.values;{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));return e}}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,_.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,_.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,_.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r)if(e in o&&typeof o[e]!="function"){if(P(o,e))throw Error(`Cannot set read-only property '${String(e)}' on ${o.constructor.name}`);o[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,o)=>e(r,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},y=G;var d=require("cesium");var u=require("cesium"),T=class{_color=u.Color.RED;_silhouette;_composite;_stages;_entity;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=u.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=u.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}show(e,t){if(!(!(0,u.defined)(e)||this._silhouette.selected[0]===e))if(e instanceof u.Cesium3DTileFeature)this._silhouette.selected.push(e);else{if(!e.model)return;this._entity=e,e.model.silhouetteSize=new u.ConstantProperty(t?.width||2),e.model.silhouetteColor=new u.ConstantProperty(t?.color||this._color)}}hide(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new u.ConstantProperty(u.Color.TRANSPARENT),this._entity=void 0)}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite)}get color(){return this._color}set color(e){this._color=e}};var a=require("cesium"),b=class{_color=a.Color.RED;_entity;_entities;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new a.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}show(e,t){if(!(!(0,a.defined)(e)||!this._entity)){this._clearGeometries();try{if(e instanceof a.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof a.GroundPrimitive)this._update(e,t);else return;return this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i);return}}}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof a.Entity){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let r;i.positions.length>0&&!a.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new a.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new a.PolygonGraphics({hierarchy:i,material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||a.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let r=e.polyline.width?.getValue();this._entity.polyline=new a.PolylineGraphics({positions:i,material:t.color,width:r+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let r=[a.Cartesian3.fromRadians(i.west,i.north),a.Cartesian3.fromRadians(i.east,i.north),a.Cartesian3.fromRadians(i.east,i.south),a.Cartesian3.fromRadians(i.west,i.south),a.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new a.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new a.RectangleGraphics({coordinates:i,material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND}))}}else if(e instanceof a.GroundPrimitive){let i=e.geometryInstances,r=Array.isArray(i)?i[0]:i;if(!r.geometry.attributes.position)return;let o=r.geometry.attributes.position.values,l=[];for(let s=0;s<o.length;s+=3)l.push(new a.Cartesian3(o[s],o[s+1],o[s+2]));t.outline?this._entity.polyline=new a.PolylineGraphics({positions:l,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new a.PolygonGraphics({hierarchy:new a.PolygonHierarchy(l),material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND,classificationType:a.ClassificationType.BOTH})}}hide(){this._entity&&(this._entity.show=!1)}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity)}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}};var C=class n{static instances=new WeakMap;_surface;_silhouette;_color=d.Color.RED;constructor(e){this._surface=new b(e),this._silhouette=new T(e),this._surface.color=this._color,this._silhouette.color=this._color}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,i=n.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),n.instances.delete(t))}show(e,t={color:this._color}){this.hide();let i=this._getObject(e);if((0,d.defined)(i))return i instanceof d.Cesium3DTileFeature||i instanceof d.Entity&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if((0,d.defined)(e)){if(e instanceof d.Entity||e instanceof d.Cesium3DTileFeature||e instanceof d.GroundPrimitive)return e;if(e.id instanceof d.Entity)return e.id;if(e.primitive instanceof d.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}};var F=require("cesium");var N=require("cesium");var H=require("cesium");function w(n,e){if(e.size===0)return new H.Rectangle;let t=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY,l=Array.from(e.keys()),s=Math.min(...l),h=e.get(s);if(h){let{start:m,end:f}=h,E=n.tileXYToRectangle(m.x,m.y,s),I=n.tileXYToRectangle(f.x,f.y,s);t=Math.min(E.west,t),i=Math.min(I.south,i),r=Math.max(I.east,r),o=Math.max(E.north,o)}return new H.Rectangle(t,i,r,o)}var g=class{_terrainProvider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(e){this._terrainProvider=e.terrainProvider,this._tileRanges=e.tileRanges,this._credit=e.credit||"custom",this._isCustom=e.isCustom!==void 0?e.isCustom:!0,this._rectangle=w(e.terrainProvider.tilingScheme,e.tileRanges),e.tileRanges.forEach((t,i)=>{this._terrainProvider.availability?.addAvailableTileRange(i,t.start.x,t.start.y,t.end.x,t.end.y)}),this._ready=!0}contains(e,t,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let r=this._tileRanges.get(i);return e>=r.start.x&&e<=r.end.x&&t>=r.start.y&&t<=r.end.y}requestTileGeometry(e,t,i,r){if(!(!this._ready||!this.contains(e,t,i)))return this._terrainProvider.requestTileGeometry(e,t,i,r)}getTileDataAvailable(e,t,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let r=this._tileRanges.get(i);return e>=r.start.x&&e<=r.end.x&&t>=r.start.y&&t<=r.end.y}get isCustom(){return this._isCustom}get credit(){return this._credit}get terrainProvider(){return this._terrainProvider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(e=>{async function n(t,i,r){let o=r?.credit||"custom",l=await N.CesiumTerrainProvider.fromUrl(t,{...r,credit:o});return new e({terrainProvider:l,tileRanges:i,credit:o})}e.fromUrl=n})(g||={});var p=class extends Array{add(e){if(Array.isArray(e)){for(let i of e)this.add(i);return this.length}let t;return e instanceof g?t=e:t=new g(e),this.push(t)}remove(e){if(Array.isArray(e))return e.forEach(i=>this.remove(i)),this;let t=this.indexOf(e);return t>=0&&this.splice(t,1),this}removeAll(){this.length=0}};var A=class{_terrainAreas=new p;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._terrainProvider=e.terrainProvider,this._fallbackProvider=e.fallbackProvider||new F.EllipsoidTerrainProvider,this._tilingScheme=e.terrainProvider.tilingScheme,this._terrainAreas=new p(...e.terrainAreas),this._availability=e.terrainProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get terrainAreas(){return[...this._terrainAreas]}get defaultProvider(){return this._terrainProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._terrainProvider?.credit}get errorEvent(){return this._terrainProvider.errorEvent}get hasWaterMask(){return this._terrainProvider.hasWaterMask}get hasVertexNormals(){return this._terrainProvider.hasVertexNormals}loadTileDataAvailability(e,t,i){return this._terrainProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){return this._terrainProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,i,r){if(this._ready){for(let o of this._terrainAreas)if(o.contains(e,t,i))return o.requestTileGeometry(e,t,i,r);return this._terrainProvider.getTileDataAvailable(e,t,i)?this._terrainProvider.requestTileGeometry(e,t,i,r):this._fallbackProvider.requestTileGeometry(e,t,i,r)}}getTileDataAvailable(e,t,i){for(let r of this._terrainAreas)if(r.contains(e,t,i))return r.getTileDataAvailable(e,t,i);return this._terrainProvider.getTileDataAvailable(e,t,i)}};var z=require("cesium");var 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 D(n,e,t){let i={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},r=new z.Viewer(e,{...i,...t});R(n,r);let o=n.imageryLayers;r.imageryLayers.removeAll();for(let h=0;h<o.length;h++){let m=o.get(h);r.imageryLayers.addImageryProvider(m.imageryProvider,h)}r.clock.startTime=n.clock.startTime.clone(),r.clock.stopTime=n.clock.stopTime.clone(),r.clock.currentTime=n.clock.currentTime.clone(),r.clock.multiplier=n.clock.multiplier,r.clock.clockStep=n.clock.clockStep,r.clock.clockRange=n.clock.clockRange,r.clock.shouldAnimate=n.clock.shouldAnimate,r.scene.globe.enableLighting=n.scene.globe.enableLighting,r.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,r.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let l=n.scene.screenSpaceCameraController.tiltEventTypes;l&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(l)?[...l]:l);let s=n.scene.screenSpaceCameraController.zoomEventTypes;return s&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(s)?[...s]:s),r}
package/dist/index.d.cts CHANGED
@@ -6,12 +6,13 @@ export { TerrainVisualizer, isGetterOnly } from './utils/index.cjs';
6
6
  export { cloneViewer, syncCamera } from './viewer/index.cjs';
7
7
 
8
8
  interface IHighlight {
9
- show(object: any, color?: Color, options?: HighlightOptions): void;
9
+ show(object: any, options?: HighlightOptions): void;
10
10
  hide(): void;
11
11
  destroy(): void;
12
12
  color: Color;
13
13
  }
14
14
  interface HighlightOptions {
15
+ color?: Color;
15
16
  outline?: boolean;
16
17
  width?: number;
17
18
  }
@@ -72,11 +73,16 @@ declare class Highlight {
72
73
  * @param viewer The viewer whose highlight instance should be released.
73
74
  */
74
75
  static releaseInstance(viewer: Viewer): void;
75
- show(picked: Picked, color?: Color, options?: {
76
- outline?: boolean;
77
- width?: number;
78
- }): void | Entity;
76
+ /**
77
+ * Highlights a picked object or a direct instance.
78
+ * @param picked The result of `Scene.pick()` or direct instance to be highlighted.
79
+ * @param options Optional style for the highlight.
80
+ */
81
+ show(picked: Picked, options?: HighlightOptions): void | Entity;
79
82
  private _getObject;
83
+ /**
84
+ * Clears the current highlight effects.
85
+ */
80
86
  hide(): void;
81
87
  /** Gets the highlight color. */
82
88
  get color(): Color;
package/dist/index.d.ts CHANGED
@@ -6,12 +6,13 @@ export { TerrainVisualizer, isGetterOnly } from './utils/index.js';
6
6
  export { cloneViewer, syncCamera } from './viewer/index.js';
7
7
 
8
8
  interface IHighlight {
9
- show(object: any, color?: Color, options?: HighlightOptions): void;
9
+ show(object: any, options?: HighlightOptions): void;
10
10
  hide(): void;
11
11
  destroy(): void;
12
12
  color: Color;
13
13
  }
14
14
  interface HighlightOptions {
15
+ color?: Color;
15
16
  outline?: boolean;
16
17
  width?: number;
17
18
  }
@@ -72,11 +73,16 @@ declare class Highlight {
72
73
  * @param viewer The viewer whose highlight instance should be released.
73
74
  */
74
75
  static releaseInstance(viewer: Viewer): void;
75
- show(picked: Picked, color?: Color, options?: {
76
- outline?: boolean;
77
- width?: number;
78
- }): void | Entity;
76
+ /**
77
+ * Highlights a picked object or a direct instance.
78
+ * @param picked The result of `Scene.pick()` or direct instance to be highlighted.
79
+ * @param options Optional style for the highlight.
80
+ */
81
+ show(picked: Picked, options?: HighlightOptions): void | Entity;
79
82
  private _getObject;
83
+ /**
84
+ * Clears the current highlight effects.
85
+ */
80
86
  hide(): void;
81
87
  /** Gets the highlight color. */
82
88
  get color(): Color;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-RXMNSDKR.js";import{a as H,b as D,c as O,d as x}from"./chunk-D2H7O3WV.js";import{a as V,b as S,c as E}from"./chunk-XTUDPAWI.js";import{a as M,b as A}from"./chunk-2JNRK7SN.js";import{Cesium3DTileFeature as m,Color as z,defined as G,Entity as T,GroundPrimitive as R,ModelGraphics as B}from"cesium";import{Cesium3DTileFeature as I,Color as _,ConstantProperty as d,defined as b,PostProcessStageLibrary as w}from"cesium";var l=class{_color=_.RED;_silhouette;_composite;_stages;_model;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=w.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=w.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}show(e,i=this._color,o){!b(e)||this._silhouette.selected[0]===e||(e instanceof I?this._silhouette.selected.push(e):(this._model=e,e.silhouetteSize=new d(o?.width||2),e.silhouetteColor=new d(i)))}hide(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._model&&(this._model.silhouetteColor=new d(_.TRANSPARENT),this._model=void 0)}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite)}get color(){return this._color}set color(e){this._color=e}};import{Cartesian3 as n,ClassificationType as C,Color as F,defined as N,Entity as f,GroundPrimitive as v,HeightReference as y,PolygonGraphics as P,PolygonHierarchy as L,PolylineGraphics as g,RectangleGraphics as U}from"cesium";var a=class{_color=F.RED;_entity;_entities;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new f({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}show(e,i=this._color,o){if(!(!N(e)||!this._entity)){this._clearGeometries();try{if(e instanceof f&&(e.polygon||e.polyline||e.rectangle))this._update(e,i,o);else if(e instanceof v)this._update(e,i,o);else return;return this._entity.show=!0,this._entity}catch(t){console.error("Failed to highlight object:",t);return}}}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,i,o={outline:!1,width:2}){if(e instanceof f){if(e.polygon)if(o.outline){let t=e.polygon.hierarchy?.getValue();if(t&&t.positions){let s;t.positions.length>0&&!n.equals(t.positions[0],t.positions[t.positions.length-1])?s=[...t.positions,t.positions[0]]:s=t.positions,this._entity.polyline=new g({positions:s,material:i,width:o.width||2,clampToGround:e.polygon.heightReference?.getValue()===y.CLAMP_TO_GROUND})}}else{let t=e.polygon.hierarchy?.getValue();t&&(this._entity.polygon=new P({hierarchy:t,material:i,heightReference:e.polygon.heightReference?.getValue(),classificationType:e.polygon.classificationType?.getValue()||C.BOTH}))}else if(e.polyline){let t=e.polyline.positions?.getValue();if(t){let s=e.polyline.width?.getValue();this._entity.polyline=new g({positions:t,material:i,width:s+(o.width||2),clampToGround:e.polyline.clampToGround?.getValue()})}}else if(e.rectangle)if(o.outline){let t=e.rectangle.coordinates?.getValue();if(t){let s=[n.fromRadians(t.west,t.north),n.fromRadians(t.east,t.north),n.fromRadians(t.east,t.south),n.fromRadians(t.west,t.south),n.fromRadians(t.west,t.north)];this._entity.polyline=new g({positions:s,material:i,width:o.width||2,clampToGround:e.rectangle.heightReference?.getValue()===y.CLAMP_TO_GROUND})}}else{let t=e.rectangle.coordinates?.getValue();t&&(this._entity.rectangle=new U({coordinates:t,material:i,heightReference:e.rectangle.heightReference?.getValue()}))}}else if(e instanceof v){let t=e.geometryInstances,s=Array.isArray(t)?t[0]:t;if(!s.geometry.attributes.position)return;let u=s.geometry.attributes.position.values,p=[];for(let h=0;h<u.length;h+=3)p.push(new n(u[h],u[h+1],u[h+2]));o.outline?this._entity.polyline=new g({positions:p,material:i,width:o.width||2,clampToGround:!0}):this._entity.polygon=new P({hierarchy:new L(p),material:i,heightReference:y.CLAMP_TO_GROUND,classificationType:C.BOTH})}}hide(){this._entity&&(this._entity.show=!1)}destroy(){}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}};var c=class r{static instances=new Map;_surface;_silhouette;_color=z.RED;constructor(e){this._surface=new a(e),this._silhouette=new l(e),this._surface.color=this._color,this._silhouette.color=this._color}static getInstance(e){let i=e.container;return r.instances.has(i)||r.instances.set(i,new r(e)),r.instances.get(i)}static releaseInstance(e){let i=e.container,o=r.instances.get(i);o&&(o.hide(),o._surface&&o._surface.destroy(),o._silhouette&&o._silhouette.destroy(),r.instances.delete(i))}show(e,i=this._color,o){let t=this._getObject(e);if(G(t))return t instanceof m||t instanceof B?this._silhouette.show(t,i):this._surface.show(t,i,o)}_getObject(e){if(G(e)){if(e instanceof T||e instanceof m||e instanceof R)return e;if(e.id instanceof T)return e.id.model?e.id.model:e.id;if(e.primitive instanceof R)return e.primitive;if(e instanceof m)return e}}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}};export{E as Collection,c as Highlight,x as HybridTerrainProvider,D as TerrainArea,O as TerrainAreaCollection,V as TerrainVisualizer,A as cloneViewer,H as computeRectangle,S as isGetterOnly,M as syncCamera};
1
+ import"./chunk-RXMNSDKR.js";import{a as R,b as S,c as V,d as D}from"./chunk-D2H7O3WV.js";import{a as E,b as G,c as O}from"./chunk-YHYFSR66.js";import{a as x,b as A}from"./chunk-2JNRK7SN.js";import{Cesium3DTileFeature as P,Color as z,defined as H,Entity as y,GroundPrimitive as T}from"cesium";import{Cesium3DTileFeature as I,Color as _,ConstantProperty as p,defined as F,PostProcessStageLibrary as m}from"cesium";var n=class{_color=_.RED;_silhouette;_composite;_stages;_entity;constructor(t){this._stages=t.scene.postProcessStages,this._silhouette=m.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=m.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}show(t,i){if(!(!F(t)||this._silhouette.selected[0]===t))if(t instanceof I)this._silhouette.selected.push(t);else{if(!t.model)return;this._entity=t,t.model.silhouetteSize=new p(i?.width||2),t.model.silhouetteColor=new p(i?.color||this._color)}}hide(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new p(_.TRANSPARENT),this._entity=void 0)}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite)}get color(){return this._color}set color(t){this._color=t}};import{Cartesian3 as r,ClassificationType as w,Color as M,defined as N,Entity as f,GroundPrimitive as v,HeightReference as d,PolygonGraphics as C,PolygonHierarchy as L,PolylineGraphics as u,RectangleGraphics as U}from"cesium";var l=class{_color=M.RED;_entity;_entities;constructor(t){this._entities=t.entities,this._entity=this._entities.add(new f({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}show(t,i){if(!(!N(t)||!this._entity)){this._clearGeometries();try{if(t instanceof f&&(t.polygon||t.polyline||t.rectangle))this._update(t,i);else if(t instanceof v)this._update(t,i);else return;return this._entity.show=!0,this._entity}catch(e){console.error("Failed to highlight object:",e);return}}}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(t,i={color:this._color,outline:!1,width:2}){if(t instanceof f){if(t.polygon)if(i.outline){let e=t.polygon.hierarchy?.getValue();if(e&&e.positions){let o;e.positions.length>0&&!r.equals(e.positions[0],e.positions[e.positions.length-1])?o=[...e.positions,e.positions[0]]:o=e.positions,this._entity.polyline=new u({positions:o,material:i.color,width:i.width||2,clampToGround:!0})}}else{let e=t.polygon.hierarchy?.getValue();e&&(this._entity.polygon=new C({hierarchy:e,material:i.color,heightReference:d.CLAMP_TO_GROUND,classificationType:t.polygon.classificationType?.getValue()||w.BOTH}))}else if(t.polyline){let e=t.polyline.positions?.getValue();if(e){let o=t.polyline.width?.getValue();this._entity.polyline=new u({positions:e,material:i.color,width:o+(i.width||2),clampToGround:!0})}}else if(t.rectangle)if(i.outline){let e=t.rectangle.coordinates?.getValue();if(e){let o=[r.fromRadians(e.west,e.north),r.fromRadians(e.east,e.north),r.fromRadians(e.east,e.south),r.fromRadians(e.west,e.south),r.fromRadians(e.west,e.north)];this._entity.polyline=new u({positions:o,material:i.color,width:i.width||2,clampToGround:!0})}}else{let e=t.rectangle.coordinates?.getValue();e&&(this._entity.rectangle=new U({coordinates:e,material:i.color,heightReference:d.CLAMP_TO_GROUND}))}}else if(t instanceof v){let e=t.geometryInstances,o=Array.isArray(e)?e[0]:e;if(!o.geometry.attributes.position)return;let c=o.geometry.attributes.position.values,g=[];for(let h=0;h<c.length;h+=3)g.push(new r(c[h],c[h+1],c[h+2]));i.outline?this._entity.polyline=new u({positions:g,material:i.color,width:i.width||2,clampToGround:!0}):this._entity.polygon=new C({hierarchy:new L(g),material:i.color,heightReference:d.CLAMP_TO_GROUND,classificationType:w.BOTH})}}hide(){this._entity&&(this._entity.show=!1)}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity)}get color(){return this._color}set color(t){this._color=t}get entity(){return this._entity}};var a=class s{static instances=new WeakMap;_surface;_silhouette;_color=z.RED;constructor(t){this._surface=new l(t),this._silhouette=new n(t),this._surface.color=this._color,this._silhouette.color=this._color}static getInstance(t){let i=t.container;return s.instances.has(i)||s.instances.set(i,new s(t)),s.instances.get(i)}static releaseInstance(t){let i=t.container,e=s.instances.get(i);e&&(e.hide(),e._surface&&e._surface.destroy(),e._silhouette&&e._silhouette.destroy(),s.instances.delete(i))}show(t,i={color:this._color}){this.hide();let e=this._getObject(t);if(H(e))return e instanceof P||e instanceof y&&e.model?this._silhouette.show(e,i):this._surface.show(e,i)}_getObject(t){if(H(t)){if(t instanceof y||t instanceof P||t instanceof T)return t;if(t.id instanceof y)return t.id;if(t.primitive instanceof T)return t.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}get color(){return this._color}set color(t){this._color=t,this._surface.color=t,this._silhouette.color=t}};export{O as Collection,a as Highlight,D as HybridTerrainProvider,S as TerrainArea,V as TerrainAreaCollection,E as TerrainVisualizer,A as cloneViewer,R as computeRectangle,G as isGetterOnly,x as syncCamera};
@@ -1 +1 @@
1
- "use strict";var _=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var O=(n,e)=>{for(var t in e)_(n,t,{get:e[t],enumerable:!0})},S=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of A(e))!M.call(n,r)&&r!==t&&_(n,r,{get:()=>e[r],enumerable:!(i=L(e,r))||i.enumerable});return n};var V=n=>S(_({},"__esModule",{value:!0}),n);var j={};O(j,{TerrainVisualizer:()=>g,isGetterOnly:()=>v});module.exports=V(j);var s=require("cesium");var u=require("cesium");var b=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache(){this._valuesCache=null}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let r=this.collection.remove(e);return r&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),r}if(Array.isArray(e)){if(e.length===0)return!1;let r=!1;for(let o of e)this.remove(o)&&(r=!0);return r}let t=this.get(e);if(t.length===0)return!1;let i=!1;for(let r of t)this.remove(r)&&(i=!0);return i}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof u.EntityCollection)return this.collection.values;{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));return e}}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,u.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,u.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,u.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(v(o,e))throw Error(`setProperty(${o}, ${e}) failed; The property is readonly.`);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=b;var g=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",s.Color.RED],["default",s.Color.BLUE],["fallback",s.Color.GRAY],["grid",s.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 s.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:s.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(a=>{this._collection.add(a.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(s.Rectangle.northwest(e),t),o=i.positionToTileXY(s.Rectangle.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],a=Math.min(e.end.x-e.start.x+1,100),l=Math.min(e.end.y-e.start.y+1,100);for(let c=e.start.x;c<e.start.x+a;c++)for(let h=e.start.y;h<e.start.y+l;h++)try{let d=this._createTileEntity(c,h,t,i);d&&r.push({entity:d})}catch(d){console.warn(`Error creating tile (${c}, ${h}, ${t}):`,d)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let a=this._getTileColor(e,t,i),l=n.createRectangle(o,a.withAlpha(.3));return l.properties?.addProperty("tileX",e),l.properties?.addProperty("tileY",t),l.properties?.addProperty("tileLevel",i),l}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||s.Color.TRANSPARENT;for(let r of this._terrainProvider.terrainAreas)if(r.contains(e,t,i))return r.isCustom?this._colors.get("custom")||s.Color.RED:this._colors.get("default")||s.Color.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||s.Color.BLUE:this._colors.get("fallback")||s.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new s.Entity({rectangle:{coordinates:r,material:o,heightReference:s.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,a){let l=a?.tag||"terrain_area_visualization",c=a?.color||s.Color.RED,h=a?.maxTilesToShow||100,d=a?.show??!0,C=a?.alpha||.7,E=a?.tileAlpha||.2,f=new w({collection:o.entities,tag:l}),{rectangle:I}=r;if(f.add(i.createRectangle(I,c.withAlpha(C)),l),d&&r.tileRanges.size>0){let{tilingScheme:R}=r.terrainProvider,p=0;r.tileRanges.forEach((m,P)=>{for(let y=m.start.x;y<=m.end.x&&p<h;y++)for(let T=m.start.y;T<=m.end.y&&p<h;T++){let x=R.tileXYToRectangle(y,T,P);f.add(e(x,c.withAlpha(E)),`${l}_tile`),p++}})}return f}i.visualize=t})(g||={});function v(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}
1
+ "use strict";var _=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var O=(n,e)=>{for(var t in e)_(n,t,{get:e[t],enumerable:!0})},S=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of A(e))!M.call(n,r)&&r!==t&&_(n,r,{get:()=>e[r],enumerable:!(i=x(e,r))||i.enumerable});return n};var V=n=>S(_({},"__esModule",{value:!0}),n);var j={};O(j,{TerrainVisualizer:()=>g,isGetterOnly:()=>v});module.exports=V(j);var s=require("cesium");var u=require("cesium");var b=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache(){this._valuesCache=null}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let r=this.collection.remove(e);return r&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),r}if(Array.isArray(e)){if(e.length===0)return!1;let r=!1;for(let o of e)this.remove(o)&&(r=!0);return r}let t=this.get(e);if(t.length===0)return!1;let i=!1;for(let r of t)this.remove(r)&&(i=!0);return i}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof u.EntityCollection)return this.collection.values;{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));return e}}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,u.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,u.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,u.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(v(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=b;var g=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",s.Color.RED],["default",s.Color.BLUE],["fallback",s.Color.GRAY],["grid",s.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 s.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:s.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(a=>{this._collection.add(a.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(s.Rectangle.northwest(e),t),o=i.positionToTileXY(s.Rectangle.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],a=Math.min(e.end.x-e.start.x+1,100),l=Math.min(e.end.y-e.start.y+1,100);for(let c=e.start.x;c<e.start.x+a;c++)for(let h=e.start.y;h<e.start.y+l;h++)try{let d=this._createTileEntity(c,h,t,i);d&&r.push({entity:d})}catch(d){console.warn(`Error creating tile (${c}, ${h}, ${t}):`,d)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let a=this._getTileColor(e,t,i),l=n.createRectangle(o,a.withAlpha(.3));return l.properties?.addProperty("tileX",e),l.properties?.addProperty("tileY",t),l.properties?.addProperty("tileLevel",i),l}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||s.Color.TRANSPARENT;for(let r of this._terrainProvider.terrainAreas)if(r.contains(e,t,i))return r.isCustom?this._colors.get("custom")||s.Color.RED:this._colors.get("default")||s.Color.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||s.Color.BLUE:this._colors.get("fallback")||s.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new s.Entity({rectangle:{coordinates:r,material:o,heightReference:s.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,a){let l=a?.tag||"terrain_area_visualization",c=a?.color||s.Color.RED,h=a?.maxTilesToShow||100,d=a?.show??!0,w=a?.alpha||.7,E=a?.tileAlpha||.2,f=new C({collection:o.entities,tag:l}),{rectangle:I}=r;if(f.add(i.createRectangle(I,c.withAlpha(w)),l),d&&r.tileRanges.size>0){let{tilingScheme:R}=r.terrainProvider,p=0;r.tileRanges.forEach((m,P)=>{for(let y=m.start.x;y<=m.end.x&&p<h;y++)for(let T=m.start.y;T<=m.end.y&&p<h;T++){let L=R.tileXYToRectangle(y,T,P);f.add(e(L,c.withAlpha(E)),`${l}_tile`),p++}})}return f}i.visualize=t})(g||={});function v(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}
@@ -1 +1 @@
1
- import{a,b}from"../chunk-XTUDPAWI.js";export{a as TerrainVisualizer,b as isGetterOnly};
1
+ import{a,b}from"../chunk-YHYFSR66.js";export{a as TerrainVisualizer,b as isGetterOnly};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juun-roh/cesium-utils",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "Utilities to handle Cesium classes easier.",
5
5
  "keywords": [
6
6
  "Cesium",
@@ -41,6 +41,11 @@
41
41
  "import": "./dist/collection/index.js",
42
42
  "require": "./dist/collection/index.cjs"
43
43
  },
44
+ "./highlight": {
45
+ "types": "./dist/highlight/index.d.ts",
46
+ "import": "./dist/highlight/index.js",
47
+ "require": "./dist/highlight/index.cjs"
48
+ },
44
49
  "./terrain": {
45
50
  "types": "./dist/terrain/index.d.ts",
46
51
  "import": "./dist/terrain/index.js",
@@ -78,14 +83,14 @@
78
83
  "@commitlint/cz-commitlint": "^19.8.1",
79
84
  "@commitlint/format": "^19.8.1",
80
85
  "@commitlint/types": "^19.8.1",
81
- "@eslint/js": "^9.27.0",
82
- "@typescript-eslint/eslint-plugin": "^8.32.1",
83
- "@typescript-eslint/parser": "^8.32.1",
84
- "@vitest/coverage-v8": "3.1.4",
85
- "cesium": "^1.129.0",
86
- "eslint": "^9.27.0",
87
- "eslint-plugin-jsdoc": "^50.6.17",
88
- "eslint-plugin-prettier": "^5.4.0",
86
+ "@eslint/js": "^9.28.0",
87
+ "@typescript-eslint/eslint-plugin": "^8.33.1",
88
+ "@typescript-eslint/parser": "^8.33.1",
89
+ "@vitest/coverage-v8": "^3.2.2",
90
+ "cesium": "^1.130.0",
91
+ "eslint": "^9.28.0",
92
+ "eslint-plugin-jsdoc": "^50.7.1",
93
+ "eslint-plugin-prettier": "^5.4.1",
89
94
  "eslint-plugin-simple-import-sort": "^12.1.1",
90
95
  "eslint-plugin-unused-imports": "^4.1.4",
91
96
  "husky": "^9.1.7",
@@ -95,7 +100,7 @@
95
100
  "typedoc": "^0.28.5",
96
101
  "typescript": "^5.8.3",
97
102
  "vite": "^6.3.5",
98
- "vitest": "^3.1.4"
103
+ "vitest": "^3.2.2"
99
104
  },
100
105
  "scripts": {
101
106
  "build": "tsup",
@@ -1 +0,0 @@
1
- import{Color as a,Entity as A,HeightReference as M,Rectangle as w,TileCoordinatesImageryProvider as O}from"cesium";import{defined as y,EntityCollection as L}from"cesium";var T=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache(){this._valuesCache=null}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let r=this.collection.remove(e);return r&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),r}if(Array.isArray(e)){if(e.length===0)return!1;let r=!1;for(let o of e)this.remove(o)&&(r=!0);return r}let t=this.get(e);if(t.length===0)return!1;let i=!1;for(let r of t)this.remove(r)&&(i=!0);return i}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof L)return this.collection.values;{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));return e}}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)y(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)y(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)y(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(`setProperty(${o}, ${e}) failed; The property is readonly.`);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)}},b=T;var u=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",a.RED],["default",a.BLUE],["fallback",a.GRAY],["grid",a.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new b({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 O({tilingScheme:this._terrainProvider.tilingScheme,color:a.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(w.northwest(e),t),o=i.positionToTileXY(w.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 h=e.start.y;h<e.start.y+l;h++)try{let d=this._createTileEntity(c,h,t,i);d&&r.push({entity:d})}catch(d){console.warn(`Error creating tile (${c}, ${h}, ${t}):`,d)}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")||a.TRANSPARENT;for(let r of this._terrainProvider.terrainAreas)if(r.contains(e,t,i))return r.isCustom?this._colors.get("custom")||a.RED:this._colors.get("default")||a.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||a.BLUE:this._colors.get("fallback")||a.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new A({rectangle:{coordinates:r,material:o,heightReference:M.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,s){let l=s?.tag||"terrain_area_visualization",c=s?.color||a.RED,h=s?.maxTilesToShow||100,d=s?.show??!0,C=s?.alpha||.7,E=s?.tileAlpha||.2,m=new b({collection:o.entities,tag:l}),{rectangle:I}=r;if(m.add(i.createRectangle(I,c.withAlpha(C)),l),d&&r.tileRanges.size>0){let{tilingScheme:R}=r.terrainProvider,v=0;r.tileRanges.forEach((g,P)=>{for(let f=g.start.x;f<=g.end.x&&v<h;f++)for(let p=g.start.y;p<=g.end.y&&v<h;p++){let x=R.tileXYToRectangle(f,p,P);m.add(e(x,c.withAlpha(E)),`${l}_tile`),v++}})}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}export{u as a,_ as b,b as c};