@juun-roh/cesium-utils 0.0.7 → 0.0.9
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/chunk-NBGR2C26.js +1 -0
- package/dist/{chunk-MIDZHLUZ.js → chunk-RJNF3DQR.js} +1 -1
- package/dist/collection/index.cjs +1 -1
- package/dist/collection/index.js +1 -1
- package/dist/{hybrid-terrain-provider-C6aXdtyo.d.cts → hybrid-terrain-provider-BGwAgH9H.d.cts} +51 -139
- package/dist/{hybrid-terrain-provider-C6aXdtyo.d.ts → hybrid-terrain-provider-BGwAgH9H.d.ts} +51 -139
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/terrain/index.cjs +1 -1
- package/dist/terrain/index.d.cts +33 -9
- package/dist/terrain/index.d.ts +33 -9
- package/dist/terrain/index.js +1 -1
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +1 -1
- package/package.json +11 -12
- package/dist/chunk-C52KJ2WP.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Rectangle as f}from"cesium";function b(o,r){if(r.size===0)return new f;let e=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY,l=Array.from(r.keys()),d=Math.min(...l),c=r.get(d);if(c){let{start:v,end:h}=c,T=o.tileXYToRectangle(v.x,v.y,d),g=o.tileXYToRectangle(h.x,h.y,d);e=Math.min(T.west,e),i=Math.min(g.south,i),t=Math.max(g.east,t),a=Math.max(T.north,a)}return new f(e,i,t,a)}import{CesiumTerrainProvider as _}from"cesium";var n=class{_terrainProvider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(r){this._terrainProvider=r.terrainProvider,this._tileRanges=r.tileRanges,this._credit=r.credit||"custom",this._isCustom=r.isCustom!==void 0?r.isCustom:!0,this._rectangle=b(r.terrainProvider.tilingScheme,r.tileRanges),r.tileRanges.forEach((e,i)=>{this._terrainProvider.availability?.addAvailableTileRange(i,e.start.x,e.start.y,e.end.x,e.end.y)}),this._ready=!0}contains(r,e,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let t=this._tileRanges.get(i);return r>=t.start.x&&r<=t.end.x&&e>=t.start.y&&e<=t.end.y}requestTileGeometry(r,e,i,t){if(!(!this._ready||!this.contains(r,e,i)))return this._terrainProvider.requestTileGeometry(r,e,i,t)}getTileDataAvailable(r,e,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let t=this._tileRanges.get(i);return r>=t.start.x&&r<=t.end.x&&e>=t.start.y&&e<=t.end.y}get isCustom(){return this._isCustom}get credit(){return this._credit}get terrainProvider(){return this._terrainProvider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(r=>{async function o(e,i,t){let a=t?.credit||"custom",l=await _.fromUrl(e,{...t,credit:a});return new r({terrainProvider:l,tileRanges:i,credit:a})}r.fromUrl=o})(n||={});var s=class extends Array{add(r){if(Array.isArray(r)){for(let i of r)this.add(i);return this.length}let e;return r instanceof n?e=r:e=new n(r),this.push(e)}remove(r){if(Array.isArray(r))return r.forEach(i=>this.remove(i)),this;let e=this.indexOf(r);return e>=0&&this.splice(e,1),this}removeAll(){this.length=0}};import{CesiumTerrainProvider as u,EllipsoidTerrainProvider as P}from"cesium";var m=class o{_terrainAreas=new s;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(r,e,i){this._terrainProvider=r,this._fallbackProvider=e,this._tilingScheme=r.tilingScheme,this._terrainAreas=new s(...i),this._availability=r.availability,this._ready=!0}static async create(r){try{let e;typeof r.terrainProvider=="string"?e=await u.fromUrl(r.terrainProvider,{requestVertexNormals:!0}):e=r.terrainProvider;let i;r.fallbackProvider?typeof r.fallbackProvider=="string"?i=await u.fromUrl(r.fallbackProvider,{requestVertexNormals:!0}):i=r.fallbackProvider:i=new P;let t=[];for(let a of r.terrainAreas){let l=typeof a.terrainProvider=="string"?await u.fromUrl(a.terrainProvider,{requestVertexNormals:!0}):a.terrainProvider;t.push(new n({terrainProvider:l,tileRanges:a.tileRanges,credit:a.credit,isCustom:a.isCustom}))}return new o(e,i,t)}catch(e){throw console.error("Failed to initialize HybridTerrainProvider:",e),e}}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(r,e,i){return this._terrainProvider.loadTileDataAvailability(r,e,i)}getLevelMaximumGeometricError(r){return this._terrainProvider.getLevelMaximumGeometricError(r)}requestTileGeometry(r,e,i,t){if(this._ready){for(let a of this._terrainAreas)if(a.contains(r,e,i))return a.requestTileGeometry(r,e,i,t);return this._terrainProvider.getTileDataAvailable(r,e,i)?this._terrainProvider.requestTileGeometry(r,e,i,t):this._fallbackProvider.requestTileGeometry(r,e,i,t)}}getTileDataAvailable(r,e,i){for(let t of this._terrainAreas)if(t.contains(r,e,i))return t.getTileDataAvailable(r,e,i);return this._terrainProvider.getTileDataAvailable(r,e,i)}};(r=>{async function o(e,i,t){let a=await u.fromUrl(e,{credit:"custom"});return r.create({terrainAreas:[{terrainProvider:a,tileRanges:t,credit:"custom"}],terrainProvider:i,fallbackProvider:new P})}r.createOverlay=o})(m||={});export{b as a,n as b,s as c,m as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Color as
|
|
1
|
+
import{Color as l,Entity as P,HeightReference as M,Rectangle as x,TileCoordinatesImageryProvider as O}from"cesium";import{defined as w,EntityCollection as A}from"cesium";var C=class s{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(n=>n(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[s.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,s.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let r=this.collection.remove(e);return r&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),r}if(Array.isArray(e)){if(e.length===0)return!1;let r=!1;for(let n of e)this.remove(n)&&(r=!0);return r}let t=this.get(e);if(t.length===0)return!1;let i=!1;for(let r of t)this.remove(r)&&(i=!0);return i}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof A)return this.collection.values;{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));return e}}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,s.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)w(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)w(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)w(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let n of r)if(e in n&&typeof n[e]!="function"){if(I(n,e))throw Error(`setProperty(${n}, ${e}) failed; The property is readonly.`);n[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,n)=>e(r,n))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},E=C;var f=class s{_viewer;_collection;_hybridTerrain;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",l.RED],["default",l.BLUE],["fallback",l.GRAY],["grid",l.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new E({collection:e.entities,tag:s.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.remove(this._collection.tags)}show(e=15){if(!this._hybridTerrain)return;this._collection.remove(s.tag.grid),this._level=e;let t=this._hybridTerrain.tilingScheme;this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new O({tilingScheme:t,color:l.YELLOW})));let i=(o,a,d)=>{if(this._hybridTerrain){for(let m of this._hybridTerrain.terrainAreas)if(m.contains(o,a,d))return m.isCustom?this._colors.get("custom")||l.RED:this._colors.get("default")||l.BLUE;if(this._hybridTerrain.getTileDataAvailable(o,a,d))return this._colors.get("default")||l.BLUE}return this._colors.get("fallback")||l.TRANSPARENT},r=this._getVisibleRectangle();if(!r)return;function n(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(!n(r)){console.warn("Invalid visible rectangle detected, skipping grid display");return}try{let o=t.positionToTileXY(x.northwest(r),e),a=t.positionToTileXY(x.southeast(r),e);if(!o||!a)return;let d=100,m=Math.min(a.x-o.x+1,d),p=Math.min(a.y-o.y+1,d);for(let c=o.x;c<=o.x+m-1;c++)for(let h=o.y;h<=o.y+p-1;h++)try{let u=t.tileXYToRectangle(c,h,e);if(!n(u)){console.warn(`Invalid rectangle for tile (${c}, ${h}, ${e}), skipping`);continue}let y=i(c,h,e),g=s.createRectangle(u,y.withAlpha(.3));g.properties?.addProperty("tileX",c),g.properties?.addProperty("tileY",h),g.properties?.addProperty("tileLevel",e),this._collection.add(g,s.tag.grid)}catch(u){console.warn(`Error creating tile (${c}, ${h}, ${e}): ${u.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.remove(s.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,n){return new P({rectangle:{coordinates:r,material:n,heightReference:M.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,n,o){let a=o?.tag||"terrain_area_visualization",d=o?.color||l.RED,m=o?.maxTilesToShow||100,p=o?.show??!0,c=o?.alpha||.7,h=o?.tileAlpha||.2,u=new E({collection:n.entities,tag:a}),{rectangle:y}=r;if(u.add(i.createRectangle(y,d.withAlpha(c)),a),p&&r.tileRanges.size>0){let{tilingScheme:g}=r.terrainProvider,b=0;r.tileRanges.forEach((v,R)=>{for(let T=v.start.x;T<=v.end.x&&b<m;T++)for(let _=v.start.y;_<=v.end.y&&b<m;_++){let L=g.tileXYToRectangle(T,_,R);u.add(e(L,d.withAlpha(h)),`${a}_tile`),b++}})}return u}i.visualize=t})(f||={});function I(s,e){let t=!1,i=Object.getOwnPropertyDescriptor(s,e);if(!i){let r=Object.getPrototypeOf(s);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}export{f as a,I as b,E as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var I=Object.defineProperty;var
|
|
1
|
+
"use strict";var I=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var O=(n,e)=>{for(var t in e)I(n,t,{get:e[t],enumerable:!0})},V=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of P(e))!M.call(n,r)&&r!==t&&I(n,r,{get:()=>e[r],enumerable:!(i=A(e,r))||i.enumerable});return n};var S=n=>V(I({},"__esModule",{value:!0}),n);var z={};O(z,{Collection:()=>p});module.exports=S(z);var f=require("cesium");var s=require("cesium");var v=class n{_viewer;_collection;_hybridTerrain;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",s.Color.RED],["default",s.Color.BLUE],["fallback",s.Color.GRAY],["grid",s.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new p({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._hybridTerrain=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._hybridTerrain)return;this._collection.remove(n.tag.grid),this._level=e;let t=this._hybridTerrain.tilingScheme;this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new s.TileCoordinatesImageryProvider({tilingScheme:t,color:s.Color.YELLOW})));let i=(o,l,d)=>{if(this._hybridTerrain){for(let m of this._hybridTerrain.terrainAreas)if(m.contains(o,l,d))return m.isCustom?this._colors.get("custom")||s.Color.RED:this._colors.get("default")||s.Color.BLUE;if(this._hybridTerrain.getTileDataAvailable(o,l,d))return this._colors.get("default")||s.Color.BLUE}return this._colors.get("fallback")||s.Color.TRANSPARENT},r=this._getVisibleRectangle();if(!r)return;function a(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(!a(r)){console.warn("Invalid visible rectangle detected, skipping grid display");return}try{let o=t.positionToTileXY(s.Rectangle.northwest(r),e),l=t.positionToTileXY(s.Rectangle.southeast(r),e);if(!o||!l)return;let d=100,m=Math.min(l.x-o.x+1,d),b=Math.min(l.y-o.y+1,d);for(let c=o.x;c<=o.x+m-1;c++)for(let h=o.y;h<=o.y+b-1;h++)try{let u=t.tileXYToRectangle(c,h,e);if(!a(u)){console.warn(`Invalid rectangle for tile (${c}, ${h}, ${e}), skipping`);continue}let T=i(c,h,e),g=n.createRectangle(u,T.withAlpha(.3));g.properties?.addProperty("tileX",c),g.properties?.addProperty("tileY",h),g.properties?.addProperty("tileLevel",e),this._collection.add(g,n.tag.grid)}catch(u){console.warn(`Error creating tile (${c}, ${h}, ${e}): ${u.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.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,a){return new s.Entity({rectangle:{coordinates:r,material:a,heightReference:s.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,a,o){let l=o?.tag||"terrain_area_visualization",d=o?.color||s.Color.RED,m=o?.maxTilesToShow||100,b=o?.show??!0,c=o?.alpha||.7,h=o?.tileAlpha||.2,u=new p({collection:a.entities,tag:l}),{rectangle:T}=r;if(u.add(i.createRectangle(T,d.withAlpha(c)),l),b&&r.tileRanges.size>0){let{tilingScheme:g}=r.terrainProvider,_=0;r.tileRanges.forEach((y,R)=>{for(let C=y.start.x;C<=y.end.x&&_<m;C++)for(let w=y.start.y;w<=y.end.y&&_<m;w++){let L=g.tileXYToRectangle(C,w,R);u.add(e(L,d.withAlpha(h)),`${l}_tile`),_++}})}return u}i.visualize=t})(v||={});function E(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var j=require("cesium");var x=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(a=>a(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache(){this._valuesCache=null}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let r=this.collection.remove(e);return r&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),r}if(Array.isArray(e)){if(e.length===0)return!1;let r=!1;for(let a of e)this.remove(a)&&(r=!0);return r}let t=this.get(e);if(t.length===0)return!1;let i=!1;for(let r of t)this.remove(r)&&(i=!0);return i}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof f.EntityCollection)return this.collection.values;{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));return e}}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,f.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,f.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,f.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let a of r)if(e in a&&typeof a[e]!="function"){if(E(a,e))throw Error(`setProperty(${a}, ${e}) failed; The property is readonly.`);a[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,a)=>e(r,a))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},p=x;
|
package/dist/collection/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as o}from"../chunk-
|
|
1
|
+
import{c as o}from"../chunk-RJNF3DQR.js";import"../chunk-YZ7AUGIO.js";export{o as Collection};
|
package/dist/{hybrid-terrain-provider-C6aXdtyo.d.cts → hybrid-terrain-provider-BGwAgH9H.d.cts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Request, TerrainData, Credit, TerrainProvider, Rectangle, CesiumTerrainProvider, TilingScheme, TileAvailability } from 'cesium';
|
|
2
2
|
|
|
3
3
|
/** A range of tiles from `start` to `end` */
|
|
4
4
|
type TileRange = {
|
|
@@ -13,90 +13,6 @@ type TileRange = {
|
|
|
13
13
|
y: number;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
-
/** A `TileRange` map with specific levels as their keys. */
|
|
17
|
-
type TileRanges = Map<number, TileRange>;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @class
|
|
21
|
-
* Defines the geographic boundaries for a terrain area and handles tile availability checks.
|
|
22
|
-
*/
|
|
23
|
-
declare class TerrainBounds {
|
|
24
|
-
private _rectangle;
|
|
25
|
-
private _tilingScheme;
|
|
26
|
-
private _tileRanges;
|
|
27
|
-
private _levels;
|
|
28
|
-
/**
|
|
29
|
-
* Creates a new instance of TerrainBounds.
|
|
30
|
-
* @param options {@link TerrainBounds.ConstructorOptions}
|
|
31
|
-
* @param tilingScheme (optional) The tiling scheme to use for coordinate calculations.
|
|
32
|
-
*/
|
|
33
|
-
constructor(options: TerrainBounds.ConstructorOptions, tilingScheme?: TilingScheme);
|
|
34
|
-
/**
|
|
35
|
-
* Checks if the specified tile coordinates are within the bounds.
|
|
36
|
-
* @param x The tile X coordinate.
|
|
37
|
-
* @param y The tile Y coordinate.
|
|
38
|
-
* @param level The tile level.
|
|
39
|
-
* @returns `true` if the tile is within bounds, `false` otherwise.
|
|
40
|
-
*/
|
|
41
|
-
contains(x: number, y: number, level: number): boolean;
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
* Configures a terrain provider's availability based on these bounds.
|
|
45
|
-
* @see WARNING This method is accessing private property of {@link https://cesium.com/learn/csiumjs/ref-doc/TileAvailability.html `TileAvailability`}.
|
|
46
|
-
* @param provider The terrain provider to configure.
|
|
47
|
-
*/
|
|
48
|
-
configureAvailability(provider: TerrainProvider): void;
|
|
49
|
-
/**
|
|
50
|
-
* Gets the rectangle representing these bounds.
|
|
51
|
-
*/
|
|
52
|
-
get rectangle(): Rectangle;
|
|
53
|
-
/** Gets the tiling scheme used by these bounds. */
|
|
54
|
-
get tilingScheme(): TilingScheme;
|
|
55
|
-
/** Gets the tile ranges defined for these bounds. */
|
|
56
|
-
get tileRanges(): TileRanges;
|
|
57
|
-
/** Gets the levels for which tile ranges are defined. */
|
|
58
|
-
get levels(): Set<number>;
|
|
59
|
-
/**
|
|
60
|
-
* Calculates a bounding rectangle that encompasses all the specified tile ranges.
|
|
61
|
-
* @private
|
|
62
|
-
*/
|
|
63
|
-
private _calculateRectangleFromTileRanges;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* @namespace
|
|
67
|
-
* Contains types and factory methods for creating `TerrainBounds` instances.
|
|
68
|
-
*/
|
|
69
|
-
declare namespace TerrainBounds {
|
|
70
|
-
/** Initialization options for Terrain Bounds constructor */
|
|
71
|
-
interface ConstructorOptions {
|
|
72
|
-
/** Type of bounds definition. */
|
|
73
|
-
type: 'tileRange' | 'rectangle';
|
|
74
|
-
/**
|
|
75
|
-
* Tile ranges by level when using tileRange type.
|
|
76
|
-
* Keys are zoom levels, values define the range of tiles at that level.
|
|
77
|
-
* Can be provided either as a Map or as a plain object with numeric keys.
|
|
78
|
-
*/
|
|
79
|
-
tileRanges?: Map<number, TileRange> | Record<string | number, TileRange>;
|
|
80
|
-
/** Rectangle bounds when using rectangle type. */
|
|
81
|
-
rectangle?: Rectangle;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Creates `TerrainBounds` from tile coordinates at a specific level.
|
|
85
|
-
* @param x The tile X coordinate.
|
|
86
|
-
* @param y The tile Y coordinate.
|
|
87
|
-
* @param level The tile level.
|
|
88
|
-
* @param tilingScheme The tiling scheme to use.
|
|
89
|
-
* @returns A new `TerrainBounds` instance for the specified tile.
|
|
90
|
-
*/
|
|
91
|
-
function fromTile(x: number, y: number, level: number, tilingScheme?: TilingScheme): TerrainBounds;
|
|
92
|
-
/**
|
|
93
|
-
* Creates `TerrainBounds` from a rectangle.
|
|
94
|
-
* @param rectangle The rectangle defining the bounds.
|
|
95
|
-
* @param tilingScheme The tiling scheme to use.
|
|
96
|
-
* @returns A new `TerrainBounds` instance for the specified rectangle.
|
|
97
|
-
*/
|
|
98
|
-
function fromRectangle(rectangle: Rectangle, tilingScheme?: TilingScheme): TerrainBounds;
|
|
99
|
-
}
|
|
100
16
|
|
|
101
17
|
/**
|
|
102
18
|
* @class
|
|
@@ -104,26 +20,23 @@ declare namespace TerrainBounds {
|
|
|
104
20
|
* `TerrainArea` pairs a provider with geographic bounds and level constraints.
|
|
105
21
|
*/
|
|
106
22
|
declare class TerrainArea {
|
|
107
|
-
private
|
|
108
|
-
private
|
|
109
|
-
private
|
|
23
|
+
private _terrainProvider;
|
|
24
|
+
private _rectangle;
|
|
25
|
+
private _tileRanges;
|
|
110
26
|
private _ready;
|
|
111
27
|
private _credit;
|
|
112
28
|
private _isCustom;
|
|
113
29
|
/**
|
|
114
30
|
* Creates a new instance of `TerrainArea`.
|
|
115
31
|
* @param options Object describing initialization options
|
|
116
|
-
* @private Use {@link TerrainArea.create} instead.
|
|
117
|
-
*/
|
|
118
|
-
private constructor();
|
|
119
|
-
/**
|
|
120
|
-
* Asynchronously creates a new instance of `TerrainArea`.
|
|
121
|
-
* @param options {@link TerrainArea.ConstructorOptions}
|
|
122
|
-
* @returns A promise that resolves to a new `TerrainArea` instance.
|
|
123
32
|
*/
|
|
124
|
-
|
|
33
|
+
constructor(options: TerrainArea.ConstructorOptions);
|
|
125
34
|
/**
|
|
126
|
-
*
|
|
35
|
+
* Checks if the specified tile coordinates are within the bounds.
|
|
36
|
+
* @param x The tile X coordinate.
|
|
37
|
+
* @param y The tile Y coordinate.
|
|
38
|
+
* @param level The tile level.
|
|
39
|
+
* @returns `true` if the tile is within bounds, `false` otherwise.
|
|
127
40
|
*/
|
|
128
41
|
contains(x: number, y: number, level: number): boolean;
|
|
129
42
|
/**
|
|
@@ -151,11 +64,11 @@ declare class TerrainArea {
|
|
|
151
64
|
/** Gets the credit associated with this terrain area. */
|
|
152
65
|
get credit(): string | Credit;
|
|
153
66
|
/** Gets the terrain provider for this terrain area. */
|
|
154
|
-
get
|
|
155
|
-
/** Gets
|
|
156
|
-
get
|
|
157
|
-
/** Gets
|
|
158
|
-
get
|
|
67
|
+
get terrainProvider(): TerrainProvider;
|
|
68
|
+
/** Gets available tile ranges with zoom levels set with this terrain area. */
|
|
69
|
+
get tileRanges(): Map<number, TileRange>;
|
|
70
|
+
/** Gets the rectangle representing this terrain area. */
|
|
71
|
+
get rectangle(): Rectangle;
|
|
159
72
|
/** Gets if this terrain area is ready. */
|
|
160
73
|
get ready(): boolean;
|
|
161
74
|
}
|
|
@@ -167,14 +80,12 @@ declare namespace TerrainArea {
|
|
|
167
80
|
/** Initialization options for `TerrainArea` constructor. */
|
|
168
81
|
interface ConstructorOptions {
|
|
169
82
|
/** The terrain provider for this area or a URL to create one from. */
|
|
170
|
-
|
|
171
|
-
/** The geographic bounds of this terrain area. */
|
|
172
|
-
bounds: TerrainBounds | TerrainBounds.ConstructorOptions;
|
|
83
|
+
terrainProvider: TerrainProvider;
|
|
173
84
|
/**
|
|
174
|
-
*
|
|
175
|
-
*
|
|
85
|
+
* Tile ranges by level when using tileRange type.
|
|
86
|
+
* Keys are zoom levels, values define the range of tiles at that level.
|
|
176
87
|
*/
|
|
177
|
-
|
|
88
|
+
tileRanges: Map<number, TileRange>;
|
|
178
89
|
/**
|
|
179
90
|
* Credit to associate with this terrain provider.
|
|
180
91
|
* Used to identify custom terrain providers.
|
|
@@ -191,11 +102,10 @@ declare namespace TerrainArea {
|
|
|
191
102
|
* Creates a `TerrainArea` from a URL and tile ranges.
|
|
192
103
|
* @param url The URL to create the terrain provider from.
|
|
193
104
|
* @param tileRanges Tile ranges by level.
|
|
194
|
-
* @param
|
|
195
|
-
* @param credit Credit to associate with this terrain provider.
|
|
105
|
+
* @param options: Constructor options for CesiumTerrainProvider.
|
|
196
106
|
* @returns A promise resolving to a new `TerrainArea`
|
|
197
107
|
*/
|
|
198
|
-
function fromUrl(url: string, tileRanges:
|
|
108
|
+
function fromUrl(url: string, tileRanges: Map<number, TileRange>, options?: CesiumTerrainProvider.ConstructorOptions): Promise<Awaited<TerrainArea>>;
|
|
199
109
|
}
|
|
200
110
|
|
|
201
111
|
/**
|
|
@@ -206,18 +116,13 @@ declare namespace TerrainArea {
|
|
|
206
116
|
*
|
|
207
117
|
* @example
|
|
208
118
|
* ``` typescript
|
|
119
|
+
* const tileRanges = new Map<number, TileRange>;
|
|
120
|
+
* tileRanges.set(15, { start: { x: 55852, y: 9556 }, end: { x: 55871, y: 9575 } });
|
|
209
121
|
* const hybridTerrain = await HybridTerrainProvider.create({
|
|
210
122
|
* terrainAreas: [
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
* tileRanges: {
|
|
215
|
-
* 15: {
|
|
216
|
-
* start: { x: 55852, y: 9556 },
|
|
217
|
-
* end: { x: 55871, y: 9575 },
|
|
218
|
-
* },
|
|
219
|
-
* },
|
|
220
|
-
* levels: [15],
|
|
123
|
+
* {
|
|
124
|
+
* provider: 'custom-terrain-url',
|
|
125
|
+
* tileRanges,
|
|
221
126
|
* }
|
|
222
127
|
* ],
|
|
223
128
|
* terrainProvider: 'default-terrain-url',
|
|
@@ -275,27 +180,36 @@ declare class HybridTerrainProvider implements TerrainProvider {
|
|
|
275
180
|
*/
|
|
276
181
|
get fallbackProvider(): TerrainProvider;
|
|
277
182
|
/**
|
|
278
|
-
*
|
|
183
|
+
* Gets the credit to display when this terrain provider is active. Typically this is used to credit
|
|
184
|
+
* the source of the terrain.
|
|
279
185
|
*/
|
|
280
186
|
get credit(): any;
|
|
281
187
|
/**
|
|
282
|
-
*
|
|
188
|
+
* Gets an event that is raised when the terrain provider encounters an asynchronous error. By subscribing
|
|
189
|
+
* to the event, you will be notified of the error and can potentially recover from it. Event listeners
|
|
190
|
+
* are passed an instance of `TileProviderError`.
|
|
283
191
|
*/
|
|
284
192
|
get errorEvent(): any;
|
|
285
193
|
/**
|
|
286
|
-
*
|
|
194
|
+
* Gets a value indicating whether or not the provider includes a water mask. The water mask
|
|
195
|
+
* indicates which areas of the globe are water rather than land, so they can be rendered
|
|
196
|
+
* as a reflective surface with animated waves.
|
|
287
197
|
*/
|
|
288
198
|
get hasWaterMask(): boolean;
|
|
289
|
-
/**
|
|
290
|
-
* @see {@link TerrainProvider.hasVertexNormals}
|
|
291
|
-
*/
|
|
199
|
+
/** Gets a value indicating whether or not the requested tiles include vertex normals. */
|
|
292
200
|
get hasVertexNormals(): boolean;
|
|
293
201
|
/**
|
|
294
|
-
*
|
|
202
|
+
* Makes sure we load availability data for a tile
|
|
203
|
+
* @param x - The X coordinate of the tile for which to request geometry.
|
|
204
|
+
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
205
|
+
* @param level - The level of the tile for which to request geometry.
|
|
206
|
+
* @returns Undefined if nothing need to be loaded or a Promise that resolves when all required tiles are loaded
|
|
295
207
|
*/
|
|
296
208
|
loadTileDataAvailability(x: number, y: number, level: number): Promise<void> | undefined;
|
|
297
209
|
/**
|
|
298
|
-
*
|
|
210
|
+
* Gets the maximum geometric error allowed in a tile at a given level.
|
|
211
|
+
* @param level - The tile level for which to get the maximum geometric error.
|
|
212
|
+
* @returns The maximum geometric error.
|
|
299
213
|
*/
|
|
300
214
|
getLevelMaximumGeometricError(level: number): number;
|
|
301
215
|
/**
|
|
@@ -308,10 +222,11 @@ declare class HybridTerrainProvider implements TerrainProvider {
|
|
|
308
222
|
*/
|
|
309
223
|
requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<Awaited<TerrainData>> | undefined;
|
|
310
224
|
/**
|
|
311
|
-
*
|
|
312
|
-
* @param x
|
|
313
|
-
* @param y
|
|
314
|
-
* @param level
|
|
225
|
+
* Determines whether data for a tile is available to be loaded. Checks the specified terrain areas first.
|
|
226
|
+
* @param x - The X coordinate of the tile for which to request geometry.
|
|
227
|
+
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
228
|
+
* @param level - The level of the tile for which to request geometry.
|
|
229
|
+
* @returns Undefined if not supported by the terrain provider, otherwise true or false.
|
|
315
230
|
*/
|
|
316
231
|
getTileDataAvailable(x: number, y: number, level: number): boolean | undefined;
|
|
317
232
|
}
|
|
@@ -320,9 +235,7 @@ declare class HybridTerrainProvider implements TerrainProvider {
|
|
|
320
235
|
* Contains types and factory methods for creating `HybridTerrainProvider` instance.
|
|
321
236
|
*/
|
|
322
237
|
declare namespace HybridTerrainProvider {
|
|
323
|
-
/**
|
|
324
|
-
* Initialization options for `HybridTerrainProvider` constructor.
|
|
325
|
-
*/
|
|
238
|
+
/** Initialization options for `HybridTerrainProvider` constructor. */
|
|
326
239
|
interface ConstructorOptions {
|
|
327
240
|
/** An array of terrain areas to include in the hybrid terrain. */
|
|
328
241
|
terrainAreas: TerrainArea.ConstructorOptions[];
|
|
@@ -336,10 +249,9 @@ declare namespace HybridTerrainProvider {
|
|
|
336
249
|
* @param customTerrainUrl URL to the custom terrain.
|
|
337
250
|
* @param baseTerrainUrl URL to the base terrain.
|
|
338
251
|
* @param tileRanges Tile ranges defining the custom terrain area.
|
|
339
|
-
* @param levels Levels to apply the custom terrain.
|
|
340
252
|
* @returns A promise resolving to a new `HybridTerrainProvider`.
|
|
341
253
|
*/
|
|
342
|
-
function createOverlay(customTerrainUrl: string, baseTerrainUrl: string, tileRanges:
|
|
254
|
+
function createOverlay(customTerrainUrl: string, baseTerrainUrl: string, tileRanges: Map<number, TileRange>): Promise<Awaited<HybridTerrainProvider>>;
|
|
343
255
|
}
|
|
344
256
|
|
|
345
|
-
export { HybridTerrainProvider as H, TerrainArea as T,
|
|
257
|
+
export { HybridTerrainProvider as H, TerrainArea as T, type TileRange as a };
|
package/dist/{hybrid-terrain-provider-C6aXdtyo.d.ts → hybrid-terrain-provider-BGwAgH9H.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Request, TerrainData, Credit, TerrainProvider, Rectangle, CesiumTerrainProvider, TilingScheme, TileAvailability } from 'cesium';
|
|
2
2
|
|
|
3
3
|
/** A range of tiles from `start` to `end` */
|
|
4
4
|
type TileRange = {
|
|
@@ -13,90 +13,6 @@ type TileRange = {
|
|
|
13
13
|
y: number;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
-
/** A `TileRange` map with specific levels as their keys. */
|
|
17
|
-
type TileRanges = Map<number, TileRange>;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @class
|
|
21
|
-
* Defines the geographic boundaries for a terrain area and handles tile availability checks.
|
|
22
|
-
*/
|
|
23
|
-
declare class TerrainBounds {
|
|
24
|
-
private _rectangle;
|
|
25
|
-
private _tilingScheme;
|
|
26
|
-
private _tileRanges;
|
|
27
|
-
private _levels;
|
|
28
|
-
/**
|
|
29
|
-
* Creates a new instance of TerrainBounds.
|
|
30
|
-
* @param options {@link TerrainBounds.ConstructorOptions}
|
|
31
|
-
* @param tilingScheme (optional) The tiling scheme to use for coordinate calculations.
|
|
32
|
-
*/
|
|
33
|
-
constructor(options: TerrainBounds.ConstructorOptions, tilingScheme?: TilingScheme);
|
|
34
|
-
/**
|
|
35
|
-
* Checks if the specified tile coordinates are within the bounds.
|
|
36
|
-
* @param x The tile X coordinate.
|
|
37
|
-
* @param y The tile Y coordinate.
|
|
38
|
-
* @param level The tile level.
|
|
39
|
-
* @returns `true` if the tile is within bounds, `false` otherwise.
|
|
40
|
-
*/
|
|
41
|
-
contains(x: number, y: number, level: number): boolean;
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
* Configures a terrain provider's availability based on these bounds.
|
|
45
|
-
* @see WARNING This method is accessing private property of {@link https://cesium.com/learn/csiumjs/ref-doc/TileAvailability.html `TileAvailability`}.
|
|
46
|
-
* @param provider The terrain provider to configure.
|
|
47
|
-
*/
|
|
48
|
-
configureAvailability(provider: TerrainProvider): void;
|
|
49
|
-
/**
|
|
50
|
-
* Gets the rectangle representing these bounds.
|
|
51
|
-
*/
|
|
52
|
-
get rectangle(): Rectangle;
|
|
53
|
-
/** Gets the tiling scheme used by these bounds. */
|
|
54
|
-
get tilingScheme(): TilingScheme;
|
|
55
|
-
/** Gets the tile ranges defined for these bounds. */
|
|
56
|
-
get tileRanges(): TileRanges;
|
|
57
|
-
/** Gets the levels for which tile ranges are defined. */
|
|
58
|
-
get levels(): Set<number>;
|
|
59
|
-
/**
|
|
60
|
-
* Calculates a bounding rectangle that encompasses all the specified tile ranges.
|
|
61
|
-
* @private
|
|
62
|
-
*/
|
|
63
|
-
private _calculateRectangleFromTileRanges;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* @namespace
|
|
67
|
-
* Contains types and factory methods for creating `TerrainBounds` instances.
|
|
68
|
-
*/
|
|
69
|
-
declare namespace TerrainBounds {
|
|
70
|
-
/** Initialization options for Terrain Bounds constructor */
|
|
71
|
-
interface ConstructorOptions {
|
|
72
|
-
/** Type of bounds definition. */
|
|
73
|
-
type: 'tileRange' | 'rectangle';
|
|
74
|
-
/**
|
|
75
|
-
* Tile ranges by level when using tileRange type.
|
|
76
|
-
* Keys are zoom levels, values define the range of tiles at that level.
|
|
77
|
-
* Can be provided either as a Map or as a plain object with numeric keys.
|
|
78
|
-
*/
|
|
79
|
-
tileRanges?: Map<number, TileRange> | Record<string | number, TileRange>;
|
|
80
|
-
/** Rectangle bounds when using rectangle type. */
|
|
81
|
-
rectangle?: Rectangle;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Creates `TerrainBounds` from tile coordinates at a specific level.
|
|
85
|
-
* @param x The tile X coordinate.
|
|
86
|
-
* @param y The tile Y coordinate.
|
|
87
|
-
* @param level The tile level.
|
|
88
|
-
* @param tilingScheme The tiling scheme to use.
|
|
89
|
-
* @returns A new `TerrainBounds` instance for the specified tile.
|
|
90
|
-
*/
|
|
91
|
-
function fromTile(x: number, y: number, level: number, tilingScheme?: TilingScheme): TerrainBounds;
|
|
92
|
-
/**
|
|
93
|
-
* Creates `TerrainBounds` from a rectangle.
|
|
94
|
-
* @param rectangle The rectangle defining the bounds.
|
|
95
|
-
* @param tilingScheme The tiling scheme to use.
|
|
96
|
-
* @returns A new `TerrainBounds` instance for the specified rectangle.
|
|
97
|
-
*/
|
|
98
|
-
function fromRectangle(rectangle: Rectangle, tilingScheme?: TilingScheme): TerrainBounds;
|
|
99
|
-
}
|
|
100
16
|
|
|
101
17
|
/**
|
|
102
18
|
* @class
|
|
@@ -104,26 +20,23 @@ declare namespace TerrainBounds {
|
|
|
104
20
|
* `TerrainArea` pairs a provider with geographic bounds and level constraints.
|
|
105
21
|
*/
|
|
106
22
|
declare class TerrainArea {
|
|
107
|
-
private
|
|
108
|
-
private
|
|
109
|
-
private
|
|
23
|
+
private _terrainProvider;
|
|
24
|
+
private _rectangle;
|
|
25
|
+
private _tileRanges;
|
|
110
26
|
private _ready;
|
|
111
27
|
private _credit;
|
|
112
28
|
private _isCustom;
|
|
113
29
|
/**
|
|
114
30
|
* Creates a new instance of `TerrainArea`.
|
|
115
31
|
* @param options Object describing initialization options
|
|
116
|
-
* @private Use {@link TerrainArea.create} instead.
|
|
117
|
-
*/
|
|
118
|
-
private constructor();
|
|
119
|
-
/**
|
|
120
|
-
* Asynchronously creates a new instance of `TerrainArea`.
|
|
121
|
-
* @param options {@link TerrainArea.ConstructorOptions}
|
|
122
|
-
* @returns A promise that resolves to a new `TerrainArea` instance.
|
|
123
32
|
*/
|
|
124
|
-
|
|
33
|
+
constructor(options: TerrainArea.ConstructorOptions);
|
|
125
34
|
/**
|
|
126
|
-
*
|
|
35
|
+
* Checks if the specified tile coordinates are within the bounds.
|
|
36
|
+
* @param x The tile X coordinate.
|
|
37
|
+
* @param y The tile Y coordinate.
|
|
38
|
+
* @param level The tile level.
|
|
39
|
+
* @returns `true` if the tile is within bounds, `false` otherwise.
|
|
127
40
|
*/
|
|
128
41
|
contains(x: number, y: number, level: number): boolean;
|
|
129
42
|
/**
|
|
@@ -151,11 +64,11 @@ declare class TerrainArea {
|
|
|
151
64
|
/** Gets the credit associated with this terrain area. */
|
|
152
65
|
get credit(): string | Credit;
|
|
153
66
|
/** Gets the terrain provider for this terrain area. */
|
|
154
|
-
get
|
|
155
|
-
/** Gets
|
|
156
|
-
get
|
|
157
|
-
/** Gets
|
|
158
|
-
get
|
|
67
|
+
get terrainProvider(): TerrainProvider;
|
|
68
|
+
/** Gets available tile ranges with zoom levels set with this terrain area. */
|
|
69
|
+
get tileRanges(): Map<number, TileRange>;
|
|
70
|
+
/** Gets the rectangle representing this terrain area. */
|
|
71
|
+
get rectangle(): Rectangle;
|
|
159
72
|
/** Gets if this terrain area is ready. */
|
|
160
73
|
get ready(): boolean;
|
|
161
74
|
}
|
|
@@ -167,14 +80,12 @@ declare namespace TerrainArea {
|
|
|
167
80
|
/** Initialization options for `TerrainArea` constructor. */
|
|
168
81
|
interface ConstructorOptions {
|
|
169
82
|
/** The terrain provider for this area or a URL to create one from. */
|
|
170
|
-
|
|
171
|
-
/** The geographic bounds of this terrain area. */
|
|
172
|
-
bounds: TerrainBounds | TerrainBounds.ConstructorOptions;
|
|
83
|
+
terrainProvider: TerrainProvider;
|
|
173
84
|
/**
|
|
174
|
-
*
|
|
175
|
-
*
|
|
85
|
+
* Tile ranges by level when using tileRange type.
|
|
86
|
+
* Keys are zoom levels, values define the range of tiles at that level.
|
|
176
87
|
*/
|
|
177
|
-
|
|
88
|
+
tileRanges: Map<number, TileRange>;
|
|
178
89
|
/**
|
|
179
90
|
* Credit to associate with this terrain provider.
|
|
180
91
|
* Used to identify custom terrain providers.
|
|
@@ -191,11 +102,10 @@ declare namespace TerrainArea {
|
|
|
191
102
|
* Creates a `TerrainArea` from a URL and tile ranges.
|
|
192
103
|
* @param url The URL to create the terrain provider from.
|
|
193
104
|
* @param tileRanges Tile ranges by level.
|
|
194
|
-
* @param
|
|
195
|
-
* @param credit Credit to associate with this terrain provider.
|
|
105
|
+
* @param options: Constructor options for CesiumTerrainProvider.
|
|
196
106
|
* @returns A promise resolving to a new `TerrainArea`
|
|
197
107
|
*/
|
|
198
|
-
function fromUrl(url: string, tileRanges:
|
|
108
|
+
function fromUrl(url: string, tileRanges: Map<number, TileRange>, options?: CesiumTerrainProvider.ConstructorOptions): Promise<Awaited<TerrainArea>>;
|
|
199
109
|
}
|
|
200
110
|
|
|
201
111
|
/**
|
|
@@ -206,18 +116,13 @@ declare namespace TerrainArea {
|
|
|
206
116
|
*
|
|
207
117
|
* @example
|
|
208
118
|
* ``` typescript
|
|
119
|
+
* const tileRanges = new Map<number, TileRange>;
|
|
120
|
+
* tileRanges.set(15, { start: { x: 55852, y: 9556 }, end: { x: 55871, y: 9575 } });
|
|
209
121
|
* const hybridTerrain = await HybridTerrainProvider.create({
|
|
210
122
|
* terrainAreas: [
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
* tileRanges: {
|
|
215
|
-
* 15: {
|
|
216
|
-
* start: { x: 55852, y: 9556 },
|
|
217
|
-
* end: { x: 55871, y: 9575 },
|
|
218
|
-
* },
|
|
219
|
-
* },
|
|
220
|
-
* levels: [15],
|
|
123
|
+
* {
|
|
124
|
+
* provider: 'custom-terrain-url',
|
|
125
|
+
* tileRanges,
|
|
221
126
|
* }
|
|
222
127
|
* ],
|
|
223
128
|
* terrainProvider: 'default-terrain-url',
|
|
@@ -275,27 +180,36 @@ declare class HybridTerrainProvider implements TerrainProvider {
|
|
|
275
180
|
*/
|
|
276
181
|
get fallbackProvider(): TerrainProvider;
|
|
277
182
|
/**
|
|
278
|
-
*
|
|
183
|
+
* Gets the credit to display when this terrain provider is active. Typically this is used to credit
|
|
184
|
+
* the source of the terrain.
|
|
279
185
|
*/
|
|
280
186
|
get credit(): any;
|
|
281
187
|
/**
|
|
282
|
-
*
|
|
188
|
+
* Gets an event that is raised when the terrain provider encounters an asynchronous error. By subscribing
|
|
189
|
+
* to the event, you will be notified of the error and can potentially recover from it. Event listeners
|
|
190
|
+
* are passed an instance of `TileProviderError`.
|
|
283
191
|
*/
|
|
284
192
|
get errorEvent(): any;
|
|
285
193
|
/**
|
|
286
|
-
*
|
|
194
|
+
* Gets a value indicating whether or not the provider includes a water mask. The water mask
|
|
195
|
+
* indicates which areas of the globe are water rather than land, so they can be rendered
|
|
196
|
+
* as a reflective surface with animated waves.
|
|
287
197
|
*/
|
|
288
198
|
get hasWaterMask(): boolean;
|
|
289
|
-
/**
|
|
290
|
-
* @see {@link TerrainProvider.hasVertexNormals}
|
|
291
|
-
*/
|
|
199
|
+
/** Gets a value indicating whether or not the requested tiles include vertex normals. */
|
|
292
200
|
get hasVertexNormals(): boolean;
|
|
293
201
|
/**
|
|
294
|
-
*
|
|
202
|
+
* Makes sure we load availability data for a tile
|
|
203
|
+
* @param x - The X coordinate of the tile for which to request geometry.
|
|
204
|
+
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
205
|
+
* @param level - The level of the tile for which to request geometry.
|
|
206
|
+
* @returns Undefined if nothing need to be loaded or a Promise that resolves when all required tiles are loaded
|
|
295
207
|
*/
|
|
296
208
|
loadTileDataAvailability(x: number, y: number, level: number): Promise<void> | undefined;
|
|
297
209
|
/**
|
|
298
|
-
*
|
|
210
|
+
* Gets the maximum geometric error allowed in a tile at a given level.
|
|
211
|
+
* @param level - The tile level for which to get the maximum geometric error.
|
|
212
|
+
* @returns The maximum geometric error.
|
|
299
213
|
*/
|
|
300
214
|
getLevelMaximumGeometricError(level: number): number;
|
|
301
215
|
/**
|
|
@@ -308,10 +222,11 @@ declare class HybridTerrainProvider implements TerrainProvider {
|
|
|
308
222
|
*/
|
|
309
223
|
requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<Awaited<TerrainData>> | undefined;
|
|
310
224
|
/**
|
|
311
|
-
*
|
|
312
|
-
* @param x
|
|
313
|
-
* @param y
|
|
314
|
-
* @param level
|
|
225
|
+
* Determines whether data for a tile is available to be loaded. Checks the specified terrain areas first.
|
|
226
|
+
* @param x - The X coordinate of the tile for which to request geometry.
|
|
227
|
+
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
228
|
+
* @param level - The level of the tile for which to request geometry.
|
|
229
|
+
* @returns Undefined if not supported by the terrain provider, otherwise true or false.
|
|
315
230
|
*/
|
|
316
231
|
getTileDataAvailable(x: number, y: number, level: number): boolean | undefined;
|
|
317
232
|
}
|
|
@@ -320,9 +235,7 @@ declare class HybridTerrainProvider implements TerrainProvider {
|
|
|
320
235
|
* Contains types and factory methods for creating `HybridTerrainProvider` instance.
|
|
321
236
|
*/
|
|
322
237
|
declare namespace HybridTerrainProvider {
|
|
323
|
-
/**
|
|
324
|
-
* Initialization options for `HybridTerrainProvider` constructor.
|
|
325
|
-
*/
|
|
238
|
+
/** Initialization options for `HybridTerrainProvider` constructor. */
|
|
326
239
|
interface ConstructorOptions {
|
|
327
240
|
/** An array of terrain areas to include in the hybrid terrain. */
|
|
328
241
|
terrainAreas: TerrainArea.ConstructorOptions[];
|
|
@@ -336,10 +249,9 @@ declare namespace HybridTerrainProvider {
|
|
|
336
249
|
* @param customTerrainUrl URL to the custom terrain.
|
|
337
250
|
* @param baseTerrainUrl URL to the base terrain.
|
|
338
251
|
* @param tileRanges Tile ranges defining the custom terrain area.
|
|
339
|
-
* @param levels Levels to apply the custom terrain.
|
|
340
252
|
* @returns A promise resolving to a new `HybridTerrainProvider`.
|
|
341
253
|
*/
|
|
342
|
-
function createOverlay(customTerrainUrl: string, baseTerrainUrl: string, tileRanges:
|
|
254
|
+
function createOverlay(customTerrainUrl: string, baseTerrainUrl: string, tileRanges: Map<number, TileRange>): Promise<Awaited<HybridTerrainProvider>>;
|
|
343
255
|
}
|
|
344
256
|
|
|
345
|
-
export { HybridTerrainProvider as H, TerrainArea as T,
|
|
257
|
+
export { HybridTerrainProvider as H, TerrainArea as T, type TileRange as a };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var M=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var W=(n,e)=>{for(var t in e)M(n,t,{get:e[t],enumerable:!0})},$=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Y(e))!q.call(n,i)&&i!==t&&M(n,i,{get:()=>e[i],enumerable:!(r=H(e,i))||r.enumerable});return n};var U=n=>$(M({},"__esModule",{value:!0}),n);var X={};W(X,{Collection:()=>R,HybridTerrainProvider:()=>P,TerrainArea:()=>h,TerrainAreas:()=>T,TerrainBounds:()=>v,TerrainVisualizer:()=>p,cloneViewer:()=>D,isGetterOnly:()=>I,syncCamera:()=>w});module.exports=U(X);var C=require("cesium");var l=require("cesium");var p=class n{_viewer;_collection;_hybridTerrain;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",l.Color.RED],["default",l.Color.BLUE],["fallback",l.Color.GRAY],["grid",l.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new R({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([r,i])=>{this._colors.set(r,i)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._hybridTerrain=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._hybridTerrain)return;this._collection.remove(n.tag.grid),this._level=e;let t=this._hybridTerrain.tilingScheme;this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new l.TileCoordinatesImageryProvider({tilingScheme:t,color:l.Color.YELLOW})));let r=(a,s,c)=>{if(this._hybridTerrain){for(let d of this._hybridTerrain.terrainAreas)if(d.contains(a,s,c))return d.isCustom?this._colors.get("custom")||l.Color.RED:this._colors.get("default")||l.Color.BLUE;if(this._hybridTerrain.getTileDataAvailable(a,s,c))return this._colors.get("default")||l.Color.BLUE}return this._colors.get("fallback")||l.Color.TRANSPARENT},i=this._getVisibleRectangle();if(!i)return;function o(a){return a&&Number.isFinite(a.west)&&Number.isFinite(a.south)&&Number.isFinite(a.east)&&Number.isFinite(a.north)&&a.west<=a.east&&a.south<=a.north}if(!o(i)){console.warn("Invalid visible rectangle detected, skipping grid display");return}try{let a=t.positionToTileXY(l.Rectangle.northwest(i),e),s=t.positionToTileXY(l.Rectangle.southeast(i),e);if(!a||!s)return;let c=100,d=Math.min(s.x-a.x+1,c),y=Math.min(s.y-a.y+1,c);for(let m=a.x;m<=a.x+d-1;m++)for(let f=a.y;f<=a.y+y-1;f++)try{let g=t.tileXYToRectangle(m,f,e);if(!o(g)){console.warn(`Invalid rectangle for tile (${m}, ${f}, ${e}), skipping`);continue}let A=r(m,f,e),_=n.createRectangle(g,A.withAlpha(.3));_.properties?.addProperty("tileX",m),_.properties?.addProperty("tileY",f),_.properties?.addProperty("tileLevel",e),this._collection.add(_,n.tag.grid)}catch(g){console.warn(`Error creating tile (${m}, ${f}, ${e}): ${g.message}`);continue}console.log("\u{1F680} ~ TerrainVisualizer ~ showGrid ~ collection:",this._collection),this._visible=!0}catch(a){console.error("Error displaying tile grid:",a)}}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,r])=>{this._colors.set(t,r)}),this.update()}flyTo(e,t){let{rectangle:r}=e.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 l.Entity({rectangle:{coordinates:i,material:o,heightReference:l.HeightReference.CLAMP_TO_GROUND}})}r.createRectangle=e;function t(i,o,a){let s=a?.tag||"terrain_area_visualization",c=a?.color||l.Color.RED,d=a?.maxTilesToShow||100,y=a?.show??!0,m=a?.alpha||.7,f=a?.tileAlpha||.2,g="provider"in i?i.bounds:i,A=new R({collection:o.entities,tag:s}),{rectangle:_}=g;if(A.add(r.createRectangle(_,c.withAlpha(m)),s),y&&g.levels.size>0){let{tilingScheme:G}=g;g.levels.forEach(V=>{let x=0,{tileRanges:j}=g;for(let[z,E]of j.entries())if(z===V)for(let S=E.start.x;S<=E.end.x&&x<d;S++)for(let k=E.start.y;k<=E.end.y&&x<d;k++){let F=G.tileXYToRectangle(S,k,V);A.add(e(F,c.withAlpha(f)),`${s}_tile`),x++}})}return A}r.visualize=t})(p||={});function I(n,e){let t=!1,r=Object.getOwnPropertyDescriptor(n,e);if(!r){let i=Object.getPrototypeOf(n);for(;i&&!r;)r=Object.getOwnPropertyDescriptor(i,e),i=Object.getPrototypeOf(i)}return r&&r.get&&!r.set&&(t=!0),t}var O=require("cesium");function w(n,e){if((0,O.defined)(n)&&(0,O.defined)(e)){let{camera:t}=n;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}var L=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let r=this._eventListeners.get(e);if(r){let i={type:e,...t};r.forEach(o=>o(i))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],r=this._tagMap.get(t);r&&(r.delete(e),r.size===0&&this._tagMap.delete(t))}_invalidateCache(){this._valuesCache=null}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,r){return Array.isArray(e)?e.forEach(i=>{this.add(i,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,r),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let i=this.collection.remove(e);return i&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),i}if(Array.isArray(e)){if(e.length===0)return!1;let i=!1;for(let o of e)this.remove(o)&&(i=!0);return i}let t=this.get(e);if(t.length===0)return!1;let r=!1;for(let i of t)this.remove(i)&&(r=!0);return r}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof C.EntityCollection)return this.collection.values;{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));return e}}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let r=this.get(e);for(let i of r)this._removeFromTagMap(i),Object.defineProperty(i,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(i,t);return r.length>0&&this._emit("update",{items:r,tag:t}),r.length}show(e){let t=this.get(e);for(let r of t)(0,C.defined)(r.show)&&(r.show=!0);return this}hide(e){let t=this.get(e);for(let r of t)(0,C.defined)(r.show)&&(r.show=!1);return this}toggle(e){let t=this.get(e);for(let r of t)(0,C.defined)(r.show)&&(r.show=!r.show);return this}setProperty(e,t,r=this.tag){let i=this.get(r);for(let o of i)if(e in o&&typeof o[e]!="function"){if(I(o,e))throw Error(`setProperty(${o}, ${e}) failed; The property is readonly.`);o[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((i,o)=>e(i,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},R=L;var b=require("cesium");var N=require("cesium");var u=require("cesium"),v=class{_rectangle;_tilingScheme;_tileRanges;_levels;constructor(e,t){if(this._tilingScheme=t||new u.GeographicTilingScheme,this._rectangle=new u.Rectangle,this._tileRanges=new Map,this._levels=new Set,e.type==="rectangle"&&e.rectangle)this._rectangle=u.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(([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 u.Rectangle.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=u.Rectangle.MAX_VALUE;return}let a=Math.min(...o),s=this._tileRanges.get(a);if(s){let{start:c,end:d}=s,y=this._tilingScheme.tileXYToRectangle(c.x,c.y,a),m=this._tilingScheme.tileXYToRectangle(d.x,d.y,a);e=Math.min(y.west,e),t=Math.min(m.south,t),r=Math.max(m.east,r),i=Math.max(y.north,i)}this._rectangle=new u.Rectangle(e,t,r,i)}};(t=>{function n(r,i,o,a=new u.GeographicTilingScheme){let s=new Map;return s.set(o,{start:{x:r,y:i},end:{x:r,y:i}}),new t({type:"tileRange",tileRanges:s},a)}t.fromTile=n;function e(r,i=new u.GeographicTilingScheme){return new t({type:"rectangle",rectangle:u.Rectangle.clone(r)},i)}t.fromRectangle=e})(v||={});var h=class n{_provider;_bounds;_levels;_ready=!1;_credit;_isCustom;constructor(e,t){this._bounds=e.bounds instanceof v?e.bounds:new v(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 N.CesiumTerrainProvider.fromUrl(e.provider,{requestVertexNormals:!0,credit:e.credit||"custom"}):t=e.provider,new n(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 n(t,r,i,o="custom"){let a=new v({type:"tileRange",tileRanges:r});return await e.create({provider:t,bounds:a,levels:i||Object.keys(r).map(c=>parseInt(c)),credit:o})}e.fromUrl=n})(h||={});var T=class extends Array{async add(e){let t;return e instanceof h?t=e:t=await h.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}};var P=class n{_terrainAreas=new T;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e,t,r){this._terrainProvider=e,this._fallbackProvider=t,this._tilingScheme=e.tilingScheme||new b.GeographicTilingScheme,this._terrainAreas=new T(...r),this._availability=e.availability,this._ready=!0}static async create(e){try{let t;typeof e.terrainProvider=="string"?t=await b.CesiumTerrainProvider.fromUrl(e.terrainProvider,{requestVertexNormals:!0}):t=e.terrainProvider;let r;e.fallbackProvider?typeof e.fallbackProvider=="string"?r=await b.CesiumTerrainProvider.fromUrl(e.fallbackProvider,{requestVertexNormals:!0}):r=e.fallbackProvider:r=new b.EllipsoidTerrainProvider;let i=[];for(let o of e.terrainAreas){let a=await h.create(o);i.push(a)}return new n(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 n(t,r,i,o){return e.create({terrainAreas:[{provider:t,bounds:{type:"tileRange",tileRanges:i},levels:o||Object.keys(i).map(a=>parseInt(a)),credit:"custom"}],terrainProvider:r,fallbackProvider:new b.EllipsoidTerrainProvider})}e.createOverlay=n})(P||={});var B=require("cesium");function D(n,e,t){let r={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},i=new B.Viewer(e,{...r,...t});w(n,i);let o=n.imageryLayers;i.imageryLayers.removeAll();for(let c=0;c<o.length;c++){let d=o.get(c);i.imageryLayers.addImageryProvider(d.imageryProvider,c)}i.clock.startTime=n.clock.startTime.clone(),i.clock.stopTime=n.clock.stopTime.clone(),i.clock.currentTime=n.clock.currentTime.clone(),i.clock.multiplier=n.clock.multiplier,i.clock.clockStep=n.clock.clockStep,i.clock.clockRange=n.clock.clockRange,i.clock.shouldAnimate=n.clock.shouldAnimate,i.scene.globe.enableLighting=n.scene.globe.enableLighting,i.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,i.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let a=n.scene.screenSpaceCameraController.tiltEventTypes;a&&(i.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(a)?[...a]:a);let s=n.scene.screenSpaceCameraController.zoomEventTypes;return s&&(i.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(s)?[...s]:s),i}
|
|
1
|
+
"use strict";var k=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var q=(n,e)=>{for(var r in e)k(n,r,{get:e[r],enumerable:!0})},Y=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of H(e))!j.call(n,i)&&i!==r&&k(n,i,{get:()=>e[i],enumerable:!(t=F(e,i))||t.enumerable});return n};var B=n=>Y(k({},"__esModule",{value:!0}),n);var U={};q(U,{Collection:()=>C,HybridTerrainProvider:()=>P,TerrainArea:()=>h,TerrainAreaCollection:()=>v,TerrainVisualizer:()=>f,cloneViewer:()=>D,computeRectangle:()=>R,isGetterOnly:()=>A,syncCamera:()=>y});module.exports=B(U);var _=require("cesium");var l=require("cesium");var f=class n{_viewer;_collection;_hybridTerrain;_visible=!1;_level=15;_tileCoordinatesLayer;_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._collection=new C({collection:e.entities,tag:n.tag.default}),r&&(r.colors&&Object.entries(r.colors).forEach(([t,i])=>{this._colors.set(t,i)}),r.tile!==void 0&&(this._visible=r.tile),r.activeLevel!==void 0&&(this._level=r.activeLevel),r.terrainProvider&&this.setTerrainProvider(r.terrainProvider))}setTerrainProvider(e){this._hybridTerrain=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._hybridTerrain)return;this._collection.remove(n.tag.grid),this._level=e;let r=this._hybridTerrain.tilingScheme;this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new l.TileCoordinatesImageryProvider({tilingScheme:r,color:l.Color.YELLOW})));let t=(o,s,c)=>{if(this._hybridTerrain){for(let d of this._hybridTerrain.terrainAreas)if(d.contains(o,s,c))return d.isCustom?this._colors.get("custom")||l.Color.RED:this._colors.get("default")||l.Color.BLUE;if(this._hybridTerrain.getTileDataAvailable(o,s,c))return this._colors.get("default")||l.Color.BLUE}return this._colors.get("fallback")||l.Color.TRANSPARENT},i=this._getVisibleRectangle();if(!i)return;function a(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(!a(i)){console.warn("Invalid visible rectangle detected, skipping grid display");return}try{let o=r.positionToTileXY(l.Rectangle.northwest(i),e),s=r.positionToTileXY(l.Rectangle.southeast(i),e);if(!o||!s)return;let c=100,d=Math.min(s.x-o.x+1,c),T=Math.min(s.y-o.y+1,c);for(let m=o.x;m<=o.x+d-1;m++)for(let u=o.y;u<=o.y+T-1;u++)try{let g=r.tileXYToRectangle(m,u,e);if(!a(g)){console.warn(`Invalid rectangle for tile (${m}, ${u}, ${e}), skipping`);continue}let I=t(m,u,e),b=n.createRectangle(g,I.withAlpha(.3));b.properties?.addProperty("tileX",m),b.properties?.addProperty("tileY",u),b.properties?.addProperty("tileLevel",e),this._collection.add(b,n.tag.grid)}catch(g){console.warn(`Error creating tile (${m}, ${u}, ${e}): ${g.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.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([r,t])=>{this._colors.set(r,t)}),this.update()}flyTo(e,r){let{rectangle:t}=e;this._viewer.camera.flyTo({destination:t,...r,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}};(t=>{t.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(i,a){return new l.Entity({rectangle:{coordinates:i,material:a,heightReference:l.HeightReference.CLAMP_TO_GROUND}})}t.createRectangle=e;function r(i,a,o){let s=o?.tag||"terrain_area_visualization",c=o?.color||l.Color.RED,d=o?.maxTilesToShow||100,T=o?.show??!0,m=o?.alpha||.7,u=o?.tileAlpha||.2,g=new C({collection:a.entities,tag:s}),{rectangle:I}=i;if(g.add(t.createRectangle(I,c.withAlpha(m)),s),T&&i.tileRanges.size>0){let{tilingScheme:b}=i.terrainProvider,x=0;i.tileRanges.forEach((w,z)=>{for(let E=w.start.x;E<=w.end.x&&x<d;E++)for(let M=w.start.y;M<=w.end.y&&x<d;M++){let G=b.tileXYToRectangle(E,M,z);g.add(e(G,c.withAlpha(u)),`${s}_tile`),x++}})}return g}t.visualize=r})(f||={});function A(n,e){let r=!1,t=Object.getOwnPropertyDescriptor(n,e);if(!t){let i=Object.getPrototypeOf(n);for(;i&&!t;)t=Object.getOwnPropertyDescriptor(i,e),i=Object.getPrototypeOf(i)}return t&&t.get&&!t.set&&(r=!0),r}var O=require("cesium");function y(n,e){if((0,O.defined)(n)&&(0,O.defined)(e)){let{camera:r}=n;e.camera.position=r.positionWC.clone(),e.camera.direction=r.directionWC.clone(),e.camera.up=r.upWC.clone()}}var L=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:r}){this.tag=r||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,r){let t=this._eventListeners.get(e);if(t){let i={type:e,...r};t.forEach(a=>a(i))}}_addToTagMap(e,r){this._tagMap.has(r)||this._tagMap.set(r,new Set),this._tagMap.get(r)?.add(e)}_removeFromTagMap(e){let r=e[n.symbol],t=this._tagMap.get(r);t&&(t.delete(e),t.size===0&&this._tagMap.delete(r))}_invalidateCache(){this._valuesCache=null}addEventListener(e,r){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(r),this}removeEventListener(e,r){return this._eventListeners.get(e)?.delete(r),this}add(e,r=this.tag,t){return Array.isArray(e)?e.forEach(i=>{this.add(i,r)}):(Object.defineProperty(e,n.symbol,{value:r,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,t),this._addToTagMap(e,r),this._invalidateCache(),this._emit("add",{items:[e],tag:r})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let r=this._tagMap.get(e);return!!r&&r.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let i=this.collection.remove(e);return i&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),i}if(Array.isArray(e)){if(e.length===0)return!1;let i=!1;for(let a of e)this.remove(a)&&(i=!0);return i}let r=this.get(e);if(r.length===0)return!1;let t=!1;for(let i of r)this.remove(i)&&(t=!0);return t}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof _.EntityCollection)return this.collection.values;{let e=[];for(let r=0;r<this.collection.length;r++)e.push(this.collection.get(r));return e}}get length(){return this.values?.length||0}get(e){let r=this._tagMap.get(e);return r?Array.from(r):[]}first(e){let r=this._tagMap.get(e);if(r&&r.size>0)return r.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,r){let t=this.get(e);for(let i of t)this._removeFromTagMap(i),Object.defineProperty(i,n.symbol,{value:r,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(i,r);return t.length>0&&this._emit("update",{items:t,tag:r}),t.length}show(e){let r=this.get(e);for(let t of r)(0,_.defined)(t.show)&&(t.show=!0);return this}hide(e){let r=this.get(e);for(let t of r)(0,_.defined)(t.show)&&(t.show=!1);return this}toggle(e){let r=this.get(e);for(let t of r)(0,_.defined)(t.show)&&(t.show=!t.show);return this}setProperty(e,r,t=this.tag){let i=this.get(t);for(let a of i)if(e in a&&typeof a[e]!="function"){if(A(a,e))throw Error(`setProperty(${a}, ${e}) failed; The property is readonly.`);a[e]=r}return this}filter(e,r){return(r?this.get(r):this.values).filter(e)}forEach(e,r){(r?this.get(r):this.values).forEach((i,a)=>e(i,a))}map(e,r){return(r?this.get(r):this.values).map(e)}find(e,r){return(r?this.get(r):this.values).find(e)}},C=L;var p=require("cesium");var V=require("cesium");var S=require("cesium");function R(n,e){if(e.size===0)return new S.Rectangle;let r=Number.POSITIVE_INFINITY,t=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY,o=Array.from(e.keys()),s=Math.min(...o),c=e.get(s);if(c){let{start:d,end:T}=c,m=n.tileXYToRectangle(d.x,d.y,s),u=n.tileXYToRectangle(T.x,T.y,s);r=Math.min(m.west,r),t=Math.min(u.south,t),i=Math.max(u.east,i),a=Math.max(m.north,a)}return new S.Rectangle(r,t,i,a)}var h=class{_terrainProvider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(e){this._terrainProvider=e.terrainProvider,this._tileRanges=e.tileRanges,this._credit=e.credit||"custom",this._isCustom=e.isCustom!==void 0?e.isCustom:!0,this._rectangle=R(e.terrainProvider.tilingScheme,e.tileRanges),e.tileRanges.forEach((r,t)=>{this._terrainProvider.availability?.addAvailableTileRange(t,r.start.x,r.start.y,r.end.x,r.end.y)}),this._ready=!0}contains(e,r,t){if(this._tileRanges.size===0||!this._tileRanges.has(t))return!1;let i=this._tileRanges.get(t);return e>=i.start.x&&e<=i.end.x&&r>=i.start.y&&r<=i.end.y}requestTileGeometry(e,r,t,i){if(!(!this._ready||!this.contains(e,r,t)))return this._terrainProvider.requestTileGeometry(e,r,t,i)}getTileDataAvailable(e,r,t){if(this._tileRanges.size===0||!this._tileRanges.has(t))return!1;let i=this._tileRanges.get(t);return e>=i.start.x&&e<=i.end.x&&r>=i.start.y&&r<=i.end.y}get isCustom(){return this._isCustom}get credit(){return this._credit}get terrainProvider(){return this._terrainProvider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(e=>{async function n(r,t,i){let a=i?.credit||"custom",o=await V.CesiumTerrainProvider.fromUrl(r,{...i,credit:a});return new e({terrainProvider:o,tileRanges:t,credit:a})}e.fromUrl=n})(h||={});var v=class extends Array{add(e){if(Array.isArray(e)){for(let t of e)this.add(t);return this.length}let r;return e instanceof h?r=e:r=new h(e),this.push(r)}remove(e){if(Array.isArray(e))return e.forEach(t=>this.remove(t)),this;let r=this.indexOf(e);return r>=0&&this.splice(r,1),this}removeAll(){this.length=0}};var P=class n{_terrainAreas=new v;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e,r,t){this._terrainProvider=e,this._fallbackProvider=r,this._tilingScheme=e.tilingScheme,this._terrainAreas=new v(...t),this._availability=e.availability,this._ready=!0}static async create(e){try{let r;typeof e.terrainProvider=="string"?r=await p.CesiumTerrainProvider.fromUrl(e.terrainProvider,{requestVertexNormals:!0}):r=e.terrainProvider;let t;e.fallbackProvider?typeof e.fallbackProvider=="string"?t=await p.CesiumTerrainProvider.fromUrl(e.fallbackProvider,{requestVertexNormals:!0}):t=e.fallbackProvider:t=new p.EllipsoidTerrainProvider;let i=[];for(let a of e.terrainAreas){let o=typeof a.terrainProvider=="string"?await p.CesiumTerrainProvider.fromUrl(a.terrainProvider,{requestVertexNormals:!0}):a.terrainProvider;i.push(new h({terrainProvider:o,tileRanges:a.tileRanges,credit:a.credit,isCustom:a.isCustom}))}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){for(let i of this._terrainAreas)if(i.contains(e,r,t))return i.getTileDataAvailable(e,r,t);return this._terrainProvider.getTileDataAvailable(e,r,t)}};(e=>{async function n(r,t,i){let a=await p.CesiumTerrainProvider.fromUrl(r,{credit:"custom"});return e.create({terrainAreas:[{terrainProvider:a,tileRanges:i,credit:"custom"}],terrainProvider:t,fallbackProvider:new p.EllipsoidTerrainProvider})}e.createOverlay=n})(P||={});var N=require("cesium");function D(n,e,r){let t={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},i=new N.Viewer(e,{...t,...r});y(n,i);let a=n.imageryLayers;i.imageryLayers.removeAll();for(let c=0;c<a.length;c++){let d=a.get(c);i.imageryLayers.addImageryProvider(d.imageryProvider,c)}i.clock.startTime=n.clock.startTime.clone(),i.clock.stopTime=n.clock.stopTime.clone(),i.clock.currentTime=n.clock.currentTime.clone(),i.clock.multiplier=n.clock.multiplier,i.clock.clockStep=n.clock.clockStep,i.clock.clockRange=n.clock.clockRange,i.clock.shouldAnimate=n.clock.shouldAnimate,i.scene.globe.enableLighting=n.scene.globe.enableLighting,i.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,i.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let o=n.scene.screenSpaceCameraController.tiltEventTypes;o&&(i.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(o)?[...o]:o);let s=n.scene.screenSpaceCameraController.zoomEventTypes;return s&&(i.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(s)?[...s]:s),i}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { CesiumCollection, CesiumCollectionItem, Collection, CollectionEventType, EventHandler, NonFunction, Tag, WithTag } from './collection/index.cjs';
|
|
2
|
-
export { H as HybridTerrainProvider, T as TerrainArea, a as
|
|
3
|
-
export {
|
|
2
|
+
export { H as HybridTerrainProvider, T as TerrainArea, a as TileRange } from './hybrid-terrain-provider-BGwAgH9H.cjs';
|
|
3
|
+
export { TerrainAreaCollection, computeRectangle } from './terrain/index.cjs';
|
|
4
4
|
export { TerrainVisualizer, isGetterOnly, syncCamera } from './utils/index.cjs';
|
|
5
5
|
export { cloneViewer } from './viewer/index.cjs';
|
|
6
6
|
import 'cesium';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { CesiumCollection, CesiumCollectionItem, Collection, CollectionEventType, EventHandler, NonFunction, Tag, WithTag } from './collection/index.js';
|
|
2
|
-
export { H as HybridTerrainProvider, T as TerrainArea, a as
|
|
3
|
-
export {
|
|
2
|
+
export { H as HybridTerrainProvider, T as TerrainArea, a as TileRange } from './hybrid-terrain-provider-BGwAgH9H.js';
|
|
3
|
+
export { TerrainAreaCollection, computeRectangle } from './terrain/index.js';
|
|
4
4
|
export { TerrainVisualizer, isGetterOnly, syncCamera } from './utils/index.js';
|
|
5
5
|
export { cloneViewer } from './viewer/index.js';
|
|
6
6
|
import 'cesium';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t,b as m,c as p,d as n}from"./chunk-
|
|
1
|
+
import{a as t,b as m,c as p,d as n}from"./chunk-NBGR2C26.js";import{a}from"./chunk-STARYORM.js";import{a as r,b as o,c as i}from"./chunk-RJNF3DQR.js";import{a as e}from"./chunk-YZ7AUGIO.js";export{i as Collection,n as HybridTerrainProvider,m as TerrainArea,p as TerrainAreaCollection,r as TerrainVisualizer,a as cloneViewer,t as computeRectangle,o as isGetterOnly,e as syncCamera};
|
package/dist/terrain/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var v=Object.defineProperty;var
|
|
1
|
+
"use strict";var v=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var R=(n,r)=>{for(var e in r)v(n,e,{get:r[e],enumerable:!0})},C=(n,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of _(r))!y.call(n,t)&&t!==e&&v(n,t,{get:()=>r[t],enumerable:!(i=A(r,t))||i.enumerable});return n};var x=n=>C(v({},"__esModule",{value:!0}),n);var w={};R(w,{HybridTerrainProvider:()=>d,TerrainArea:()=>o,TerrainAreaCollection:()=>s,computeRectangle:()=>c});module.exports=x(w);var l=require("cesium");var p=require("cesium");var T=require("cesium");function c(n,r){if(r.size===0)return new T.Rectangle;let e=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY,u=Array.from(r.keys()),m=Math.min(...u),h=r.get(m);if(h){let{start:f,end:g}=h,b=n.tileXYToRectangle(f.x,f.y,m),P=n.tileXYToRectangle(g.x,g.y,m);e=Math.min(b.west,e),i=Math.min(P.south,i),t=Math.max(P.east,t),a=Math.max(b.north,a)}return new T.Rectangle(e,i,t,a)}var o=class{_terrainProvider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(r){this._terrainProvider=r.terrainProvider,this._tileRanges=r.tileRanges,this._credit=r.credit||"custom",this._isCustom=r.isCustom!==void 0?r.isCustom:!0,this._rectangle=c(r.terrainProvider.tilingScheme,r.tileRanges),r.tileRanges.forEach((e,i)=>{this._terrainProvider.availability?.addAvailableTileRange(i,e.start.x,e.start.y,e.end.x,e.end.y)}),this._ready=!0}contains(r,e,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let t=this._tileRanges.get(i);return r>=t.start.x&&r<=t.end.x&&e>=t.start.y&&e<=t.end.y}requestTileGeometry(r,e,i,t){if(!(!this._ready||!this.contains(r,e,i)))return this._terrainProvider.requestTileGeometry(r,e,i,t)}getTileDataAvailable(r,e,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let t=this._tileRanges.get(i);return r>=t.start.x&&r<=t.end.x&&e>=t.start.y&&e<=t.end.y}get isCustom(){return this._isCustom}get credit(){return this._credit}get terrainProvider(){return this._terrainProvider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(r=>{async function n(e,i,t){let a=t?.credit||"custom",u=await p.CesiumTerrainProvider.fromUrl(e,{...t,credit:a});return new r({terrainProvider:u,tileRanges:i,credit:a})}r.fromUrl=n})(o||={});var s=class extends Array{add(r){if(Array.isArray(r)){for(let i of r)this.add(i);return this.length}let e;return r instanceof o?e=r:e=new o(r),this.push(e)}remove(r){if(Array.isArray(r))return r.forEach(i=>this.remove(i)),this;let e=this.indexOf(r);return e>=0&&this.splice(e,1),this}removeAll(){this.length=0}};var d=class n{_terrainAreas=new s;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(r,e,i){this._terrainProvider=r,this._fallbackProvider=e,this._tilingScheme=r.tilingScheme,this._terrainAreas=new s(...i),this._availability=r.availability,this._ready=!0}static async create(r){try{let e;typeof r.terrainProvider=="string"?e=await l.CesiumTerrainProvider.fromUrl(r.terrainProvider,{requestVertexNormals:!0}):e=r.terrainProvider;let i;r.fallbackProvider?typeof r.fallbackProvider=="string"?i=await l.CesiumTerrainProvider.fromUrl(r.fallbackProvider,{requestVertexNormals:!0}):i=r.fallbackProvider:i=new l.EllipsoidTerrainProvider;let t=[];for(let a of r.terrainAreas){let u=typeof a.terrainProvider=="string"?await l.CesiumTerrainProvider.fromUrl(a.terrainProvider,{requestVertexNormals:!0}):a.terrainProvider;t.push(new o({terrainProvider:u,tileRanges:a.tileRanges,credit:a.credit,isCustom:a.isCustom}))}return new n(e,i,t)}catch(e){throw console.error("Failed to initialize HybridTerrainProvider:",e),e}}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(r,e,i){return this._terrainProvider.loadTileDataAvailability(r,e,i)}getLevelMaximumGeometricError(r){return this._terrainProvider.getLevelMaximumGeometricError(r)}requestTileGeometry(r,e,i,t){if(this._ready){for(let a of this._terrainAreas)if(a.contains(r,e,i))return a.requestTileGeometry(r,e,i,t);return this._terrainProvider.getTileDataAvailable(r,e,i)?this._terrainProvider.requestTileGeometry(r,e,i,t):this._fallbackProvider.requestTileGeometry(r,e,i,t)}}getTileDataAvailable(r,e,i){for(let t of this._terrainAreas)if(t.contains(r,e,i))return t.getTileDataAvailable(r,e,i);return this._terrainProvider.getTileDataAvailable(r,e,i)}};(r=>{async function n(e,i,t){let a=await l.CesiumTerrainProvider.fromUrl(e,{credit:"custom"});return r.create({terrainAreas:[{terrainProvider:a,tileRanges:t,credit:"custom"}],terrainProvider:i,fallbackProvider:new l.EllipsoidTerrainProvider})}r.createOverlay=n})(d||={});
|
package/dist/terrain/index.d.cts
CHANGED
|
@@ -1,22 +1,46 @@
|
|
|
1
|
-
import { T as TerrainArea } from '../hybrid-terrain-provider-
|
|
2
|
-
export { H as HybridTerrainProvider
|
|
3
|
-
import 'cesium';
|
|
1
|
+
import { a as TileRange, T as TerrainArea } from '../hybrid-terrain-provider-BGwAgH9H.cjs';
|
|
2
|
+
export { H as HybridTerrainProvider } from '../hybrid-terrain-provider-BGwAgH9H.cjs';
|
|
3
|
+
import { TilingScheme, Rectangle } from 'cesium';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Calculates a bounding rectangle that encompasses all the specified tile ranges.
|
|
7
|
+
* @param tilingScheme The tiling scheme to use for calculation.
|
|
8
|
+
* @param from Tile ranges to calculate from.
|
|
9
|
+
*/
|
|
10
|
+
declare function computeRectangle(tilingScheme: TilingScheme, from: Map<number, TileRange>): Rectangle;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @extends Array
|
|
14
|
+
* @class
|
|
15
|
+
* Collection-like Extended Array Class of `TerrainArea`.
|
|
16
|
+
*/
|
|
17
|
+
declare class TerrainAreaCollection extends Array<TerrainArea> {
|
|
6
18
|
/**
|
|
7
19
|
* Adds a new terrain area to the collection.
|
|
8
20
|
* @param area A TerrainArea instance or constructor options
|
|
9
|
-
* @returns
|
|
21
|
+
* @returns The index of the added item
|
|
22
|
+
*/
|
|
23
|
+
add(area: TerrainArea | TerrainArea.ConstructorOptions): number;
|
|
24
|
+
/**
|
|
25
|
+
* Adds terrain areas to the collection.
|
|
26
|
+
* @param areas An array of TerrainArea instance or constructor options
|
|
27
|
+
* @returns The index of the added item
|
|
10
28
|
*/
|
|
11
|
-
add(
|
|
29
|
+
add(areas: (TerrainArea | TerrainArea.ConstructorOptions)[]): number;
|
|
12
30
|
/**
|
|
13
31
|
* Removes a terrain area from the collection.
|
|
32
|
+
* @param area The terrain area to remove.
|
|
33
|
+
*/
|
|
34
|
+
remove(area: TerrainArea): this;
|
|
35
|
+
/**
|
|
36
|
+
* Removes multiple terrain areas from the collection.
|
|
37
|
+
* @param areas The terrain areas to remove.
|
|
14
38
|
*/
|
|
15
|
-
remove(
|
|
39
|
+
remove(areas: TerrainArea[]): this;
|
|
16
40
|
/**
|
|
17
41
|
* Clears all terrain areas.
|
|
18
42
|
*/
|
|
19
|
-
|
|
43
|
+
removeAll(): void;
|
|
20
44
|
}
|
|
21
45
|
|
|
22
|
-
export { TerrainArea,
|
|
46
|
+
export { TerrainArea, TerrainAreaCollection, TileRange, computeRectangle };
|
package/dist/terrain/index.d.ts
CHANGED
|
@@ -1,22 +1,46 @@
|
|
|
1
|
-
import { T as TerrainArea } from '../hybrid-terrain-provider-
|
|
2
|
-
export { H as HybridTerrainProvider
|
|
3
|
-
import 'cesium';
|
|
1
|
+
import { a as TileRange, T as TerrainArea } from '../hybrid-terrain-provider-BGwAgH9H.js';
|
|
2
|
+
export { H as HybridTerrainProvider } from '../hybrid-terrain-provider-BGwAgH9H.js';
|
|
3
|
+
import { TilingScheme, Rectangle } from 'cesium';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Calculates a bounding rectangle that encompasses all the specified tile ranges.
|
|
7
|
+
* @param tilingScheme The tiling scheme to use for calculation.
|
|
8
|
+
* @param from Tile ranges to calculate from.
|
|
9
|
+
*/
|
|
10
|
+
declare function computeRectangle(tilingScheme: TilingScheme, from: Map<number, TileRange>): Rectangle;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @extends Array
|
|
14
|
+
* @class
|
|
15
|
+
* Collection-like Extended Array Class of `TerrainArea`.
|
|
16
|
+
*/
|
|
17
|
+
declare class TerrainAreaCollection extends Array<TerrainArea> {
|
|
6
18
|
/**
|
|
7
19
|
* Adds a new terrain area to the collection.
|
|
8
20
|
* @param area A TerrainArea instance or constructor options
|
|
9
|
-
* @returns
|
|
21
|
+
* @returns The index of the added item
|
|
22
|
+
*/
|
|
23
|
+
add(area: TerrainArea | TerrainArea.ConstructorOptions): number;
|
|
24
|
+
/**
|
|
25
|
+
* Adds terrain areas to the collection.
|
|
26
|
+
* @param areas An array of TerrainArea instance or constructor options
|
|
27
|
+
* @returns The index of the added item
|
|
10
28
|
*/
|
|
11
|
-
add(
|
|
29
|
+
add(areas: (TerrainArea | TerrainArea.ConstructorOptions)[]): number;
|
|
12
30
|
/**
|
|
13
31
|
* Removes a terrain area from the collection.
|
|
32
|
+
* @param area The terrain area to remove.
|
|
33
|
+
*/
|
|
34
|
+
remove(area: TerrainArea): this;
|
|
35
|
+
/**
|
|
36
|
+
* Removes multiple terrain areas from the collection.
|
|
37
|
+
* @param areas The terrain areas to remove.
|
|
14
38
|
*/
|
|
15
|
-
remove(
|
|
39
|
+
remove(areas: TerrainArea[]): this;
|
|
16
40
|
/**
|
|
17
41
|
* Clears all terrain areas.
|
|
18
42
|
*/
|
|
19
|
-
|
|
43
|
+
removeAll(): void;
|
|
20
44
|
}
|
|
21
45
|
|
|
22
|
-
export { TerrainArea,
|
|
46
|
+
export { TerrainArea, TerrainAreaCollection, TileRange, computeRectangle };
|
package/dist/terrain/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r,b as
|
|
1
|
+
import{a as r,b as e,c as o,d as t}from"../chunk-NBGR2C26.js";export{t as HybridTerrainProvider,e as TerrainArea,o as TerrainAreaCollection,r as computeRectangle};
|
package/dist/utils/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var I=Object.defineProperty;var
|
|
1
|
+
"use strict";var I=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var S=(n,e)=>{for(var t in e)I(n,t,{get:e[t],enumerable:!0})},j=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of O(e))!V.call(n,r)&&r!==t&&I(n,r,{get:()=>e[r],enumerable:!(i=M(e,r))||i.enumerable});return n};var z=n=>j(I({},"__esModule",{value:!0}),n);var F={};S(F,{TerrainVisualizer:()=>v,isGetterOnly:()=>y,syncCamera:()=>L});module.exports=z(F);var s=require("cesium");var f=require("cesium");var E=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(a=>a(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache(){this._valuesCache=null}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let r=this.collection.remove(e);return r&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),r}if(Array.isArray(e)){if(e.length===0)return!1;let r=!1;for(let a of e)this.remove(a)&&(r=!0);return r}let t=this.get(e);if(t.length===0)return!1;let i=!1;for(let r of t)this.remove(r)&&(i=!0);return i}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof f.EntityCollection)return this.collection.values;{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));return e}}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,f.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,f.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,f.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let a of r)if(e in a&&typeof a[e]!="function"){if(y(a,e))throw Error(`setProperty(${a}, ${e}) failed; The property is readonly.`);a[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,a)=>e(r,a))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},x=E;var v=class n{_viewer;_collection;_hybridTerrain;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",s.Color.RED],["default",s.Color.BLUE],["fallback",s.Color.GRAY],["grid",s.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new x({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._hybridTerrain=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._hybridTerrain)return;this._collection.remove(n.tag.grid),this._level=e;let t=this._hybridTerrain.tilingScheme;this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new s.TileCoordinatesImageryProvider({tilingScheme:t,color:s.Color.YELLOW})));let i=(o,l,d)=>{if(this._hybridTerrain){for(let m of this._hybridTerrain.terrainAreas)if(m.contains(o,l,d))return m.isCustom?this._colors.get("custom")||s.Color.RED:this._colors.get("default")||s.Color.BLUE;if(this._hybridTerrain.getTileDataAvailable(o,l,d))return this._colors.get("default")||s.Color.BLUE}return this._colors.get("fallback")||s.Color.TRANSPARENT},r=this._getVisibleRectangle();if(!r)return;function a(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(!a(r)){console.warn("Invalid visible rectangle detected, skipping grid display");return}try{let o=t.positionToTileXY(s.Rectangle.northwest(r),e),l=t.positionToTileXY(s.Rectangle.southeast(r),e);if(!o||!l)return;let d=100,m=Math.min(l.x-o.x+1,d),b=Math.min(l.y-o.y+1,d);for(let c=o.x;c<=o.x+m-1;c++)for(let h=o.y;h<=o.y+b-1;h++)try{let u=t.tileXYToRectangle(c,h,e);if(!a(u)){console.warn(`Invalid rectangle for tile (${c}, ${h}, ${e}), skipping`);continue}let T=i(c,h,e),g=n.createRectangle(u,T.withAlpha(.3));g.properties?.addProperty("tileX",c),g.properties?.addProperty("tileY",h),g.properties?.addProperty("tileLevel",e),this._collection.add(g,n.tag.grid)}catch(u){console.warn(`Error creating tile (${c}, ${h}, ${e}): ${u.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.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,a){return new s.Entity({rectangle:{coordinates:r,material:a,heightReference:s.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,a,o){let l=o?.tag||"terrain_area_visualization",d=o?.color||s.Color.RED,m=o?.maxTilesToShow||100,b=o?.show??!0,c=o?.alpha||.7,h=o?.tileAlpha||.2,u=new x({collection:a.entities,tag:l}),{rectangle:T}=r;if(u.add(i.createRectangle(T,d.withAlpha(c)),l),b&&r.tileRanges.size>0){let{tilingScheme:g}=r.terrainProvider,_=0;r.tileRanges.forEach((p,A)=>{for(let C=p.start.x;C<=p.end.x&&_<m;C++)for(let w=p.start.y;w<=p.end.y&&_<m;w++){let P=g.tileXYToRectangle(C,w,A);u.add(e(P,d.withAlpha(h)),`${l}_tile`),_++}})}return u}i.visualize=t})(v||={});function y(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var R=require("cesium");function L(n,e){if((0,R.defined)(n)&&(0,R.defined)(e)){let{camera:t}=n;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Viewer, Color, EntityCollection, Entity, Rectangle } from 'cesium';
|
|
2
|
-
import { H as HybridTerrainProvider, T as TerrainArea
|
|
2
|
+
import { H as HybridTerrainProvider, T as TerrainArea } from '../hybrid-terrain-provider-BGwAgH9H.cjs';
|
|
3
3
|
import { Collection } from '../collection/index.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -120,7 +120,7 @@ declare namespace TerrainVisualizer {
|
|
|
120
120
|
* @param options Visualization options.
|
|
121
121
|
* @returns Collection of created entities.
|
|
122
122
|
*/
|
|
123
|
-
function visualize(
|
|
123
|
+
function visualize(area: TerrainArea, viewer: Viewer, options?: Options): Collection<EntityCollection, Entity>;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/**
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Viewer, Color, EntityCollection, Entity, Rectangle } from 'cesium';
|
|
2
|
-
import { H as HybridTerrainProvider, T as TerrainArea
|
|
2
|
+
import { H as HybridTerrainProvider, T as TerrainArea } from '../hybrid-terrain-provider-BGwAgH9H.js';
|
|
3
3
|
import { Collection } from '../collection/index.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -120,7 +120,7 @@ declare namespace TerrainVisualizer {
|
|
|
120
120
|
* @param options Visualization options.
|
|
121
121
|
* @returns Collection of created entities.
|
|
122
122
|
*/
|
|
123
|
-
function visualize(
|
|
123
|
+
function visualize(area: TerrainArea, viewer: Viewer, options?: Options): Collection<EntityCollection, Entity>;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/**
|
package/dist/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"../chunk-
|
|
1
|
+
import{a,b}from"../chunk-RJNF3DQR.js";import{a as c}from"../chunk-YZ7AUGIO.js";export{a as TerrainVisualizer,b as isGetterOnly,c as syncCamera};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juun-roh/cesium-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Utilities to handle Cesium classes easier.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Cesium",
|
|
@@ -67,30 +67,29 @@
|
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@changesets/cli": "^2.29.
|
|
70
|
+
"@changesets/cli": "^2.29.2",
|
|
71
71
|
"@commitlint/cli": "^19.8.0",
|
|
72
72
|
"@commitlint/config-conventional": "^19.8.0",
|
|
73
73
|
"@commitlint/cz-commitlint": "^19.8.0",
|
|
74
74
|
"@commitlint/format": "^19.8.0",
|
|
75
75
|
"@commitlint/types": "^19.8.0",
|
|
76
|
-
"@eslint/js": "^9.
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
78
|
-
"@typescript-eslint/parser": "^8.
|
|
79
|
-
"@vitest/coverage-v8": "3.1.
|
|
76
|
+
"@eslint/js": "^9.25.1",
|
|
77
|
+
"@typescript-eslint/eslint-plugin": "^8.31.1",
|
|
78
|
+
"@typescript-eslint/parser": "^8.31.1",
|
|
79
|
+
"@vitest/coverage-v8": "3.1.2",
|
|
80
80
|
"cesium": "^1.128.0",
|
|
81
|
-
"eslint": "^9.
|
|
82
|
-
"eslint-plugin-jsdoc": "^50.6.
|
|
81
|
+
"eslint": "^9.25.1",
|
|
82
|
+
"eslint-plugin-jsdoc": "^50.6.11",
|
|
83
83
|
"eslint-plugin-prettier": "^5.2.6",
|
|
84
84
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
85
85
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
86
86
|
"husky": "^9.1.7",
|
|
87
87
|
"rimraf": "^6.0.1",
|
|
88
88
|
"tsup": "^8.4.0",
|
|
89
|
-
"typedoc": "^0.28.
|
|
90
|
-
"typedoc-material-theme": "^1.4.0",
|
|
89
|
+
"typedoc": "^0.28.3",
|
|
91
90
|
"typescript": "^5.8.3",
|
|
92
|
-
"vite": "^6.
|
|
93
|
-
"vitest": "^3.1.
|
|
91
|
+
"vite": "^6.3.3",
|
|
92
|
+
"vitest": "^3.1.2"
|
|
94
93
|
},
|
|
95
94
|
"scripts": {
|
|
96
95
|
"build": "tsup",
|
package/dist/chunk-C52KJ2WP.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{GeographicTilingScheme as h,Rectangle as c}from"cesium";var o=class{_rectangle;_tilingScheme;_tileRanges;_levels;constructor(e,r){if(this._tilingScheme=r||new h,this._rectangle=new c,this._tileRanges=new Map,this._levels=new Set,e.type==="rectangle"&&e.rectangle)this._rectangle=c.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 c.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=c.MAX_VALUE;return}let n=Math.min(...a),u=this._tileRanges.get(n);if(u){let{start:m,end:v}=u,b=this._tilingScheme.tileXYToRectangle(m.x,m.y,n),T=this._tilingScheme.tileXYToRectangle(v.x,v.y,n);e=Math.min(b.west,e),r=Math.min(T.south,r),t=Math.max(T.east,t),i=Math.max(b.north,i)}this._rectangle=new c(e,r,t,i)}};(r=>{function l(t,i,a,n=new h){let u=new Map;return u.set(a,{start:{x:t,y:i},end:{x:t,y:i}}),new r({type:"tileRange",tileRanges:u},n)}r.fromTile=l;function e(t,i=new h){return new r({type:"rectangle",rectangle:c.clone(t)},i)}r.fromRectangle=e})(o||={});import{CesiumTerrainProvider as p}from"cesium";var s=class l{_provider;_bounds;_levels;_ready=!1;_credit;_isCustom;constructor(e,r){this._bounds=e.bounds instanceof o?e.bounds:new o(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 p.fromUrl(e.provider,{requestVertexNormals:!0,credit:e.credit||"custom"}):r=e.provider,new l(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 l(r,t,i,a="custom"){let n=new o({type:"tileRange",tileRanges:t});return await e.create({provider:r,bounds:n,levels:i||Object.keys(t).map(m=>parseInt(m)),credit:a})}e.fromUrl=l})(s||={});var d=class extends Array{async add(e){let r;return e instanceof s?r=e:r=await s.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}};import{CesiumTerrainProvider as _,EllipsoidTerrainProvider as f,GeographicTilingScheme as P}from"cesium";var g=class l{_terrainAreas=new d;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e,r,t){this._terrainProvider=e,this._fallbackProvider=r,this._tilingScheme=e.tilingScheme||new P,this._terrainAreas=new d(...t),this._availability=e.availability,this._ready=!0}static async create(e){try{let r;typeof e.terrainProvider=="string"?r=await _.fromUrl(e.terrainProvider,{requestVertexNormals:!0}):r=e.terrainProvider;let t;e.fallbackProvider?typeof e.fallbackProvider=="string"?t=await _.fromUrl(e.fallbackProvider,{requestVertexNormals:!0}):t=e.fallbackProvider:t=new f;let i=[];for(let a of e.terrainAreas){let n=await s.create(a);i.push(n)}return new l(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 l(r,t,i,a){return e.create({terrainAreas:[{provider:r,bounds:{type:"tileRange",tileRanges:i},levels:a||Object.keys(i).map(n=>parseInt(n)),credit:"custom"}],terrainProvider:t,fallbackProvider:new f})}e.createOverlay=l})(g||={});export{o as a,s as b,d as c,g as d};
|