@juun-roh/cesium-utils 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as r}from"./chunk-WTOAUTEK.js";import{a as e,b as i,c as o}from"./chunk-PSCNWZUR.js";import"./chunk-6I6OKECI.js";import{a as t}from"./chunk-XHMLNB5Q.js";import{a as p,b as m}from"./chunk-Z2COOTT4.js";export{r as Collection,o as Highlight,t as HybridTerrainProvider,e as SilhouetteHighlight,i as SurfaceHighlight,m as cloneViewer,p as syncCamera};
1
+ import{DataSourceCollection as z,defined as _,EntityCollection as x,ImageryLayerCollection as K,PrimitiveCollection as U}from"cesium";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}function y(n,e,t){let i=e.split(".");for(let a of i)if(E(a))return{success:!1,reason:"dangerous-property",message:`Property path contains dangerous property name: "${a}"`};let r=n,o=0;for(;o<i.length-1;o++){let a=i[o];if(!r||typeof r!="object"||!Object.prototype.hasOwnProperty.call(r,a))return{success:!1,reason:"invalid-path",message:`Property path "${e}" does not exist or contains inherited properties`};if(r=r[a],!r||typeof r!="object"||r===Object.prototype)return{success:!1,reason:"invalid-path",message:`Cannot traverse path "${e}" - reached non-object or prototype`}}if(o!==i.length-1)return{success:!1,reason:"invalid-path",message:`Failed to traverse property path "${e}"`};let s=i[i.length-1];if(E(s))return{success:!1,reason:"dangerous-property",message:`Cannot set dangerous property "${s}"`};if(!r||typeof r!="object"||r===Object.prototype)return{success:!1,reason:"invalid-path",message:"Cannot set property on invalid target"};if(s in r){if(typeof r[s]=="function")return{success:!1,reason:"function-property",message:`Cannot set function property "${s}"`};if(v(r,s))return{success:!1,reason:"read-only",message:`Cannot set read-only property "${e}"`}}return r[s]=t,{success:!0}}var W=["__proto__","constructor","prototype"];function E(n){return W.includes(n)}var C=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof x)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get tags(){return Array.from(this._tagMap.keys())}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)_(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)_(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)_(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r){let s=y(o,e,t);if(!s.success&&s.reason==="read-only")throw Error(`Cannot set read-only property '${e}' on ${o.constructor.name}`)}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,o)=>e(r,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof x?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof U?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof z?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof K&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}},S=C;import{Cesium3DTileFeature as M,Color as ee,defined as j,Entity as O,GroundPrimitive as D}from"cesium";import{Cesium3DTileFeature as Y,Color as b,ConstantProperty as p,defined as J,PostProcessStageLibrary as R}from"cesium";var h=class{_color=b.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=R.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=R.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}show(e,t){if(J(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{if(e instanceof Y)this._silhouette.uniforms.color=t?.color||this._color,this._silhouette.selected.push(e);else{if(!e.model)return;this._entity=e,e.model.silhouetteSize=new p(t?.width||2),e.model.silhouetteColor=new p(t?.color||this._color)}this._currentObject=e,this._currentOptions=t?{...t}:void 0}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0}}}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&b.equals(e.color||this._color,t.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new p(b.TRANSPARENT),this._entity.model.silhouetteSize=new p(0),this._entity=void 0)}};import{Cartesian3 as d,ClassificationType as H,Color as I,defined as Q,Entity as T,GroundPrimitive as L,HeightReference as P,PolygonGraphics as A,PolygonHierarchy as X,PolylineGraphics as f,RectangleGraphics as Z}from"cesium";var u=class{_color=I.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new T({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}show(e,t){if(!(!Q(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof T&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof L)this._update(e,t);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=e,this._currentOptions=t?{...t}:void 0,this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0;return}}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&I.equals(e.color||this._color,t.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof T){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let r;i.positions.length>0&&!d.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new f({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new A({hierarchy:i,material:t.color,heightReference:P.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||H.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let r=e.polyline.width?.getValue();this._entity.polyline=new f({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=[d.fromRadians(i.west,i.north),d.fromRadians(i.east,i.north),d.fromRadians(i.east,i.south),d.fromRadians(i.west,i.south),d.fromRadians(i.west,i.north)];this._entity.polyline=new f({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new Z({coordinates:i,material:t.color,heightReference:P.CLAMP_TO_GROUND}))}}else if(e instanceof L){let i=e.geometryInstances,r=Array.isArray(i)?i[0]:i;if(!r.geometry.attributes.position)return;let o=r.geometry.attributes.position.values,s=[];for(let a=0;a<o.length;a+=3)s.push(new d(o[a],o[a+1],o[a+2]));t.outline?this._entity.polyline=new f({positions:s,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new A({hierarchy:new X(s),material:t.color,heightReference:P.CLAMP_TO_GROUND,classificationType:H.BOTH})}}};var w=class n{static instances=new WeakMap;_surface;_silhouette;_color=ee.RED;constructor(e){this._surface=new u(e),this._silhouette=new h(e),this._surface.color=this._color,this._silhouette.color=this._color}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,i=n.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),n.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if(j(i))return i instanceof M?this._silhouette.show(i,t):i instanceof O&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if(j(e)){if(e instanceof O||e instanceof M||e instanceof D)return e;if(e.id instanceof O)return e.id;if(e.primitive instanceof D)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}},k=w;import{EllipsoidTerrainProvider as te}from"cesium";var m=class n{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new te,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,t,i){return this._defaultProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,i,r){if(this._ready){for(let o of this._regions)if(n.TerrainRegion.contains(o,e,t,i))return o.provider.requestTileGeometry(e,t,i,r);return this._defaultProvider.getTileDataAvailable(e,t,i)?this._defaultProvider.requestTileGeometry(e,t,i,r):this._fallbackProvider.requestTileGeometry(e,t,i,r)}}getTileDataAvailable(e,t,i){for(let r of this._regions)if(n.TerrainRegion.contains(r,e,t,i))return!0;return this._defaultProvider.getTileDataAvailable(e,t,i)}};(t=>{function n(i,r,o){return new t({regions:i.map(s=>({...s})),defaultProvider:r,fallbackProvider:o})}t.fromTileRanges=n;let e;(r=>{function i(o,s,a,c){if(o.levels&&!o.levels.includes(c))return!1;if(o.tiles){let l=o.tiles.get(c);if(!l)return!1;let[N,B]=Array.isArray(l.x)?l.x:[l.x,l.x],[q,$]=Array.isArray(l.y)?l.y:[l.y,l.y];return s>=N&&s<=B&&a>=q&&a<=$}return!1}r.contains=i})(e=t.TerrainRegion||={})})(m||={});var G=m;import{Viewer as ie}from"cesium";import{defined as V}from"cesium";function g(n,e){if(V(n)&&V(e)){let{camera:t}=n;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}function F(n,e,t){let i={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},r=new ie(e,{...i,...t});g(n,r);let o=n.imageryLayers;r.imageryLayers.removeAll();for(let c=0;c<o.length;c++){let l=o.get(c);r.imageryLayers.addImageryProvider(l.imageryProvider,c)}r.clock.startTime=n.clock.startTime.clone(),r.clock.stopTime=n.clock.stopTime.clone(),r.clock.currentTime=n.clock.currentTime.clone(),r.clock.multiplier=n.clock.multiplier,r.clock.clockStep=n.clock.clockStep,r.clock.clockRange=n.clock.clockRange,r.clock.shouldAnimate=n.clock.shouldAnimate,r.scene.globe.enableLighting=n.scene.globe.enableLighting,r.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,r.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let s=n.scene.screenSpaceCameraController.tiltEventTypes;s&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(s)?[...s]:s);let a=n.scene.screenSpaceCameraController.zoomEventTypes;return a&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(a)?[...a]:a),r}export{S as Collection,k as Highlight,G as HybridTerrainProvider,h as SilhouetteHighlight,u as SurfaceHighlight,F as cloneViewer,g as syncCamera};
@@ -0,0 +1 @@
1
+ "use strict";var y=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var w=(a,e)=>{for(var r in e)y(a,r,{get:e[r],enumerable:!0})},I=(a,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of C(e))!L.call(a,t)&&t!==r&&y(a,t,{get:()=>e[t],enumerable:!(i=T(e,t))||i.enumerable});return a};var x=a=>I(y({},"__esModule",{value:!0}),a);var R={};w(R,{TerrainVisualizer:()=>m});module.exports=x(R);var l=require("cesium");var v=require("cesium");var b=require("cesium"),h=class a{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new b.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,r,i){return this._defaultProvider.loadTileDataAvailability(e,r,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,r,i,t){if(this._ready){for(let o of this._regions)if(a.TerrainRegion.contains(o,e,r,i))return o.provider.requestTileGeometry(e,r,i,t);return this._defaultProvider.getTileDataAvailable(e,r,i)?this._defaultProvider.requestTileGeometry(e,r,i,t):this._fallbackProvider.requestTileGeometry(e,r,i,t)}}getTileDataAvailable(e,r,i){for(let t of this._regions)if(a.TerrainRegion.contains(t,e,r,i))return!0;return this._defaultProvider.getTileDataAvailable(e,r,i)}};(r=>{function a(i,t,o){return new r({regions:i.map(s=>({...s})),defaultProvider:t,fallbackProvider:o})}r.fromTileRanges=a;let e;(t=>{function i(o,s,d,c){if(o.levels&&!o.levels.includes(c))return!1;if(o.tiles){let n=o.tiles.get(c);if(!n)return!1;let[f,_]=Array.isArray(n.x)?n.x:[n.x,n.x],[P,p]=Array.isArray(n.y)?n.y:[n.y,n.y];return s>=f&&s<=_&&d>=P&&d<=p}return!1}t.contains=i})(e=r.TerrainRegion||={})})(h||={});var g=h;var u=class extends v.GridImageryProvider{_terrainProvider;_colors;constructor(e){let{terrainProvider:r,colors:i,...t}=e;super(t),this._terrainProvider=r,this._colors=i}requestImage(e,r,i){for(let t of this._terrainProvider.regions)if(this._isInRegionOrUpsampled(t,e,r,i))return this._createCanvasElement(this._colors.get("custom")||v.Color.RED);return this._terrainProvider.defaultProvider.getTileDataAvailable(e,r,i)?this._createCanvasElement(this._colors.get("default")||v.Color.BLUE):this._createCanvasElement(this._colors.get("fallback")||v.Color.GRAY)}_isInRegionOrUpsampled(e,r,i,t){let o=r,s=i,d=t;for(;d>=0;){if(g.TerrainRegion.contains(e,o,s,d))return!0;if(d===0)break;d--,o=Math.floor(o/2),s=Math.floor(s/2)}return!1}_createCanvasElement(e){let r=document.createElement("canvas");r.width=256,r.height=256;let i=r.getContext("2d"),t=e.withAlpha(.3).toCssColorString();if(!i)throw new Error("canvas context undefined");return i.fillStyle=t,i.fillRect(0,0,256,256),Promise.resolve(r)}};var m=class{_viewer;_terrainProvider;_visible=!1;_tileCoordinatesLayer;_hybridImageryLayer;_colors=new Map([["custom",l.Color.RED],["default",l.Color.BLUE],["fallback",l.Color.GRAY],["grid",l.Color.YELLOW]]);constructor(e,r){this._viewer=e,this._terrainProvider=r.terrainProvider,r.colors&&Object.entries(r.colors).forEach(([i,t])=>{this._colors.set(i,t)}),r.tile!==void 0&&r.tile&&this.show()}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){let e=this._visible,r=!!this._tileCoordinatesLayer,i=this._hybridImageryLayer?.alpha??.5;this.clear(),e&&this.show({showTileCoordinates:r,alpha:i})}clear(){this.hide()}show(e){if(!this._terrainProvider)return;let r=e?.showTileCoordinates??!0,i=e?.alpha??.5;r&&this._ensureTileCoordinatesLayer(),this.showImageryOverlay(i),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new l.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:l.Color.YELLOW})))}hide(){this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this.hideImageryOverlay(),this._visible=!1}setColors(e){Object.entries(e).forEach(([r,i])=>{this._colors.set(r,i)}),this.update()}showImageryOverlay(e=.5){this._hybridImageryLayer&&this._viewer.imageryLayers.remove(this._hybridImageryLayer);let r=new u({terrainProvider:this._terrainProvider,colors:this._colors,tilingScheme:this._terrainProvider.tilingScheme});this._hybridImageryLayer=this._viewer.imageryLayers.addImageryProvider(r),this._hybridImageryLayer.alpha=e,console.log("HybridImageryProvider overlay enabled")}hideImageryOverlay(){this._hybridImageryLayer&&(this._viewer.imageryLayers.remove(this._hybridImageryLayer),this._hybridImageryLayer=void 0,console.log("HybridImageryProvider overlay disabled"))}showTileCoordinates(){this._ensureTileCoordinatesLayer()}hideTileCoordinates(){this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0)}setAlpha(e){this._hybridImageryLayer&&(this._hybridImageryLayer.alpha=e)}flyTo(e,r){this._viewer.camera.flyTo({destination:e,...r,complete:()=>{this._visible&&this.update()}})}get tileCoordinatesVisible(){return!!this._tileCoordinatesLayer}get visible(){return this._visible}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};
@@ -0,0 +1 @@
1
+ import{Color as h,TileCoordinatesImageryProvider as T}from"cesium";import{Color as u,GridImageryProvider as p}from"cesium";import{EllipsoidTerrainProvider as P}from"cesium";var d=class l{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new P,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,r,i){return this._defaultProvider.loadTileDataAvailability(e,r,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,r,i,t){if(this._ready){for(let a of this._regions)if(l.TerrainRegion.contains(a,e,r,i))return a.provider.requestTileGeometry(e,r,i,t);return this._defaultProvider.getTileDataAvailable(e,r,i)?this._defaultProvider.requestTileGeometry(e,r,i,t):this._fallbackProvider.requestTileGeometry(e,r,i,t)}}getTileDataAvailable(e,r,i){for(let t of this._regions)if(l.TerrainRegion.contains(t,e,r,i))return!0;return this._defaultProvider.getTileDataAvailable(e,r,i)}};(r=>{function l(i,t,a){return new r({regions:i.map(n=>({...n})),defaultProvider:t,fallbackProvider:a})}r.fromTileRanges=l;let e;(t=>{function i(a,n,s,y){if(a.levels&&!a.levels.includes(y))return!1;if(a.tiles){let o=a.tiles.get(y);if(!o)return!1;let[b,g]=Array.isArray(o.x)?o.x:[o.x,o.x],[f,_]=Array.isArray(o.y)?o.y:[o.y,o.y];return n>=b&&n<=g&&s>=f&&s<=_}return!1}t.contains=i})(e=r.TerrainRegion||={})})(d||={});var c=d;var v=class extends p{_terrainProvider;_colors;constructor(e){let{terrainProvider:r,colors:i,...t}=e;super(t),this._terrainProvider=r,this._colors=i}requestImage(e,r,i){for(let t of this._terrainProvider.regions)if(this._isInRegionOrUpsampled(t,e,r,i))return this._createCanvasElement(this._colors.get("custom")||u.RED);return this._terrainProvider.defaultProvider.getTileDataAvailable(e,r,i)?this._createCanvasElement(this._colors.get("default")||u.BLUE):this._createCanvasElement(this._colors.get("fallback")||u.GRAY)}_isInRegionOrUpsampled(e,r,i,t){let a=r,n=i,s=t;for(;s>=0;){if(c.TerrainRegion.contains(e,a,n,s))return!0;if(s===0)break;s--,a=Math.floor(a/2),n=Math.floor(n/2)}return!1}_createCanvasElement(e){let r=document.createElement("canvas");r.width=256,r.height=256;let i=r.getContext("2d"),t=e.withAlpha(.3).toCssColorString();if(!i)throw new Error("canvas context undefined");return i.fillStyle=t,i.fillRect(0,0,256,256),Promise.resolve(r)}};var m=class{_viewer;_terrainProvider;_visible=!1;_tileCoordinatesLayer;_hybridImageryLayer;_colors=new Map([["custom",h.RED],["default",h.BLUE],["fallback",h.GRAY],["grid",h.YELLOW]]);constructor(e,r){this._viewer=e,this._terrainProvider=r.terrainProvider,r.colors&&Object.entries(r.colors).forEach(([i,t])=>{this._colors.set(i,t)}),r.tile!==void 0&&r.tile&&this.show()}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){let e=this._visible,r=!!this._tileCoordinatesLayer,i=this._hybridImageryLayer?.alpha??.5;this.clear(),e&&this.show({showTileCoordinates:r,alpha:i})}clear(){this.hide()}show(e){if(!this._terrainProvider)return;let r=e?.showTileCoordinates??!0,i=e?.alpha??.5;r&&this._ensureTileCoordinatesLayer(),this.showImageryOverlay(i),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new T({tilingScheme:this._terrainProvider.tilingScheme,color:h.YELLOW})))}hide(){this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this.hideImageryOverlay(),this._visible=!1}setColors(e){Object.entries(e).forEach(([r,i])=>{this._colors.set(r,i)}),this.update()}showImageryOverlay(e=.5){this._hybridImageryLayer&&this._viewer.imageryLayers.remove(this._hybridImageryLayer);let r=new v({terrainProvider:this._terrainProvider,colors:this._colors,tilingScheme:this._terrainProvider.tilingScheme});this._hybridImageryLayer=this._viewer.imageryLayers.addImageryProvider(r),this._hybridImageryLayer.alpha=e,console.log("HybridImageryProvider overlay enabled")}hideImageryOverlay(){this._hybridImageryLayer&&(this._viewer.imageryLayers.remove(this._hybridImageryLayer),this._hybridImageryLayer=void 0,console.log("HybridImageryProvider overlay disabled"))}showTileCoordinates(){this._ensureTileCoordinatesLayer()}hideTileCoordinates(){this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0)}setAlpha(e){this._hybridImageryLayer&&(this._hybridImageryLayer.alpha=e)}flyTo(e,r){this._viewer.camera.flyTo({destination:e,...r,complete:()=>{this._visible&&this.update()}})}get tileCoordinatesVisible(){return!!this._tileCoordinatesLayer}get visible(){return this._visible}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};export{m as TerrainVisualizer};
@@ -1 +1 @@
1
- import"../chunk-6I6OKECI.js";import{a}from"../chunk-XHMLNB5Q.js";export{a as HybridTerrainProvider};
1
+ import{EllipsoidTerrainProvider as T}from"cesium";var o=class d{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(r){this._defaultProvider=r.defaultProvider,this._fallbackProvider=r.fallbackProvider||new T,this._tilingScheme=r.defaultProvider.tilingScheme,this._regions=r.regions||[],this._availability=r.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(r,e,i){return this._defaultProvider.loadTileDataAvailability(r,e,i)}getLevelMaximumGeometricError(r){return this._defaultProvider.getLevelMaximumGeometricError(r)}requestTileGeometry(r,e,i,n){if(this._ready){for(let t of this._regions)if(d.TerrainRegion.contains(t,r,e,i))return t.provider.requestTileGeometry(r,e,i,n);return this._defaultProvider.getTileDataAvailable(r,e,i)?this._defaultProvider.requestTileGeometry(r,e,i,n):this._fallbackProvider.requestTileGeometry(r,e,i,n)}}getTileDataAvailable(r,e,i){for(let n of this._regions)if(d.TerrainRegion.contains(n,r,e,i))return!0;return this._defaultProvider.getTileDataAvailable(r,e,i)}};(e=>{function d(i,n,t){return new e({regions:i.map(l=>({...l})),defaultProvider:n,fallbackProvider:t})}e.fromTileRanges=d;let r;(n=>{function i(t,l,u,s){if(t.levels&&!t.levels.includes(s))return!1;if(t.tiles){let a=t.tiles.get(s);if(!a)return!1;let[v,m]=Array.isArray(a.x)?a.x:[a.x,a.x],[b,f]=Array.isArray(a.y)?a.y:[a.y,a.y];return l>=v&&l<=m&&u>=b&&u<=f}return!1}n.contains=i})(r=e.TerrainRegion||={})})(o||={});var P=o;export{P as HybridTerrainProvider};
@@ -1 +1 @@
1
- import{a,b}from"../chunk-Z2COOTT4.js";export{b as cloneViewer,a as syncCamera};
1
+ import{Viewer as p}from"cesium";import{defined as m}from"cesium";function c(e,i){if(m(e)&&m(i)){let{camera:t}=e;i.camera.position=t.positionWC.clone(),i.camera.direction=t.directionWC.clone(),i.camera.up=t.upWC.clone()}}function y(e,i,t){let d={baseLayerPicker:e.baseLayerPicker!==void 0,geocoder:e.geocoder!==void 0,homeButton:e.homeButton!==void 0,sceneModePicker:e.sceneModePicker!==void 0,timeline:e.timeline!==void 0,navigationHelpButton:e.navigationHelpButton!==void 0,animation:e.animation!==void 0,fullscreenButton:e.fullscreenButton!==void 0,shouldAnimate:e.clock.shouldAnimate,terrainProvider:e.terrainProvider,requestRenderMode:e.scene.requestRenderMode,infoBox:e.infoBox!==void 0},n=new p(i,{...d,...t});c(e,n);let l=e.imageryLayers;n.imageryLayers.removeAll();for(let a=0;a<l.length;a++){let s=l.get(a);n.imageryLayers.addImageryProvider(s.imageryProvider,a)}n.clock.startTime=e.clock.startTime.clone(),n.clock.stopTime=e.clock.stopTime.clone(),n.clock.currentTime=e.clock.currentTime.clone(),n.clock.multiplier=e.clock.multiplier,n.clock.clockStep=e.clock.clockStep,n.clock.clockRange=e.clock.clockRange,n.clock.shouldAnimate=e.clock.shouldAnimate,n.scene.globe.enableLighting=e.scene.globe.enableLighting,n.scene.globe.depthTestAgainstTerrain=e.scene.globe.depthTestAgainstTerrain,n.scene.screenSpaceCameraController.enableCollisionDetection=e.scene.screenSpaceCameraController.enableCollisionDetection;let o=e.scene.screenSpaceCameraController.tiltEventTypes;o&&(n.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(o)?[...o]:o);let r=e.scene.screenSpaceCameraController.zoomEventTypes;return r&&(n.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(r)?[...r]:r),n}export{y as cloneViewer,c as syncCamera};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juun-roh/cesium-utils",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Solve common Cesium.js challenges: combine multiple terrain sources, tag and filter entity collections, and add visual highlights.",
5
5
  "keywords": [
6
6
  "cesium",
@@ -47,46 +47,91 @@
47
47
  "types": "dist/index.d.ts",
48
48
  "exports": {
49
49
  ".": {
50
- "types": "./dist/index.d.ts",
51
- "require": "./dist/index.cjs",
52
- "default": "./dist/index.js"
50
+ "import": {
51
+ "types": "./dist/index.d.ts",
52
+ "default": "./dist/index.js"
53
+ },
54
+ "require": {
55
+ "types": "./dist/index.d.cts",
56
+ "default": "./dist/index.cjs"
57
+ }
53
58
  },
54
59
  "./collection": {
55
- "types": "./dist/collection/index.d.ts",
56
- "import": "./dist/collection/index.js",
57
- "require": "./dist/collection/index.cjs"
60
+ "import": {
61
+ "types": "./dist/index.d.ts",
62
+ "default": "./dist/collection/index.js"
63
+ },
64
+ "require": {
65
+ "types": "./dist/index.d.cts",
66
+ "default": "./dist/collection/index.cjs"
67
+ }
58
68
  },
59
69
  "./highlight": {
60
- "types": "./dist/highlight/index.d.ts",
61
- "import": "./dist/highlight/index.js",
62
- "require": "./dist/highlight/index.cjs"
70
+ "import": {
71
+ "types": "./dist/index.d.ts",
72
+ "default": "./dist/highlight/index.js"
73
+ },
74
+ "require": {
75
+ "types": "./dist/index.d.cts",
76
+ "default": "./dist/highlight/index.cjs"
77
+ }
63
78
  },
64
79
  "./terrain": {
65
- "types": "./dist/terrain/index.d.ts",
66
- "import": "./dist/terrain/index.js",
67
- "require": "./dist/terrain/index.cjs"
80
+ "import": {
81
+ "types": "./dist/index.d.ts",
82
+ "default": "./dist/terrain/index.js"
83
+ },
84
+ "require": {
85
+ "types": "./dist/index.d.cts",
86
+ "default": "./dist/terrain/index.cjs"
87
+ }
88
+ },
89
+ "./terrain/dev": {
90
+ "import": {
91
+ "types": "./dist/index.d.ts",
92
+ "default": "./dist/terrain/dev/index.js"
93
+ },
94
+ "require": {
95
+ "types": "./dist/index.d.cts",
96
+ "default": "./dist/terrain/dev/index.cjs"
97
+ }
68
98
  },
69
99
  "./dev": {
70
- "types": "./dist/dev/index.d.ts",
71
- "import": "./dist/dev/index.js",
72
- "require": "./dist/dev/index.cjs"
100
+ "import": {
101
+ "types": "./dist/index.d.ts",
102
+ "default": "./dist/dev/index.js"
103
+ },
104
+ "require": {
105
+ "types": "./dist/index.d.cts",
106
+ "default": "./dist/dev/index.cjs"
107
+ }
73
108
  },
74
109
  "./experimental": {
75
- "types": "./dist/experimental/index.d.ts",
76
- "import": "./dist/experimental/index.js",
77
- "require": "./dist/experimental/index.cjs"
110
+ "import": {
111
+ "types": "./dist/index.d.ts",
112
+ "default": "./dist/experimental/index.js"
113
+ },
114
+ "require": {
115
+ "types": "./dist/index.d.cts",
116
+ "default": "./dist/experimental/index.cjs"
117
+ }
78
118
  },
79
119
  "./viewer": {
80
- "types": "./dist/viewer/index.d.ts",
81
- "import": "./dist/viewer/index.js",
82
- "require": "./dist/viewer/index.cjs"
120
+ "import": {
121
+ "types": "./dist/index.d.ts",
122
+ "default": "./dist/viewer/index.js"
123
+ },
124
+ "require": {
125
+ "types": "./dist/index.d.cts",
126
+ "default": "./dist/viewer/index.cjs"
127
+ }
83
128
  }
84
129
  },
85
130
  "engines": {
86
131
  "node": ">=20.0.0"
87
132
  },
88
133
  "peerDependencies": {
89
- "cesium": "^1.133.0"
134
+ "cesium": ">=1.133.0"
90
135
  },
91
136
  "publishConfig": {
92
137
  "access": "public"
@@ -97,31 +142,31 @@
97
142
  }
98
143
  },
99
144
  "devDependencies": {
100
- "@changesets/cli": "^2.29.8",
101
- "@commitlint/cli": "^20.2.0",
102
- "@commitlint/config-conventional": "^20.2.0",
103
- "@commitlint/cz-commitlint": "^20.2.0",
104
- "@commitlint/format": "^20.2.0",
105
- "@commitlint/types": "^20.2.0",
106
- "@eslint/js": "^9.39.2",
107
- "@types/node": "^25.0.3",
108
- "@typescript-eslint/eslint-plugin": "^8.50.1",
109
- "@typescript-eslint/parser": "^8.50.1",
110
- "@vitest/coverage-v8": "^4.0.16",
111
- "cesium": "^1.136.0",
112
- "eslint": "^9.39.2",
113
- "eslint-plugin-jsdoc": "^61.5.0",
114
- "eslint-plugin-prettier": "^5.5.4",
145
+ "@changesets/cli": "^2.30.0",
146
+ "@commitlint/cli": "^20.5.0",
147
+ "@commitlint/config-conventional": "^20.5.0",
148
+ "@commitlint/cz-commitlint": "^20.5.0",
149
+ "@commitlint/format": "^20.5.0",
150
+ "@commitlint/types": "^20.5.0",
151
+ "@eslint/js": "^10.0.1",
152
+ "@types/node": "^25.5.0",
153
+ "@typescript-eslint/eslint-plugin": "^8.57.2",
154
+ "@typescript-eslint/parser": "^8.57.2",
155
+ "@vitest/coverage-v8": "^4.1.2",
156
+ "cesium": "^1.139.1",
157
+ "eslint": "^10.1.0",
158
+ "eslint-plugin-jsdoc": "^62.8.1",
159
+ "eslint-plugin-prettier": "^5.5.5",
115
160
  "eslint-plugin-simple-import-sort": "^12.1.1",
116
- "eslint-plugin-unused-imports": "^4.3.0",
161
+ "eslint-plugin-unused-imports": "^4.4.1",
117
162
  "husky": "^9.1.7",
118
- "jsdom": "^27.4.0",
119
- "rimraf": "^6.1.2",
163
+ "jsdom": "^29.0.1",
164
+ "rimraf": "^6.1.3",
120
165
  "tsup": "^8.5.1",
121
- "typedoc": "^0.28.15",
166
+ "typedoc": "^0.28.18",
122
167
  "typescript": "^5.9.3",
123
- "vite": "^7.3.0",
124
- "vitest": "^4.0.16"
168
+ "vite": "^8.0.3",
169
+ "vitest": "^4.1.2"
125
170
  },
126
171
  "scripts": {
127
172
  "build": "tsup",
File without changes
@@ -1 +0,0 @@
1
- import{Cesium3DTileFeature as P,Color as R,defined as H,Entity as p,GroundPrimitive as E}from"cesium";import{Cesium3DTileFeature as T,Color as f,ConstantProperty as u,defined as G,PostProcessStageLibrary as m}from"cesium";var s=class{_color=f.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(t){this._stages=t.scene.postProcessStages,this._silhouette=m.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=m.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}get color(){return this._color}set color(t){this._color=t}get currentObject(){return this._currentObject}show(t,i){if(G(t)&&!(this._currentObject===t&&this._optionsEqual(this._currentOptions,i))){this._clearHighlights();try{if(t instanceof T)this._silhouette.uniforms.color=i?.color||this._color,this._silhouette.selected.push(t);else{if(!t.model)return;this._entity=t,t.model.silhouetteSize=new u(i?.width||2),t.model.silhouetteColor=new u(i?.color||this._color)}this._currentObject=t,this._currentOptions=i?{...i}:void 0}catch(e){console.error("Failed to highlight object:",e),this._currentObject=void 0,this._currentOptions=void 0}}}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(t,i){return!t&&!i?!0:!t||!i?!1:t.outline===i.outline&&t.width===i.width&&f.equals(t.color||this._color,i.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new u(f.TRANSPARENT),this._entity.model.silhouetteSize=new u(0),this._entity=void 0)}};import{Cartesian3 as o,ClassificationType as v,Color as O,defined as S,Entity as g,GroundPrimitive as w,HeightReference as _,PolygonGraphics as C,PolygonHierarchy as b,PolylineGraphics as a,RectangleGraphics as D}from"cesium";var l=class{_color=O.RED;_entity;_entities;_currentObject;_currentOptions;constructor(t){this._entities=t.entities,this._entity=this._entities.add(new g({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}get color(){return this._color}set color(t){this._color=t}get entity(){return this._entity}get currentObject(){return this._currentObject}show(t,i){if(!(!S(t)||!this._entity)){if(this._currentObject===t&&this._optionsEqual(this._currentOptions,i))return this._entity;this._clearGeometries();try{if(t instanceof g&&(t.polygon||t.polyline||t.rectangle))this._update(t,i);else if(t instanceof w)this._update(t,i);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=t,this._currentOptions=i?{...i}:void 0,this._entity.show=!0,this._entity}catch(e){console.error("Failed to highlight object:",e),this._currentObject=void 0,this._currentOptions=void 0;return}}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(t,i){return!t&&!i?!0:!t||!i?!1:t.outline===i.outline&&t.width===i.width&&O.equals(t.color||this._color,i.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(t,i={color:this._color,outline:!1,width:2}){if(t instanceof g){if(t.polygon)if(i.outline){let e=t.polygon.hierarchy?.getValue();if(e&&e.positions){let r;e.positions.length>0&&!o.equals(e.positions[0],e.positions[e.positions.length-1])?r=[...e.positions,e.positions[0]]:r=e.positions,this._entity.polyline=new a({positions:r,material:i.color,width:i.width||2,clampToGround:!0})}}else{let e=t.polygon.hierarchy?.getValue();e&&(this._entity.polygon=new C({hierarchy:e,material:i.color,heightReference:_.CLAMP_TO_GROUND,classificationType:t.polygon.classificationType?.getValue()||v.BOTH}))}else if(t.polyline){let e=t.polyline.positions?.getValue();if(e){let r=t.polyline.width?.getValue();this._entity.polyline=new a({positions:e,material:i.color,width:r+(i.width||2),clampToGround:!0})}}else if(t.rectangle)if(i.outline){let e=t.rectangle.coordinates?.getValue();if(e){let r=[o.fromRadians(e.west,e.north),o.fromRadians(e.east,e.north),o.fromRadians(e.east,e.south),o.fromRadians(e.west,e.south),o.fromRadians(e.west,e.north)];this._entity.polyline=new a({positions:r,material:i.color,width:i.width||2,clampToGround:!0})}}else{let e=t.rectangle.coordinates?.getValue();e&&(this._entity.rectangle=new D({coordinates:e,material:i.color,heightReference:_.CLAMP_TO_GROUND}))}}else if(t instanceof w){let e=t.geometryInstances,r=Array.isArray(e)?e[0]:e;if(!r.geometry.attributes.position)return;let c=r.geometry.attributes.position.values,d=[];for(let h=0;h<c.length;h+=3)d.push(new o(c[h],c[h+1],c[h+2]));i.outline?this._entity.polyline=new a({positions:d,material:i.color,width:i.width||2,clampToGround:!0}):this._entity.polygon=new C({hierarchy:new b(d),material:i.color,heightReference:_.CLAMP_TO_GROUND,classificationType:v.BOTH})}}};var y=class n{static instances=new WeakMap;_surface;_silhouette;_color=R.RED;constructor(t){this._surface=new l(t),this._silhouette=new s(t),this._surface.color=this._color,this._silhouette.color=this._color}get color(){return this._color}set color(t){this._color=t,this._surface.color=t,this._silhouette.color=t}static getInstance(t){let i=t.container;return n.instances.has(i)||n.instances.set(i,new n(t)),n.instances.get(i)}static releaseInstance(t){let i=t.container,e=n.instances.get(i);e&&(e.hide(),e._surface&&e._surface.destroy(),e._silhouette&&e._silhouette.destroy(),n.instances.delete(i))}show(t,i={color:this._color}){let e=this._getObject(t);if(H(e))return e instanceof P?this._silhouette.show(e,i):e instanceof p&&e.model?this._silhouette.show(e,i):this._surface.show(e,i)}_getObject(t){if(H(t)){if(t instanceof p||t instanceof P||t instanceof E)return t;if(t.id instanceof p)return t.id;if(t.primitive instanceof E)return t.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}},V=y;export{s as a,l as b,V as c};
@@ -1 +0,0 @@
1
- import{DataSourceCollection as m,defined as h,EntityCollection as v,ImageryLayerCollection as y,PrimitiveCollection as f}from"cesium";function l(a,e){let t=!1,i=Object.getOwnPropertyDescriptor(a,e);if(!i){let n=Object.getPrototypeOf(a);for(;n&&!i;)i=Object.getOwnPropertyDescriptor(n,e),n=Object.getPrototypeOf(n)}return i&&i.get&&!i.set&&(t=!0),t}function c(a,e,t){let i=e.split(".");for(let o of i)if(u(o))return{success:!1,reason:"dangerous-property",message:`Property path contains dangerous property name: "${o}"`};let n=a,s=0;for(;s<i.length-1;s++){let o=i[s];if(!n||typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,o))return{success:!1,reason:"invalid-path",message:`Property path "${e}" does not exist or contains inherited properties`};if(n=n[o],!n||typeof n!="object"||n===Object.prototype)return{success:!1,reason:"invalid-path",message:`Cannot traverse path "${e}" - reached non-object or prototype`}}if(s!==i.length-1)return{success:!1,reason:"invalid-path",message:`Failed to traverse property path "${e}"`};let r=i[i.length-1];if(u(r))return{success:!1,reason:"dangerous-property",message:`Cannot set dangerous property "${r}"`};if(!n||typeof n!="object"||n===Object.prototype)return{success:!1,reason:"invalid-path",message:"Cannot set property on invalid target"};if(r in n){if(typeof n[r]=="function")return{success:!1,reason:"function-property",message:`Cannot set function property "${r}"`};if(l(n,r))return{success:!1,reason:"read-only",message:`Cannot set read-only property "${e}"`}}return n[r]=t,{success:!0}}var p=["__proto__","constructor","prototype"];function u(a){return p.includes(a)}var d=class a{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof v)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get tags(){return Array.from(this._tagMap.keys())}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(n=>{this.add(n,t)}):(Object.defineProperty(e,a.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}update(e,t){let i=this.get(e);for(let n of i)this._removeFromTagMap(n),Object.defineProperty(n,a.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(n,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)h(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)h(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)h(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let n=this.get(i);for(let s of n){let r=c(s,e,t);if(!r.success&&r.reason==="read-only")throw Error(`Cannot set read-only property '${e}' on ${s.constructor.name}`)}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((n,s)=>e(n,s))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}_emit(e,t){let i=this._eventListeners.get(e);if(i){let n={type:e,...t};i.forEach(s=>s(n))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[a.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof v?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof f?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof m?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof y&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}},g=d;export{g as a};
@@ -1 +0,0 @@
1
- import{EllipsoidTerrainProvider as P}from"cesium";var o=class u{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new P,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,r,i){return this._defaultProvider.loadTileDataAvailability(e,r,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,r,i,n){if(this._ready){for(let t of this._regions)if(u.TerrainRegion.contains(t,e,r,i))return t.provider.requestTileGeometry(e,r,i,n);return this._defaultProvider.getTileDataAvailable(e,r,i)?this._defaultProvider.requestTileGeometry(e,r,i,n):this._fallbackProvider.requestTileGeometry(e,r,i,n)}}getTileDataAvailable(e,r,i){for(let n of this._regions)if(u.TerrainRegion.contains(n,e,r,i))return!0;return this._defaultProvider.getTileDataAvailable(e,r,i)}};(r=>{function u(i,n,t){return new r({regions:i.map(l=>({...l})),defaultProvider:n,fallbackProvider:t})}r.fromTileRanges=u;let e;(n=>{function i(t,l,d,s){if(t.levels&&!t.levels.includes(s))return!1;if(t.tiles){let a=t.tiles.get(s);if(!a)return!1;let[v,m]=Array.isArray(a.x)?a.x:[a.x,a.x],[b,f]=Array.isArray(a.y)?a.y:[a.y,a.y];return l>=v&&l<=m&&d>=b&&d<=f}return!1}n.contains=i})(e=r.TerrainRegion||={})})(o||={});var T=o;export{T as a};
@@ -1 +0,0 @@
1
- import{Viewer as p}from"cesium";import{defined as m}from"cesium";function c(e,i){if(m(e)&&m(i)){let{camera:t}=e;i.camera.position=t.positionWC.clone(),i.camera.direction=t.directionWC.clone(),i.camera.up=t.upWC.clone()}}function y(e,i,t){let d={baseLayerPicker:e.baseLayerPicker!==void 0,geocoder:e.geocoder!==void 0,homeButton:e.homeButton!==void 0,sceneModePicker:e.sceneModePicker!==void 0,timeline:e.timeline!==void 0,navigationHelpButton:e.navigationHelpButton!==void 0,animation:e.animation!==void 0,fullscreenButton:e.fullscreenButton!==void 0,shouldAnimate:e.clock.shouldAnimate,terrainProvider:e.terrainProvider,requestRenderMode:e.scene.requestRenderMode,infoBox:e.infoBox!==void 0},n=new p(i,{...d,...t});c(e,n);let l=e.imageryLayers;n.imageryLayers.removeAll();for(let a=0;a<l.length;a++){let s=l.get(a);n.imageryLayers.addImageryProvider(s.imageryProvider,a)}n.clock.startTime=e.clock.startTime.clone(),n.clock.stopTime=e.clock.stopTime.clone(),n.clock.currentTime=e.clock.currentTime.clone(),n.clock.multiplier=e.clock.multiplier,n.clock.clockStep=e.clock.clockStep,n.clock.clockRange=e.clock.clockRange,n.clock.shouldAnimate=e.clock.shouldAnimate,n.scene.globe.enableLighting=e.scene.globe.enableLighting,n.scene.globe.depthTestAgainstTerrain=e.scene.globe.depthTestAgainstTerrain,n.scene.screenSpaceCameraController.enableCollisionDetection=e.scene.screenSpaceCameraController.enableCollisionDetection;let o=e.scene.screenSpaceCameraController.tiltEventTypes;o&&(n.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(o)?[...o]:o);let r=e.scene.screenSpaceCameraController.zoomEventTypes;return r&&(n.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(r)?[...r]:r),n}export{c as a,y as b};