@juun-roh/cesium-utils 0.4.5 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +24 -12
- package/dist/index.d.ts +24 -12
- package/dist/index.js +1 -1
- package/dist/terrain/dev/index.cjs +1 -1
- package/dist/terrain/dev/index.js +1 -1
- package/dist/terrain/index.cjs +1 -1
- package/dist/terrain/index.js +1 -1
- package/package.json +13 -13
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var G=(n,e)=>{for(var t in e)_(n,t,{get:e[t],enumerable:!0})},V=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of k(e))!D.call(n,r)&&r!==t&&_(n,r,{get:()=>e[r],enumerable:!(i=j(e,r))||i.enumerable});return n};var N=n=>V(_({},"__esModule",{value:!0}),n);var B={};G(B,{Collection:()=>P,Highlight:()=>O,HybridTerrainProvider:()=>w,SilhouetteHighlight:()=>m,SurfaceHighlight:()=>p,cloneViewer:()=>S,syncCamera:()=>y});module.exports=N(B);var d=require("cesium");function C(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}function b(n,e,t){let i=e.split(".");for(let l of i)if(L(l))return{success:!1,reason:"dangerous-property",message:`Property path contains dangerous property name: "${l}"`};let r=n,s=0;for(;s<i.length-1;s++){let l=i[s];if(!r||typeof r!="object"||!Object.prototype.hasOwnProperty.call(r,l))return{success:!1,reason:"invalid-path",message:`Property path "${e}" does not exist or contains inherited properties`};if(r=r[l],!r||typeof r!="object"||r===Object.prototype)return{success:!1,reason:"invalid-path",message:`Cannot traverse path "${e}" - reached non-object or prototype`}}if(s!==i.length-1)return{success:!1,reason:"invalid-path",message:`Failed to traverse property path "${e}"`};let a=i[i.length-1];if(L(a))return{success:!1,reason:"dangerous-property",message:`Cannot set dangerous property "${a}"`};if(!r||typeof r!="object"||r===Object.prototype)return{success:!1,reason:"invalid-path",message:"Cannot set property on invalid target"};if(a in r){if(typeof r[a]=="function")return{success:!1,reason:"function-property",message:`Cannot set function property "${a}"`};if(C(r,a))return{success:!1,reason:"read-only",message:`Cannot set read-only property "${e}"`}}return r[a]=t,{success:!0}}var F=["__proto__","constructor","prototype"];function L(n){return F.includes(n)}var T=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof d.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get tags(){return Array.from(this._tagMap.keys())}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,d.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,d.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,d.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let s of r){let a=b(s,e,t);if(!a.success&&a.reason==="read-only")throw Error(`Cannot set read-only property '${e}' on ${s.constructor.name}`)}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,s)=>e(r,s))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(s=>s(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof d.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof d.PrimitiveCollection?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof d.DataSourceCollection?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof d.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}},P=T;var h=require("cesium");var c=require("cesium"),m=class{_color=c.Color.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=c.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=c.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}show(e,t){if((0,c.defined)(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{if(e instanceof c.Cesium3DTileFeature)this._silhouette.uniforms.color=t?.color||this._color,this._silhouette.selected.push(e);else{if(!e.model)return;this._entity=e,e.model.silhouetteSize=new c.ConstantProperty(t?.width||2),e.model.silhouetteColor=new c.ConstantProperty(t?.color||this._color)}this._currentObject=e,this._currentOptions=t?{...t}:void 0}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0}}}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&c.Color.equals(e.color||this._color,t.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new c.ConstantProperty(c.Color.TRANSPARENT),this._entity.model.silhouetteSize=new c.ConstantProperty(0),this._entity=void 0)}};var o=require("cesium"),p=class{_color=o.Color.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new o.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}show(e,t){if(!(!(0,o.defined)(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof o.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof o.GroundPrimitive)this._update(e,t);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=e,this._currentOptions=t?{...t}:void 0,this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0;return}}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&o.Color.equals(e.color||this._color,t.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof o.Entity){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let r;i.positions.length>0&&!o.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new o.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new o.PolygonGraphics({hierarchy:i,material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||o.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let r=e.polyline.width?.getValue();this._entity.polyline=new o.PolylineGraphics({positions:i,material:t.color,width:r+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let r=[o.Cartesian3.fromRadians(i.west,i.north),o.Cartesian3.fromRadians(i.east,i.north),o.Cartesian3.fromRadians(i.east,i.south),o.Cartesian3.fromRadians(i.west,i.south),o.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new o.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new o.RectangleGraphics({coordinates:i,material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND}))}}else if(e instanceof o.GroundPrimitive){let i=e.geometryInstances,r=Array.isArray(i)?i[0]:i;if(!r.geometry.attributes.position)return;let s=r.geometry.attributes.position.values,a=[];for(let l=0;l<s.length;l+=3)a.push(new o.Cartesian3(s[l],s[l+1],s[l+2]));t.outline?this._entity.polyline=new o.PolylineGraphics({positions:a,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new o.PolygonGraphics({hierarchy:new o.PolygonHierarchy(a),material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND,classificationType:o.ClassificationType.BOTH})}}};var E=class n{static instances=new WeakMap;_surface;_silhouette;_color=h.Color.RED;constructor(e){this._surface=new p(e),this._silhouette=new m(e),this._surface.color=this._color,this._silhouette.color=this._color}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,i=n.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),n.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if((0,h.defined)(i))return i instanceof h.Cesium3DTileFeature?this._silhouette.show(i,t):i instanceof h.Entity&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if((0,h.defined)(e)){if(e instanceof h.Entity||e instanceof h.Cesium3DTileFeature||e instanceof h.GroundPrimitive)return e;if(e.id instanceof h.Entity)return e.id;if(e.primitive instanceof h.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}},O=E;var v=require("cesium"),g=class n{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;_errorEvent;_removeEventListeners;_hasWaterMask;_hasVertexNormals;_credit;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new v.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._hasWaterMask=this._defaultProvider.hasWaterMask||this._regions.some(i=>i.provider.hasWaterMask),this._hasVertexNormals=this._defaultProvider.hasVertexNormals||this._regions.some(i=>i.provider.hasVertexNormals),e.credit?this._credit=typeof e.credit=="string"?new v.Credit(e.credit):e.credit:this._credit=this._defaultProvider.credit,this._errorEvent=new v.Event,this._removeEventListeners=[];let t=new Set;for(let i of this._regions)t.has(i.provider)||(t.add(i.provider),this._removeEventListeners.push(i.provider.errorEvent.addEventListener(r=>{this._errorEvent.raiseEvent(r)})));t.has(this._defaultProvider)||this._removeEventListeners.push(this._defaultProvider.errorEvent.addEventListener(i=>{this._errorEvent.raiseEvent(i)})),t.has(this._fallbackProvider)||this._removeEventListeners.push(this._fallbackProvider.errorEvent.addEventListener(i=>{this._errorEvent.raiseEvent(i)})),this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._credit}get errorEvent(){return this._errorEvent}get hasWaterMask(){return this._hasWaterMask}get hasVertexNormals(){return this._hasVertexNormals}loadTileDataAvailability(e,t,i){for(let r of this._regions)if(n.TerrainRegion.contains(r,e,t,i))return r.provider.loadTileDataAvailability(e,t,i);return this._defaultProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){let t=this._defaultProvider.getLevelMaximumGeometricError(e);for(let i of this._regions){let r=i.provider.getLevelMaximumGeometricError(e);r>t&&(t=r)}return t}requestTileGeometry(e,t,i,r){if(this._ready){for(let s of this._regions)if(n.TerrainRegion.contains(s,e,t,i))return s.provider.requestTileGeometry(e,t,i,r);return this._defaultProvider.getTileDataAvailable(e,t,i)?this._defaultProvider.requestTileGeometry(e,t,i,r):this._fallbackProvider.requestTileGeometry(e,t,i,r)}}getTileDataAvailable(e,t,i){for(let r of this._regions)if(n.TerrainRegion.contains(r,e,t,i))return!0;return this._defaultProvider.getTileDataAvailable(e,t,i)}destroy(){for(let e of this._removeEventListeners)e();this._removeEventListeners.length=0,this._ready=!1}};(t=>{function n(i,r,s){return new t({regions:i.map(a=>({...a})),defaultProvider:r,fallbackProvider:s})}t.fromTileRanges=n;let e;(r=>{function i(s,a,l,f){if(s.levels&&!s.levels.includes(f))return!1;if(s.tiles){let u=s.tiles.get(f);if(!u)return!1;let[H,I]=Array.isArray(u.x)?u.x:[u.x,u.x],[M,A]=Array.isArray(u.y)?u.y:[u.y,u.y];return a>=H&&a<=I&&l>=M&&l<=A}return!1}r.contains=i})(e=t.TerrainRegion||={})})(g||={});var w=g;var R=require("cesium");var x=require("cesium");function y(n,e){if((0,x.defined)(n)&&(0,x.defined)(e)){let{camera:t}=n;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}function S(n,e,t){let i={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},r=new R.Viewer(e,{...i,...t});y(n,r);let s=n.imageryLayers;r.imageryLayers.removeAll();for(let f=0;f<s.length;f++){let u=s.get(f);r.imageryLayers.addImageryProvider(u.imageryProvider,f)}r.clock.startTime=n.clock.startTime.clone(),r.clock.stopTime=n.clock.stopTime.clone(),r.clock.currentTime=n.clock.currentTime.clone(),r.clock.multiplier=n.clock.multiplier,r.clock.clockStep=n.clock.clockStep,r.clock.clockRange=n.clock.clockRange,r.clock.shouldAnimate=n.clock.shouldAnimate,r.scene.globe.enableLighting=n.scene.globe.enableLighting,r.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,r.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let a=n.scene.screenSpaceCameraController.tiltEventTypes;a&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(a)?[...a]:a);let l=n.scene.screenSpaceCameraController.zoomEventTypes;return l&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(l)?[...l]:l),r}
|
|
1
|
+
"use strict";var E=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var q=(n,e)=>{for(var t in e)E(n,t,{get:e[t],enumerable:!0})},z=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of $(e))!W.call(n,r)&&r!==t&&E(n,r,{get:()=>e[r],enumerable:!(i=H(e,r))||i.enumerable});return n};var K=n=>z(E({},"__esModule",{value:!0}),n),D=(n,e,t,i)=>{for(var r=i>1?void 0:i?H(e,t):e,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=(i?s(e,t,r):s(r))||r);return i&&r&&E(e,t,r),r};var Q={};q(Q,{Collection:()=>S,Highlight:()=>M,HybridTerrainProvider:()=>k,SilhouetteHighlight:()=>p,SurfaceHighlight:()=>v,cloneViewer:()=>I,syncCamera:()=>P});module.exports=K(Q);var m=require("cesium");function w(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}function O(n,e,t){let i=e.split(".");for(let a of i)if(j(a))return{success:!1,reason:"dangerous-property",message:`Property path contains dangerous property name: "${a}"`};let r=n,o=0;for(;o<i.length-1;o++){let a=i[o];if(!r||typeof r!="object"||!Object.prototype.hasOwnProperty.call(r,a))return{success:!1,reason:"invalid-path",message:`Property path "${e}" does not exist or contains inherited properties`};if(r=r[a],!r||typeof r!="object"||r===Object.prototype)return{success:!1,reason:"invalid-path",message:`Cannot traverse path "${e}" - reached non-object or prototype`}}if(o!==i.length-1)return{success:!1,reason:"invalid-path",message:`Failed to traverse property path "${e}"`};let s=i[i.length-1];if(j(s))return{success:!1,reason:"dangerous-property",message:`Cannot set dangerous property "${s}"`};if(!r||typeof r!="object"||r===Object.prototype)return{success:!1,reason:"invalid-path",message:"Cannot set property on invalid target"};if(s in r){if(typeof r[s]=="function")return{success:!1,reason:"function-property",message:`Cannot set function property "${s}"`};if(w(r,s))return{success:!1,reason:"read-only",message:`Cannot set read-only property "${e}"`}}return r[s]=t,{success:!0}}var U=["__proto__","constructor","prototype"];function j(n){return U.includes(n)}var L=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof m.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get tags(){return Array.from(this._tagMap.keys())}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,m.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,m.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,m.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r){let s=O(o,e,t);if(!s.success&&s.reason==="read-only")throw Error(`Cannot set read-only property '${e}' on ${o.constructor.name}`)}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,o)=>e(r,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof m.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof m.PrimitiveCollection?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof m.DataSourceCollection?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof m.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}},S=L;var u=require("cesium");var d=require("cesium"),p=class{_color=d.Color.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=d.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=d.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}show(e,t){if((0,d.defined)(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{if(e instanceof d.Cesium3DTileFeature)this._silhouette.uniforms.color=t?.color||this._color,this._silhouette.selected.push(e);else{if(!e.model)return;this._entity=e,e.model.silhouetteSize=new d.ConstantProperty(t?.width||2),e.model.silhouetteColor=new d.ConstantProperty(t?.color||this._color)}this._currentObject=e,this._currentOptions=t?{...t}:void 0}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0}}}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&d.Color.equals(e.color||this._color,t.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new d.ConstantProperty(d.Color.TRANSPARENT),this._entity.model.silhouetteSize=new d.ConstantProperty(0),this._entity=void 0)}};var l=require("cesium"),v=class{_color=l.Color.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new l.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}show(e,t){if(!(!(0,l.defined)(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof l.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof l.GroundPrimitive)this._update(e,t);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=e,this._currentOptions=t?{...t}:void 0,this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0;return}}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&l.Color.equals(e.color||this._color,t.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof l.Entity){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let r;i.positions.length>0&&!l.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new l.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new l.PolygonGraphics({hierarchy:i,material:t.color,heightReference:l.HeightReference.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||l.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let r=e.polyline.width?.getValue();this._entity.polyline=new l.PolylineGraphics({positions:i,material:t.color,width:r+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let r=[l.Cartesian3.fromRadians(i.west,i.north),l.Cartesian3.fromRadians(i.east,i.north),l.Cartesian3.fromRadians(i.east,i.south),l.Cartesian3.fromRadians(i.west,i.south),l.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new l.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new l.RectangleGraphics({coordinates:i,material:t.color,heightReference:l.HeightReference.CLAMP_TO_GROUND}))}}else if(e instanceof l.GroundPrimitive){let i=e.geometryInstances,r=Array.isArray(i)?i[0]:i;if(!r.geometry.attributes.position)return;let o=r.geometry.attributes.position.values,s=[];for(let a=0;a<o.length;a+=3)s.push(new l.Cartesian3(o[a],o[a+1],o[a+2]));t.outline?this._entity.polyline=new l.PolylineGraphics({positions:s,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new l.PolygonGraphics({hierarchy:new l.PolygonHierarchy(s),material:t.color,heightReference:l.HeightReference.CLAMP_TO_GROUND,classificationType:l.ClassificationType.BOTH})}}};var A=class n{static instances=new WeakMap;_surface;_silhouette;_color=u.Color.RED;constructor(e){this._surface=new v(e),this._silhouette=new p(e),this._surface.color=this._color,this._silhouette.color=this._color}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,i=n.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),n.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if((0,u.defined)(i))return i instanceof u.Cesium3DTileFeature?this._silhouette.show(i,t):i instanceof u.Entity&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if((0,u.defined)(e)){if(e instanceof u.Entity||e instanceof u.Cesium3DTileFeature||e instanceof u.GroundPrimitive)return e;if(e.id instanceof u.Entity)return e.id;if(e.primitive instanceof u.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}},M=A;var y=require("cesium");var C=class n{static _instance;_level=n._fromEnv();constructor(){}static get(){return this._instance||(this._instance=new n),this._instance}debug(...e){this._emit(n.Level.debug,e)}info(...e){this._emit(n.Level.info,e)}warn(...e){this._emit(n.Level.warn,e)}error(...e){this._emit(n.Level.error,e)}static _fromEnv(){let e=process.env.LOG_LEVEL?.toLowerCase();return e&&e in n.Level?n.Level[e]:n.Level.info}_emit(e,t){if(e<this._level)return;let i=n.Level[e];console[i==="debug"?"log":i](`[${i.toUpperCase()}]`.padEnd(n.LABEL_PAD+2),...t)}};(t=>{let n;(a=>(a[a.debug=0]="debug",a[a.info=1]="info",a[a.warn=2]="warn",a[a.error=3]="error"))(n=t.Level||={}),t.LABEL_PAD=Math.max(...Object.keys(t.Level).map(i=>i.length))})(C||={});var V=C;var Y=V.get();function b({once:n=!0,includeStack:e=!1,message:t}){return(i,r,o)=>{let{label:s}=t;function a(){(!n||!b.has(s))&&(Y.warn(J(t)),e&&console.trace("Deprecation stack trace:"),b.add(s))}if(r===void 0)return class extends i{constructor(...f){a(),super(...f)}};if(o===void 0){a();return}if(o.get){let f=o.get;if(o.get=function(){return a(),f.call(this)},o.set){let h=o.set;o.set=function(_){a(),h.call(this,_)}}return o}if(o.set){let f=o.set;return o.set=function(h){a(),f.call(this,h)},o}if(typeof o.value=="function"){let f=o.value;return o.value=function(...h){return a(),f.apply(this,h)},o}return o}}(o=>{let n=new Set;function e(s){n.add(s)}o.add=e;function t(){n.clear()}o.clear=t;function i(){return n.size}o.size=i;function r(s){return n.has(s)}o.has=r})(b||={});function J({label:n,since:e,removedIn:t,replacement:i,additional:r}){return[`${n} is deprecated since ${e}.`,i?`Use ${i} instead.`:void 0,`This will be removed in ${t}.`,r].filter(Boolean).join(" ")}var G=b;var g=class g{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;_errorEvent;_removeEventListeners;_hasWaterMask;_hasVertexNormals;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new y.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._hasWaterMask=this._defaultProvider.hasWaterMask||this._regions.some(i=>i.provider.hasWaterMask),this._hasVertexNormals=this._defaultProvider.hasVertexNormals||this._regions.some(i=>i.provider.hasVertexNormals),this._errorEvent=new y.Event,this._removeEventListeners=[];let t=new Set;for(let i of this._regions)t.has(i.provider)||(t.add(i.provider),this._removeEventListeners.push(i.provider.errorEvent.addEventListener(r=>{this._errorEvent.raiseEvent(r)})));t.has(this._defaultProvider)||this._removeEventListeners.push(this._defaultProvider.errorEvent.addEventListener(i=>{this._errorEvent.raiseEvent(i)})),t.has(this._fallbackProvider)||this._removeEventListeners.push(this._fallbackProvider.errorEvent.addEventListener(i=>{this._errorEvent.raiseEvent(i)})),this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){let e=new Set,t=[];for(let i of this._regions){if(e.has(i.provider))continue;e.add(i.provider);let r=i.provider.credit?.html;r&&t.push(r)}if(!e.has(this._defaultProvider)){let i=this._defaultProvider.credit?.html;i&&t.push(i)}return new y.Credit(t.join(" "))}get errorEvent(){return this._errorEvent}get hasWaterMask(){return this._hasWaterMask}get hasVertexNormals(){return this._hasVertexNormals}loadTileDataAvailability(e,t,i){for(let r of this._regions)if(g.regionContainsTile(r,e,t,i))return r.provider.loadTileDataAvailability(e,t,i);return this._defaultProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){let t=this._defaultProvider.getLevelMaximumGeometricError(e);for(let i of this._regions){let r=i.provider.getLevelMaximumGeometricError(e);r>t&&(t=r)}return t}requestTileGeometry(e,t,i,r){if(this._ready){for(let o of this._regions)if(g.regionContainsTile(o,e,t,i))return o.provider.requestTileGeometry(e,t,i,r);return this._defaultProvider.getTileDataAvailable(e,t,i)?this._defaultProvider.requestTileGeometry(e,t,i,r):this._fallbackProvider.requestTileGeometry(e,t,i,r)}}getTileDataAvailable(e,t,i){for(let r of this._regions)if(g.regionContainsTile(r,e,t,i))return!0;return this._defaultProvider.getTileDataAvailable(e,t,i)}destroy(){for(let e of this._removeEventListeners)e();this._removeEventListeners.length=0,this._ready=!1}};D([G({message:{label:"_fallbackProvider",since:"0.4.6",removedIn:"0.5.0"}})],g.prototype,"fallbackProvider",1);var T=g;(i=>{function n(r,o,s){return new i({regions:r.map(a=>({...a})),defaultProvider:o,fallbackProvider:s})}i.fromTileRanges=n;function e(r,o,s,a){if(r.levels&&!r.levels.includes(a))return!1;if(r.tiles){let c=r.tiles.get(a);if(!c)return!1;let[f,h]=Array.isArray(c.x)?c.x:[c.x,c.x],[_,x]=Array.isArray(c.y)?c.y:[c.y,c.y];return o>=f&&o<=h&&s>=_&&s<=x}return!1}i.regionContainsTile=e;let t;(o=>{function r(s,a,c,f){if(s.levels&&!s.levels.includes(f))return!1;if(s.tiles){let h=s.tiles.get(f);if(!h)return!1;let[_,x]=Array.isArray(h.x)?h.x:[h.x,h.x],[F,B]=Array.isArray(h.y)?h.y:[h.y,h.y];return a>=_&&a<=x&&c>=F&&c<=B}return!1}o.contains=r})(t=i.TerrainRegion||={})})(T||={});var k=T;var N=require("cesium");var R=require("cesium");function P(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()}}function I(n,e,t){let i={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},r=new N.Viewer(e,{...i,...t});P(n,r);let o=n.imageryLayers;r.imageryLayers.removeAll();for(let c=0;c<o.length;c++){let f=o.get(c);r.imageryLayers.addImageryProvider(f.imageryProvider,c)}r.clock.startTime=n.clock.startTime.clone(),r.clock.stopTime=n.clock.stopTime.clone(),r.clock.currentTime=n.clock.currentTime.clone(),r.clock.multiplier=n.clock.multiplier,r.clock.clockStep=n.clock.clockStep,r.clock.clockRange=n.clock.clockRange,r.clock.shouldAnimate=n.clock.shouldAnimate,r.scene.globe.enableLighting=n.scene.globe.enableLighting,r.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,r.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let s=n.scene.screenSpaceCameraController.tiltEventTypes;s&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(s)?[...s]:s);let a=n.scene.screenSpaceCameraController.zoomEventTypes;return a&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(a)?[...a]:a),r}
|
package/dist/index.d.cts
CHANGED
|
@@ -821,6 +821,7 @@ declare class SurfaceHighlight implements Highlight.Base {
|
|
|
821
821
|
declare class HybridTerrainProvider implements TerrainProvider {
|
|
822
822
|
private _regions;
|
|
823
823
|
private _defaultProvider;
|
|
824
|
+
/** @deprecated This will be removed in 0.5.0. */
|
|
824
825
|
private _fallbackProvider;
|
|
825
826
|
private _tilingScheme;
|
|
826
827
|
private _ready;
|
|
@@ -829,7 +830,6 @@ declare class HybridTerrainProvider implements TerrainProvider {
|
|
|
829
830
|
private _removeEventListeners;
|
|
830
831
|
private _hasWaterMask;
|
|
831
832
|
private _hasVertexNormals;
|
|
832
|
-
private _credit?;
|
|
833
833
|
/**
|
|
834
834
|
* Creates a new `HybridTerrainProvider` instance.
|
|
835
835
|
* @param options {@link HybridTerrainProvider.ConstructorOptions}
|
|
@@ -858,11 +858,12 @@ declare class HybridTerrainProvider implements TerrainProvider {
|
|
|
858
858
|
*/
|
|
859
859
|
get defaultProvider(): TerrainProvider;
|
|
860
860
|
/**
|
|
861
|
-
*
|
|
861
|
+
* @deprecated
|
|
862
862
|
*/
|
|
863
863
|
get fallbackProvider(): TerrainProvider;
|
|
864
864
|
/**
|
|
865
|
-
* Gets the
|
|
865
|
+
* Gets all the credits to display from registered providers when
|
|
866
|
+
* this terrain provider is active. Typically this is used to credit
|
|
866
867
|
* the source of the terrain.
|
|
867
868
|
*/
|
|
868
869
|
get credit(): Credit;
|
|
@@ -871,7 +872,7 @@ declare class HybridTerrainProvider implements TerrainProvider {
|
|
|
871
872
|
* to the event, you will be notified of the error and can potentially recover from it. Event listeners
|
|
872
873
|
* are passed an instance of `TileProviderError`.
|
|
873
874
|
*/
|
|
874
|
-
get errorEvent(): Event
|
|
875
|
+
get errorEvent(): Event<TerrainProvider.ErrorEvent>;
|
|
875
876
|
/**
|
|
876
877
|
* Gets a value indicating whether or not the provider includes a water mask. The water mask
|
|
877
878
|
* indicates which areas of the globe are water rather than land, so they can be rendered
|
|
@@ -933,10 +934,13 @@ declare namespace HybridTerrainProvider {
|
|
|
933
934
|
regions?: TerrainRegion[];
|
|
934
935
|
/** Default provider to use outside of specified terrain regions. */
|
|
935
936
|
defaultProvider: TerrainProvider;
|
|
936
|
-
/**
|
|
937
|
+
/**
|
|
938
|
+
* Optional fallback provider when data is not available from default provider.
|
|
939
|
+
*
|
|
940
|
+
* @default EllipsoidTerrainProvider
|
|
941
|
+
* @deprecated
|
|
942
|
+
*/
|
|
937
943
|
fallbackProvider?: TerrainProvider;
|
|
938
|
-
/** A credit for the data source, which is displayed on the canvas. */
|
|
939
|
-
credit?: Credit | string;
|
|
940
944
|
}
|
|
941
945
|
/**
|
|
942
946
|
* A factory function which creates a HybridTerrainProvider from tile-coordinate based regions.
|
|
@@ -969,18 +973,26 @@ declare namespace HybridTerrainProvider {
|
|
|
969
973
|
/** Optional level constraints. If specified, region only applies to these levels. */
|
|
970
974
|
levels?: number[];
|
|
971
975
|
}
|
|
976
|
+
/**
|
|
977
|
+
* Checks if a terrain region contains the specified tile.
|
|
978
|
+
* @param region The terrain region to check
|
|
979
|
+
* @param x The X coordinate of the tile
|
|
980
|
+
* @param y The Y coordinate of the tile
|
|
981
|
+
* @param level The zoom level of the tile
|
|
982
|
+
* @returns True if the region contains the tile, false otherwise
|
|
983
|
+
*/
|
|
984
|
+
function regionContainsTile(region: HybridTerrainProvider.TerrainRegion, x: number, y: number, level: number): boolean;
|
|
972
985
|
/**
|
|
973
986
|
* @namespace
|
|
974
987
|
* Utility functions for working with TerrainRegion objects.
|
|
988
|
+
*
|
|
989
|
+
* @deprecated This will be removed in 0.5.0, due to the usage of nested namespace.
|
|
975
990
|
*/
|
|
976
991
|
namespace TerrainRegion {
|
|
977
992
|
/**
|
|
978
993
|
* Checks if a terrain region contains the specified tile.
|
|
979
|
-
*
|
|
980
|
-
* @
|
|
981
|
-
* @param y The Y coordinate of the tile
|
|
982
|
-
* @param level The zoom level of the tile
|
|
983
|
-
* @returns True if the region contains the tile, false otherwise
|
|
994
|
+
*
|
|
995
|
+
* @deprecated This will be removed in 0.5.0. Use {@link HybridTerrainProvider.regionContainsTile} instead.
|
|
984
996
|
*/
|
|
985
997
|
function contains(region: HybridTerrainProvider.TerrainRegion, x: number, y: number, level: number): boolean;
|
|
986
998
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -821,6 +821,7 @@ declare class SurfaceHighlight implements Highlight.Base {
|
|
|
821
821
|
declare class HybridTerrainProvider implements TerrainProvider {
|
|
822
822
|
private _regions;
|
|
823
823
|
private _defaultProvider;
|
|
824
|
+
/** @deprecated This will be removed in 0.5.0. */
|
|
824
825
|
private _fallbackProvider;
|
|
825
826
|
private _tilingScheme;
|
|
826
827
|
private _ready;
|
|
@@ -829,7 +830,6 @@ declare class HybridTerrainProvider implements TerrainProvider {
|
|
|
829
830
|
private _removeEventListeners;
|
|
830
831
|
private _hasWaterMask;
|
|
831
832
|
private _hasVertexNormals;
|
|
832
|
-
private _credit?;
|
|
833
833
|
/**
|
|
834
834
|
* Creates a new `HybridTerrainProvider` instance.
|
|
835
835
|
* @param options {@link HybridTerrainProvider.ConstructorOptions}
|
|
@@ -858,11 +858,12 @@ declare class HybridTerrainProvider implements TerrainProvider {
|
|
|
858
858
|
*/
|
|
859
859
|
get defaultProvider(): TerrainProvider;
|
|
860
860
|
/**
|
|
861
|
-
*
|
|
861
|
+
* @deprecated
|
|
862
862
|
*/
|
|
863
863
|
get fallbackProvider(): TerrainProvider;
|
|
864
864
|
/**
|
|
865
|
-
* Gets the
|
|
865
|
+
* Gets all the credits to display from registered providers when
|
|
866
|
+
* this terrain provider is active. Typically this is used to credit
|
|
866
867
|
* the source of the terrain.
|
|
867
868
|
*/
|
|
868
869
|
get credit(): Credit;
|
|
@@ -871,7 +872,7 @@ declare class HybridTerrainProvider implements TerrainProvider {
|
|
|
871
872
|
* to the event, you will be notified of the error and can potentially recover from it. Event listeners
|
|
872
873
|
* are passed an instance of `TileProviderError`.
|
|
873
874
|
*/
|
|
874
|
-
get errorEvent(): Event
|
|
875
|
+
get errorEvent(): Event<TerrainProvider.ErrorEvent>;
|
|
875
876
|
/**
|
|
876
877
|
* Gets a value indicating whether or not the provider includes a water mask. The water mask
|
|
877
878
|
* indicates which areas of the globe are water rather than land, so they can be rendered
|
|
@@ -933,10 +934,13 @@ declare namespace HybridTerrainProvider {
|
|
|
933
934
|
regions?: TerrainRegion[];
|
|
934
935
|
/** Default provider to use outside of specified terrain regions. */
|
|
935
936
|
defaultProvider: TerrainProvider;
|
|
936
|
-
/**
|
|
937
|
+
/**
|
|
938
|
+
* Optional fallback provider when data is not available from default provider.
|
|
939
|
+
*
|
|
940
|
+
* @default EllipsoidTerrainProvider
|
|
941
|
+
* @deprecated
|
|
942
|
+
*/
|
|
937
943
|
fallbackProvider?: TerrainProvider;
|
|
938
|
-
/** A credit for the data source, which is displayed on the canvas. */
|
|
939
|
-
credit?: Credit | string;
|
|
940
944
|
}
|
|
941
945
|
/**
|
|
942
946
|
* A factory function which creates a HybridTerrainProvider from tile-coordinate based regions.
|
|
@@ -969,18 +973,26 @@ declare namespace HybridTerrainProvider {
|
|
|
969
973
|
/** Optional level constraints. If specified, region only applies to these levels. */
|
|
970
974
|
levels?: number[];
|
|
971
975
|
}
|
|
976
|
+
/**
|
|
977
|
+
* Checks if a terrain region contains the specified tile.
|
|
978
|
+
* @param region The terrain region to check
|
|
979
|
+
* @param x The X coordinate of the tile
|
|
980
|
+
* @param y The Y coordinate of the tile
|
|
981
|
+
* @param level The zoom level of the tile
|
|
982
|
+
* @returns True if the region contains the tile, false otherwise
|
|
983
|
+
*/
|
|
984
|
+
function regionContainsTile(region: HybridTerrainProvider.TerrainRegion, x: number, y: number, level: number): boolean;
|
|
972
985
|
/**
|
|
973
986
|
* @namespace
|
|
974
987
|
* Utility functions for working with TerrainRegion objects.
|
|
988
|
+
*
|
|
989
|
+
* @deprecated This will be removed in 0.5.0, due to the usage of nested namespace.
|
|
975
990
|
*/
|
|
976
991
|
namespace TerrainRegion {
|
|
977
992
|
/**
|
|
978
993
|
* Checks if a terrain region contains the specified tile.
|
|
979
|
-
*
|
|
980
|
-
* @
|
|
981
|
-
* @param y The Y coordinate of the tile
|
|
982
|
-
* @param level The zoom level of the tile
|
|
983
|
-
* @returns True if the region contains the tile, false otherwise
|
|
994
|
+
*
|
|
995
|
+
* @deprecated This will be removed in 0.5.0. Use {@link HybridTerrainProvider.regionContainsTile} instead.
|
|
984
996
|
*/
|
|
985
997
|
function contains(region: HybridTerrainProvider.TerrainRegion, x: number, y: number, level: number): boolean;
|
|
986
998
|
}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DataSourceCollection as z,defined as _,EntityCollection as x,ImageryLayerCollection as K,PrimitiveCollection as U}from"cesium";function g(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}function y(n,e,t){let i=e.split(".");for(let a of i)if(w(a))return{success:!1,reason:"dangerous-property",message:`Property path contains dangerous property name: "${a}"`};let r=n,o=0;for(;o<i.length-1;o++){let a=i[o];if(!r||typeof r!="object"||!Object.prototype.hasOwnProperty.call(r,a))return{success:!1,reason:"invalid-path",message:`Property path "${e}" does not exist or contains inherited properties`};if(r=r[a],!r||typeof r!="object"||r===Object.prototype)return{success:!1,reason:"invalid-path",message:`Cannot traverse path "${e}" - reached non-object or prototype`}}if(o!==i.length-1)return{success:!1,reason:"invalid-path",message:`Failed to traverse property path "${e}"`};let s=i[i.length-1];if(w(s))return{success:!1,reason:"dangerous-property",message:`Cannot set dangerous property "${s}"`};if(!r||typeof r!="object"||r===Object.prototype)return{success:!1,reason:"invalid-path",message:"Cannot set property on invalid target"};if(s in r){if(typeof r[s]=="function")return{success:!1,reason:"function-property",message:`Cannot set function property "${s}"`};if(g(r,s))return{success:!1,reason:"read-only",message:`Cannot set read-only property "${e}"`}}return r[s]=t,{success:!0}}var $=["__proto__","constructor","prototype"];function w(n){return $.includes(n)}var C=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof x)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get tags(){return Array.from(this._tagMap.keys())}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)_(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)_(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)_(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r){let s=y(o,e,t);if(!s.success&&s.reason==="read-only")throw Error(`Cannot set read-only property '${e}' on ${o.constructor.name}`)}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,o)=>e(r,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof x?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof U?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof z?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof K&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}},S=C;import{Cesium3DTileFeature as A,Color as ee,defined as j,Entity as E,GroundPrimitive as k}from"cesium";import{Cesium3DTileFeature as Y,Color as b,ConstantProperty as p,defined as J,PostProcessStageLibrary as L}from"cesium";var h=class{_color=b.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=L.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=L.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}show(e,t){if(J(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{if(e instanceof Y)this._silhouette.uniforms.color=t?.color||this._color,this._silhouette.selected.push(e);else{if(!e.model)return;this._entity=e,e.model.silhouetteSize=new p(t?.width||2),e.model.silhouetteColor=new p(t?.color||this._color)}this._currentObject=e,this._currentOptions=t?{...t}:void 0}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0}}}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&b.equals(e.color||this._color,t.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new p(b.TRANSPARENT),this._entity.model.silhouetteSize=new p(0),this._entity=void 0)}};import{Cartesian3 as d,ClassificationType as R,Color as H,defined as Q,Entity as T,GroundPrimitive as I,HeightReference as P,PolygonGraphics as M,PolygonHierarchy as X,PolylineGraphics as f,RectangleGraphics as Z}from"cesium";var u=class{_color=H.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new T({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}show(e,t){if(!(!Q(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof T&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof I)this._update(e,t);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=e,this._currentOptions=t?{...t}:void 0,this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0;return}}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&H.equals(e.color||this._color,t.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof T){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let r;i.positions.length>0&&!d.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new f({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new M({hierarchy:i,material:t.color,heightReference:P.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||R.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let r=e.polyline.width?.getValue();this._entity.polyline=new f({positions:i,material:t.color,width:r+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let r=[d.fromRadians(i.west,i.north),d.fromRadians(i.east,i.north),d.fromRadians(i.east,i.south),d.fromRadians(i.west,i.south),d.fromRadians(i.west,i.north)];this._entity.polyline=new f({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new Z({coordinates:i,material:t.color,heightReference:P.CLAMP_TO_GROUND}))}}else if(e instanceof I){let i=e.geometryInstances,r=Array.isArray(i)?i[0]:i;if(!r.geometry.attributes.position)return;let o=r.geometry.attributes.position.values,s=[];for(let a=0;a<o.length;a+=3)s.push(new d(o[a],o[a+1],o[a+2]));t.outline?this._entity.polyline=new f({positions:s,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new M({hierarchy:new X(s),material:t.color,heightReference:P.CLAMP_TO_GROUND,classificationType:R.BOTH})}}};var O=class n{static instances=new WeakMap;_surface;_silhouette;_color=ee.RED;constructor(e){this._surface=new u(e),this._silhouette=new h(e),this._surface.color=this._color,this._silhouette.color=this._color}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,i=n.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),n.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if(j(i))return i instanceof A?this._silhouette.show(i,t):i instanceof E&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if(j(e)){if(e instanceof E||e instanceof A||e instanceof k)return e;if(e.id instanceof E)return e.id;if(e.primitive instanceof k)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}},D=O;import{Credit as te,EllipsoidTerrainProvider as ie,Event as re}from"cesium";var m=class n{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;_errorEvent;_removeEventListeners;_hasWaterMask;_hasVertexNormals;_credit;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new ie,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._hasWaterMask=this._defaultProvider.hasWaterMask||this._regions.some(i=>i.provider.hasWaterMask),this._hasVertexNormals=this._defaultProvider.hasVertexNormals||this._regions.some(i=>i.provider.hasVertexNormals),e.credit?this._credit=typeof e.credit=="string"?new te(e.credit):e.credit:this._credit=this._defaultProvider.credit,this._errorEvent=new re,this._removeEventListeners=[];let t=new Set;for(let i of this._regions)t.has(i.provider)||(t.add(i.provider),this._removeEventListeners.push(i.provider.errorEvent.addEventListener(r=>{this._errorEvent.raiseEvent(r)})));t.has(this._defaultProvider)||this._removeEventListeners.push(this._defaultProvider.errorEvent.addEventListener(i=>{this._errorEvent.raiseEvent(i)})),t.has(this._fallbackProvider)||this._removeEventListeners.push(this._fallbackProvider.errorEvent.addEventListener(i=>{this._errorEvent.raiseEvent(i)})),this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._credit}get errorEvent(){return this._errorEvent}get hasWaterMask(){return this._hasWaterMask}get hasVertexNormals(){return this._hasVertexNormals}loadTileDataAvailability(e,t,i){for(let r of this._regions)if(n.TerrainRegion.contains(r,e,t,i))return r.provider.loadTileDataAvailability(e,t,i);return this._defaultProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){let t=this._defaultProvider.getLevelMaximumGeometricError(e);for(let i of this._regions){let r=i.provider.getLevelMaximumGeometricError(e);r>t&&(t=r)}return t}requestTileGeometry(e,t,i,r){if(this._ready){for(let o of this._regions)if(n.TerrainRegion.contains(o,e,t,i))return o.provider.requestTileGeometry(e,t,i,r);return this._defaultProvider.getTileDataAvailable(e,t,i)?this._defaultProvider.requestTileGeometry(e,t,i,r):this._fallbackProvider.requestTileGeometry(e,t,i,r)}}getTileDataAvailable(e,t,i){for(let r of this._regions)if(n.TerrainRegion.contains(r,e,t,i))return!0;return this._defaultProvider.getTileDataAvailable(e,t,i)}destroy(){for(let e of this._removeEventListeners)e();this._removeEventListeners.length=0,this._ready=!1}};(t=>{function n(i,r,o){return new t({regions:i.map(s=>({...s})),defaultProvider:r,fallbackProvider:o})}t.fromTileRanges=n;let e;(r=>{function i(o,s,a,c){if(o.levels&&!o.levels.includes(c))return!1;if(o.tiles){let l=o.tiles.get(c);if(!l)return!1;let[F,B]=Array.isArray(l.x)?l.x:[l.x,l.x],[W,q]=Array.isArray(l.y)?l.y:[l.y,l.y];return s>=F&&s<=B&&a>=W&&a<=q}return!1}r.contains=i})(e=t.TerrainRegion||={})})(m||={});var G=m;import{Viewer as ne}from"cesium";import{defined as V}from"cesium";function v(n,e){if(V(n)&&V(e)){let{camera:t}=n;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}function N(n,e,t){let i={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},r=new ne(e,{...i,...t});v(n,r);let o=n.imageryLayers;r.imageryLayers.removeAll();for(let c=0;c<o.length;c++){let l=o.get(c);r.imageryLayers.addImageryProvider(l.imageryProvider,c)}r.clock.startTime=n.clock.startTime.clone(),r.clock.stopTime=n.clock.stopTime.clone(),r.clock.currentTime=n.clock.currentTime.clone(),r.clock.multiplier=n.clock.multiplier,r.clock.clockStep=n.clock.clockStep,r.clock.clockRange=n.clock.clockRange,r.clock.shouldAnimate=n.clock.shouldAnimate,r.scene.globe.enableLighting=n.scene.globe.enableLighting,r.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,r.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let s=n.scene.screenSpaceCameraController.tiltEventTypes;s&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(s)?[...s]:s);let a=n.scene.screenSpaceCameraController.zoomEventTypes;return a&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(a)?[...a]:a),r}export{S as Collection,D as Highlight,G as HybridTerrainProvider,h as SilhouetteHighlight,u as SurfaceHighlight,N as cloneViewer,v as syncCamera};
|
|
1
|
+
var X=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var k=(n,e,t,i)=>{for(var r=i>1?void 0:i?Z(e,t):e,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=(i?s(e,t,r):s(r))||r);return i&&r&&X(e,t,r),r};import{DataSourceCollection as te,defined as x,EntityCollection as I,ImageryLayerCollection as ie,PrimitiveCollection as re}from"cesium";function P(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}function E(n,e,t){let i=e.split(".");for(let a of i)if(R(a))return{success:!1,reason:"dangerous-property",message:`Property path contains dangerous property name: "${a}"`};let r=n,o=0;for(;o<i.length-1;o++){let a=i[o];if(!r||typeof r!="object"||!Object.prototype.hasOwnProperty.call(r,a))return{success:!1,reason:"invalid-path",message:`Property path "${e}" does not exist or contains inherited properties`};if(r=r[a],!r||typeof r!="object"||r===Object.prototype)return{success:!1,reason:"invalid-path",message:`Cannot traverse path "${e}" - reached non-object or prototype`}}if(o!==i.length-1)return{success:!1,reason:"invalid-path",message:`Failed to traverse property path "${e}"`};let s=i[i.length-1];if(R(s))return{success:!1,reason:"dangerous-property",message:`Cannot set dangerous property "${s}"`};if(!r||typeof r!="object"||r===Object.prototype)return{success:!1,reason:"invalid-path",message:"Cannot set property on invalid target"};if(s in r){if(typeof r[s]=="function")return{success:!1,reason:"function-property",message:`Cannot set function property "${s}"`};if(P(r,s))return{success:!1,reason:"read-only",message:`Cannot set read-only property "${e}"`}}return r[s]=t,{success:!0}}var ee=["__proto__","constructor","prototype"];function R(n){return ee.includes(n)}var w=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof I)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get tags(){return Array.from(this._tagMap.keys())}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)x(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)x(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)x(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r){let s=E(o,e,t);if(!s.success&&s.reason==="read-only")throw Error(`Cannot set read-only property '${e}' on ${o.constructor.name}`)}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,o)=>e(r,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof I?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof re?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof te?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof ie&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}},H=w;import{Cesium3DTileFeature as F,Color as ce,defined as B,Entity as A,GroundPrimitive as $}from"cesium";import{Cesium3DTileFeature as ne,Color as O,ConstantProperty as _,defined as oe,PostProcessStageLibrary as D}from"cesium";var d=class{_color=O.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=D.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=D.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}show(e,t){if(oe(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{if(e instanceof ne)this._silhouette.uniforms.color=t?.color||this._color,this._silhouette.selected.push(e);else{if(!e.model)return;this._entity=e,e.model.silhouetteSize=new _(t?.width||2),e.model.silhouetteColor=new _(t?.color||this._color)}this._currentObject=e,this._currentOptions=t?{...t}:void 0}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0}}}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&O.equals(e.color||this._color,t.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new _(O.TRANSPARENT),this._entity.model.silhouetteSize=new _(0),this._entity=void 0)}};import{Cartesian3 as u,ClassificationType as j,Color as V,defined as se,Entity as L,GroundPrimitive as G,HeightReference as S,PolygonGraphics as N,PolygonHierarchy as ae,PolylineGraphics as C,RectangleGraphics as le}from"cesium";var f=class{_color=V.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new L({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}show(e,t){if(!(!se(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof L&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof G)this._update(e,t);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=e,this._currentOptions=t?{...t}:void 0,this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0;return}}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&V.equals(e.color||this._color,t.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof L){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let r;i.positions.length>0&&!u.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new C({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new N({hierarchy:i,material:t.color,heightReference:S.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||j.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let r=e.polyline.width?.getValue();this._entity.polyline=new C({positions:i,material:t.color,width:r+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let r=[u.fromRadians(i.west,i.north),u.fromRadians(i.east,i.north),u.fromRadians(i.east,i.south),u.fromRadians(i.west,i.south),u.fromRadians(i.west,i.north)];this._entity.polyline=new C({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new le({coordinates:i,material:t.color,heightReference:S.CLAMP_TO_GROUND}))}}else if(e instanceof G){let i=e.geometryInstances,r=Array.isArray(i)?i[0]:i;if(!r.geometry.attributes.position)return;let o=r.geometry.attributes.position.values,s=[];for(let a=0;a<o.length;a+=3)s.push(new u(o[a],o[a+1],o[a+2]));t.outline?this._entity.polyline=new C({positions:s,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new N({hierarchy:new ae(s),material:t.color,heightReference:S.CLAMP_TO_GROUND,classificationType:j.BOTH})}}};var M=class n{static instances=new WeakMap;_surface;_silhouette;_color=ce.RED;constructor(e){this._surface=new f(e),this._silhouette=new d(e),this._surface.color=this._color,this._silhouette.color=this._color}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,i=n.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),n.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if(B(i))return i instanceof F?this._silhouette.show(i,t):i instanceof A&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if(B(e)){if(e instanceof A||e instanceof F||e instanceof $)return e;if(e.id instanceof A)return e.id;if(e.primitive instanceof $)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}},W=M;import{Credit as ue,EllipsoidTerrainProvider as fe,Event as me}from"cesium";var v=class n{static _instance;_level=n._fromEnv();constructor(){}static get(){return this._instance||(this._instance=new n),this._instance}debug(...e){this._emit(n.Level.debug,e)}info(...e){this._emit(n.Level.info,e)}warn(...e){this._emit(n.Level.warn,e)}error(...e){this._emit(n.Level.error,e)}static _fromEnv(){let e=process.env.LOG_LEVEL?.toLowerCase();return e&&e in n.Level?n.Level[e]:n.Level.info}_emit(e,t){if(e<this._level)return;let i=n.Level[e];console[i==="debug"?"log":i](`[${i.toUpperCase()}]`.padEnd(n.LABEL_PAD+2),...t)}};(t=>{let n;(a=>(a[a.debug=0]="debug",a[a.info=1]="info",a[a.warn=2]="warn",a[a.error=3]="error"))(n=t.Level||={}),t.LABEL_PAD=Math.max(...Object.keys(t.Level).map(i=>i.length))})(v||={});var q=v;var he=q.get();function g({once:n=!0,includeStack:e=!1,message:t}){return(i,r,o)=>{let{label:s}=t;function a(){(!n||!g.has(s))&&(he.warn(de(t)),e&&console.trace("Deprecation stack trace:"),g.add(s))}if(r===void 0)return class extends i{constructor(...h){a(),super(...h)}};if(o===void 0){a();return}if(o.get){let h=o.get;if(o.get=function(){return a(),h.call(this)},o.set){let c=o.set;o.set=function(p){a(),c.call(this,p)}}return o}if(o.set){let h=o.set;return o.set=function(c){a(),h.call(this,c)},o}if(typeof o.value=="function"){let h=o.value;return o.value=function(...c){return a(),h.apply(this,c)},o}return o}}(o=>{let n=new Set;function e(s){n.add(s)}o.add=e;function t(){n.clear()}o.clear=t;function i(){return n.size}o.size=i;function r(s){return n.has(s)}o.has=r})(g||={});function de({label:n,since:e,removedIn:t,replacement:i,additional:r}){return[`${n} is deprecated since ${e}.`,i?`Use ${i} instead.`:void 0,`This will be removed in ${t}.`,r].filter(Boolean).join(" ")}var z=g;var m=class m{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;_errorEvent;_removeEventListeners;_hasWaterMask;_hasVertexNormals;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new fe,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._hasWaterMask=this._defaultProvider.hasWaterMask||this._regions.some(i=>i.provider.hasWaterMask),this._hasVertexNormals=this._defaultProvider.hasVertexNormals||this._regions.some(i=>i.provider.hasVertexNormals),this._errorEvent=new me,this._removeEventListeners=[];let t=new Set;for(let i of this._regions)t.has(i.provider)||(t.add(i.provider),this._removeEventListeners.push(i.provider.errorEvent.addEventListener(r=>{this._errorEvent.raiseEvent(r)})));t.has(this._defaultProvider)||this._removeEventListeners.push(this._defaultProvider.errorEvent.addEventListener(i=>{this._errorEvent.raiseEvent(i)})),t.has(this._fallbackProvider)||this._removeEventListeners.push(this._fallbackProvider.errorEvent.addEventListener(i=>{this._errorEvent.raiseEvent(i)})),this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){let e=new Set,t=[];for(let i of this._regions){if(e.has(i.provider))continue;e.add(i.provider);let r=i.provider.credit?.html;r&&t.push(r)}if(!e.has(this._defaultProvider)){let i=this._defaultProvider.credit?.html;i&&t.push(i)}return new ue(t.join(" "))}get errorEvent(){return this._errorEvent}get hasWaterMask(){return this._hasWaterMask}get hasVertexNormals(){return this._hasVertexNormals}loadTileDataAvailability(e,t,i){for(let r of this._regions)if(m.regionContainsTile(r,e,t,i))return r.provider.loadTileDataAvailability(e,t,i);return this._defaultProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){let t=this._defaultProvider.getLevelMaximumGeometricError(e);for(let i of this._regions){let r=i.provider.getLevelMaximumGeometricError(e);r>t&&(t=r)}return t}requestTileGeometry(e,t,i,r){if(this._ready){for(let o of this._regions)if(m.regionContainsTile(o,e,t,i))return o.provider.requestTileGeometry(e,t,i,r);return this._defaultProvider.getTileDataAvailable(e,t,i)?this._defaultProvider.requestTileGeometry(e,t,i,r):this._fallbackProvider.requestTileGeometry(e,t,i,r)}}getTileDataAvailable(e,t,i){for(let r of this._regions)if(m.regionContainsTile(r,e,t,i))return!0;return this._defaultProvider.getTileDataAvailable(e,t,i)}destroy(){for(let e of this._removeEventListeners)e();this._removeEventListeners.length=0,this._ready=!1}};k([z({message:{label:"_fallbackProvider",since:"0.4.6",removedIn:"0.5.0"}})],m.prototype,"fallbackProvider",1);var y=m;(i=>{function n(r,o,s){return new i({regions:r.map(a=>({...a})),defaultProvider:o,fallbackProvider:s})}i.fromTileRanges=n;function e(r,o,s,a){if(r.levels&&!r.levels.includes(a))return!1;if(r.tiles){let l=r.tiles.get(a);if(!l)return!1;let[h,c]=Array.isArray(l.x)?l.x:[l.x,l.x],[p,T]=Array.isArray(l.y)?l.y:[l.y,l.y];return o>=h&&o<=c&&s>=p&&s<=T}return!1}i.regionContainsTile=e;let t;(o=>{function r(s,a,l,h){if(s.levels&&!s.levels.includes(h))return!1;if(s.tiles){let c=s.tiles.get(h);if(!c)return!1;let[p,T]=Array.isArray(c.x)?c.x:[c.x,c.x],[J,Q]=Array.isArray(c.y)?c.y:[c.y,c.y];return a>=p&&a<=T&&l>=J&&l<=Q}return!1}o.contains=r})(t=i.TerrainRegion||={})})(y||={});var K=y;import{Viewer as pe}from"cesium";import{defined as U}from"cesium";function b(n,e){if(U(n)&&U(e)){let{camera:t}=n;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}function Y(n,e,t){let i={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},r=new pe(e,{...i,...t});b(n,r);let o=n.imageryLayers;r.imageryLayers.removeAll();for(let l=0;l<o.length;l++){let h=o.get(l);r.imageryLayers.addImageryProvider(h.imageryProvider,l)}r.clock.startTime=n.clock.startTime.clone(),r.clock.stopTime=n.clock.stopTime.clone(),r.clock.currentTime=n.clock.currentTime.clone(),r.clock.multiplier=n.clock.multiplier,r.clock.clockStep=n.clock.clockStep,r.clock.clockRange=n.clock.clockRange,r.clock.shouldAnimate=n.clock.shouldAnimate,r.scene.globe.enableLighting=n.scene.globe.enableLighting,r.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,r.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let s=n.scene.screenSpaceCameraController.tiltEventTypes;s&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(s)?[...s]:s);let a=n.scene.screenSpaceCameraController.zoomEventTypes;return a&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(a)?[...a]:a),r}export{H as Collection,W as Highlight,K as HybridTerrainProvider,d as SilhouetteHighlight,f as SurfaceHighlight,Y as cloneViewer,b as syncCamera};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var R=(n,e)=>{for(var r in e)p(n,r,{get:e[r],enumerable:!0})},O=(n,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of M(e))!A.call(n,t)&&t!==r&&p(n,t,{get:()=>e[t],enumerable:!(i=L(e,t))||i.enumerable});return n};var S=n=>O(p({},"__esModule",{value:!0}),n),C=(n,e,r,i)=>{for(var t=i>1?void 0:i?L(e,r):e,o=n.length-1,s;o>=0;o--)(s=n[o])&&(t=(i?s(e,r,t):s(t))||t);return i&&t&&p(e,r,t),t};var H={};R(H,{TerrainVisualizer:()=>P});module.exports=S(H);var u=require("cesium");var c=require("cesium");var m=require("cesium");var g=class n{static _instance;_level=n._fromEnv();constructor(){}static get(){return this._instance||(this._instance=new n),this._instance}debug(...e){this._emit(n.Level.debug,e)}info(...e){this._emit(n.Level.info,e)}warn(...e){this._emit(n.Level.warn,e)}error(...e){this._emit(n.Level.error,e)}static _fromEnv(){let e=process.env.LOG_LEVEL?.toLowerCase();return e&&e in n.Level?n.Level[e]:n.Level.info}_emit(e,r){if(e<this._level)return;let i=n.Level[e];console[i==="debug"?"log":i](`[${i.toUpperCase()}]`.padEnd(n.LABEL_PAD+2),...r)}};(r=>{let n;(a=>(a[a.debug=0]="debug",a[a.info=1]="info",a[a.warn=2]="warn",a[a.error=3]="error"))(n=r.Level||={}),r.LABEL_PAD=Math.max(...Object.keys(r.Level).map(i=>i.length))})(g||={});var E=g;var D=E.get();function y({once:n=!0,includeStack:e=!1,message:r}){return(i,t,o)=>{let{label:s}=r;function a(){(!n||!y.has(s))&&(D.warn(V(r)),e&&console.trace("Deprecation stack trace:"),y.add(s))}if(t===void 0)return class extends i{constructor(...v){a(),super(...v)}};if(o===void 0){a();return}if(o.get){let v=o.get;if(o.get=function(){return a(),v.call(this)},o.set){let l=o.set;o.set=function(f){a(),l.call(this,f)}}return o}if(o.set){let v=o.set;return o.set=function(l){a(),v.call(this,l)},o}if(typeof o.value=="function"){let v=o.value;return o.value=function(...l){return a(),v.apply(this,l)},o}return o}}(o=>{let n=new Set;function e(s){n.add(s)}o.add=e;function r(){n.clear()}o.clear=r;function i(){return n.size}o.size=i;function t(s){return n.has(s)}o.has=t})(y||={});function V({label:n,since:e,removedIn:r,replacement:i,additional:t}){return[`${n} is deprecated since ${e}.`,i?`Use ${i} instead.`:void 0,`This will be removed in ${r}.`,t].filter(Boolean).join(" ")}var w=y;var h=class h{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;_errorEvent;_removeEventListeners;_hasWaterMask;_hasVertexNormals;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new m.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._hasWaterMask=this._defaultProvider.hasWaterMask||this._regions.some(i=>i.provider.hasWaterMask),this._hasVertexNormals=this._defaultProvider.hasVertexNormals||this._regions.some(i=>i.provider.hasVertexNormals),this._errorEvent=new m.Event,this._removeEventListeners=[];let r=new Set;for(let i of this._regions)r.has(i.provider)||(r.add(i.provider),this._removeEventListeners.push(i.provider.errorEvent.addEventListener(t=>{this._errorEvent.raiseEvent(t)})));r.has(this._defaultProvider)||this._removeEventListeners.push(this._defaultProvider.errorEvent.addEventListener(i=>{this._errorEvent.raiseEvent(i)})),r.has(this._fallbackProvider)||this._removeEventListeners.push(this._fallbackProvider.errorEvent.addEventListener(i=>{this._errorEvent.raiseEvent(i)})),this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){let e=new Set,r=[];for(let i of this._regions){if(e.has(i.provider))continue;e.add(i.provider);let t=i.provider.credit?.html;t&&r.push(t)}if(!e.has(this._defaultProvider)){let i=this._defaultProvider.credit?.html;i&&r.push(i)}return new m.Credit(r.join(" "))}get errorEvent(){return this._errorEvent}get hasWaterMask(){return this._hasWaterMask}get hasVertexNormals(){return this._hasVertexNormals}loadTileDataAvailability(e,r,i){for(let t of this._regions)if(h.regionContainsTile(t,e,r,i))return t.provider.loadTileDataAvailability(e,r,i);return this._defaultProvider.loadTileDataAvailability(e,r,i)}getLevelMaximumGeometricError(e){let r=this._defaultProvider.getLevelMaximumGeometricError(e);for(let i of this._regions){let t=i.provider.getLevelMaximumGeometricError(e);t>r&&(r=t)}return r}requestTileGeometry(e,r,i,t){if(this._ready){for(let o of this._regions)if(h.regionContainsTile(o,e,r,i))return o.provider.requestTileGeometry(e,r,i,t);return this._defaultProvider.getTileDataAvailable(e,r,i)?this._defaultProvider.requestTileGeometry(e,r,i,t):this._fallbackProvider.requestTileGeometry(e,r,i,t)}}getTileDataAvailable(e,r,i){for(let t of this._regions)if(h.regionContainsTile(t,e,r,i))return!0;return this._defaultProvider.getTileDataAvailable(e,r,i)}destroy(){for(let e of this._removeEventListeners)e();this._removeEventListeners.length=0,this._ready=!1}};C([w({message:{label:"_fallbackProvider",since:"0.4.6",removedIn:"0.5.0"}})],h.prototype,"fallbackProvider",1);var b=h;(i=>{function n(t,o,s){return new i({regions:t.map(a=>({...a})),defaultProvider:o,fallbackProvider:s})}i.fromTileRanges=n;function e(t,o,s,a){if(t.levels&&!t.levels.includes(a))return!1;if(t.tiles){let d=t.tiles.get(a);if(!d)return!1;let[v,l]=Array.isArray(d.x)?d.x:[d.x,d.x],[f,T]=Array.isArray(d.y)?d.y:[d.y,d.y];return o>=v&&o<=l&&s>=f&&s<=T}return!1}i.regionContainsTile=e;let r;(o=>{function t(s,a,d,v){if(s.levels&&!s.levels.includes(v))return!1;if(s.tiles){let l=s.tiles.get(v);if(!l)return!1;let[f,T]=Array.isArray(l.x)?l.x:[l.x,l.x],[k,I]=Array.isArray(l.y)?l.y:[l.y,l.y];return a>=f&&a<=T&&d>=k&&d<=I}return!1}o.contains=t})(r=i.TerrainRegion||={})})(b||={});var x=b;var _=class extends c.GridImageryProvider{_terrainProvider;_colors;constructor(e){let{terrainProvider:r,colors:i,...t}=e;super(t),this._terrainProvider=r,this._colors=i}requestImage(e,r,i){for(let t of this._terrainProvider.regions)if(this._isInRegionOrUpsampled(t,e,r,i))return this._createCanvasElement(this._colors.get("custom")||c.Color.RED);return this._terrainProvider.defaultProvider.getTileDataAvailable(e,r,i)?this._createCanvasElement(this._colors.get("default")||c.Color.BLUE):this._createCanvasElement(this._colors.get("fallback")||c.Color.GRAY)}_isInRegionOrUpsampled(e,r,i,t){let o=r,s=i,a=t;for(;a>=0;){if(x.TerrainRegion.contains(e,o,s,a))return!0;if(a===0)break;a--,o=Math.floor(o/2),s=Math.floor(s/2)}return!1}_createCanvasElement(e){let r=document.createElement("canvas");r.width=256,r.height=256;let i=r.getContext("2d"),t=e.withAlpha(.3).toCssColorString();if(!i)throw new Error("canvas context undefined");return i.fillStyle=t,i.fillRect(0,0,256,256),Promise.resolve(r)}};var P=class{_viewer;_terrainProvider;_visible=!1;_tileCoordinatesLayer;_hybridImageryLayer;_colors=new Map([["custom",u.Color.RED],["default",u.Color.BLUE],["fallback",u.Color.GRAY],["grid",u.Color.YELLOW]]);constructor(e,r){this._viewer=e,this._terrainProvider=r.terrainProvider,r.colors&&Object.entries(r.colors).forEach(([i,t])=>{this._colors.set(i,t)}),r.tile!==void 0&&r.tile&&this.show()}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){let e=this._visible,r=!!this._tileCoordinatesLayer,i=this._hybridImageryLayer?.alpha??.5;this.clear(),e&&this.show({showTileCoordinates:r,alpha:i})}clear(){this.hide()}show(e){if(!this._terrainProvider)return;let r=e?.showTileCoordinates??!0,i=e?.alpha??.5;r&&this._ensureTileCoordinatesLayer(),this.showImageryOverlay(i),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new u.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:u.Color.YELLOW})))}hide(){this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this.hideImageryOverlay(),this._visible=!1}setColors(e){Object.entries(e).forEach(([r,i])=>{this._colors.set(r,i)}),this.update()}showImageryOverlay(e=.5){this._hybridImageryLayer&&this._viewer.imageryLayers.remove(this._hybridImageryLayer);let r=new _({terrainProvider:this._terrainProvider,colors:this._colors,tilingScheme:this._terrainProvider.tilingScheme});this._hybridImageryLayer=this._viewer.imageryLayers.addImageryProvider(r),this._hybridImageryLayer.alpha=e,console.log("HybridImageryProvider overlay enabled")}hideImageryOverlay(){this._hybridImageryLayer&&(this._viewer.imageryLayers.remove(this._hybridImageryLayer),this._hybridImageryLayer=void 0,console.log("HybridImageryProvider overlay disabled"))}showTileCoordinates(){this._ensureTileCoordinatesLayer()}hideTileCoordinates(){this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0)}setAlpha(e){this._hybridImageryLayer&&(this._hybridImageryLayer.alpha=e)}flyTo(e,r){this._viewer.camera.flyTo({destination:e,...r,complete:()=>{this._visible&&this.update()}})}get tileCoordinatesVisible(){return!!this._tileCoordinatesLayer}get visible(){return this._visible}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Color as
|
|
1
|
+
var x=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var P=(o,e,i,r)=>{for(var t=r>1?void 0:r?k(e,i):e,n=o.length-1,s;n>=0;n--)(s=o[n])&&(t=(r?s(e,i,t):s(t))||t);return r&&t&&x(e,i,t),t};import{Color as y,TileCoordinatesImageryProvider as D}from"cesium";import{Color as _,GridImageryProvider as S}from"cesium";import{Credit as A,EllipsoidTerrainProvider as R,Event as O}from"cesium";var m=class o{static _instance;_level=o._fromEnv();constructor(){}static get(){return this._instance||(this._instance=new o),this._instance}debug(...e){this._emit(o.Level.debug,e)}info(...e){this._emit(o.Level.info,e)}warn(...e){this._emit(o.Level.warn,e)}error(...e){this._emit(o.Level.error,e)}static _fromEnv(){let e=process.env.LOG_LEVEL?.toLowerCase();return e&&e in o.Level?o.Level[e]:o.Level.info}_emit(e,i){if(e<this._level)return;let r=o.Level[e];console[r==="debug"?"log":r](`[${r.toUpperCase()}]`.padEnd(o.LABEL_PAD+2),...i)}};(i=>{let o;(a=>(a[a.debug=0]="debug",a[a.info=1]="info",a[a.warn=2]="warn",a[a.error=3]="error"))(o=i.Level||={}),i.LABEL_PAD=Math.max(...Object.keys(i.Level).map(r=>r.length))})(m||={});var T=m;var I=T.get();function c({once:o=!0,includeStack:e=!1,message:i}){return(r,t,n)=>{let{label:s}=i;function a(){(!o||!c.has(s))&&(I.warn(M(i)),e&&console.trace("Deprecation stack trace:"),c.add(s))}if(t===void 0)return class extends r{constructor(...v){a(),super(...v)}};if(n===void 0){a();return}if(n.get){let v=n.get;if(n.get=function(){return a(),v.call(this)},n.set){let l=n.set;n.set=function(h){a(),l.call(this,h)}}return n}if(n.set){let v=n.set;return n.set=function(l){a(),v.call(this,l)},n}if(typeof n.value=="function"){let v=n.value;return n.value=function(...l){return a(),v.apply(this,l)},n}return n}}(n=>{let o=new Set;function e(s){o.add(s)}n.add=e;function i(){o.clear()}n.clear=i;function r(){return o.size}n.size=r;function t(s){return o.has(s)}n.has=t})(c||={});function M({label:o,since:e,removedIn:i,replacement:r,additional:t}){return[`${o} is deprecated since ${e}.`,r?`Use ${r} instead.`:void 0,`This will be removed in ${i}.`,t].filter(Boolean).join(" ")}var L=c;var u=class u{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;_errorEvent;_removeEventListeners;_hasWaterMask;_hasVertexNormals;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new R,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._hasWaterMask=this._defaultProvider.hasWaterMask||this._regions.some(r=>r.provider.hasWaterMask),this._hasVertexNormals=this._defaultProvider.hasVertexNormals||this._regions.some(r=>r.provider.hasVertexNormals),this._errorEvent=new O,this._removeEventListeners=[];let i=new Set;for(let r of this._regions)i.has(r.provider)||(i.add(r.provider),this._removeEventListeners.push(r.provider.errorEvent.addEventListener(t=>{this._errorEvent.raiseEvent(t)})));i.has(this._defaultProvider)||this._removeEventListeners.push(this._defaultProvider.errorEvent.addEventListener(r=>{this._errorEvent.raiseEvent(r)})),i.has(this._fallbackProvider)||this._removeEventListeners.push(this._fallbackProvider.errorEvent.addEventListener(r=>{this._errorEvent.raiseEvent(r)})),this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){let e=new Set,i=[];for(let r of this._regions){if(e.has(r.provider))continue;e.add(r.provider);let t=r.provider.credit?.html;t&&i.push(t)}if(!e.has(this._defaultProvider)){let r=this._defaultProvider.credit?.html;r&&i.push(r)}return new A(i.join(" "))}get errorEvent(){return this._errorEvent}get hasWaterMask(){return this._hasWaterMask}get hasVertexNormals(){return this._hasVertexNormals}loadTileDataAvailability(e,i,r){for(let t of this._regions)if(u.regionContainsTile(t,e,i,r))return t.provider.loadTileDataAvailability(e,i,r);return this._defaultProvider.loadTileDataAvailability(e,i,r)}getLevelMaximumGeometricError(e){let i=this._defaultProvider.getLevelMaximumGeometricError(e);for(let r of this._regions){let t=r.provider.getLevelMaximumGeometricError(e);t>i&&(i=t)}return i}requestTileGeometry(e,i,r,t){if(this._ready){for(let n of this._regions)if(u.regionContainsTile(n,e,i,r))return n.provider.requestTileGeometry(e,i,r,t);return this._defaultProvider.getTileDataAvailable(e,i,r)?this._defaultProvider.requestTileGeometry(e,i,r,t):this._fallbackProvider.requestTileGeometry(e,i,r,t)}}getTileDataAvailable(e,i,r){for(let t of this._regions)if(u.regionContainsTile(t,e,i,r))return!0;return this._defaultProvider.getTileDataAvailable(e,i,r)}destroy(){for(let e of this._removeEventListeners)e();this._removeEventListeners.length=0,this._ready=!1}};P([L({message:{label:"_fallbackProvider",since:"0.4.6",removedIn:"0.5.0"}})],u.prototype,"fallbackProvider",1);var f=u;(r=>{function o(t,n,s){return new r({regions:t.map(a=>({...a})),defaultProvider:n,fallbackProvider:s})}r.fromTileRanges=o;function e(t,n,s,a){if(t.levels&&!t.levels.includes(a))return!1;if(t.tiles){let d=t.tiles.get(a);if(!d)return!1;let[v,l]=Array.isArray(d.x)?d.x:[d.x,d.x],[h,b]=Array.isArray(d.y)?d.y:[d.y,d.y];return n>=v&&n<=l&&s>=h&&s<=b}return!1}r.regionContainsTile=e;let i;(n=>{function t(s,a,d,v){if(s.levels&&!s.levels.includes(v))return!1;if(s.tiles){let l=s.tiles.get(v);if(!l)return!1;let[h,b]=Array.isArray(l.x)?l.x:[l.x,l.x],[E,w]=Array.isArray(l.y)?l.y:[l.y,l.y];return a>=h&&a<=b&&d>=E&&d<=w}return!1}n.contains=t})(i=r.TerrainRegion||={})})(f||={});var C=f;var g=class extends S{_terrainProvider;_colors;constructor(e){let{terrainProvider:i,colors:r,...t}=e;super(t),this._terrainProvider=i,this._colors=r}requestImage(e,i,r){for(let t of this._terrainProvider.regions)if(this._isInRegionOrUpsampled(t,e,i,r))return this._createCanvasElement(this._colors.get("custom")||_.RED);return this._terrainProvider.defaultProvider.getTileDataAvailable(e,i,r)?this._createCanvasElement(this._colors.get("default")||_.BLUE):this._createCanvasElement(this._colors.get("fallback")||_.GRAY)}_isInRegionOrUpsampled(e,i,r,t){let n=i,s=r,a=t;for(;a>=0;){if(C.TerrainRegion.contains(e,n,s,a))return!0;if(a===0)break;a--,n=Math.floor(n/2),s=Math.floor(s/2)}return!1}_createCanvasElement(e){let i=document.createElement("canvas");i.width=256,i.height=256;let r=i.getContext("2d"),t=e.withAlpha(.3).toCssColorString();if(!r)throw new Error("canvas context undefined");return r.fillStyle=t,r.fillRect(0,0,256,256),Promise.resolve(i)}};var p=class{_viewer;_terrainProvider;_visible=!1;_tileCoordinatesLayer;_hybridImageryLayer;_colors=new Map([["custom",y.RED],["default",y.BLUE],["fallback",y.GRAY],["grid",y.YELLOW]]);constructor(e,i){this._viewer=e,this._terrainProvider=i.terrainProvider,i.colors&&Object.entries(i.colors).forEach(([r,t])=>{this._colors.set(r,t)}),i.tile!==void 0&&i.tile&&this.show()}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){let e=this._visible,i=!!this._tileCoordinatesLayer,r=this._hybridImageryLayer?.alpha??.5;this.clear(),e&&this.show({showTileCoordinates:i,alpha:r})}clear(){this.hide()}show(e){if(!this._terrainProvider)return;let i=e?.showTileCoordinates??!0,r=e?.alpha??.5;i&&this._ensureTileCoordinatesLayer(),this.showImageryOverlay(r),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new D({tilingScheme:this._terrainProvider.tilingScheme,color:y.YELLOW})))}hide(){this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this.hideImageryOverlay(),this._visible=!1}setColors(e){Object.entries(e).forEach(([i,r])=>{this._colors.set(i,r)}),this.update()}showImageryOverlay(e=.5){this._hybridImageryLayer&&this._viewer.imageryLayers.remove(this._hybridImageryLayer);let i=new g({terrainProvider:this._terrainProvider,colors:this._colors,tilingScheme:this._terrainProvider.tilingScheme});this._hybridImageryLayer=this._viewer.imageryLayers.addImageryProvider(i),this._hybridImageryLayer.alpha=e,console.log("HybridImageryProvider overlay enabled")}hideImageryOverlay(){this._hybridImageryLayer&&(this._viewer.imageryLayers.remove(this._hybridImageryLayer),this._hybridImageryLayer=void 0,console.log("HybridImageryProvider overlay disabled"))}showTileCoordinates(){this._ensureTileCoordinatesLayer()}hideTileCoordinates(){this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0)}setAlpha(e){this._hybridImageryLayer&&(this._hybridImageryLayer.alpha=e)}flyTo(e,i){this._viewer.camera.flyTo({destination:e,...i,complete:()=>{this._visible&&this.update()}})}get tileCoordinatesVisible(){return!!this._tileCoordinatesLayer}get visible(){return this._visible}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};export{p as TerrainVisualizer};
|
package/dist/terrain/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var b=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var w=(n,e)=>{for(var i in e)b(n,i,{get:e[i],enumerable:!0})},M=(n,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of k(e))!A.call(n,t)&&t!==i&&b(n,t,{get:()=>e[t],enumerable:!(r=y(e,t))||r.enumerable});return n};var C=n=>M(b({},"__esModule",{value:!0}),n),_=(n,e,i,r)=>{for(var t=r>1?void 0:r?y(e,i):e,a=n.length-1,s;a>=0;a--)(s=n[a])&&(t=(r?s(e,i,t):s(t))||t);return r&&t&&b(e,i,t),t};var S={};w(S,{HybridTerrainProvider:()=>E});module.exports=C(S);var f=require("cesium");var c=class n{static _instance;_level=n._fromEnv();constructor(){}static get(){return this._instance||(this._instance=new n),this._instance}debug(...e){this._emit(n.Level.debug,e)}info(...e){this._emit(n.Level.info,e)}warn(...e){this._emit(n.Level.warn,e)}error(...e){this._emit(n.Level.error,e)}static _fromEnv(){let e=process.env.LOG_LEVEL?.toLowerCase();return e&&e in n.Level?n.Level[e]:n.Level.info}_emit(e,i){if(e<this._level)return;let r=n.Level[e];console[r==="debug"?"log":r](`[${r.toUpperCase()}]`.padEnd(n.LABEL_PAD+2),...i)}};(i=>{let n;(o=>(o[o.debug=0]="debug",o[o.info=1]="info",o[o.warn=2]="warn",o[o.error=3]="error"))(n=i.Level||={}),i.LABEL_PAD=Math.max(...Object.keys(i.Level).map(r=>r.length))})(c||={});var T=c;var D=T.get();function h({once:n=!0,includeStack:e=!1,message:i}){return(r,t,a)=>{let{label:s}=i;function o(){(!n||!h.has(s))&&(D.warn(R(i)),e&&console.trace("Deprecation stack trace:"),h.add(s))}if(t===void 0)return class extends r{constructor(...d){o(),super(...d)}};if(a===void 0){o();return}if(a.get){let d=a.get;if(a.get=function(){return o(),d.call(this)},a.set){let l=a.set;a.set=function(m){o(),l.call(this,m)}}return a}if(a.set){let d=a.set;return a.set=function(l){o(),d.call(this,l)},a}if(typeof a.value=="function"){let d=a.value;return a.value=function(...l){return o(),d.apply(this,l)},a}return a}}(a=>{let n=new Set;function e(s){n.add(s)}a.add=e;function i(){n.clear()}a.clear=i;function r(){return n.size}a.size=r;function t(s){return n.has(s)}a.has=t})(h||={});function R({label:n,since:e,removedIn:i,replacement:r,additional:t}){return[`${n} is deprecated since ${e}.`,r?`Use ${r} instead.`:void 0,`This will be removed in ${i}.`,t].filter(Boolean).join(" ")}var P=h;var v=class v{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;_errorEvent;_removeEventListeners;_hasWaterMask;_hasVertexNormals;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new f.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._hasWaterMask=this._defaultProvider.hasWaterMask||this._regions.some(r=>r.provider.hasWaterMask),this._hasVertexNormals=this._defaultProvider.hasVertexNormals||this._regions.some(r=>r.provider.hasVertexNormals),this._errorEvent=new f.Event,this._removeEventListeners=[];let i=new Set;for(let r of this._regions)i.has(r.provider)||(i.add(r.provider),this._removeEventListeners.push(r.provider.errorEvent.addEventListener(t=>{this._errorEvent.raiseEvent(t)})));i.has(this._defaultProvider)||this._removeEventListeners.push(this._defaultProvider.errorEvent.addEventListener(r=>{this._errorEvent.raiseEvent(r)})),i.has(this._fallbackProvider)||this._removeEventListeners.push(this._fallbackProvider.errorEvent.addEventListener(r=>{this._errorEvent.raiseEvent(r)})),this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){let e=new Set,i=[];for(let r of this._regions){if(e.has(r.provider))continue;e.add(r.provider);let t=r.provider.credit?.html;t&&i.push(t)}if(!e.has(this._defaultProvider)){let r=this._defaultProvider.credit?.html;r&&i.push(r)}return new f.Credit(i.join(" "))}get errorEvent(){return this._errorEvent}get hasWaterMask(){return this._hasWaterMask}get hasVertexNormals(){return this._hasVertexNormals}loadTileDataAvailability(e,i,r){for(let t of this._regions)if(v.regionContainsTile(t,e,i,r))return t.provider.loadTileDataAvailability(e,i,r);return this._defaultProvider.loadTileDataAvailability(e,i,r)}getLevelMaximumGeometricError(e){let i=this._defaultProvider.getLevelMaximumGeometricError(e);for(let r of this._regions){let t=r.provider.getLevelMaximumGeometricError(e);t>i&&(i=t)}return i}requestTileGeometry(e,i,r,t){if(this._ready){for(let a of this._regions)if(v.regionContainsTile(a,e,i,r))return a.provider.requestTileGeometry(e,i,r,t);return this._defaultProvider.getTileDataAvailable(e,i,r)?this._defaultProvider.requestTileGeometry(e,i,r,t):this._fallbackProvider.requestTileGeometry(e,i,r,t)}}getTileDataAvailable(e,i,r){for(let t of this._regions)if(v.regionContainsTile(t,e,i,r))return!0;return this._defaultProvider.getTileDataAvailable(e,i,r)}destroy(){for(let e of this._removeEventListeners)e();this._removeEventListeners.length=0,this._ready=!1}};_([P({message:{label:"_fallbackProvider",since:"0.4.6",removedIn:"0.5.0"}})],v.prototype,"fallbackProvider",1);var g=v;(r=>{function n(t,a,s){return new r({regions:t.map(o=>({...o})),defaultProvider:a,fallbackProvider:s})}r.fromTileRanges=n;function e(t,a,s,o){if(t.levels&&!t.levels.includes(o))return!1;if(t.tiles){let u=t.tiles.get(o);if(!u)return!1;let[d,l]=Array.isArray(u.x)?u.x:[u.x,u.x],[m,p]=Array.isArray(u.y)?u.y:[u.y,u.y];return a>=d&&a<=l&&s>=m&&s<=p}return!1}r.regionContainsTile=e;let i;(a=>{function t(s,o,u,d){if(s.levels&&!s.levels.includes(d))return!1;if(s.tiles){let l=s.tiles.get(d);if(!l)return!1;let[m,p]=Array.isArray(l.x)?l.x:[l.x,l.x],[x,L]=Array.isArray(l.y)?l.y:[l.y,l.y];return o>=m&&o<=p&&u>=x&&u<=L}return!1}a.contains=t})(i=r.TerrainRegion||={})})(g||={});var E=g;
|
package/dist/terrain/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Credit as
|
|
1
|
+
var P=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var b=(a,e,i,r)=>{for(var t=r>1?void 0:r?E(e,i):e,n=a.length-1,s;n>=0;n--)(s=a[n])&&(t=(r?s(e,i,t):s(t))||t);return r&&t&&P(e,i,t),t};import{Credit as k,EllipsoidTerrainProvider as A,Event as w}from"cesium";var m=class a{static _instance;_level=a._fromEnv();constructor(){}static get(){return this._instance||(this._instance=new a),this._instance}debug(...e){this._emit(a.Level.debug,e)}info(...e){this._emit(a.Level.info,e)}warn(...e){this._emit(a.Level.warn,e)}error(...e){this._emit(a.Level.error,e)}static _fromEnv(){let e=process.env.LOG_LEVEL?.toLowerCase();return e&&e in a.Level?a.Level[e]:a.Level.info}_emit(e,i){if(e<this._level)return;let r=a.Level[e];console[r==="debug"?"log":r](`[${r.toUpperCase()}]`.padEnd(a.LABEL_PAD+2),...i)}};(i=>{let a;(o=>(o[o.debug=0]="debug",o[o.info=1]="info",o[o.warn=2]="warn",o[o.error=3]="error"))(a=i.Level||={}),i.LABEL_PAD=Math.max(...Object.keys(i.Level).map(r=>r.length))})(m||={});var p=m;var x=p.get();function c({once:a=!0,includeStack:e=!1,message:i}){return(r,t,n)=>{let{label:s}=i;function o(){(!a||!c.has(s))&&(x.warn(L(i)),e&&console.trace("Deprecation stack trace:"),c.add(s))}if(t===void 0)return class extends r{constructor(...d){o(),super(...d)}};if(n===void 0){o();return}if(n.get){let d=n.get;if(n.get=function(){return o(),d.call(this)},n.set){let l=n.set;n.set=function(f){o(),l.call(this,f)}}return n}if(n.set){let d=n.set;return n.set=function(l){o(),d.call(this,l)},n}if(typeof n.value=="function"){let d=n.value;return n.value=function(...l){return o(),d.apply(this,l)},n}return n}}(n=>{let a=new Set;function e(s){a.add(s)}n.add=e;function i(){a.clear()}n.clear=i;function r(){return a.size}n.size=r;function t(s){return a.has(s)}n.has=t})(c||={});function L({label:a,since:e,removedIn:i,replacement:r,additional:t}){return[`${a} is deprecated since ${e}.`,r?`Use ${r} instead.`:void 0,`This will be removed in ${i}.`,t].filter(Boolean).join(" ")}var y=c;var v=class v{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;_errorEvent;_removeEventListeners;_hasWaterMask;_hasVertexNormals;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new A,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._hasWaterMask=this._defaultProvider.hasWaterMask||this._regions.some(r=>r.provider.hasWaterMask),this._hasVertexNormals=this._defaultProvider.hasVertexNormals||this._regions.some(r=>r.provider.hasVertexNormals),this._errorEvent=new w,this._removeEventListeners=[];let i=new Set;for(let r of this._regions)i.has(r.provider)||(i.add(r.provider),this._removeEventListeners.push(r.provider.errorEvent.addEventListener(t=>{this._errorEvent.raiseEvent(t)})));i.has(this._defaultProvider)||this._removeEventListeners.push(this._defaultProvider.errorEvent.addEventListener(r=>{this._errorEvent.raiseEvent(r)})),i.has(this._fallbackProvider)||this._removeEventListeners.push(this._fallbackProvider.errorEvent.addEventListener(r=>{this._errorEvent.raiseEvent(r)})),this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){let e=new Set,i=[];for(let r of this._regions){if(e.has(r.provider))continue;e.add(r.provider);let t=r.provider.credit?.html;t&&i.push(t)}if(!e.has(this._defaultProvider)){let r=this._defaultProvider.credit?.html;r&&i.push(r)}return new k(i.join(" "))}get errorEvent(){return this._errorEvent}get hasWaterMask(){return this._hasWaterMask}get hasVertexNormals(){return this._hasVertexNormals}loadTileDataAvailability(e,i,r){for(let t of this._regions)if(v.regionContainsTile(t,e,i,r))return t.provider.loadTileDataAvailability(e,i,r);return this._defaultProvider.loadTileDataAvailability(e,i,r)}getLevelMaximumGeometricError(e){let i=this._defaultProvider.getLevelMaximumGeometricError(e);for(let r of this._regions){let t=r.provider.getLevelMaximumGeometricError(e);t>i&&(i=t)}return i}requestTileGeometry(e,i,r,t){if(this._ready){for(let n of this._regions)if(v.regionContainsTile(n,e,i,r))return n.provider.requestTileGeometry(e,i,r,t);return this._defaultProvider.getTileDataAvailable(e,i,r)?this._defaultProvider.requestTileGeometry(e,i,r,t):this._fallbackProvider.requestTileGeometry(e,i,r,t)}}getTileDataAvailable(e,i,r){for(let t of this._regions)if(v.regionContainsTile(t,e,i,r))return!0;return this._defaultProvider.getTileDataAvailable(e,i,r)}destroy(){for(let e of this._removeEventListeners)e();this._removeEventListeners.length=0,this._ready=!1}};b([y({message:{label:"_fallbackProvider",since:"0.4.6",removedIn:"0.5.0"}})],v.prototype,"fallbackProvider",1);var h=v;(r=>{function a(t,n,s){return new r({regions:t.map(o=>({...o})),defaultProvider:n,fallbackProvider:s})}r.fromTileRanges=a;function e(t,n,s,o){if(t.levels&&!t.levels.includes(o))return!1;if(t.tiles){let u=t.tiles.get(o);if(!u)return!1;let[d,l]=Array.isArray(u.x)?u.x:[u.x,u.x],[f,g]=Array.isArray(u.y)?u.y:[u.y,u.y];return n>=d&&n<=l&&s>=f&&s<=g}return!1}r.regionContainsTile=e;let i;(n=>{function t(s,o,u,d){if(s.levels&&!s.levels.includes(d))return!1;if(s.tiles){let l=s.tiles.get(d);if(!l)return!1;let[f,g]=Array.isArray(l.x)?l.x:[l.x,l.x],[_,T]=Array.isArray(l.y)?l.y:[l.y,l.y];return o>=f&&o<=g&&u>=_&&u<=T}return!1}n.contains=t})(i=r.TerrainRegion||={})})(h||={});var M=h;export{M as HybridTerrainProvider};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juun-roh/cesium-utils",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "Solve common Cesium.js challenges: combine multiple terrain sources, tag and filter entity collections, and add visual highlights.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cesium",
|
|
@@ -142,31 +142,31 @@
|
|
|
142
142
|
}
|
|
143
143
|
},
|
|
144
144
|
"devDependencies": {
|
|
145
|
-
"@changesets/cli": "^2.
|
|
146
|
-
"@commitlint/cli": "^20.5.
|
|
145
|
+
"@changesets/cli": "^2.31.0",
|
|
146
|
+
"@commitlint/cli": "^20.5.2",
|
|
147
147
|
"@commitlint/config-conventional": "^20.5.0",
|
|
148
|
-
"@commitlint/cz-commitlint": "^20.5.
|
|
148
|
+
"@commitlint/cz-commitlint": "^20.5.2",
|
|
149
149
|
"@commitlint/format": "^20.5.0",
|
|
150
150
|
"@commitlint/types": "^20.5.0",
|
|
151
151
|
"@eslint/js": "^10.0.1",
|
|
152
152
|
"@types/node": "^25.6.0",
|
|
153
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
154
|
-
"@typescript-eslint/parser": "^8.
|
|
155
|
-
"@vitest/coverage-v8": "^4.1.
|
|
153
|
+
"@typescript-eslint/eslint-plugin": "^8.59.1",
|
|
154
|
+
"@typescript-eslint/parser": "^8.59.1",
|
|
155
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
156
156
|
"cesium": "^1.140.0",
|
|
157
|
-
"eslint": "^10.2.
|
|
157
|
+
"eslint": "^10.2.1",
|
|
158
158
|
"eslint-plugin-jsdoc": "^62.9.0",
|
|
159
159
|
"eslint-plugin-prettier": "^5.5.5",
|
|
160
|
-
"eslint-plugin-simple-import-sort": "^
|
|
160
|
+
"eslint-plugin-simple-import-sort": "^13.0.0",
|
|
161
161
|
"eslint-plugin-unused-imports": "^4.4.1",
|
|
162
162
|
"husky": "^9.1.7",
|
|
163
|
-
"jsdom": "^29.0
|
|
163
|
+
"jsdom": "^29.1.0",
|
|
164
164
|
"rimraf": "^6.1.3",
|
|
165
165
|
"tsup": "^8.5.1",
|
|
166
166
|
"typedoc": "^0.28.19",
|
|
167
|
-
"typescript": "^
|
|
168
|
-
"vite": "^8.0.
|
|
169
|
-
"vitest": "^4.1.
|
|
167
|
+
"typescript": "^6.0.3",
|
|
168
|
+
"vite": "^8.0.10",
|
|
169
|
+
"vitest": "^4.1.5"
|
|
170
170
|
},
|
|
171
171
|
"scripts": {
|
|
172
172
|
"attw": "pnpx @arethetypeswrong/cli --pack --ignore-rules 'no-resolution'",
|