@juun-roh/cesium-utils 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2JNRK7SN.js +1 -0
- package/dist/chunk-D2H7O3WV.js +1 -0
- package/dist/chunk-RXMNSDKR.js +0 -0
- package/dist/collection/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +92 -2
- package/dist/index.d.ts +92 -2
- package/dist/index.js +1 -1
- package/dist/terrain/index.js +1 -1
- package/dist/viewer/index.cjs +1 -1
- package/dist/viewer/index.d.cts +2 -82
- package/dist/viewer/index.d.ts +2 -82
- package/dist/viewer/index.js +1 -1
- package/package.json +15 -10
- package/dist/chunk-ATVZC562.js +0 -1
- package/dist/chunk-OFZW33MB.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Viewer as p}from"cesium";import{defined as m}from"cesium";function c(e,i){if(m(e)&&m(i)){let{camera:o}=e;i.camera.position=o.positionWC.clone(),i.camera.direction=o.directionWC.clone(),i.camera.up=o.upWC.clone()}}function y(e,i,o){let d={baseLayerPicker:e.baseLayerPicker!==void 0,geocoder:e.geocoder!==void 0,homeButton:e.homeButton!==void 0,sceneModePicker:e.sceneModePicker!==void 0,timeline:e.timeline!==void 0,navigationHelpButton:e.navigationHelpButton!==void 0,animation:e.animation!==void 0,fullscreenButton:e.fullscreenButton!==void 0,shouldAnimate:e.clock.shouldAnimate,terrainProvider:e.terrainProvider,requestRenderMode:e.scene.requestRenderMode,infoBox:e.infoBox!==void 0},n=new p(i,{...d,...o});c(e,n);let l=e.imageryLayers;n.imageryLayers.removeAll();for(let a=0;a<l.length;a++){let s=l.get(a);n.imageryLayers.addImageryProvider(s.imageryProvider,a)}n.clock.startTime=e.clock.startTime.clone(),n.clock.stopTime=e.clock.stopTime.clone(),n.clock.currentTime=e.clock.currentTime.clone(),n.clock.multiplier=e.clock.multiplier,n.clock.clockStep=e.clock.clockStep,n.clock.clockRange=e.clock.clockRange,n.clock.shouldAnimate=e.clock.shouldAnimate,n.scene.globe.enableLighting=e.scene.globe.enableLighting,n.scene.globe.depthTestAgainstTerrain=e.scene.globe.depthTestAgainstTerrain,n.scene.screenSpaceCameraController.enableCollisionDetection=e.scene.screenSpaceCameraController.enableCollisionDetection;let t=e.scene.screenSpaceCameraController.tiltEventTypes;t&&(n.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(t)?[...t]:t);let r=e.scene.screenSpaceCameraController.zoomEventTypes;return r&&(n.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(r)?[...r]:r),n}export{c as a,y as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{EllipsoidTerrainProvider as _}from"cesium";import{CesiumTerrainProvider as f}from"cesium";import{Rectangle as b}from"cesium";function d(s,r){if(r.size===0)return new b;let e=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY,u=Array.from(r.keys()),l=Math.min(...u),c=r.get(l);if(c){let{start:h,end:v}=c,T=s.tileXYToRectangle(h.x,h.y,l),g=s.tileXYToRectangle(v.x,v.y,l);e=Math.min(T.west,e),i=Math.min(g.south,i),t=Math.max(g.east,t),a=Math.max(T.north,a)}return new b(e,i,t,a)}var n=class{_terrainProvider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(r){this._terrainProvider=r.terrainProvider,this._tileRanges=r.tileRanges,this._credit=r.credit||"custom",this._isCustom=r.isCustom!==void 0?r.isCustom:!0,this._rectangle=d(r.terrainProvider.tilingScheme,r.tileRanges),r.tileRanges.forEach((e,i)=>{this._terrainProvider.availability?.addAvailableTileRange(i,e.start.x,e.start.y,e.end.x,e.end.y)}),this._ready=!0}contains(r,e,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let t=this._tileRanges.get(i);return r>=t.start.x&&r<=t.end.x&&e>=t.start.y&&e<=t.end.y}requestTileGeometry(r,e,i,t){if(!(!this._ready||!this.contains(r,e,i)))return this._terrainProvider.requestTileGeometry(r,e,i,t)}getTileDataAvailable(r,e,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let t=this._tileRanges.get(i);return r>=t.start.x&&r<=t.end.x&&e>=t.start.y&&e<=t.end.y}get isCustom(){return this._isCustom}get credit(){return this._credit}get terrainProvider(){return this._terrainProvider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(r=>{async function s(e,i,t){let a=t?.credit||"custom",u=await f.fromUrl(e,{...t,credit:a});return new r({terrainProvider:u,tileRanges:i,credit:a})}r.fromUrl=s})(n||={});var o=class extends Array{add(r){if(Array.isArray(r)){for(let i of r)this.add(i);return this.length}let e;return r instanceof n?e=r:e=new n(r),this.push(e)}remove(r){if(Array.isArray(r))return r.forEach(i=>this.remove(i)),this;let e=this.indexOf(r);return e>=0&&this.splice(e,1),this}removeAll(){this.length=0}};var m=class{_terrainAreas=new o;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(r){this._terrainProvider=r.terrainProvider,this._fallbackProvider=r.fallbackProvider||new _,this._tilingScheme=r.terrainProvider.tilingScheme,this._terrainAreas=new o(...r.terrainAreas),this._availability=r.terrainProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get terrainAreas(){return[...this._terrainAreas]}get defaultProvider(){return this._terrainProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._terrainProvider?.credit}get errorEvent(){return this._terrainProvider.errorEvent}get hasWaterMask(){return this._terrainProvider.hasWaterMask}get hasVertexNormals(){return this._terrainProvider.hasVertexNormals}loadTileDataAvailability(r,e,i){return this._terrainProvider.loadTileDataAvailability(r,e,i)}getLevelMaximumGeometricError(r){return this._terrainProvider.getLevelMaximumGeometricError(r)}requestTileGeometry(r,e,i,t){if(this._ready){for(let a of this._terrainAreas)if(a.contains(r,e,i))return a.requestTileGeometry(r,e,i,t);return this._terrainProvider.getTileDataAvailable(r,e,i)?this._terrainProvider.requestTileGeometry(r,e,i,t):this._fallbackProvider.requestTileGeometry(r,e,i,t)}}getTileDataAvailable(r,e,i){for(let t of this._terrainAreas)if(t.contains(r,e,i))return t.getTileDataAvailable(r,e,i);return this._terrainProvider.getTileDataAvailable(r,e,i)}};export{d as a,n as b,o as c,m as d};
|
|
File without changes
|
package/dist/collection/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import"../chunk-RXMNSDKR.js";import{c as a}from"../chunk-XTUDPAWI.js";export{a as Collection};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var V=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var W=(n,e)=>{for(var t in e)V(n,t,{get:e[t],enumerable:!0})},q=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Y(e))!j.call(n,i)&&i!==t&&V(n,i,{get:()=>e[i],enumerable:!(r=F(e,i))||r.enumerable});return n};var U=n=>q(V({},"__esModule",{value:!0}),n);var X={};W(X,{Collection:()=>v,Highlight:()=>_,HybridTerrainProvider:()=>A,TerrainArea:()=>m,TerrainAreaCollection:()=>f,TerrainVisualizer:()=>g,cloneViewer:()=>S,computeRectangle:()=>w,isGetterOnly:()=>y,syncCamera:()=>T});module.exports=U(X);var p=require("cesium");var d=require("cesium");var g=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",d.Color.RED],["default",d.Color.BLUE],["fallback",d.Color.GRAY],["grid",d.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new v({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([r,i])=>{this._colors.set(r,i)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(n.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new d.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:d.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let r=this._terrainProvider.tilingScheme;try{let i=this._calculateTileBounds(e,t,r);this._generateVisibleTiles(i,t,r).forEach(s=>{this._collection.add(s.entity,n.tag.grid)})}catch(i){console.error("Error displaying tile grid:",i)}}_calculateTileBounds(e,t,r){let i=r.positionToTileXY(d.Rectangle.northwest(e),t),a=r.positionToTileXY(d.Rectangle.southeast(e),t);if(!i||!a)throw new Error("Failed to calculate tile bounds");return{start:i,end:a}}_generateVisibleTiles(e,t,r){let i=[],s=Math.min(e.end.x-e.start.x+1,100),l=Math.min(e.end.y-e.start.y+1,100);for(let c=e.start.x;c<e.start.x+s;c++)for(let h=e.start.y;h<e.start.y+l;h++)try{let u=this._createTileEntity(c,h,t,r);u&&i.push({entity:u})}catch(u){console.warn(`Error creating tile (${c}, ${h}, ${t}):`,u)}return i}_createTileEntity(e,t,r,i){let a=i.tileXYToRectangle(e,t,r);if(!this._isValidRectangle(a))return null;let s=this._getTileColor(e,t,r),l=n.createRectangle(a,s.withAlpha(.3));return l.properties?.addProperty("tileX",e),l.properties?.addProperty("tileY",t),l.properties?.addProperty("tileLevel",r),l}_getTileColor(e,t,r){if(!this._terrainProvider)return this._colors.get("fallback")||d.Color.TRANSPARENT;for(let i of this._terrainProvider.terrainAreas)if(i.contains(e,t,r))return i.isCustom?this._colors.get("custom")||d.Color.RED:this._colors.get("default")||d.Color.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,r)?this._colors.get("default")||d.Color.BLUE:this._colors.get("fallback")||d.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,r])=>{this._colors.set(t,r)}),this.update()}flyTo(e,t){let{rectangle:r}=e;this._viewer.camera.flyTo({destination:r,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(r=>{r.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(i,a){return new d.Entity({rectangle:{coordinates:i,material:a,heightReference:d.HeightReference.CLAMP_TO_GROUND}})}r.createRectangle=e;function t(i,a,s){let l=s?.tag||"terrain_area_visualization",c=s?.color||d.Color.RED,h=s?.maxTilesToShow||100,u=s?.show??!0,b=s?.alpha||.7,C=s?.tileAlpha||.2,R=new v({collection:a.entities,tag:l}),{rectangle:D}=i;if(R.add(r.createRectangle(D,c.withAlpha(b)),l),u&&i.tileRanges.size>0){let{tilingScheme:H}=i.terrainProvider,E=0;i.tileRanges.forEach((P,z)=>{for(let I=P.start.x;I<=P.end.x&&E<h;I++)for(let x=P.start.y;x<=P.end.y&&E<h;x++){let B=H.tileXYToRectangle(I,x,z);R.add(e(B,c.withAlpha(C)),`${l}_tile`),E++}})}return R}r.visualize=t})(g||={});function y(n,e){let t=!1,r=Object.getOwnPropertyDescriptor(n,e);if(!r){let i=Object.getPrototypeOf(n);for(;i&&!r;)r=Object.getOwnPropertyDescriptor(i,e),i=Object.getPrototypeOf(i)}return r&&r.get&&!r.set&&(t=!0),t}var O=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let r=this._eventListeners.get(e);if(r){let i={type:e,...t};r.forEach(a=>a(i))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],r=this._tagMap.get(t);r&&(r.delete(e),r.size===0&&this._tagMap.delete(t))}_invalidateCache(){this._valuesCache=null}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,r){return Array.isArray(e)?e.forEach(i=>{this.add(i,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,r),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let i=this.collection.remove(e);return i&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),i}if(Array.isArray(e)){if(e.length===0)return!1;let i=!1;for(let a of e)this.remove(a)&&(i=!0);return i}let t=this.get(e);if(t.length===0)return!1;let r=!1;for(let i of t)this.remove(i)&&(r=!0);return r}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof p.EntityCollection)return this.collection.values;{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));return e}}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let r=this.get(e);for(let i of r)this._removeFromTagMap(i),Object.defineProperty(i,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(i,t);return r.length>0&&this._emit("update",{items:r,tag:t}),r.length}show(e){let t=this.get(e);for(let r of t)(0,p.defined)(r.show)&&(r.show=!0);return this}hide(e){let t=this.get(e);for(let r of t)(0,p.defined)(r.show)&&(r.show=!1);return this}toggle(e){let t=this.get(e);for(let r of t)(0,p.defined)(r.show)&&(r.show=!r.show);return this}setProperty(e,t,r=this.tag){let i=this.get(r);for(let a of i)if(e in a&&typeof a[e]!="function"){if(y(a,e))throw Error(`setProperty(${a}, ${e}) failed; The property is readonly.`);a[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((i,a)=>e(i,a))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},v=O;var k=require("cesium");var G=require("cesium");var L=require("cesium");function w(n,e){if(e.size===0)return new L.Rectangle;let t=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY,s=Array.from(e.keys()),l=Math.min(...s),c=e.get(l);if(c){let{start:h,end:u}=c,b=n.tileXYToRectangle(h.x,h.y,l),C=n.tileXYToRectangle(u.x,u.y,l);t=Math.min(b.west,t),r=Math.min(C.south,r),i=Math.max(C.east,i),a=Math.max(b.north,a)}return new L.Rectangle(t,r,i,a)}var m=class{_terrainProvider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(e){this._terrainProvider=e.terrainProvider,this._tileRanges=e.tileRanges,this._credit=e.credit||"custom",this._isCustom=e.isCustom!==void 0?e.isCustom:!0,this._rectangle=w(e.terrainProvider.tilingScheme,e.tileRanges),e.tileRanges.forEach((t,r)=>{this._terrainProvider.availability?.addAvailableTileRange(r,t.start.x,t.start.y,t.end.x,t.end.y)}),this._ready=!0}contains(e,t,r){if(this._tileRanges.size===0||!this._tileRanges.has(r))return!1;let i=this._tileRanges.get(r);return e>=i.start.x&&e<=i.end.x&&t>=i.start.y&&t<=i.end.y}requestTileGeometry(e,t,r,i){if(!(!this._ready||!this.contains(e,t,r)))return this._terrainProvider.requestTileGeometry(e,t,r,i)}getTileDataAvailable(e,t,r){if(this._tileRanges.size===0||!this._tileRanges.has(r))return!1;let i=this._tileRanges.get(r);return e>=i.start.x&&e<=i.end.x&&t>=i.start.y&&t<=i.end.y}get isCustom(){return this._isCustom}get credit(){return this._credit}get terrainProvider(){return this._terrainProvider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(e=>{async function n(t,r,i){let a=i?.credit||"custom",s=await G.CesiumTerrainProvider.fromUrl(t,{...i,credit:a});return new e({terrainProvider:s,tileRanges:r,credit:a})}e.fromUrl=n})(m||={});var f=class extends Array{add(e){if(Array.isArray(e)){for(let r of e)this.add(r);return this.length}let t;return e instanceof m?t=e:t=new m(e),this.push(t)}remove(e){if(Array.isArray(e))return e.forEach(r=>this.remove(r)),this;let t=this.indexOf(e);return t>=0&&this.splice(t,1),this}removeAll(){this.length=0}};var A=class{_terrainAreas=new f;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._terrainProvider=e.terrainProvider,this._fallbackProvider=e.fallbackProvider||new k.EllipsoidTerrainProvider,this._tilingScheme=e.terrainProvider.tilingScheme,this._terrainAreas=new f(...e.terrainAreas),this._availability=e.terrainProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get terrainAreas(){return[...this._terrainAreas]}get defaultProvider(){return this._terrainProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._terrainProvider?.credit}get errorEvent(){return this._terrainProvider.errorEvent}get hasWaterMask(){return this._terrainProvider.hasWaterMask}get hasVertexNormals(){return this._terrainProvider.hasVertexNormals}loadTileDataAvailability(e,t,r){return this._terrainProvider.loadTileDataAvailability(e,t,r)}getLevelMaximumGeometricError(e){return this._terrainProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,r,i){if(this._ready){for(let a of this._terrainAreas)if(a.contains(e,t,r))return a.requestTileGeometry(e,t,r,i);return this._terrainProvider.getTileDataAvailable(e,t,r)?this._terrainProvider.requestTileGeometry(e,t,r,i):this._fallbackProvider.requestTileGeometry(e,t,r,i)}}getTileDataAvailable(e,t,r){for(let i of this._terrainAreas)if(i.contains(e,t,r))return i.getTileDataAvailable(e,t,r);return this._terrainProvider.getTileDataAvailable(e,t,r)}};var N=require("cesium");var M=require("cesium");function T(n,e){if((0,M.defined)(n)&&(0,M.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 r={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},i=new N.Viewer(e,{...r,...t});T(n,i);let a=n.imageryLayers;i.imageryLayers.removeAll();for(let c=0;c<a.length;c++){let h=a.get(c);i.imageryLayers.addImageryProvider(h.imageryProvider,c)}i.clock.startTime=n.clock.startTime.clone(),i.clock.stopTime=n.clock.stopTime.clone(),i.clock.currentTime=n.clock.currentTime.clone(),i.clock.multiplier=n.clock.multiplier,i.clock.clockStep=n.clock.clockStep,i.clock.clockRange=n.clock.clockRange,i.clock.shouldAnimate=n.clock.shouldAnimate,i.scene.globe.enableLighting=n.scene.globe.enableLighting,i.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,i.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let s=n.scene.screenSpaceCameraController.tiltEventTypes;s&&(i.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(s)?[...s]:s);let l=n.scene.screenSpaceCameraController.zoomEventTypes;return l&&(i.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(l)?[...l]:l),i}var o=require("cesium"),_=class n{static instances=new Map;_defaultColor=o.Color.YELLOW.withAlpha(.5);_entity;_entities;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}))}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,r=n.instances.get(t);r&&(r.hide(),r._entity&&e.entities.remove(r._entity),n.instances.delete(t))}show(e,t=this._defaultColor,r=!1){if(!(!(0,o.defined)(e)||!this._entity)){this._clearGeometries();try{if(e instanceof o.Entity)this._update(e,t,r);else if(e.id instanceof o.Entity)this._update(e.id,t,r);else if(e.primitive instanceof o.GroundPrimitive)this._update(e.primitive,t,r);else return;return this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i);return}}}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t,r){if(e instanceof o.Entity){if(e.polygon)if(r){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let a;i.positions.length>0&&!o.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?a=[...i.positions,i.positions[0]]:a=i.positions,this._entity.polyline=new o.PolylineGraphics({positions:a,material:t,width:2,clampToGround:e.polygon.heightReference?.getValue()===o.HeightReference.CLAMP_TO_GROUND})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new o.PolygonGraphics({hierarchy:i,material:t,heightReference:e.polygon.heightReference?.getValue(),classificationType:e.polygon.classificationType?.getValue()||o.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let a=e.polyline.width?.getValue();this._entity.polyline=new o.PolylineGraphics({positions:i,material:t,width:a+2,clampToGround:e.polyline.clampToGround?.getValue()})}}else if(e.rectangle)if(r){let i=e.rectangle.coordinates?.getValue();if(i){let a=[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:a,material:t,width:2,clampToGround:e.rectangle.heightReference?.getValue()===o.HeightReference.CLAMP_TO_GROUND})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new o.RectangleGraphics({coordinates:i,material:t,heightReference:e.rectangle.heightReference?.getValue()}))}}else if(e instanceof o.GroundPrimitive){let i=e.geometryInstances,a=Array.isArray(i)?i[0]:i;if(!a.geometry.attributes.position)return;let s=a.geometry.attributes.position.values,l=[];for(let c=0;c<s.length;c+=3)l.push(new o.Cartesian3(s[c],s[c+1],s[c+2]));r?this._entity.polyline=new o.PolylineGraphics({positions:l,material:t,width:2,clampToGround:!0}):this._entity.polygon=new o.PolygonGraphics({hierarchy:new o.PolygonHierarchy(l),material:t,heightReference:o.HeightReference.CLAMP_TO_GROUND,classificationType:o.ClassificationType.BOTH})}}hide(){this._entity&&(this._entity.show=!1)}get defaultColor(){return this._defaultColor}set defaultColor(e){this._defaultColor=e}get entity(){return this._entity}};
|
|
1
|
+
"use strict";var L=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var $=(n,e)=>{for(var t in e)L(n,t,{get:e[t],enumerable:!0})},K=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of U(e))!X.call(n,i)&&i!==t&&L(n,i,{get:()=>e[i],enumerable:!(r=j(e,i))||r.enumerable});return n};var J=n=>K(L({},"__esModule",{value:!0}),n);var Q={};$(Q,{Collection:()=>y,Highlight:()=>C,HybridTerrainProvider:()=>A,TerrainArea:()=>g,TerrainAreaCollection:()=>p,TerrainVisualizer:()=>v,cloneViewer:()=>D,computeRectangle:()=>w,isGetterOnly:()=>P,syncCamera:()=>R});module.exports=J(Q);var _=require("cesium");var h=require("cesium");var v=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",h.Color.RED],["default",h.Color.BLUE],["fallback",h.Color.GRAY],["grid",h.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new y({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([r,i])=>{this._colors.set(r,i)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(n.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new h.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:h.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let r=this._terrainProvider.tilingScheme;try{let i=this._calculateTileBounds(e,t,r);this._generateVisibleTiles(i,t,r).forEach(s=>{this._collection.add(s.entity,n.tag.grid)})}catch(i){console.error("Error displaying tile grid:",i)}}_calculateTileBounds(e,t,r){let i=r.positionToTileXY(h.Rectangle.northwest(e),t),o=r.positionToTileXY(h.Rectangle.southeast(e),t);if(!i||!o)throw new Error("Failed to calculate tile bounds");return{start:i,end:o}}_generateVisibleTiles(e,t,r){let i=[],s=Math.min(e.end.x-e.start.x+1,100),l=Math.min(e.end.y-e.start.y+1,100);for(let c=e.start.x;c<e.start.x+s;c++)for(let m=e.start.y;m<e.start.y+l;m++)try{let f=this._createTileEntity(c,m,t,r);f&&i.push({entity:f})}catch(f){console.warn(`Error creating tile (${c}, ${m}, ${t}):`,f)}return i}_createTileEntity(e,t,r,i){let o=i.tileXYToRectangle(e,t,r);if(!this._isValidRectangle(o))return null;let s=this._getTileColor(e,t,r),l=n.createRectangle(o,s.withAlpha(.3));return l.properties?.addProperty("tileX",e),l.properties?.addProperty("tileY",t),l.properties?.addProperty("tileLevel",r),l}_getTileColor(e,t,r){if(!this._terrainProvider)return this._colors.get("fallback")||h.Color.TRANSPARENT;for(let i of this._terrainProvider.terrainAreas)if(i.contains(e,t,r))return i.isCustom?this._colors.get("custom")||h.Color.RED:this._colors.get("default")||h.Color.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,r)?this._colors.get("default")||h.Color.BLUE:this._colors.get("fallback")||h.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,r])=>{this._colors.set(t,r)}),this.update()}flyTo(e,t){let{rectangle:r}=e;this._viewer.camera.flyTo({destination:r,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(r=>{r.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(i,o){return new h.Entity({rectangle:{coordinates:i,material:o,heightReference:h.HeightReference.CLAMP_TO_GROUND}})}r.createRectangle=e;function t(i,o,s){let l=s?.tag||"terrain_area_visualization",c=s?.color||h.Color.RED,m=s?.maxTilesToShow||100,f=s?.show??!0,E=s?.alpha||.7,I=s?.tileAlpha||.2,S=new y({collection:o.entities,tag:l}),{rectangle:B}=i;if(S.add(r.createRectangle(B,c.withAlpha(E)),l),f&&i.tileRanges.size>0){let{tilingScheme:Y}=i.terrainProvider,O=0;i.tileRanges.forEach((x,W)=>{for(let V=x.start.x;V<=x.end.x&&O<m;V++)for(let M=x.start.y;M<=x.end.y&&O<m;M++){let q=Y.tileXYToRectangle(V,M,W);S.add(e(q,c.withAlpha(I)),`${l}_tile`),O++}})}return S}r.visualize=t})(v||={});function P(n,e){let t=!1,r=Object.getOwnPropertyDescriptor(n,e);if(!r){let i=Object.getPrototypeOf(n);for(;i&&!r;)r=Object.getOwnPropertyDescriptor(i,e),i=Object.getPrototypeOf(i)}return r&&r.get&&!r.set&&(t=!0),t}var G=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let r=this._eventListeners.get(e);if(r){let i={type:e,...t};r.forEach(o=>o(i))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],r=this._tagMap.get(t);r&&(r.delete(e),r.size===0&&this._tagMap.delete(t))}_invalidateCache(){this._valuesCache=null}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,r){return Array.isArray(e)?e.forEach(i=>{this.add(i,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,r),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let i=this.collection.remove(e);return i&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),i}if(Array.isArray(e)){if(e.length===0)return!1;let i=!1;for(let o of e)this.remove(o)&&(i=!0);return i}let t=this.get(e);if(t.length===0)return!1;let r=!1;for(let i of t)this.remove(i)&&(r=!0);return r}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof _.EntityCollection)return this.collection.values;{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));return e}}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let r=this.get(e);for(let i of r)this._removeFromTagMap(i),Object.defineProperty(i,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(i,t);return r.length>0&&this._emit("update",{items:r,tag:t}),r.length}show(e){let t=this.get(e);for(let r of t)(0,_.defined)(r.show)&&(r.show=!0);return this}hide(e){let t=this.get(e);for(let r of t)(0,_.defined)(r.show)&&(r.show=!1);return this}toggle(e){let t=this.get(e);for(let r of t)(0,_.defined)(r.show)&&(r.show=!r.show);return this}setProperty(e,t,r=this.tag){let i=this.get(r);for(let o of i)if(e in o&&typeof o[e]!="function"){if(P(o,e))throw Error(`setProperty(${o}, ${e}) failed; The property is readonly.`);o[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((i,o)=>e(i,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},y=G;var d=require("cesium");var u=require("cesium"),T=class{_color=u.Color.RED;_silhouette;_composite;_stages;_entity;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=u.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=u.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}show(e,t=this._color,r){if(!(!(0,u.defined)(e)||this._silhouette.selected[0]===e))if(e instanceof u.Cesium3DTileFeature)this._silhouette.selected.push(e);else{if(!e.model)return;this._entity=e,e.model.silhouetteSize=new u.ConstantProperty(r?.width||2),e.model.silhouetteColor=new u.ConstantProperty(t)}}hide(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new u.ConstantProperty(u.Color.TRANSPARENT),this._entity=void 0)}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite)}get color(){return this._color}set color(e){this._color=e}};var a=require("cesium"),b=class{_color=a.Color.RED;_entity;_entities;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new a.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}show(e,t=this._color,r){if(!(!(0,a.defined)(e)||!this._entity)){this._clearGeometries();try{if(e instanceof a.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t,r);else if(e instanceof a.GroundPrimitive)this._update(e,t,r);else return;return this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i);return}}}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t,r={outline:!1,width:2}){if(e instanceof a.Entity){if(e.polygon)if(r.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let o;i.positions.length>0&&!a.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?o=[...i.positions,i.positions[0]]:o=i.positions,this._entity.polyline=new a.PolylineGraphics({positions:o,material:t,width:r.width||2,clampToGround:e.polygon.heightReference?.getValue()===a.HeightReference.CLAMP_TO_GROUND})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new a.PolygonGraphics({hierarchy:i,material:t,heightReference:e.polygon.heightReference?.getValue(),classificationType:e.polygon.classificationType?.getValue()||a.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let o=e.polyline.width?.getValue();this._entity.polyline=new a.PolylineGraphics({positions:i,material:t,width:o+(r.width||2),clampToGround:e.polyline.clampToGround?.getValue()})}}else if(e.rectangle)if(r.outline){let i=e.rectangle.coordinates?.getValue();if(i){let o=[a.Cartesian3.fromRadians(i.west,i.north),a.Cartesian3.fromRadians(i.east,i.north),a.Cartesian3.fromRadians(i.east,i.south),a.Cartesian3.fromRadians(i.west,i.south),a.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new a.PolylineGraphics({positions:o,material:t,width:r.width||2,clampToGround:e.rectangle.heightReference?.getValue()===a.HeightReference.CLAMP_TO_GROUND})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new a.RectangleGraphics({coordinates:i,material:t,heightReference:e.rectangle.heightReference?.getValue()}))}}else if(e instanceof a.GroundPrimitive){let i=e.geometryInstances,o=Array.isArray(i)?i[0]:i;if(!o.geometry.attributes.position)return;let s=o.geometry.attributes.position.values,l=[];for(let c=0;c<s.length;c+=3)l.push(new a.Cartesian3(s[c],s[c+1],s[c+2]));r.outline?this._entity.polyline=new a.PolylineGraphics({positions:l,material:t,width:r.width||2,clampToGround:!0}):this._entity.polygon=new a.PolygonGraphics({hierarchy:new a.PolygonHierarchy(l),material:t,heightReference:a.HeightReference.CLAMP_TO_GROUND,classificationType:a.ClassificationType.BOTH})}}hide(){this._entity&&(this._entity.show=!1)}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity)}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}};var C=class n{static instances=new WeakMap;_surface;_silhouette;_color=d.Color.RED;constructor(e){this._surface=new b(e),this._silhouette=new T(e),this._surface.color=this._color,this._silhouette.color=this._color}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,r=n.instances.get(t);r&&(r.hide(),r._surface&&r._surface.destroy(),r._silhouette&&r._silhouette.destroy(),n.instances.delete(t))}show(e,t=this._color,r){this.hide();let i=this._getObject(e);if((0,d.defined)(i))return i instanceof d.Cesium3DTileFeature||i instanceof d.Entity&&i.model?this._silhouette.show(i,t,r):this._surface.show(i,t,r)}_getObject(e){if((0,d.defined)(e)){if(e instanceof d.Entity||e instanceof d.Cesium3DTileFeature||e instanceof d.GroundPrimitive)return e;if(e.id instanceof d.Entity)return e.id;if(e.primitive instanceof d.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}};var F=require("cesium");var N=require("cesium");var H=require("cesium");function w(n,e){if(e.size===0)return new H.Rectangle;let t=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY,s=Array.from(e.keys()),l=Math.min(...s),c=e.get(l);if(c){let{start:m,end:f}=c,E=n.tileXYToRectangle(m.x,m.y,l),I=n.tileXYToRectangle(f.x,f.y,l);t=Math.min(E.west,t),r=Math.min(I.south,r),i=Math.max(I.east,i),o=Math.max(E.north,o)}return new H.Rectangle(t,r,i,o)}var g=class{_terrainProvider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(e){this._terrainProvider=e.terrainProvider,this._tileRanges=e.tileRanges,this._credit=e.credit||"custom",this._isCustom=e.isCustom!==void 0?e.isCustom:!0,this._rectangle=w(e.terrainProvider.tilingScheme,e.tileRanges),e.tileRanges.forEach((t,r)=>{this._terrainProvider.availability?.addAvailableTileRange(r,t.start.x,t.start.y,t.end.x,t.end.y)}),this._ready=!0}contains(e,t,r){if(this._tileRanges.size===0||!this._tileRanges.has(r))return!1;let i=this._tileRanges.get(r);return e>=i.start.x&&e<=i.end.x&&t>=i.start.y&&t<=i.end.y}requestTileGeometry(e,t,r,i){if(!(!this._ready||!this.contains(e,t,r)))return this._terrainProvider.requestTileGeometry(e,t,r,i)}getTileDataAvailable(e,t,r){if(this._tileRanges.size===0||!this._tileRanges.has(r))return!1;let i=this._tileRanges.get(r);return e>=i.start.x&&e<=i.end.x&&t>=i.start.y&&t<=i.end.y}get isCustom(){return this._isCustom}get credit(){return this._credit}get terrainProvider(){return this._terrainProvider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(e=>{async function n(t,r,i){let o=i?.credit||"custom",s=await N.CesiumTerrainProvider.fromUrl(t,{...i,credit:o});return new e({terrainProvider:s,tileRanges:r,credit:o})}e.fromUrl=n})(g||={});var p=class extends Array{add(e){if(Array.isArray(e)){for(let r of e)this.add(r);return this.length}let t;return e instanceof g?t=e:t=new g(e),this.push(t)}remove(e){if(Array.isArray(e))return e.forEach(r=>this.remove(r)),this;let t=this.indexOf(e);return t>=0&&this.splice(t,1),this}removeAll(){this.length=0}};var A=class{_terrainAreas=new p;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._terrainProvider=e.terrainProvider,this._fallbackProvider=e.fallbackProvider||new F.EllipsoidTerrainProvider,this._tilingScheme=e.terrainProvider.tilingScheme,this._terrainAreas=new p(...e.terrainAreas),this._availability=e.terrainProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get terrainAreas(){return[...this._terrainAreas]}get defaultProvider(){return this._terrainProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._terrainProvider?.credit}get errorEvent(){return this._terrainProvider.errorEvent}get hasWaterMask(){return this._terrainProvider.hasWaterMask}get hasVertexNormals(){return this._terrainProvider.hasVertexNormals}loadTileDataAvailability(e,t,r){return this._terrainProvider.loadTileDataAvailability(e,t,r)}getLevelMaximumGeometricError(e){return this._terrainProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,r,i){if(this._ready){for(let o of this._terrainAreas)if(o.contains(e,t,r))return o.requestTileGeometry(e,t,r,i);return this._terrainProvider.getTileDataAvailable(e,t,r)?this._terrainProvider.requestTileGeometry(e,t,r,i):this._fallbackProvider.requestTileGeometry(e,t,r,i)}}getTileDataAvailable(e,t,r){for(let i of this._terrainAreas)if(i.contains(e,t,r))return i.getTileDataAvailable(e,t,r);return this._terrainProvider.getTileDataAvailable(e,t,r)}};var z=require("cesium");var k=require("cesium");function R(n,e){if((0,k.defined)(n)&&(0,k.defined)(e)){let{camera:t}=n;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}function D(n,e,t){let r={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},i=new z.Viewer(e,{...r,...t});R(n,i);let o=n.imageryLayers;i.imageryLayers.removeAll();for(let c=0;c<o.length;c++){let m=o.get(c);i.imageryLayers.addImageryProvider(m.imageryProvider,c)}i.clock.startTime=n.clock.startTime.clone(),i.clock.stopTime=n.clock.stopTime.clone(),i.clock.currentTime=n.clock.currentTime.clone(),i.clock.multiplier=n.clock.multiplier,i.clock.clockStep=n.clock.clockStep,i.clock.clockRange=n.clock.clockRange,i.clock.shouldAnimate=n.clock.shouldAnimate,i.scene.globe.enableLighting=n.scene.globe.enableLighting,i.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,i.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let s=n.scene.screenSpaceCameraController.tiltEventTypes;s&&(i.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(s)?[...s]:s);let l=n.scene.screenSpaceCameraController.zoomEventTypes;return l&&(i.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(l)?[...l]:l),i}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,96 @@
|
|
|
1
1
|
export { CesiumCollection, CesiumCollectionItem, Collection, CollectionEventType, EventHandler, NonFunction, Tag, WithTag } from './collection/index.cjs';
|
|
2
|
+
import { Entity, Cesium3DTileFeature, GroundPrimitive, Primitive, Model, Cesium3DTileset, Color, Viewer } from 'cesium';
|
|
2
3
|
export { H as HybridTerrainProvider, T as TerrainArea, a as TileRange } from './hybrid-terrain-provider-C4b9z5pv.cjs';
|
|
3
4
|
export { TerrainAreaCollection, computeRectangle } from './terrain/index.cjs';
|
|
4
5
|
export { TerrainVisualizer, isGetterOnly } from './utils/index.cjs';
|
|
5
|
-
export {
|
|
6
|
-
|
|
6
|
+
export { cloneViewer, syncCamera } from './viewer/index.cjs';
|
|
7
|
+
|
|
8
|
+
interface IHighlight {
|
|
9
|
+
show(object: any, color?: Color, options?: HighlightOptions): void;
|
|
10
|
+
hide(): void;
|
|
11
|
+
destroy(): void;
|
|
12
|
+
color: Color;
|
|
13
|
+
}
|
|
14
|
+
interface HighlightOptions {
|
|
15
|
+
outline?: boolean;
|
|
16
|
+
width?: number;
|
|
17
|
+
}
|
|
18
|
+
type PickedObject = {
|
|
19
|
+
id?: Entity;
|
|
20
|
+
primitive?: Primitive | GroundPrimitive | Model | Cesium3DTileset;
|
|
21
|
+
tileset?: Cesium3DTileset;
|
|
22
|
+
detail?: {
|
|
23
|
+
model?: Model;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
type Picked = Entity | Cesium3DTileFeature | GroundPrimitive | PickedObject;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @class
|
|
30
|
+
* Lightweight multiton highlight manager for Cesium using flyweight pattern.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```
|
|
34
|
+
* // Setup
|
|
35
|
+
* const viewer1 = new Viewer('cesiumContainer1');
|
|
36
|
+
* const viewer2 = new Viewer('cesiumContainer2');
|
|
37
|
+
*
|
|
38
|
+
* const highlighter1 = Highlight.getInstance(viewer1);
|
|
39
|
+
* const highlighter2 = Highlight.getInstance(viewer2);
|
|
40
|
+
*
|
|
41
|
+
* // This highlight only affects viewer1
|
|
42
|
+
* highlighter1.show(someEntity, Color.RED);
|
|
43
|
+
*
|
|
44
|
+
* // This highlight only affects viewer2
|
|
45
|
+
* highlighter2.show(someEntity, Color.BLUE);
|
|
46
|
+
*
|
|
47
|
+
* // When done with viewers
|
|
48
|
+
* Highlight.releaseInstance(viewer1);
|
|
49
|
+
* Highlight.releaseInstance(viewer2);
|
|
50
|
+
* viewer1.destroy();
|
|
51
|
+
* viewer2.destroy();
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare class Highlight {
|
|
55
|
+
private static instances;
|
|
56
|
+
private _surface;
|
|
57
|
+
private _silhouette;
|
|
58
|
+
private _color;
|
|
59
|
+
/**
|
|
60
|
+
* Creates a new `Highlight` instance.
|
|
61
|
+
* @private Use {@link getInstance `Highlight.getInstance()`}
|
|
62
|
+
* @param viewer A viewer to create highlight entity in
|
|
63
|
+
*/
|
|
64
|
+
private constructor();
|
|
65
|
+
/**
|
|
66
|
+
* Gets or creates highlight instance from a viewer.
|
|
67
|
+
* @param viewer The viewer to get or create a new instance from.
|
|
68
|
+
*/
|
|
69
|
+
static getInstance(viewer: Viewer): Highlight;
|
|
70
|
+
/**
|
|
71
|
+
* Releases the highlight instance associated with a viewer.
|
|
72
|
+
* @param viewer The viewer whose highlight instance should be released.
|
|
73
|
+
*/
|
|
74
|
+
static releaseInstance(viewer: Viewer): void;
|
|
75
|
+
/**
|
|
76
|
+
* Highlights a picked object or a direct instance.
|
|
77
|
+
* @param picked The result of `Scene.pick()` or direct instance to be highlighted.
|
|
78
|
+
* @param color Optional color for the highlight.
|
|
79
|
+
* @param options Optional style for the highlight.
|
|
80
|
+
*/
|
|
81
|
+
show(picked: Picked, color?: Color, options?: HighlightOptions): void | Entity;
|
|
82
|
+
private _getObject;
|
|
83
|
+
/**
|
|
84
|
+
* Clears the current highlight effects.
|
|
85
|
+
*/
|
|
86
|
+
hide(): void;
|
|
87
|
+
/** Gets the highlight color. */
|
|
88
|
+
get color(): Color;
|
|
89
|
+
/**
|
|
90
|
+
* Sets the highlight color.
|
|
91
|
+
* @param color The new color for highlights
|
|
92
|
+
*/
|
|
93
|
+
set color(color: Color);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { Highlight, type HighlightOptions, type IHighlight, type Picked, type PickedObject };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,96 @@
|
|
|
1
1
|
export { CesiumCollection, CesiumCollectionItem, Collection, CollectionEventType, EventHandler, NonFunction, Tag, WithTag } from './collection/index.js';
|
|
2
|
+
import { Entity, Cesium3DTileFeature, GroundPrimitive, Primitive, Model, Cesium3DTileset, Color, Viewer } from 'cesium';
|
|
2
3
|
export { H as HybridTerrainProvider, T as TerrainArea, a as TileRange } from './hybrid-terrain-provider-C4b9z5pv.js';
|
|
3
4
|
export { TerrainAreaCollection, computeRectangle } from './terrain/index.js';
|
|
4
5
|
export { TerrainVisualizer, isGetterOnly } from './utils/index.js';
|
|
5
|
-
export {
|
|
6
|
-
|
|
6
|
+
export { cloneViewer, syncCamera } from './viewer/index.js';
|
|
7
|
+
|
|
8
|
+
interface IHighlight {
|
|
9
|
+
show(object: any, color?: Color, options?: HighlightOptions): void;
|
|
10
|
+
hide(): void;
|
|
11
|
+
destroy(): void;
|
|
12
|
+
color: Color;
|
|
13
|
+
}
|
|
14
|
+
interface HighlightOptions {
|
|
15
|
+
outline?: boolean;
|
|
16
|
+
width?: number;
|
|
17
|
+
}
|
|
18
|
+
type PickedObject = {
|
|
19
|
+
id?: Entity;
|
|
20
|
+
primitive?: Primitive | GroundPrimitive | Model | Cesium3DTileset;
|
|
21
|
+
tileset?: Cesium3DTileset;
|
|
22
|
+
detail?: {
|
|
23
|
+
model?: Model;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
type Picked = Entity | Cesium3DTileFeature | GroundPrimitive | PickedObject;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @class
|
|
30
|
+
* Lightweight multiton highlight manager for Cesium using flyweight pattern.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```
|
|
34
|
+
* // Setup
|
|
35
|
+
* const viewer1 = new Viewer('cesiumContainer1');
|
|
36
|
+
* const viewer2 = new Viewer('cesiumContainer2');
|
|
37
|
+
*
|
|
38
|
+
* const highlighter1 = Highlight.getInstance(viewer1);
|
|
39
|
+
* const highlighter2 = Highlight.getInstance(viewer2);
|
|
40
|
+
*
|
|
41
|
+
* // This highlight only affects viewer1
|
|
42
|
+
* highlighter1.show(someEntity, Color.RED);
|
|
43
|
+
*
|
|
44
|
+
* // This highlight only affects viewer2
|
|
45
|
+
* highlighter2.show(someEntity, Color.BLUE);
|
|
46
|
+
*
|
|
47
|
+
* // When done with viewers
|
|
48
|
+
* Highlight.releaseInstance(viewer1);
|
|
49
|
+
* Highlight.releaseInstance(viewer2);
|
|
50
|
+
* viewer1.destroy();
|
|
51
|
+
* viewer2.destroy();
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare class Highlight {
|
|
55
|
+
private static instances;
|
|
56
|
+
private _surface;
|
|
57
|
+
private _silhouette;
|
|
58
|
+
private _color;
|
|
59
|
+
/**
|
|
60
|
+
* Creates a new `Highlight` instance.
|
|
61
|
+
* @private Use {@link getInstance `Highlight.getInstance()`}
|
|
62
|
+
* @param viewer A viewer to create highlight entity in
|
|
63
|
+
*/
|
|
64
|
+
private constructor();
|
|
65
|
+
/**
|
|
66
|
+
* Gets or creates highlight instance from a viewer.
|
|
67
|
+
* @param viewer The viewer to get or create a new instance from.
|
|
68
|
+
*/
|
|
69
|
+
static getInstance(viewer: Viewer): Highlight;
|
|
70
|
+
/**
|
|
71
|
+
* Releases the highlight instance associated with a viewer.
|
|
72
|
+
* @param viewer The viewer whose highlight instance should be released.
|
|
73
|
+
*/
|
|
74
|
+
static releaseInstance(viewer: Viewer): void;
|
|
75
|
+
/**
|
|
76
|
+
* Highlights a picked object or a direct instance.
|
|
77
|
+
* @param picked The result of `Scene.pick()` or direct instance to be highlighted.
|
|
78
|
+
* @param color Optional color for the highlight.
|
|
79
|
+
* @param options Optional style for the highlight.
|
|
80
|
+
*/
|
|
81
|
+
show(picked: Picked, color?: Color, options?: HighlightOptions): void | Entity;
|
|
82
|
+
private _getObject;
|
|
83
|
+
/**
|
|
84
|
+
* Clears the current highlight effects.
|
|
85
|
+
*/
|
|
86
|
+
hide(): void;
|
|
87
|
+
/** Gets the highlight color. */
|
|
88
|
+
get color(): Color;
|
|
89
|
+
/**
|
|
90
|
+
* Sets the highlight color.
|
|
91
|
+
* @param color The new color for highlights
|
|
92
|
+
*/
|
|
93
|
+
set color(color: Color);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { Highlight, type HighlightOptions, type IHighlight, type Picked, type PickedObject };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import"./chunk-RXMNSDKR.js";import{a as S,b as O,c as D,d as x}from"./chunk-D2H7O3WV.js";import{a as H,b as E,c as G}from"./chunk-XTUDPAWI.js";import{a as A,b as I}from"./chunk-2JNRK7SN.js";import{Cesium3DTileFeature as T,Color as B,defined as R,Entity as _,GroundPrimitive as V}from"cesium";import{Cesium3DTileFeature as F,Color as m,ConstantProperty as d,defined as M,PostProcessStageLibrary as w}from"cesium";var l=class{_color=m.RED;_silhouette;_composite;_stages;_entity;constructor(t){this._stages=t.scene.postProcessStages,this._silhouette=w.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=w.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}show(t,i=this._color,o){if(!(!M(t)||this._silhouette.selected[0]===t))if(t instanceof F)this._silhouette.selected.push(t);else{if(!t.model)return;this._entity=t,t.model.silhouetteSize=new d(o?.width||2),t.model.silhouetteColor=new d(i)}}hide(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new d(m.TRANSPARENT),this._entity=void 0)}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite)}get color(){return this._color}set color(t){this._color=t}};import{Cartesian3 as r,ClassificationType as C,Color as N,defined as L,Entity as f,GroundPrimitive as v,HeightReference as y,PolygonGraphics as P,PolygonHierarchy as U,PolylineGraphics as g,RectangleGraphics as z}from"cesium";var h=class{_color=N.RED;_entity;_entities;constructor(t){this._entities=t.entities,this._entity=this._entities.add(new f({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}show(t,i=this._color,o){if(!(!L(t)||!this._entity)){this._clearGeometries();try{if(t instanceof f&&(t.polygon||t.polyline||t.rectangle))this._update(t,i,o);else if(t instanceof v)this._update(t,i,o);else return;return this._entity.show=!0,this._entity}catch(e){console.error("Failed to highlight object:",e);return}}}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(t,i,o={outline:!1,width:2}){if(t instanceof f){if(t.polygon)if(o.outline){let e=t.polygon.hierarchy?.getValue();if(e&&e.positions){let s;e.positions.length>0&&!r.equals(e.positions[0],e.positions[e.positions.length-1])?s=[...e.positions,e.positions[0]]:s=e.positions,this._entity.polyline=new g({positions:s,material:i,width:o.width||2,clampToGround:t.polygon.heightReference?.getValue()===y.CLAMP_TO_GROUND})}}else{let e=t.polygon.hierarchy?.getValue();e&&(this._entity.polygon=new P({hierarchy:e,material:i,heightReference:t.polygon.heightReference?.getValue(),classificationType:t.polygon.classificationType?.getValue()||C.BOTH}))}else if(t.polyline){let e=t.polyline.positions?.getValue();if(e){let s=t.polyline.width?.getValue();this._entity.polyline=new g({positions:e,material:i,width:s+(o.width||2),clampToGround:t.polyline.clampToGround?.getValue()})}}else if(t.rectangle)if(o.outline){let e=t.rectangle.coordinates?.getValue();if(e){let s=[r.fromRadians(e.west,e.north),r.fromRadians(e.east,e.north),r.fromRadians(e.east,e.south),r.fromRadians(e.west,e.south),r.fromRadians(e.west,e.north)];this._entity.polyline=new g({positions:s,material:i,width:o.width||2,clampToGround:t.rectangle.heightReference?.getValue()===y.CLAMP_TO_GROUND})}}else{let e=t.rectangle.coordinates?.getValue();e&&(this._entity.rectangle=new z({coordinates:e,material:i,heightReference:t.rectangle.heightReference?.getValue()}))}}else if(t instanceof v){let e=t.geometryInstances,s=Array.isArray(e)?e[0]:e;if(!s.geometry.attributes.position)return;let u=s.geometry.attributes.position.values,p=[];for(let a=0;a<u.length;a+=3)p.push(new r(u[a],u[a+1],u[a+2]));o.outline?this._entity.polyline=new g({positions:p,material:i,width:o.width||2,clampToGround:!0}):this._entity.polygon=new P({hierarchy:new U(p),material:i,heightReference:y.CLAMP_TO_GROUND,classificationType:C.BOTH})}}hide(){this._entity&&(this._entity.show=!1)}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity)}get color(){return this._color}set color(t){this._color=t}get entity(){return this._entity}};var c=class n{static instances=new WeakMap;_surface;_silhouette;_color=B.RED;constructor(t){this._surface=new h(t),this._silhouette=new l(t),this._surface.color=this._color,this._silhouette.color=this._color}static getInstance(t){let i=t.container;return n.instances.has(i)||n.instances.set(i,new n(t)),n.instances.get(i)}static releaseInstance(t){let i=t.container,o=n.instances.get(i);o&&(o.hide(),o._surface&&o._surface.destroy(),o._silhouette&&o._silhouette.destroy(),n.instances.delete(i))}show(t,i=this._color,o){this.hide();let e=this._getObject(t);if(R(e))return e instanceof T||e instanceof _&&e.model?this._silhouette.show(e,i,o):this._surface.show(e,i,o)}_getObject(t){if(R(t)){if(t instanceof _||t instanceof T||t instanceof V)return t;if(t.id instanceof _)return t.id;if(t.primitive instanceof V)return t.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}get color(){return this._color}set color(t){this._color=t,this._surface.color=t,this._silhouette.color=t}};export{G as Collection,c as Highlight,x as HybridTerrainProvider,O as TerrainArea,D as TerrainAreaCollection,H as TerrainVisualizer,I as cloneViewer,S as computeRectangle,E as isGetterOnly,A as syncCamera};
|
package/dist/terrain/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{a,b,c,d}from"../chunk-D2H7O3WV.js";export{d as HybridTerrainProvider,b as TerrainArea,c as TerrainAreaCollection,a as computeRectangle};
|
package/dist/viewer/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var T=(e,i)=>{for(var o in i)m(e,o,{get:i[o],enumerable:!0})},v=(e,i,o,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of k(i))!C.call(e,n)&&n!==o&&m(e,n,{get:()=>i[n],enumerable:!(t=g(i,n))||t.enumerable});return e};var b=e=>v(m({},"__esModule",{value:!0}),e);var h={};T(h,{cloneViewer:()=>y,syncCamera:()=>l});module.exports=b(h);var p=require("cesium");var d=require("cesium");function l(e,i){if((0,d.defined)(e)&&(0,d.defined)(i)){let{camera:o}=e;i.camera.position=o.positionWC.clone(),i.camera.direction=o.directionWC.clone(),i.camera.up=o.upWC.clone()}}function y(e,i,o){let t={baseLayerPicker:e.baseLayerPicker!==void 0,geocoder:e.geocoder!==void 0,homeButton:e.homeButton!==void 0,sceneModePicker:e.sceneModePicker!==void 0,timeline:e.timeline!==void 0,navigationHelpButton:e.navigationHelpButton!==void 0,animation:e.animation!==void 0,fullscreenButton:e.fullscreenButton!==void 0,shouldAnimate:e.clock.shouldAnimate,terrainProvider:e.terrainProvider,requestRenderMode:e.scene.requestRenderMode,infoBox:e.infoBox!==void 0},n=new p.Viewer(i,{...t,...o});l(e,n);let s=e.imageryLayers;n.imageryLayers.removeAll();for(let c=0;c<s.length;c++){let f=s.get(c);n.imageryLayers.addImageryProvider(f.imageryProvider,c)}n.clock.startTime=e.clock.startTime.clone(),n.clock.stopTime=e.clock.stopTime.clone(),n.clock.currentTime=e.clock.currentTime.clone(),n.clock.multiplier=e.clock.multiplier,n.clock.clockStep=e.clock.clockStep,n.clock.clockRange=e.clock.clockRange,n.clock.shouldAnimate=e.clock.shouldAnimate,n.scene.globe.enableLighting=e.scene.globe.enableLighting,n.scene.globe.depthTestAgainstTerrain=e.scene.globe.depthTestAgainstTerrain,n.scene.screenSpaceCameraController.enableCollisionDetection=e.scene.screenSpaceCameraController.enableCollisionDetection;let r=e.scene.screenSpaceCameraController.tiltEventTypes;r&&(n.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(r)?[...r]:r);let a=e.scene.screenSpaceCameraController.zoomEventTypes;return a&&(n.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(a)?[...a]:a),n}
|
package/dist/viewer/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Viewer
|
|
1
|
+
import { Viewer } from 'cesium';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Copies configuration and state from one Cesium Viewer to another.
|
|
@@ -9,86 +9,6 @@ import { Viewer, Color, Entity } from 'cesium';
|
|
|
9
9
|
*/
|
|
10
10
|
declare function cloneViewer(source: Viewer, container: Element | string, options?: Viewer.ConstructorOptions): Viewer;
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* @class
|
|
14
|
-
* Lightweight multiton highlight manager for Cesium using a single reusable entity.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```
|
|
18
|
-
* // Setup
|
|
19
|
-
* const viewer1 = new Viewer('cesiumContainer1');
|
|
20
|
-
* const viewer2 = new Viewer('cesiumContainer2');
|
|
21
|
-
*
|
|
22
|
-
* const highlighter1 = Highlight.getInstance(viewer1);
|
|
23
|
-
* const highlighter2 = Highlight.getInstance(viewer2);
|
|
24
|
-
*
|
|
25
|
-
* // This highlight only affects viewer1
|
|
26
|
-
* highlighter1.show(someEntity, Color.RED);
|
|
27
|
-
*
|
|
28
|
-
* // This highlight only affects viewer2
|
|
29
|
-
* highlighter2.show(someEntity, Color.BLUE);
|
|
30
|
-
*
|
|
31
|
-
* // When done with viewers
|
|
32
|
-
* Highlight.releaseInstance(viewer1);
|
|
33
|
-
* Highlight.releaseInstance(viewer2);
|
|
34
|
-
* viewer1.destroy();
|
|
35
|
-
* viewer2.destroy();
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
declare class Highlight {
|
|
39
|
-
private static instances;
|
|
40
|
-
private _defaultColor;
|
|
41
|
-
private _entity;
|
|
42
|
-
private _entities;
|
|
43
|
-
/**
|
|
44
|
-
* Creates a new `Highlight` instance.
|
|
45
|
-
* @private Use {@link getInstance `Highlight.getInstance()`}
|
|
46
|
-
* @param viewer A viewer to create highlight entity in
|
|
47
|
-
*/
|
|
48
|
-
private constructor();
|
|
49
|
-
/**
|
|
50
|
-
* Gets or creates highlight instance from a viewer.
|
|
51
|
-
* @param viewer The viewer to get or create a new instance from.
|
|
52
|
-
*/
|
|
53
|
-
static getInstance(viewer: Viewer): Highlight;
|
|
54
|
-
/**
|
|
55
|
-
* Releases the highlight instance associated with a viewer.
|
|
56
|
-
* @param viewer The viewer whose highlight instance should be released.
|
|
57
|
-
*/
|
|
58
|
-
static releaseInstance(viewer: Viewer): void;
|
|
59
|
-
/**
|
|
60
|
-
* Highlights a picked object by updating the reusable entity
|
|
61
|
-
* @param picked The object returned from `scene.pick()` or `drillPick()`
|
|
62
|
-
* @param color Optional color for the highlight. Defaults to yellow with 0.5 alpha.
|
|
63
|
-
* @param outline Optional style for the highlight. Defaults to `false`.
|
|
64
|
-
* @returns The entity being used for highlighting
|
|
65
|
-
*/
|
|
66
|
-
show(picked: any, color?: Color, outline?: boolean): Entity | undefined;
|
|
67
|
-
/**
|
|
68
|
-
* Removes all geometry properties from the highlight entity
|
|
69
|
-
* @private
|
|
70
|
-
*/
|
|
71
|
-
private _clearGeometries;
|
|
72
|
-
/**
|
|
73
|
-
* Updates the highlight entity from an Entity object
|
|
74
|
-
* @private
|
|
75
|
-
*/
|
|
76
|
-
private _update;
|
|
77
|
-
/**
|
|
78
|
-
* Clears the current highlight
|
|
79
|
-
*/
|
|
80
|
-
hide(): void;
|
|
81
|
-
/** Gets the default highlight color. */
|
|
82
|
-
get defaultColor(): Color;
|
|
83
|
-
/**
|
|
84
|
-
* Sets the default highlight color.
|
|
85
|
-
* @param color The new default color for highlights
|
|
86
|
-
*/
|
|
87
|
-
set defaultColor(color: Color);
|
|
88
|
-
/** Gets the highlight entity */
|
|
89
|
-
get entity(): Entity;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
12
|
/**
|
|
93
13
|
* Copies camera state from source viewer to destination viewer.
|
|
94
14
|
* @param source The source viewer to copy camera states from.
|
|
@@ -96,4 +16,4 @@ declare class Highlight {
|
|
|
96
16
|
*/
|
|
97
17
|
declare function syncCamera(source: Viewer, dest: Viewer): void;
|
|
98
18
|
|
|
99
|
-
export {
|
|
19
|
+
export { cloneViewer, syncCamera };
|
package/dist/viewer/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Viewer
|
|
1
|
+
import { Viewer } from 'cesium';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Copies configuration and state from one Cesium Viewer to another.
|
|
@@ -9,86 +9,6 @@ import { Viewer, Color, Entity } from 'cesium';
|
|
|
9
9
|
*/
|
|
10
10
|
declare function cloneViewer(source: Viewer, container: Element | string, options?: Viewer.ConstructorOptions): Viewer;
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* @class
|
|
14
|
-
* Lightweight multiton highlight manager for Cesium using a single reusable entity.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```
|
|
18
|
-
* // Setup
|
|
19
|
-
* const viewer1 = new Viewer('cesiumContainer1');
|
|
20
|
-
* const viewer2 = new Viewer('cesiumContainer2');
|
|
21
|
-
*
|
|
22
|
-
* const highlighter1 = Highlight.getInstance(viewer1);
|
|
23
|
-
* const highlighter2 = Highlight.getInstance(viewer2);
|
|
24
|
-
*
|
|
25
|
-
* // This highlight only affects viewer1
|
|
26
|
-
* highlighter1.show(someEntity, Color.RED);
|
|
27
|
-
*
|
|
28
|
-
* // This highlight only affects viewer2
|
|
29
|
-
* highlighter2.show(someEntity, Color.BLUE);
|
|
30
|
-
*
|
|
31
|
-
* // When done with viewers
|
|
32
|
-
* Highlight.releaseInstance(viewer1);
|
|
33
|
-
* Highlight.releaseInstance(viewer2);
|
|
34
|
-
* viewer1.destroy();
|
|
35
|
-
* viewer2.destroy();
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
declare class Highlight {
|
|
39
|
-
private static instances;
|
|
40
|
-
private _defaultColor;
|
|
41
|
-
private _entity;
|
|
42
|
-
private _entities;
|
|
43
|
-
/**
|
|
44
|
-
* Creates a new `Highlight` instance.
|
|
45
|
-
* @private Use {@link getInstance `Highlight.getInstance()`}
|
|
46
|
-
* @param viewer A viewer to create highlight entity in
|
|
47
|
-
*/
|
|
48
|
-
private constructor();
|
|
49
|
-
/**
|
|
50
|
-
* Gets or creates highlight instance from a viewer.
|
|
51
|
-
* @param viewer The viewer to get or create a new instance from.
|
|
52
|
-
*/
|
|
53
|
-
static getInstance(viewer: Viewer): Highlight;
|
|
54
|
-
/**
|
|
55
|
-
* Releases the highlight instance associated with a viewer.
|
|
56
|
-
* @param viewer The viewer whose highlight instance should be released.
|
|
57
|
-
*/
|
|
58
|
-
static releaseInstance(viewer: Viewer): void;
|
|
59
|
-
/**
|
|
60
|
-
* Highlights a picked object by updating the reusable entity
|
|
61
|
-
* @param picked The object returned from `scene.pick()` or `drillPick()`
|
|
62
|
-
* @param color Optional color for the highlight. Defaults to yellow with 0.5 alpha.
|
|
63
|
-
* @param outline Optional style for the highlight. Defaults to `false`.
|
|
64
|
-
* @returns The entity being used for highlighting
|
|
65
|
-
*/
|
|
66
|
-
show(picked: any, color?: Color, outline?: boolean): Entity | undefined;
|
|
67
|
-
/**
|
|
68
|
-
* Removes all geometry properties from the highlight entity
|
|
69
|
-
* @private
|
|
70
|
-
*/
|
|
71
|
-
private _clearGeometries;
|
|
72
|
-
/**
|
|
73
|
-
* Updates the highlight entity from an Entity object
|
|
74
|
-
* @private
|
|
75
|
-
*/
|
|
76
|
-
private _update;
|
|
77
|
-
/**
|
|
78
|
-
* Clears the current highlight
|
|
79
|
-
*/
|
|
80
|
-
hide(): void;
|
|
81
|
-
/** Gets the default highlight color. */
|
|
82
|
-
get defaultColor(): Color;
|
|
83
|
-
/**
|
|
84
|
-
* Sets the default highlight color.
|
|
85
|
-
* @param color The new default color for highlights
|
|
86
|
-
*/
|
|
87
|
-
set defaultColor(color: Color);
|
|
88
|
-
/** Gets the highlight entity */
|
|
89
|
-
get entity(): Entity;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
12
|
/**
|
|
93
13
|
* Copies camera state from source viewer to destination viewer.
|
|
94
14
|
* @param source The source viewer to copy camera states from.
|
|
@@ -96,4 +16,4 @@ declare class Highlight {
|
|
|
96
16
|
*/
|
|
97
17
|
declare function syncCamera(source: Viewer, dest: Viewer): void;
|
|
98
18
|
|
|
99
|
-
export {
|
|
19
|
+
export { cloneViewer, syncCamera };
|
package/dist/viewer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b
|
|
1
|
+
import{a,b}from"../chunk-2JNRK7SN.js";export{b as cloneViewer,a as syncCamera};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juun-roh/cesium-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "Utilities to handle Cesium classes easier.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Cesium",
|
|
@@ -41,6 +41,11 @@
|
|
|
41
41
|
"import": "./dist/collection/index.js",
|
|
42
42
|
"require": "./dist/collection/index.cjs"
|
|
43
43
|
},
|
|
44
|
+
"./highlight": {
|
|
45
|
+
"types": "./dist/highlight/index.d.ts",
|
|
46
|
+
"import": "./dist/highlight/index.js",
|
|
47
|
+
"require": "./dist/highlight/index.cjs"
|
|
48
|
+
},
|
|
44
49
|
"./terrain": {
|
|
45
50
|
"types": "./dist/terrain/index.d.ts",
|
|
46
51
|
"import": "./dist/terrain/index.js",
|
|
@@ -78,14 +83,14 @@
|
|
|
78
83
|
"@commitlint/cz-commitlint": "^19.8.1",
|
|
79
84
|
"@commitlint/format": "^19.8.1",
|
|
80
85
|
"@commitlint/types": "^19.8.1",
|
|
81
|
-
"@eslint/js": "^9.
|
|
82
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
83
|
-
"@typescript-eslint/parser": "^8.
|
|
84
|
-
"@vitest/coverage-v8": "3.1
|
|
85
|
-
"cesium": "^1.
|
|
86
|
-
"eslint": "^9.
|
|
87
|
-
"eslint-plugin-jsdoc": "^50.
|
|
88
|
-
"eslint-plugin-prettier": "^5.4.
|
|
86
|
+
"@eslint/js": "^9.28.0",
|
|
87
|
+
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
|
88
|
+
"@typescript-eslint/parser": "^8.33.1",
|
|
89
|
+
"@vitest/coverage-v8": "3.2.1",
|
|
90
|
+
"cesium": "^1.130.0",
|
|
91
|
+
"eslint": "^9.28.0",
|
|
92
|
+
"eslint-plugin-jsdoc": "^50.7.1",
|
|
93
|
+
"eslint-plugin-prettier": "^5.4.1",
|
|
89
94
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
90
95
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
91
96
|
"husky": "^9.1.7",
|
|
@@ -95,7 +100,7 @@
|
|
|
95
100
|
"typedoc": "^0.28.5",
|
|
96
101
|
"typescript": "^5.8.3",
|
|
97
102
|
"vite": "^6.3.5",
|
|
98
|
-
"vitest": "^3.1
|
|
103
|
+
"vitest": "^3.2.1"
|
|
99
104
|
},
|
|
100
105
|
"scripts": {
|
|
101
106
|
"build": "tsup",
|
package/dist/chunk-ATVZC562.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Viewer as _}from"cesium";import{defined as f}from"cesium";function p(i,t){if(f(i)&&f(t)){let{camera:n}=i;t.camera.position=n.positionWC.clone(),t.camera.direction=n.directionWC.clone(),t.camera.up=n.upWC.clone()}}function v(i,t,n){let o={baseLayerPicker:i.baseLayerPicker!==void 0,geocoder:i.geocoder!==void 0,homeButton:i.homeButton!==void 0,sceneModePicker:i.sceneModePicker!==void 0,timeline:i.timeline!==void 0,navigationHelpButton:i.navigationHelpButton!==void 0,animation:i.animation!==void 0,fullscreenButton:i.fullscreenButton!==void 0,shouldAnimate:i.clock.shouldAnimate,terrainProvider:i.terrainProvider,requestRenderMode:i.scene.requestRenderMode,infoBox:i.infoBox!==void 0},e=new _(t,{...o,...n});p(i,e);let a=i.imageryLayers;e.imageryLayers.removeAll();for(let r=0;r<a.length;r++){let w=a.get(r);e.imageryLayers.addImageryProvider(w.imageryProvider,r)}e.clock.startTime=i.clock.startTime.clone(),e.clock.stopTime=i.clock.stopTime.clone(),e.clock.currentTime=i.clock.currentTime.clone(),e.clock.multiplier=i.clock.multiplier,e.clock.clockStep=i.clock.clockStep,e.clock.clockRange=i.clock.clockRange,e.clock.shouldAnimate=i.clock.shouldAnimate,e.scene.globe.enableLighting=i.scene.globe.enableLighting,e.scene.globe.depthTestAgainstTerrain=i.scene.globe.depthTestAgainstTerrain,e.scene.screenSpaceCameraController.enableCollisionDetection=i.scene.screenSpaceCameraController.enableCollisionDetection;let s=i.scene.screenSpaceCameraController.tiltEventTypes;s&&(e.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(s)?[...s]:s);let l=i.scene.screenSpaceCameraController.zoomEventTypes;return l&&(e.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(l)?[...l]:l),e}import{Cartesian3 as c,ClassificationType as m,Color as T,defined as V,Entity as h,GroundPrimitive as u,HeightReference as y,PolygonGraphics as C,PolygonHierarchy as R,PolylineGraphics as d,RectangleGraphics as b}from"cesium";var g=class i{static instances=new Map;_defaultColor=T.YELLOW.withAlpha(.5);_entity;_entities;constructor(t){this._entities=t.entities,this._entity=this._entities.add(new h({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}static getInstance(t){let n=t.container;return i.instances.has(n)||i.instances.set(n,new i(t)),i.instances.get(n)}static releaseInstance(t){let n=t.container,o=i.instances.get(n);o&&(o.hide(),o._entity&&t.entities.remove(o._entity),i.instances.delete(n))}show(t,n=this._defaultColor,o=!1){if(!(!V(t)||!this._entity)){this._clearGeometries();try{if(t instanceof h)this._update(t,n,o);else if(t.id instanceof h)this._update(t.id,n,o);else if(t.primitive instanceof u)this._update(t.primitive,n,o);else return;return this._entity.show=!0,this._entity}catch(e){console.error("Failed to highlight object:",e);return}}}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(t,n,o){if(t instanceof h){if(t.polygon)if(o){let e=t.polygon.hierarchy?.getValue();if(e&&e.positions){let a;e.positions.length>0&&!c.equals(e.positions[0],e.positions[e.positions.length-1])?a=[...e.positions,e.positions[0]]:a=e.positions,this._entity.polyline=new d({positions:a,material:n,width:2,clampToGround:t.polygon.heightReference?.getValue()===y.CLAMP_TO_GROUND})}}else{let e=t.polygon.hierarchy?.getValue();e&&(this._entity.polygon=new C({hierarchy:e,material:n,heightReference:t.polygon.heightReference?.getValue(),classificationType:t.polygon.classificationType?.getValue()||m.BOTH}))}else if(t.polyline){let e=t.polyline.positions?.getValue();if(e){let a=t.polyline.width?.getValue();this._entity.polyline=new d({positions:e,material:n,width:a+2,clampToGround:t.polyline.clampToGround?.getValue()})}}else if(t.rectangle)if(o){let e=t.rectangle.coordinates?.getValue();if(e){let a=[c.fromRadians(e.west,e.north),c.fromRadians(e.east,e.north),c.fromRadians(e.east,e.south),c.fromRadians(e.west,e.south),c.fromRadians(e.west,e.north)];this._entity.polyline=new d({positions:a,material:n,width:2,clampToGround:t.rectangle.heightReference?.getValue()===y.CLAMP_TO_GROUND})}}else{let e=t.rectangle.coordinates?.getValue();e&&(this._entity.rectangle=new b({coordinates:e,material:n,heightReference:t.rectangle.heightReference?.getValue()}))}}else if(t instanceof u){let e=t.geometryInstances,a=Array.isArray(e)?e[0]:e;if(!a.geometry.attributes.position)return;let s=a.geometry.attributes.position.values,l=[];for(let r=0;r<s.length;r+=3)l.push(new c(s[r],s[r+1],s[r+2]));o?this._entity.polyline=new d({positions:l,material:n,width:2,clampToGround:!0}):this._entity.polygon=new C({hierarchy:new R(l),material:n,heightReference:y.CLAMP_TO_GROUND,classificationType:m.BOTH})}}hide(){this._entity&&(this._entity.show=!1)}get defaultColor(){return this._defaultColor}set defaultColor(t){this._defaultColor=t}get entity(){return this._entity}};export{p as a,v as b,g as c};
|
package/dist/chunk-OFZW33MB.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Rectangle as T}from"cesium";function g(s,r){if(r.size===0)return new T;let e=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY,u=Array.from(r.keys()),l=Math.min(...u),d=r.get(l);if(d){let{start:m,end:c}=d,h=s.tileXYToRectangle(m.x,m.y,l),v=s.tileXYToRectangle(c.x,c.y,l);e=Math.min(h.west,e),i=Math.min(v.south,i),t=Math.max(v.east,t),a=Math.max(h.north,a)}return new T(e,i,t,a)}import{CesiumTerrainProvider as f}from"cesium";var n=class{_terrainProvider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(r){this._terrainProvider=r.terrainProvider,this._tileRanges=r.tileRanges,this._credit=r.credit||"custom",this._isCustom=r.isCustom!==void 0?r.isCustom:!0,this._rectangle=g(r.terrainProvider.tilingScheme,r.tileRanges),r.tileRanges.forEach((e,i)=>{this._terrainProvider.availability?.addAvailableTileRange(i,e.start.x,e.start.y,e.end.x,e.end.y)}),this._ready=!0}contains(r,e,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let t=this._tileRanges.get(i);return r>=t.start.x&&r<=t.end.x&&e>=t.start.y&&e<=t.end.y}requestTileGeometry(r,e,i,t){if(!(!this._ready||!this.contains(r,e,i)))return this._terrainProvider.requestTileGeometry(r,e,i,t)}getTileDataAvailable(r,e,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let t=this._tileRanges.get(i);return r>=t.start.x&&r<=t.end.x&&e>=t.start.y&&e<=t.end.y}get isCustom(){return this._isCustom}get credit(){return this._credit}get terrainProvider(){return this._terrainProvider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(r=>{async function s(e,i,t){let a=t?.credit||"custom",u=await f.fromUrl(e,{...t,credit:a});return new r({terrainProvider:u,tileRanges:i,credit:a})}r.fromUrl=s})(n||={});var o=class extends Array{add(r){if(Array.isArray(r)){for(let i of r)this.add(i);return this.length}let e;return r instanceof n?e=r:e=new n(r),this.push(e)}remove(r){if(Array.isArray(r))return r.forEach(i=>this.remove(i)),this;let e=this.indexOf(r);return e>=0&&this.splice(e,1),this}removeAll(){this.length=0}};import{EllipsoidTerrainProvider as _}from"cesium";var b=class{_terrainAreas=new o;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(r){this._terrainProvider=r.terrainProvider,this._fallbackProvider=r.fallbackProvider||new _,this._tilingScheme=r.terrainProvider.tilingScheme,this._terrainAreas=new o(...r.terrainAreas),this._availability=r.terrainProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get terrainAreas(){return[...this._terrainAreas]}get defaultProvider(){return this._terrainProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._terrainProvider?.credit}get errorEvent(){return this._terrainProvider.errorEvent}get hasWaterMask(){return this._terrainProvider.hasWaterMask}get hasVertexNormals(){return this._terrainProvider.hasVertexNormals}loadTileDataAvailability(r,e,i){return this._terrainProvider.loadTileDataAvailability(r,e,i)}getLevelMaximumGeometricError(r){return this._terrainProvider.getLevelMaximumGeometricError(r)}requestTileGeometry(r,e,i,t){if(this._ready){for(let a of this._terrainAreas)if(a.contains(r,e,i))return a.requestTileGeometry(r,e,i,t);return this._terrainProvider.getTileDataAvailable(r,e,i)?this._terrainProvider.requestTileGeometry(r,e,i,t):this._fallbackProvider.requestTileGeometry(r,e,i,t)}}getTileDataAvailable(r,e,i){for(let t of this._terrainAreas)if(t.contains(r,e,i))return t.getTileDataAvailable(r,e,i);return this._terrainProvider.getTileDataAvailable(r,e,i)}};export{g as a,n as b,o as c,b as d};
|