@juun-roh/cesium-utils 0.0.3 → 0.0.5

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{defined as I,EntityCollection as H}from"cesium";var S=class a{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}_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[a.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)}):(Object.defineProperty(e,a.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){return this.collection.contains(e)}remove(e){let t=this.collection.remove(e);return t&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),t}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this._valuesCache)return this._valuesCache;if(this.collection instanceof H)this._valuesCache=this.collection.values||[];else{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));this._valuesCache=e}return this._valuesCache}get length(){return this.values?.length||0}getByTag(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}getFirstByTag(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}getTags(){return Array.from(this._tagMap.keys())}hasTag(e){let t=this._tagMap.get(e);return!!t&&t.size>0}updateTag(e,t){let r=this.getByTag(e);for(let i of r)this._removeFromTagMap(i),Object.defineProperty(i,a.symbol,t),this._addToTagMap(i,t);return r.length>0&&this._emit("update",{items:r,tag:t}),r.length}removeByTag(e){let t=0;return Array.isArray(e)?e.forEach(r=>{this.removeByTag(r)}):this.getByTag(e).forEach(r=>{this.remove(r)&&t++}),t}show(e){let t=this.getByTag(e),r=0;for(let i of t)I(i.show)&&(i.show=!0,r++);return r}hide(e){let t=this.getByTag(e),r=0;for(let i of t)I(i.show)&&(i.show=!1,r++);return r}toggle(e){let t=this.getByTag(e),r=0;for(let i of t)I(i.show)&&(i.show=!i.show,r++);return r}setProperty(e,t,r){let i=this.getByTag(e),o=0;for(let n of i)t in n?(n[t]=r,o++):console.warn(`${t} does not exists in ${n}`);return o}filter(e,t){return(t?this.getByTag(t):this.values).filter(e)}forEach(e,t){(t?this.getByTag(t):this.values).forEach((i,o)=>e(i,o))}},C=S;import{CesiumTerrainProvider as k,EllipsoidTerrainProvider as M,GeographicTilingScheme as q}from"cesium";import{CesiumTerrainProvider as Y}from"cesium";import{GeographicTilingScheme as x,Rectangle as b}from"cesium";var h=class{_rectangle;_tilingScheme;_tileRanges;_levels;constructor(e,t){if(this._tilingScheme=t||new x,this._rectangle=new b,this._tileRanges=new Map,this._levels=new Set,e.type==="rectangle"&&e.rectangle)this._rectangle=b.clone(e.rectangle);else if(e.type==="tileRange"&&e.tileRanges)e.tileRanges instanceof Map?this._tileRanges=new Map(e.tileRanges):this._tileRanges=new Map(Object.entries(e.tileRanges).map(([r,i])=>[parseInt(r),i])),this._calculateRectangleFromTileRanges();else throw new Error("Either rectangle or tileRanges must be provided.");this._levels=new Set(Array.from(this._tileRanges.keys()))}contains(e,t,r){if(this._tileRanges.has(r)){let o=this._tileRanges.get(r);return e>=o.start.x&&e<=o.end.x&&t>=o.start.y&&t<=o.end.y}let i=this._tilingScheme.tileXYToRectangle(e,t,r);return b.intersection(i,this._rectangle)!==void 0}configureAvailability(e){if(e.availability){e.availability._tilingScheme&&(e.availability._tilingScheme=this._tilingScheme);for(let[t,r]of this._tileRanges.entries())e.availability.addAvailableTileRange(t,r.start.x,r.start.y,r.end.x,r.end.y)}}get rectangle(){return this._rectangle}get tilingScheme(){return this._tilingScheme}get tileRanges(){return this._tileRanges}get levels(){return this._levels}_calculateRectangleFromTileRanges(){let e=Number.POSITIVE_INFINITY,t=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY,o=Array.from(this._tileRanges.keys());if(o.length===0){this._rectangle=b.MAX_VALUE;return}let n=Math.min(...o),s=this._tileRanges.get(n);if(s){let{start:l,end:c}=s,T=this._tilingScheme.tileXYToRectangle(l.x,l.y,n),d=this._tilingScheme.tileXYToRectangle(c.x,c.y,n);e=Math.min(T.west,e),t=Math.min(d.south,t),r=Math.max(d.east,r),i=Math.max(T.north,i)}this._rectangle=new b(e,t,r,i)}};(t=>{function a(r,i,o,n=new x){let s=new Map;return s.set(o,{start:{x:r,y:i},end:{x:r,y:i}}),new t({type:"tileRange",tileRanges:s},n)}t.fromTile=a;function e(r,i=new x){return new t({type:"rectangle",rectangle:b.clone(r)},i)}t.fromRectangle=e})(h||={});var v=class a{_provider;_bounds;_levels;_ready=!1;_credit;_isCustom;constructor(e,t){this._bounds=e.bounds instanceof h?e.bounds:new h(e.bounds),this._levels=new Set(e.levels||[]),this._credit=e.credit||"custom",this._isCustom=e.isCustom!==void 0?e.isCustom:!0,this._provider=t,this._ready=!0,this._bounds.configureAvailability(this._provider)}static async create(e){let t;return typeof e.provider=="string"?t=await Y.fromUrl(e.provider,{requestVertexNormals:!0,credit:e.credit||"custom"}):t=e.provider,new a(e,t)}contains(e,t,r){return this._levels.size>0&&!this._levels.has(r)?!1:this._bounds.contains(e,t,r)}requestTileGeometry(e,t,r,i){if(!(!this._ready||!this.contains(e,t,r)||!this._provider?.getTileDataAvailable(e,t,r)))return this._provider.requestTileGeometry(e,t,r,i)}getTileDataAvailable(e,t,r){return!this.contains(e,t,r)||!this._ready?!1:this._provider?.getTileDataAvailable(e,t,r)??!1}get isCustom(){return this._isCustom}get credit(){return this._credit}get provider(){return this._provider}get bounds(){return this._bounds}get levels(){return this._levels}get ready(){return this._ready}};(e=>{async function a(t,r,i,o="custom"){let n=new h({type:"tileRange",tileRanges:r});return await e.create({provider:t,bounds:n,levels:i||Object.keys(r).map(l=>parseInt(l)),credit:o})}e.fromUrl=a})(v||={});var P=class extends Array{async add(e){let t;return e instanceof v?t=e:t=await v.create(e),this.push(t)}remove(e){let t=this.indexOf(e);return t>=0?(this.splice(t,1),!0):!1}clear(){this.length=0}},p=class a{_terrainAreas=new P;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e,t,r){this._terrainProvider=e,this._fallbackProvider=t,this._tilingScheme=e.tilingScheme||new q,this._terrainAreas=new P(...r),this._availability=e.availability,this._ready=!0}static async create(e){try{let t;typeof e.terrainProvider=="string"?t=await k.fromUrl(e.terrainProvider,{requestVertexNormals:!0}):t=e.terrainProvider;let r;e.fallbackProvider?typeof e.fallbackProvider=="string"?r=await k.fromUrl(e.fallbackProvider,{requestVertexNormals:!0}):r=e.fallbackProvider:r=new M;let i=[];for(let o of e.terrainAreas){let n=await v.create(o);i.push(n)}return new a(t,r,i)}catch(t){throw console.error("Failed to initialize HybridTerrainProvider:",t),t}}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){return this._terrainAreas.forEach(i=>{if(i.contains(e,t,r)&&i.getTileDataAvailable(e,t,r))return!0}),this._terrainProvider.getTileDataAvailable(e,t,r)||!0}};(e=>{async function a(t,r,i,o){return e.create({terrainAreas:[{provider:t,bounds:{type:"tileRange",tileRanges:i},levels:o||Object.keys(i).map(n=>parseInt(n)),credit:"custom"}],terrainProvider:r,fallbackProvider:new M})}e.createOverlay=a})(p||={});import{defined as B,Viewer as z}from"cesium";function W(a,e,t){let r={baseLayerPicker:a.baseLayerPicker!==void 0,geocoder:a.geocoder!==void 0,homeButton:a.homeButton!==void 0,sceneModePicker:a.sceneModePicker!==void 0,timeline:a.timeline!==void 0,navigationHelpButton:a.navigationHelpButton!==void 0,animation:a.animation!==void 0,fullscreenButton:a.fullscreenButton!==void 0,shouldAnimate:a.clock.shouldAnimate,terrainProvider:a.terrainProvider,requestRenderMode:a.scene.requestRenderMode,infoBox:a.infoBox!==void 0},i=new z(e,{...r,...t});V(a,i);let o=a.imageryLayers;i.imageryLayers.removeAll();for(let l=0;l<o.length;l++){let c=o.get(l);i.imageryLayers.addImageryProvider(c.imageryProvider,l)}i.clock.startTime=a.clock.startTime.clone(),i.clock.stopTime=a.clock.stopTime.clone(),i.clock.currentTime=a.clock.currentTime.clone(),i.clock.multiplier=a.clock.multiplier,i.clock.clockStep=a.clock.clockStep,i.clock.clockRange=a.clock.clockRange,i.clock.shouldAnimate=a.clock.shouldAnimate,i.scene.globe.enableLighting=a.scene.globe.enableLighting,i.scene.globe.depthTestAgainstTerrain=a.scene.globe.depthTestAgainstTerrain,i.scene.screenSpaceCameraController.enableCollisionDetection=a.scene.screenSpaceCameraController.enableCollisionDetection;let n=a.scene.screenSpaceCameraController.tiltEventTypes;n&&(i.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(n)?[...n]:n);let s=a.scene.screenSpaceCameraController.zoomEventTypes;return s&&(i.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(s)?[...s]:s),i}function V(a,e){if(B(a)&&B(e)){let{camera:t}=a;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}import{Color as m,Entity as $,HeightReference as U,Rectangle as O,TileCoordinatesImageryProvider as X}from"cesium";var w=class a{_viewer;_collection;_hybridTerrain;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",m.RED],["default",m.BLUE],["fallback",m.GRAY],["grid",m.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new C({collection:e.entities,tag:a.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._hybridTerrain=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.removeByTag(this._collection.getTags())}show(e=15){if(!this._hybridTerrain)return;this._collection.removeByTag(a.tag.grid),this._level=e;let t=this._hybridTerrain.tilingScheme;this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new X({tilingScheme:t,color:m.YELLOW})));let r=(n,s,l)=>{if(this._hybridTerrain){for(let c of this._hybridTerrain.terrainAreas)if(c.contains(n,s,l))return c.isCustom?this._colors.get("custom")||m.RED:this._colors.get("default")||m.BLUE;if(this._hybridTerrain.getTileDataAvailable(n,s,l))return this._colors.get("default")||m.BLUE}return this._colors.get("fallback")||m.TRANSPARENT},i=this._getVisibleRectangle();if(!i)return;function o(n){return n&&Number.isFinite(n.west)&&Number.isFinite(n.south)&&Number.isFinite(n.east)&&Number.isFinite(n.north)&&n.west<=n.east&&n.south<=n.north}if(!o(i)){console.warn("Invalid visible rectangle detected, skipping grid display");return}try{let n=t.positionToTileXY(O.northwest(i),e),s=t.positionToTileXY(O.southeast(i),e);if(!n||!s)return;let l=100,c=Math.min(s.x-n.x+1,l),T=Math.min(s.y-n.y+1,l);for(let d=n.x;d<=n.x+c-1;d++)for(let g=n.y;g<=n.y+T-1;g++)try{let u=t.tileXYToRectangle(d,g,e);if(!o(u)){console.warn(`Invalid rectangle for tile (${d}, ${g}, ${e}), skipping`);continue}let y=r(d,g,e),f=a.createRectangle(u,y.withAlpha(.3));f.properties?.addProperty("tileX",d),f.properties?.addProperty("tileY",g),f.properties?.addProperty("tileLevel",e),this._collection.add(f,a.tag.grid)}catch(u){console.warn(`Error creating tile (${d}, ${g}, ${e}): ${u.message}`);continue}console.log("\u{1F680} ~ TerrainVisualizer ~ showGrid ~ collection:",this._collection),this._visible=!0}catch(n){console.error("Error displaying tile grid:",n)}}hide(){this._collection.removeByTag(a.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.bounds;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}};(r=>{r.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(i,o){return new $({rectangle:{coordinates:i,material:o,heightReference:U.CLAMP_TO_GROUND}})}r.createRectangle=e;function t(i,o,n){let s=n?.tag||"terrain_area_visualization",l=n?.color||m.RED,c=n?.maxTilesToShow||100,T=n?.show!==void 0?n.show:!0,d=n?.alpha||.7,g=n?.tileAlpha||.2,u="provider"in i?i.bounds:i,y=new C({collection:o.entities,tag:s}),{rectangle:f}=u;if(y.add(r.createRectangle(f,l.withAlpha(d)),s),T&&u.levels.size>0){let{tilingScheme:D}=u;u.levels.forEach(L=>{let A=0,{tileRanges:N}=u;for(let[G,_]of N.entries())if(G===L)for(let R=_.start.x;R<=_.end.x&&A<c;R++)for(let E=_.start.y;E<=_.end.y&&A<c;E++){let F=D.tileXYToRectangle(R,E,L);y.add(e(F,l.withAlpha(g)),`${s}_tile`),A++}})}return y}r.visualize=t})(w||={});export{C as Collection,p as HybridTerrainProvider,v as TerrainArea,h as TerrainBounds,w as TerrainVisualizer,W as cloneViewer,V as syncCameraState};
1
+ import{a as e,b as i,c as t,d as m}from"./chunk-C52KJ2WP.js";import{a}from"./chunk-STARYORM.js";import{a as r}from"./chunk-KDRPSZ3A.js";import{a as o}from"./chunk-CNYZN4AC.js";import{a as p}from"./chunk-YZ7AUGIO.js";export{o as Collection,m as HybridTerrainProvider,i as TerrainArea,t as TerrainAreas,e as TerrainBounds,r as TerrainVisualizer,a as cloneViewer,p as syncCamera};
@@ -0,0 +1 @@
1
+ "use strict";var v=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var R=(n,e)=>{for(var r in e)v(n,r,{get:e[r],enumerable:!0})},A=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of P(e))!y.call(n,i)&&i!==r&&v(n,i,{get:()=>e[i],enumerable:!(t=p(e,i))||t.enumerable});return n};var w=n=>A(v({},"__esModule",{value:!0}),n);var S={};R(S,{HybridTerrainProvider:()=>g,TerrainArea:()=>o,TerrainAreas:()=>c,TerrainBounds:()=>u});module.exports=w(S);var d=require("cesium");var _=require("cesium");var l=require("cesium"),u=class{_rectangle;_tilingScheme;_tileRanges;_levels;constructor(e,r){if(this._tilingScheme=r||new l.GeographicTilingScheme,this._rectangle=new l.Rectangle,this._tileRanges=new Map,this._levels=new Set,e.type==="rectangle"&&e.rectangle)this._rectangle=l.Rectangle.clone(e.rectangle);else if(e.type==="tileRange"&&e.tileRanges)e.tileRanges instanceof Map?this._tileRanges=new Map(e.tileRanges):this._tileRanges=new Map(Object.entries(e.tileRanges).map(([t,i])=>[parseInt(t),i])),this._calculateRectangleFromTileRanges();else throw new Error("Either rectangle or tileRanges must be provided.");this._levels=new Set(Array.from(this._tileRanges.keys()))}contains(e,r,t){if(this._tileRanges.has(t)){let a=this._tileRanges.get(t);return e>=a.start.x&&e<=a.end.x&&r>=a.start.y&&r<=a.end.y}let i=this._tilingScheme.tileXYToRectangle(e,r,t);return l.Rectangle.intersection(i,this._rectangle)!==void 0}configureAvailability(e){if(e.availability){e.availability._tilingScheme&&(e.availability._tilingScheme=this._tilingScheme);for(let[r,t]of this._tileRanges.entries())e.availability.addAvailableTileRange(r,t.start.x,t.start.y,t.end.x,t.end.y)}}get rectangle(){return this._rectangle}get tilingScheme(){return this._tilingScheme}get tileRanges(){return this._tileRanges}get levels(){return this._levels}_calculateRectangleFromTileRanges(){let e=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY,a=Array.from(this._tileRanges.keys());if(a.length===0){this._rectangle=l.Rectangle.MAX_VALUE;return}let s=Math.min(...a),m=this._tileRanges.get(s);if(m){let{start:h,end:b}=m,T=this._tilingScheme.tileXYToRectangle(h.x,h.y,s),f=this._tilingScheme.tileXYToRectangle(b.x,b.y,s);e=Math.min(T.west,e),r=Math.min(f.south,r),t=Math.max(f.east,t),i=Math.max(T.north,i)}this._rectangle=new l.Rectangle(e,r,t,i)}};(r=>{function n(t,i,a,s=new l.GeographicTilingScheme){let m=new Map;return m.set(a,{start:{x:t,y:i},end:{x:t,y:i}}),new r({type:"tileRange",tileRanges:m},s)}r.fromTile=n;function e(t,i=new l.GeographicTilingScheme){return new r({type:"rectangle",rectangle:l.Rectangle.clone(t)},i)}r.fromRectangle=e})(u||={});var o=class n{_provider;_bounds;_levels;_ready=!1;_credit;_isCustom;constructor(e,r){this._bounds=e.bounds instanceof u?e.bounds:new u(e.bounds),this._levels=new Set(e.levels||[]),this._credit=e.credit||"custom",this._isCustom=e.isCustom!==void 0?e.isCustom:!0,this._provider=r,this._ready=!0,this._bounds.configureAvailability(this._provider)}static async create(e){let r;return typeof e.provider=="string"?r=await _.CesiumTerrainProvider.fromUrl(e.provider,{requestVertexNormals:!0,credit:e.credit||"custom"}):r=e.provider,new n(e,r)}contains(e,r,t){return this._levels.size>0&&!this._levels.has(t)?!1:this._bounds.contains(e,r,t)}requestTileGeometry(e,r,t,i){if(!(!this._ready||!this.contains(e,r,t)||!this._provider?.getTileDataAvailable(e,r,t)))return this._provider.requestTileGeometry(e,r,t,i)}getTileDataAvailable(e,r,t){return!this.contains(e,r,t)||!this._ready?!1:this._provider?.getTileDataAvailable(e,r,t)??!1}get isCustom(){return this._isCustom}get credit(){return this._credit}get provider(){return this._provider}get bounds(){return this._bounds}get levels(){return this._levels}get ready(){return this._ready}};(e=>{async function n(r,t,i,a="custom"){let s=new u({type:"tileRange",tileRanges:t});return await e.create({provider:r,bounds:s,levels:i||Object.keys(t).map(h=>parseInt(h)),credit:a})}e.fromUrl=n})(o||={});var c=class extends Array{async add(e){let r;return e instanceof o?r=e:r=await o.create(e),this.push(r)}remove(e){let r=this.indexOf(e);return r>=0?(this.splice(r,1),!0):!1}clear(){this.length=0}};var g=class n{_terrainAreas=new c;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e,r,t){this._terrainProvider=e,this._fallbackProvider=r,this._tilingScheme=e.tilingScheme||new d.GeographicTilingScheme,this._terrainAreas=new c(...t),this._availability=e.availability,this._ready=!0}static async create(e){try{let r;typeof e.terrainProvider=="string"?r=await d.CesiumTerrainProvider.fromUrl(e.terrainProvider,{requestVertexNormals:!0}):r=e.terrainProvider;let t;e.fallbackProvider?typeof e.fallbackProvider=="string"?t=await d.CesiumTerrainProvider.fromUrl(e.fallbackProvider,{requestVertexNormals:!0}):t=e.fallbackProvider:t=new d.EllipsoidTerrainProvider;let i=[];for(let a of e.terrainAreas){let s=await o.create(a);i.push(s)}return new n(r,t,i)}catch(r){throw console.error("Failed to initialize HybridTerrainProvider:",r),r}}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,r,t){return this._terrainProvider.loadTileDataAvailability(e,r,t)}getLevelMaximumGeometricError(e){return this._terrainProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,r,t,i){if(this._ready){for(let a of this._terrainAreas)if(a.contains(e,r,t))return a.requestTileGeometry(e,r,t,i);return this._terrainProvider.getTileDataAvailable(e,r,t)?this._terrainProvider.requestTileGeometry(e,r,t,i):this._fallbackProvider.requestTileGeometry(e,r,t,i)}}getTileDataAvailable(e,r,t){return this._terrainAreas.forEach(i=>{if(i.contains(e,r,t)&&i.getTileDataAvailable(e,r,t))return!0}),this._terrainProvider.getTileDataAvailable(e,r,t)||!0}};(e=>{async function n(r,t,i,a){return e.create({terrainAreas:[{provider:r,bounds:{type:"tileRange",tileRanges:i},levels:a||Object.keys(i).map(s=>parseInt(s)),credit:"custom"}],terrainProvider:t,fallbackProvider:new d.EllipsoidTerrainProvider})}e.createOverlay=n})(g||={});
@@ -0,0 +1,22 @@
1
+ import { T as TerrainArea } from '../hybrid-terrain-provider-C6aXdtyo.cjs';
2
+ export { H as HybridTerrainProvider, a as TerrainBounds, b as TileRange, c as TileRanges } from '../hybrid-terrain-provider-C6aXdtyo.cjs';
3
+ import 'cesium';
4
+
5
+ declare class TerrainAreas extends Array<TerrainArea> {
6
+ /**
7
+ * Adds a new terrain area to the collection.
8
+ * @param area A TerrainArea instance or constructor options
9
+ * @returns A promise that resolves to the index of the added item
10
+ */
11
+ add(area: TerrainArea | TerrainArea.ConstructorOptions): Promise<number>;
12
+ /**
13
+ * Removes a terrain area from the collection.
14
+ */
15
+ remove(area: TerrainArea): boolean;
16
+ /**
17
+ * Clears all terrain areas.
18
+ */
19
+ clear(): void;
20
+ }
21
+
22
+ export { TerrainArea, TerrainAreas };
@@ -0,0 +1,22 @@
1
+ import { T as TerrainArea } from '../hybrid-terrain-provider-C6aXdtyo.js';
2
+ export { H as HybridTerrainProvider, a as TerrainBounds, b as TileRange, c as TileRanges } from '../hybrid-terrain-provider-C6aXdtyo.js';
3
+ import 'cesium';
4
+
5
+ declare class TerrainAreas extends Array<TerrainArea> {
6
+ /**
7
+ * Adds a new terrain area to the collection.
8
+ * @param area A TerrainArea instance or constructor options
9
+ * @returns A promise that resolves to the index of the added item
10
+ */
11
+ add(area: TerrainArea | TerrainArea.ConstructorOptions): Promise<number>;
12
+ /**
13
+ * Removes a terrain area from the collection.
14
+ */
15
+ remove(area: TerrainArea): boolean;
16
+ /**
17
+ * Clears all terrain areas.
18
+ */
19
+ clear(): void;
20
+ }
21
+
22
+ export { TerrainArea, TerrainAreas };
@@ -0,0 +1 @@
1
+ import{a as r,b as o,c as e,d as i}from"../chunk-C52KJ2WP.js";export{i as HybridTerrainProvider,o as TerrainArea,e as TerrainAreas,r as TerrainBounds};
@@ -0,0 +1 @@
1
+ "use strict";var w=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var z=(a,e)=>{for(var t in e)w(a,t,{get:e[t],enumerable:!0})},W=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of S(e))!O.call(a,r)&&r!==t&&w(a,r,{get:()=>e[r],enumerable:!(i=V(e,r))||i.enumerable});return a};var $=a=>W(w({},"__esModule",{value:!0}),a);var H={};z(H,{TerrainVisualizer:()=>f,syncCamera:()=>R});module.exports=$(H);var n=require("cesium");var v=require("cesium"),E=class a{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}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(s=>s(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[a.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,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})),e}contains(e){return this.collection.contains(e)}remove(e){let t=this.collection.remove(e);return t&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),t}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this._valuesCache)return this._valuesCache;if(this.collection instanceof v.EntityCollection)this._valuesCache=this.collection.values||[];else{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));this._valuesCache=e}return this._valuesCache}get length(){return this.values?.length||0}getByTag(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}getFirstByTag(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}getTags(){return Array.from(this._tagMap.keys())}hasTag(e){let t=this._tagMap.get(e);return!!t&&t.size>0}updateTag(e,t){let i=this.getByTag(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,a.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}removeByTag(e){let t=0;return Array.isArray(e)?e.forEach(i=>{this.removeByTag(i)}):this.getByTag(e).forEach(i=>{this.remove(i)&&t++}),t}show(e){let t=this.getByTag(e),i=0;for(let r of t)(0,v.defined)(r.show)&&(r.show=!0,i++);return i}hide(e){let t=this.getByTag(e),i=0;for(let r of t)(0,v.defined)(r.show)&&(r.show=!1,i++);return i}toggle(e){let t=this.getByTag(e),i=0;for(let r of t)(0,v.defined)(r.show)&&(r.show=!r.show,i++);return i}setProperty(e,t,i){let r=this.getByTag(e),s=0;for(let o of r)t in o?(o[t]=i,s++):console.warn(`${t} does not exists in ${o}`);return s}filter(e,t){return(t?this.getByTag(t):this.values).filter(e)}forEach(e,t){(t?this.getByTag(t):this.values).forEach((r,s)=>e(r,s))}},I=E;var f=class a{_viewer;_collection;_hybridTerrain;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",n.Color.RED],["default",n.Color.BLUE],["fallback",n.Color.GRAY],["grid",n.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new I({collection:e.entities,tag:a.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._hybridTerrain=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.removeByTag(this._collection.getTags())}show(e=15){if(!this._hybridTerrain)return;this._collection.removeByTag(a.tag.grid),this._level=e;let t=this._hybridTerrain.tilingScheme;this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new n.TileCoordinatesImageryProvider({tilingScheme:t,color:n.Color.YELLOW})));let i=(o,l,g)=>{if(this._hybridTerrain){for(let u of this._hybridTerrain.terrainAreas)if(u.contains(o,l,g))return u.isCustom?this._colors.get("custom")||n.Color.RED:this._colors.get("default")||n.Color.BLUE;if(this._hybridTerrain.getTileDataAvailable(o,l,g))return this._colors.get("default")||n.Color.BLUE}return this._colors.get("fallback")||n.Color.TRANSPARENT},r=this._getVisibleRectangle();if(!r)return;function s(o){return o&&Number.isFinite(o.west)&&Number.isFinite(o.south)&&Number.isFinite(o.east)&&Number.isFinite(o.north)&&o.west<=o.east&&o.south<=o.north}if(!s(r)){console.warn("Invalid visible rectangle detected, skipping grid display");return}try{let o=t.positionToTileXY(n.Rectangle.northwest(r),e),l=t.positionToTileXY(n.Rectangle.southeast(r),e);if(!o||!l)return;let g=100,u=Math.min(l.x-o.x+1,g),p=Math.min(l.y-o.y+1,g);for(let h=o.x;h<=o.x+u-1;h++)for(let d=o.y;d<=o.y+p-1;d++)try{let c=t.tileXYToRectangle(h,d,e);if(!s(c)){console.warn(`Invalid rectangle for tile (${h}, ${d}, ${e}), skipping`);continue}let T=i(h,d,e),m=a.createRectangle(c,T.withAlpha(.3));m.properties?.addProperty("tileX",h),m.properties?.addProperty("tileY",d),m.properties?.addProperty("tileLevel",e),this._collection.add(m,a.tag.grid)}catch(c){console.warn(`Error creating tile (${h}, ${d}, ${e}): ${c.message}`);continue}console.log("\u{1F680} ~ TerrainVisualizer ~ showGrid ~ collection:",this._collection),this._visible=!0}catch(o){console.error("Error displaying tile grid:",o)}}hide(){this._collection.removeByTag(a.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.bounds;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}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,s){return new n.Entity({rectangle:{coordinates:r,material:s,heightReference:n.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,s,o){let l=o?.tag||"terrain_area_visualization",g=o?.color||n.Color.RED,u=o?.maxTilesToShow||100,p=o?.show??!0,h=o?.alpha||.7,d=o?.tileAlpha||.2,c="provider"in r?r.bounds:r,T=new I({collection:s.entities,tag:l}),{rectangle:m}=c;if(T.add(i.createRectangle(m,g.withAlpha(h)),l),p&&c.levels.size>0){let{tilingScheme:A}=c;c.levels.forEach(x=>{let b=0,{tileRanges:M}=c;for(let[B,y]of M.entries())if(B===x)for(let _=y.start.x;_<=y.end.x&&b<u;_++)for(let C=y.start.y;C<=y.end.y&&b<u;C++){let P=A.tileXYToRectangle(_,C,x);T.add(e(P,g.withAlpha(d)),`${l}_tile`),b++}})}return T}i.visualize=t})(f||={});var L=require("cesium");function R(a,e){if((0,L.defined)(a)&&(0,L.defined)(e)){let{camera:t}=a;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}
@@ -0,0 +1,133 @@
1
+ import { Viewer, Color, EntityCollection, Entity, Rectangle } from 'cesium';
2
+ import { H as HybridTerrainProvider, T as TerrainArea, a as TerrainBounds } from '../hybrid-terrain-provider-C6aXdtyo.cjs';
3
+ import { Collection } from '../collection/index.cjs';
4
+
5
+ /**
6
+ * @class
7
+ * Utility class for visualizing terrain provider boundaries and debugging terrain loading.
8
+ */
9
+ declare class TerrainVisualizer {
10
+ private _viewer;
11
+ private _collection;
12
+ private _hybridTerrain?;
13
+ private _visible;
14
+ private _level;
15
+ private _tileCoordinatesLayer;
16
+ private _colors;
17
+ /**
18
+ * Creates a new `TerrainVisualizer`.
19
+ * @param viewer The Cesium viewer instance
20
+ * @param options {@link TerrainVisualizer.ConstructorOptions}
21
+ */
22
+ constructor(viewer: Viewer, options?: TerrainVisualizer.ConstructorOptions);
23
+ /**
24
+ * Sets the terrain provider to visualize.
25
+ * @param terrainProvider The terrain provider to visualize.
26
+ */
27
+ setTerrainProvider(terrainProvider: HybridTerrainProvider): void;
28
+ /**
29
+ * Updates all active visualizations.
30
+ */
31
+ update(): void;
32
+ /**
33
+ * Clears all visualizations.
34
+ */
35
+ clear(): void;
36
+ /**
37
+ * Shows a grid of tiles at the specified level.
38
+ * @param level The zoom level to visualize
39
+ */
40
+ show(level?: number): void;
41
+ /**
42
+ * Hides the tile grid.
43
+ */
44
+ hide(): void;
45
+ /**
46
+ * Sets the colors used for visualization.
47
+ * @param colors Map of role names to colors
48
+ */
49
+ setColors(colors: Record<string, Color>): void;
50
+ /**
51
+ * Flies the camera to focus on a terrain area.
52
+ * @param area The terrain area to focus on.
53
+ * @param options {@link Viewer.flyTo}
54
+ */
55
+ flyTo(area: TerrainArea, options?: {
56
+ duration?: number;
57
+ }): void;
58
+ /**
59
+ * Gets the rectangle representing the current view.
60
+ * @returns The current view rectangle or undefined.
61
+ * @private
62
+ */
63
+ private _getVisibleRectangle;
64
+ /** The current zoom level set on the visualizer. */
65
+ get level(): number;
66
+ /** Set zoom level on the visualizer. */
67
+ set level(level: number);
68
+ /** Whether the grid is currently visible. */
69
+ get visible(): boolean;
70
+ /** The collection used in the visualizer. */
71
+ get collection(): Collection<EntityCollection, Entity>;
72
+ /** The viewer used in the visualizer */
73
+ get viewer(): Viewer;
74
+ }
75
+ /**
76
+ * @namespace
77
+ * Contains types, utility functions, and constants for terrain visualization.
78
+ */
79
+ declare namespace TerrainVisualizer {
80
+ /** Initialization options for `TerrainVisualizer` constructor. */
81
+ interface ConstructorOptions {
82
+ /** Colors to use for different visualization elements */
83
+ colors?: Record<string, Color>;
84
+ /** Whether to show boundaries initially. */
85
+ boundaries?: boolean;
86
+ /** Whether to show tile grid initially. */
87
+ tile?: boolean;
88
+ /** Initial zoom level to use for visualizations. */
89
+ activeLevel?: number;
90
+ /** Terrain provider to visualize. */
91
+ terrainProvider?: HybridTerrainProvider;
92
+ }
93
+ /** Tag constants for entity collection management. */
94
+ const tag: {
95
+ default: string;
96
+ boundary: string;
97
+ grid: string;
98
+ };
99
+ /**
100
+ * Creates a ground-clamped rectangle entity for visualization.
101
+ * @param rectangle The rectangle to visualize
102
+ * @param color The color to use
103
+ * @returns A new entity
104
+ */
105
+ function createRectangle(rectangle: Rectangle, color: Color): Entity;
106
+ /** Options for {@link TerrainVisualizer.visualize} */
107
+ interface Options {
108
+ color?: Color;
109
+ show?: boolean;
110
+ maxTilesToShow?: number;
111
+ levels?: number[];
112
+ tag?: string;
113
+ alpha?: number;
114
+ tileAlpha?: number;
115
+ }
116
+ /**
117
+ * Visualizes a specific terrain area in a viewer.
118
+ * @param terrain The terrain area to visualize.
119
+ * @param viewer The Cesium viewer.
120
+ * @param options Visualization options.
121
+ * @returns Collection of created entities.
122
+ */
123
+ function visualize(terrain: TerrainArea | TerrainBounds, viewer: Viewer, options?: Options): Collection<EntityCollection, Entity>;
124
+ }
125
+
126
+ /**
127
+ * Copies camera state from source viewer to destination viewer.
128
+ * @param source The source viewer to copy camera states from.
129
+ * @param dest The destination viewer to apply camera properties from the source.
130
+ */
131
+ declare function syncCamera(source: Viewer, dest: Viewer): void;
132
+
133
+ export { TerrainVisualizer, syncCamera };
@@ -0,0 +1,133 @@
1
+ import { Viewer, Color, EntityCollection, Entity, Rectangle } from 'cesium';
2
+ import { H as HybridTerrainProvider, T as TerrainArea, a as TerrainBounds } from '../hybrid-terrain-provider-C6aXdtyo.js';
3
+ import { Collection } from '../collection/index.js';
4
+
5
+ /**
6
+ * @class
7
+ * Utility class for visualizing terrain provider boundaries and debugging terrain loading.
8
+ */
9
+ declare class TerrainVisualizer {
10
+ private _viewer;
11
+ private _collection;
12
+ private _hybridTerrain?;
13
+ private _visible;
14
+ private _level;
15
+ private _tileCoordinatesLayer;
16
+ private _colors;
17
+ /**
18
+ * Creates a new `TerrainVisualizer`.
19
+ * @param viewer The Cesium viewer instance
20
+ * @param options {@link TerrainVisualizer.ConstructorOptions}
21
+ */
22
+ constructor(viewer: Viewer, options?: TerrainVisualizer.ConstructorOptions);
23
+ /**
24
+ * Sets the terrain provider to visualize.
25
+ * @param terrainProvider The terrain provider to visualize.
26
+ */
27
+ setTerrainProvider(terrainProvider: HybridTerrainProvider): void;
28
+ /**
29
+ * Updates all active visualizations.
30
+ */
31
+ update(): void;
32
+ /**
33
+ * Clears all visualizations.
34
+ */
35
+ clear(): void;
36
+ /**
37
+ * Shows a grid of tiles at the specified level.
38
+ * @param level The zoom level to visualize
39
+ */
40
+ show(level?: number): void;
41
+ /**
42
+ * Hides the tile grid.
43
+ */
44
+ hide(): void;
45
+ /**
46
+ * Sets the colors used for visualization.
47
+ * @param colors Map of role names to colors
48
+ */
49
+ setColors(colors: Record<string, Color>): void;
50
+ /**
51
+ * Flies the camera to focus on a terrain area.
52
+ * @param area The terrain area to focus on.
53
+ * @param options {@link Viewer.flyTo}
54
+ */
55
+ flyTo(area: TerrainArea, options?: {
56
+ duration?: number;
57
+ }): void;
58
+ /**
59
+ * Gets the rectangle representing the current view.
60
+ * @returns The current view rectangle or undefined.
61
+ * @private
62
+ */
63
+ private _getVisibleRectangle;
64
+ /** The current zoom level set on the visualizer. */
65
+ get level(): number;
66
+ /** Set zoom level on the visualizer. */
67
+ set level(level: number);
68
+ /** Whether the grid is currently visible. */
69
+ get visible(): boolean;
70
+ /** The collection used in the visualizer. */
71
+ get collection(): Collection<EntityCollection, Entity>;
72
+ /** The viewer used in the visualizer */
73
+ get viewer(): Viewer;
74
+ }
75
+ /**
76
+ * @namespace
77
+ * Contains types, utility functions, and constants for terrain visualization.
78
+ */
79
+ declare namespace TerrainVisualizer {
80
+ /** Initialization options for `TerrainVisualizer` constructor. */
81
+ interface ConstructorOptions {
82
+ /** Colors to use for different visualization elements */
83
+ colors?: Record<string, Color>;
84
+ /** Whether to show boundaries initially. */
85
+ boundaries?: boolean;
86
+ /** Whether to show tile grid initially. */
87
+ tile?: boolean;
88
+ /** Initial zoom level to use for visualizations. */
89
+ activeLevel?: number;
90
+ /** Terrain provider to visualize. */
91
+ terrainProvider?: HybridTerrainProvider;
92
+ }
93
+ /** Tag constants for entity collection management. */
94
+ const tag: {
95
+ default: string;
96
+ boundary: string;
97
+ grid: string;
98
+ };
99
+ /**
100
+ * Creates a ground-clamped rectangle entity for visualization.
101
+ * @param rectangle The rectangle to visualize
102
+ * @param color The color to use
103
+ * @returns A new entity
104
+ */
105
+ function createRectangle(rectangle: Rectangle, color: Color): Entity;
106
+ /** Options for {@link TerrainVisualizer.visualize} */
107
+ interface Options {
108
+ color?: Color;
109
+ show?: boolean;
110
+ maxTilesToShow?: number;
111
+ levels?: number[];
112
+ tag?: string;
113
+ alpha?: number;
114
+ tileAlpha?: number;
115
+ }
116
+ /**
117
+ * Visualizes a specific terrain area in a viewer.
118
+ * @param terrain The terrain area to visualize.
119
+ * @param viewer The Cesium viewer.
120
+ * @param options Visualization options.
121
+ * @returns Collection of created entities.
122
+ */
123
+ function visualize(terrain: TerrainArea | TerrainBounds, viewer: Viewer, options?: Options): Collection<EntityCollection, Entity>;
124
+ }
125
+
126
+ /**
127
+ * Copies camera state from source viewer to destination viewer.
128
+ * @param source The source viewer to copy camera states from.
129
+ * @param dest The destination viewer to apply camera properties from the source.
130
+ */
131
+ declare function syncCamera(source: Viewer, dest: Viewer): void;
132
+
133
+ export { TerrainVisualizer, syncCamera };
@@ -0,0 +1 @@
1
+ import{a as r}from"../chunk-KDRPSZ3A.js";import"../chunk-CNYZN4AC.js";import{a as o}from"../chunk-YZ7AUGIO.js";export{r as TerrainVisualizer,o as syncCamera};
@@ -0,0 +1 @@
1
+ "use strict";var l=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var T=(e,i)=>{for(var o in i)l(e,o,{get:i[o],enumerable:!0})},v=(e,i,o,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of k(i))!C.call(e,n)&&n!==o&&l(e,n,{get:()=>i[n],enumerable:!(t=g(i,n))||t.enumerable});return e};var b=e=>v(l({},"__esModule",{value:!0}),e);var h={};T(h,{cloneViewer:()=>y});module.exports=b(h);var p=require("cesium");var m=require("cesium");function d(e,i){if((0,m.defined)(e)&&(0,m.defined)(i)){let{camera:o}=e;i.camera.position=o.positionWC.clone(),i.camera.direction=o.directionWC.clone(),i.camera.up=o.upWC.clone()}}function y(e,i,o){let t={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.Viewer(i,{...t,...o});d(e,n);let s=e.imageryLayers;n.imageryLayers.removeAll();for(let c=0;c<s.length;c++){let f=s.get(c);n.imageryLayers.addImageryProvider(f.imageryProvider,c)}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 r=e.scene.screenSpaceCameraController.tiltEventTypes;r&&(n.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(r)?[...r]:r);let a=e.scene.screenSpaceCameraController.zoomEventTypes;return a&&(n.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(a)?[...a]:a),n}
@@ -0,0 +1,12 @@
1
+ import { Viewer } from 'cesium';
2
+
3
+ /**
4
+ * Copies configuration and state from one Cesium Viewer to another.
5
+ * @param source - The source viewer to copy properties from
6
+ * @param container - DOM element ID or element for the new viewer
7
+ * @param options - Optional override options for the new viewer
8
+ * @returns A new Viewer instance with copied properties
9
+ */
10
+ declare function cloneViewer(source: Viewer, container: Element | string, options?: Viewer.ConstructorOptions): Viewer;
11
+
12
+ export { cloneViewer };
@@ -0,0 +1,12 @@
1
+ import { Viewer } from 'cesium';
2
+
3
+ /**
4
+ * Copies configuration and state from one Cesium Viewer to another.
5
+ * @param source - The source viewer to copy properties from
6
+ * @param container - DOM element ID or element for the new viewer
7
+ * @param options - Optional override options for the new viewer
8
+ * @returns A new Viewer instance with copied properties
9
+ */
10
+ declare function cloneViewer(source: Viewer, container: Element | string, options?: Viewer.ConstructorOptions): Viewer;
11
+
12
+ export { cloneViewer };
@@ -0,0 +1 @@
1
+ import{a as e}from"../chunk-STARYORM.js";import"../chunk-YZ7AUGIO.js";export{e as cloneViewer};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juun-roh/cesium-utils",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Utilities to handle Cesium classes easier.",
5
5
  "keywords": [
6
6
  "Cesium",
@@ -35,6 +35,21 @@
35
35
  "import": "./dist/index.js",
36
36
  "require": "./dist/index.cjs",
37
37
  "default": "./dist/index.js"
38
+ },
39
+ "./collection": {
40
+ "types": "./dist/collection/index.d.ts",
41
+ "import": "./dist/collection/index.js",
42
+ "require": "./dist/collection/index.cjs"
43
+ },
44
+ "./terrain": {
45
+ "types": "./dist/terrain/index.d.ts",
46
+ "import": "./dist/terrain/index.js",
47
+ "require": "./dist/terrain/index.cjs"
48
+ },
49
+ "./utils": {
50
+ "types": "./dist/utils/index.d.ts",
51
+ "import": "./dist/utils/index.js",
52
+ "require": "./dist/utils/index.cjs"
38
53
  }
39
54
  },
40
55
  "engines": {
@@ -52,15 +67,16 @@
52
67
  }
53
68
  },
54
69
  "devDependencies": {
55
- "@changesets/cli": "^2.28.1",
70
+ "@changesets/cli": "^2.29.0",
56
71
  "@commitlint/cli": "^19.8.0",
57
72
  "@commitlint/config-conventional": "^19.8.0",
58
73
  "@commitlint/cz-commitlint": "^19.8.0",
59
74
  "@commitlint/format": "^19.8.0",
60
75
  "@commitlint/types": "^19.8.0",
61
76
  "@eslint/js": "^9.24.0",
62
- "@typescript-eslint/eslint-plugin": "^8.29.1",
63
- "@typescript-eslint/parser": "^8.29.1",
77
+ "@typescript-eslint/eslint-plugin": "^8.30.1",
78
+ "@typescript-eslint/parser": "^8.30.1",
79
+ "@vitest/coverage-v8": "3.1.1",
64
80
  "cesium": "^1.128.0",
65
81
  "eslint": "^9.24.0",
66
82
  "eslint-plugin-jsdoc": "^50.6.9",
@@ -73,7 +89,8 @@
73
89
  "typedoc": "^0.28.2",
74
90
  "typedoc-material-theme": "^1.4.0",
75
91
  "typescript": "^5.8.3",
76
- "vite": "^6.2.6"
92
+ "vite": "^6.2.6",
93
+ "vitest": "^3.1.1"
77
94
  },
78
95
  "scripts": {
79
96
  "build": "tsup",
@@ -82,7 +99,8 @@
82
99
  "lint": "eslint .",
83
100
  "ci:publish": "pnpm build && pnpm publish --no-git-checks",
84
101
  "prebuild": "pnpm clean",
85
- "test": "node tests/cjs-require.cjs && node tests/esm-import.mjs",
102
+ "test": "vitest run",
103
+ "test:watch": "vitest watch --coverage",
86
104
  "dev": "pnpm build && vite"
87
105
  }
88
106
  }