@juun-roh/cesium-utils 0.1.2 → 0.1.3
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-4EI5BBVR.js +1 -0
- package/dist/chunk-VMZ2PVXH.js +1 -0
- package/dist/chunk-ZV7FKRP6.js +1 -0
- package/dist/collection/index.cjs +1 -1
- package/dist/collection/index.d.cts +11 -11
- package/dist/collection/index.d.ts +11 -11
- package/dist/collection/index.js +1 -1
- package/dist/highlight/index.cjs +1 -0
- package/dist/highlight/index.d.cts +243 -0
- package/dist/highlight/index.d.ts +243 -0
- package/dist/highlight/index.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -220
- package/dist/index.d.ts +2 -220
- package/dist/index.js +1 -1
- package/dist/terrain/index.cjs +1 -1
- package/dist/terrain/index.d.cts +2 -2
- package/dist/terrain/index.d.ts +2 -2
- package/dist/terrain/index.js +1 -1
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +9 -9
- package/dist/chunk-D2H7O3WV.js +0 -1
- package/dist/chunk-I53ZQ7WC.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{EllipsoidTerrainProvider as _}from"cesium";import{CesiumTerrainProvider as b}from"cesium";import{Rectangle as f}from"cesium";function u(s,r){if(r.size===0)return new f;let e=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY,d=Array.from(r.keys()),l=Math.min(...d),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 f(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=u(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",d=await b.fromUrl(e,{...t,credit:a});return new r({terrainProvider:d,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}let e;return r instanceof n?e=r:e=new n(r),this.push(e),this}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{u as a,n as b,o as c,m as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Cesium3DTileFeature as P,Color as D,defined as H,Entity as y,GroundPrimitive as E}from"cesium";import{Cesium3DTileFeature as T,Color as f,ConstantProperty as u,defined as G,PostProcessStageLibrary as m}from"cesium";var o=class{_color=f.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(t){this._stages=t.scene.postProcessStages,this._silhouette=m.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=m.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}show(t,i){if(G(t)&&!(this._currentObject===t&&this._optionsEqual(this._currentOptions,i))){this._clearHighlights();try{if(t instanceof T)this._silhouette.uniforms.color=i?.color||this._color,this._silhouette.selected.push(t);else{if(!t.model)return;this._entity=t,t.model.silhouetteSize=new u(i?.width||2),t.model.silhouetteColor=new u(i?.color||this._color)}this._currentObject=t,this._currentOptions=i?{...i}:void 0}catch(e){console.error("Failed to highlight object:",e),this._currentObject=void 0,this._currentOptions=void 0}}}_optionsEqual(t,i){return!t&&!i?!0:!t||!i?!1:t.outline===i.outline&&t.width===i.width&&f.equals(t.color||this._color,i.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new u(f.TRANSPARENT),this._entity.model.silhouetteSize=new u(0),this._entity=void 0)}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}get color(){return this._color}set color(t){this._color=t}get currentObject(){return this._currentObject}};import{Cartesian3 as s,ClassificationType as O,Color as w,defined as S,Entity as _,GroundPrimitive as v,HeightReference as p,PolygonGraphics as C,PolygonHierarchy as R,PolylineGraphics as a,RectangleGraphics as V}from"cesium";var h=class{_color=w.RED;_entity;_entities;_currentObject;_currentOptions;constructor(t){this._entities=t.entities,this._entity=this._entities.add(new _({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}show(t,i){if(!(!S(t)||!this._entity)){if(this._currentObject===t&&this._optionsEqual(this._currentOptions,i))return this._entity;this._clearGeometries();try{if(t instanceof _&&(t.polygon||t.polyline||t.rectangle))this._update(t,i);else if(t instanceof v)this._update(t,i);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=t,this._currentOptions=i?{...i}:void 0,this._entity.show=!0,this._entity}catch(e){console.error("Failed to highlight object:",e),this._currentObject=void 0,this._currentOptions=void 0;return}}}_optionsEqual(t,i){return!t&&!i?!0:!t||!i?!1:t.outline===i.outline&&t.width===i.width&&w.equals(t.color||this._color,i.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(t,i={color:this._color,outline:!1,width:2}){if(t instanceof _){if(t.polygon)if(i.outline){let e=t.polygon.hierarchy?.getValue();if(e&&e.positions){let r;e.positions.length>0&&!s.equals(e.positions[0],e.positions[e.positions.length-1])?r=[...e.positions,e.positions[0]]:r=e.positions,this._entity.polyline=new a({positions:r,material:i.color,width:i.width||2,clampToGround:!0})}}else{let e=t.polygon.hierarchy?.getValue();e&&(this._entity.polygon=new C({hierarchy:e,material:i.color,heightReference:p.CLAMP_TO_GROUND,classificationType:t.polygon.classificationType?.getValue()||O.BOTH}))}else if(t.polyline){let e=t.polyline.positions?.getValue();if(e){let r=t.polyline.width?.getValue();this._entity.polyline=new a({positions:e,material:i.color,width:r+(i.width||2),clampToGround:!0})}}else if(t.rectangle)if(i.outline){let e=t.rectangle.coordinates?.getValue();if(e){let r=[s.fromRadians(e.west,e.north),s.fromRadians(e.east,e.north),s.fromRadians(e.east,e.south),s.fromRadians(e.west,e.south),s.fromRadians(e.west,e.north)];this._entity.polyline=new a({positions:r,material:i.color,width:i.width||2,clampToGround:!0})}}else{let e=t.rectangle.coordinates?.getValue();e&&(this._entity.rectangle=new V({coordinates:e,material:i.color,heightReference:p.CLAMP_TO_GROUND}))}}else if(t instanceof v){let e=t.geometryInstances,r=Array.isArray(e)?e[0]:e;if(!r.geometry.attributes.position)return;let c=r.geometry.attributes.position.values,g=[];for(let l=0;l<c.length;l+=3)g.push(new s(c[l],c[l+1],c[l+2]));i.outline?this._entity.polyline=new a({positions:g,material:i.color,width:i.width||2,clampToGround:!0}):this._entity.polygon=new C({hierarchy:new R(g),material:i.color,heightReference:p.CLAMP_TO_GROUND,classificationType:O.BOTH})}}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}get color(){return this._color}set color(t){this._color=t}get entity(){return this._entity}get currentObject(){return this._currentObject}};var d=class n{static instances=new WeakMap;_surface;_silhouette;_color=D.RED;constructor(t){this._surface=new h(t),this._silhouette=new o(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,e=n.instances.get(i);e&&(e.hide(),e._surface&&e._surface.destroy(),e._silhouette&&e._silhouette.destroy(),n.instances.delete(i))}show(t,i={color:this._color}){let e=this._getObject(t);if(H(e))return e instanceof P?this._silhouette.show(e,i):e instanceof y&&e.model?this._silhouette.show(e,i):this._surface.show(e,i)}_getObject(t){if(H(t)){if(t instanceof y||t instanceof P||t instanceof E)return t;if(t.id instanceof y)return t.id;if(t.primitive instanceof E)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{o as a,h as b,d as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Color as o,Entity as O,HeightReference as F,Rectangle as E,TileCoordinatesImageryProvider as V}from"cesium";import{DataSourceCollection as S,defined as p,EntityCollection as b,ImageryLayerCollection as x,PrimitiveCollection as M}from"cesium";var y=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]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(a=>a(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof b?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof M?(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 S?(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 x&&(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)))}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 values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof b)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(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)p(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)p(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)p(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let a of r)if(e in a&&typeof a[e]!="function"){if(T(a,e))throw Error(`Cannot set read-only property '${String(e)}' on ${a.constructor.name}`);a[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,a)=>e(r,a))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},C=y;var v=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",o.RED],["default",o.BLUE],["fallback",o.GRAY],["grid",o.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new C({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._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 V({tilingScheme:this._terrainProvider.tilingScheme,color:o.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 i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(s=>{this._collection.add(s.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(E.northwest(e),t),a=i.positionToTileXY(E.southeast(e),t);if(!r||!a)throw new Error("Failed to calculate tile bounds");return{start:r,end:a}}_generateVisibleTiles(e,t,i){let r=[],s=Math.min(e.end.x-e.start.x+1,100),l=Math.min(e.end.y-e.start.y+1,100);for(let h=e.start.x;h<e.start.x+s;h++)for(let c=e.start.y;c<e.start.y+l;c++)try{let d=this._createTileEntity(h,c,t,i);d&&r.push({entity:d})}catch(d){console.warn(`Error creating tile (${h}, ${c}, ${t}):`,d)}return r}_createTileEntity(e,t,i,r){let a=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(a))return null;let s=this._getTileColor(e,t,i),l=n.createRectangle(a,s.withAlpha(.3));return l.properties?.addProperty("tileX",e),l.properties?.addProperty("tileY",t),l.properties?.addProperty("tileLevel",i),l}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||o.TRANSPARENT;for(let r of this._terrainProvider.terrainAreas)if(r.contains(e,t,i))return r.isCustom?this._colors.get("custom")||o.RED:this._colors.get("default")||o.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||o.BLUE:this._colors.get("fallback")||o.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,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,a){return new O({rectangle:{coordinates:r,material:a,heightReference:F.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,a,s){let l=s?.tag||"terrain_area_visualization",h=s?.color||o.RED,c=s?.maxTilesToShow||100,d=s?.show??!0,w=s?.alpha||.7,L=s?.tileAlpha||.2,m=new C({collection:a.entities,tag:l}),{rectangle:I}=r;if(m.add(i.createRectangle(I,h.withAlpha(w)),l),d&&r.tileRanges.size>0){let{tilingScheme:R}=r.terrainProvider,g=0;r.tileRanges.forEach((u,A)=>{for(let f=u.start.x;f<=u.end.x&&g<c;f++)for(let _=u.start.y;_<=u.end.y&&g<c;_++){let P=R.tileXYToRectangle(f,_,A);m.add(e(P,h.withAlpha(L)),`${l}_tile`),g++}})}return m}i.visualize=t})(v||={});function T(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}export{v as a,T as b,C as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var T=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var M=(n,e)=>{for(var t in e)T(n,t,{get:e[t],enumerable:!0})},O=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of S(e))!x.call(n,r)&&r!==t&&T(n,r,{get:()=>e[r],enumerable:!(i=P(e,r))||i.enumerable});return n};var F=n=>O(T({},"__esModule",{value:!0}),n);var V={};M(V,{Collection:()=>m});module.exports=F(V);var o=require("cesium");var s=require("cesium");var u=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",s.Color.RED],["default",s.Color.BLUE],["fallback",s.Color.GRAY],["grid",s.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new m({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._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 s.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:s.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 i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(l=>{this._collection.add(l.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(s.Rectangle.northwest(e),t),a=i.positionToTileXY(s.Rectangle.southeast(e),t);if(!r||!a)throw new Error("Failed to calculate tile bounds");return{start:r,end:a}}_generateVisibleTiles(e,t,i){let r=[],l=Math.min(e.end.x-e.start.x+1,100),h=Math.min(e.end.y-e.start.y+1,100);for(let c=e.start.x;c<e.start.x+l;c++)for(let d=e.start.y;d<e.start.y+h;d++)try{let v=this._createTileEntity(c,d,t,i);v&&r.push({entity:v})}catch(v){console.warn(`Error creating tile (${c}, ${d}, ${t}):`,v)}return r}_createTileEntity(e,t,i,r){let a=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(a))return null;let l=this._getTileColor(e,t,i),h=n.createRectangle(a,l.withAlpha(.3));return h.properties?.addProperty("tileX",e),h.properties?.addProperty("tileY",t),h.properties?.addProperty("tileLevel",i),h}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||s.Color.TRANSPARENT;for(let r of this._terrainProvider.terrainAreas)if(r.contains(e,t,i))return r.isCustom?this._colors.get("custom")||s.Color.RED:this._colors.get("default")||s.Color.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||s.Color.BLUE:this._colors.get("fallback")||s.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,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,a){return new s.Entity({rectangle:{coordinates:r,material:a,heightReference:s.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,a,l){let h=l?.tag||"terrain_area_visualization",c=l?.color||s.Color.RED,d=l?.maxTilesToShow||100,v=l?.show??!0,E=l?.alpha||.7,w=l?.tileAlpha||.2,f=new m({collection:a.entities,tag:h}),{rectangle:L}=r;if(f.add(i.createRectangle(L,c.withAlpha(E)),h),v&&r.tileRanges.size>0){let{tilingScheme:I}=r.terrainProvider,_=0;r.tileRanges.forEach((g,R)=>{for(let p=g.start.x;p<=g.end.x&&_<d;p++)for(let y=g.start.y;y<=g.end.y&&_<d;y++){let A=I.tileXYToRectangle(p,y,R);f.add(e(A,c.withAlpha(w)),`${h}_tile`),_++}})}return f}i.visualize=t})(u||={});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}var b=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]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(a=>a(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof o.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof o.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 o.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 o.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)))}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let r=this.collection.remove(e);return r&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),r}if(Array.isArray(e)){if(e.length===0)return!1;let r=!1;for(let a of e)this.remove(a)&&(r=!0);return r}let t=this.get(e);if(t.length===0)return!1;let i=!1;for(let r of t)this.remove(r)&&(i=!0);return i}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof o.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(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,o.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,o.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,o.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let a of r)if(e in a&&typeof a[e]!="function"){if(C(a,e))throw Error(`Cannot set read-only property '${String(e)}' on ${a.constructor.name}`);a[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,a)=>e(r,a))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},m=b;
|
|
1
|
+
"use strict";var T=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var M=(a,e)=>{for(var t in e)T(a,t,{get:e[t],enumerable:!0})},O=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of S(e))!x.call(a,r)&&r!==t&&T(a,r,{get:()=>e[r],enumerable:!(i=P(e,r))||i.enumerable});return a};var F=a=>O(T({},"__esModule",{value:!0}),a);var V={};M(V,{Collection:()=>m});module.exports=F(V);var o=require("cesium");var s=require("cesium");var u=class a{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",s.Color.RED],["default",s.Color.BLUE],["fallback",s.Color.GRAY],["grid",s.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new m({collection:e.entities,tag:a.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._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(a.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 s.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:s.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 i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(l=>{this._collection.add(l.entity,a.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(s.Rectangle.northwest(e),t),n=i.positionToTileXY(s.Rectangle.southeast(e),t);if(!r||!n)throw new Error("Failed to calculate tile bounds");return{start:r,end:n}}_generateVisibleTiles(e,t,i){let r=[],l=Math.min(e.end.x-e.start.x+1,100),h=Math.min(e.end.y-e.start.y+1,100);for(let c=e.start.x;c<e.start.x+l;c++)for(let d=e.start.y;d<e.start.y+h;d++)try{let v=this._createTileEntity(c,d,t,i);v&&r.push({entity:v})}catch(v){console.warn(`Error creating tile (${c}, ${d}, ${t}):`,v)}return r}_createTileEntity(e,t,i,r){let n=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(n))return null;let l=this._getTileColor(e,t,i),h=a.createRectangle(n,l.withAlpha(.3));return h.properties?.addProperty("tileX",e),h.properties?.addProperty("tileY",t),h.properties?.addProperty("tileLevel",i),h}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||s.Color.TRANSPARENT;for(let r of this._terrainProvider.terrainAreas)if(r.contains(e,t,i))return r.isCustom?this._colors.get("custom")||s.Color.RED:this._colors.get("default")||s.Color.BLUE;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||s.Color.BLUE:this._colors.get("fallback")||s.Color.GRAY}hide(){this._collection.remove(a.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,n){return new s.Entity({rectangle:{coordinates:r,material:n,heightReference:s.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,n,l){let h=l?.tag||"terrain_area_visualization",c=l?.color||s.Color.RED,d=l?.maxTilesToShow||100,v=l?.show??!0,E=l?.alpha||.7,w=l?.tileAlpha||.2,f=new m({collection:n.entities,tag:h}),{rectangle:L}=r;if(f.add(i.createRectangle(L,c.withAlpha(E)),h),v&&r.tileRanges.size>0){let{tilingScheme:I}=r.terrainProvider,_=0;r.tileRanges.forEach((g,R)=>{for(let p=g.start.x;p<=g.end.x&&_<d;p++)for(let y=g.start.y;y<=g.end.y&&_<d;y++){let A=I.tileXYToRectangle(p,y,R);f.add(e(A,c.withAlpha(w)),`${h}_tile`),_++}})}return f}i.visualize=t})(u||={});function C(a,e){let t=!1,i=Object.getOwnPropertyDescriptor(a,e);if(!i){let r=Object.getPrototypeOf(a);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var b=class a{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(n=>n(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[a.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof o.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof o.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 o.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 o.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)))}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,a.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),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 values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof o.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(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,a.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,o.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,o.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,o.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let n of r)if(e in n&&typeof n[e]!="function"){if(C(n,e))throw Error(`Cannot set read-only property '${String(e)}' on ${n.constructor.name}`);n[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,n)=>e(r,n))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},m=b;
|
|
@@ -239,25 +239,25 @@ declare class Collection<C extends CesiumCollection, I extends CesiumCollectionI
|
|
|
239
239
|
* @param item - The item to add to the collection
|
|
240
240
|
* @param tag - Tag to associate with this item (defaults to the collection's default tag)
|
|
241
241
|
* @param index - The index to add the item at (if supported by the collection)
|
|
242
|
-
* @returns The
|
|
242
|
+
* @returns The collection instance for method chaining
|
|
243
243
|
*
|
|
244
244
|
* @example
|
|
245
245
|
* const entity = collection.add(new Entity({ ... }), 'landmarks');
|
|
246
246
|
*/
|
|
247
|
-
add(item: I, tag?: Tag, index?: number):
|
|
247
|
+
add(item: I, tag?: Tag, index?: number): this;
|
|
248
248
|
/**
|
|
249
249
|
* Adds multiple items with the same tag to the collection.
|
|
250
250
|
*
|
|
251
251
|
* @param items - The array of items to add to the collection
|
|
252
252
|
* @param tag - Tag to associate with this item (defaults to the collection's default tag)
|
|
253
|
-
* @returns The
|
|
253
|
+
* @returns The collection instance for method chaining
|
|
254
254
|
*
|
|
255
255
|
* @example
|
|
256
256
|
* // Add multiple entities with the same tag
|
|
257
257
|
* const entities = [new Entity({ ... }), new Entity({ ... })];
|
|
258
258
|
* const addedEntities = collection.add(entities, 'buildings');
|
|
259
259
|
*/
|
|
260
|
-
add(items: I[], tag?: Tag):
|
|
260
|
+
add(items: I[], tag?: Tag): this;
|
|
261
261
|
/**
|
|
262
262
|
* Returns true if the provided item is in this collection, false otherwise.
|
|
263
263
|
*
|
|
@@ -281,23 +281,23 @@ declare class Collection<C extends CesiumCollection, I extends CesiumCollectionI
|
|
|
281
281
|
* Removes an item from the collection.
|
|
282
282
|
*
|
|
283
283
|
* @param item - The item to remove
|
|
284
|
-
* @returns
|
|
284
|
+
* @returns The collection instance for method chaining
|
|
285
285
|
*/
|
|
286
|
-
remove(item: I):
|
|
286
|
+
remove(item: I): this;
|
|
287
287
|
/**
|
|
288
288
|
* Removes all items with the specified tag from the collection.
|
|
289
289
|
*
|
|
290
290
|
* @param by - The tag identifying which items to remove
|
|
291
|
-
* @returns
|
|
291
|
+
* @returns The collection instance for method chaining
|
|
292
292
|
*/
|
|
293
|
-
remove(by: Tag):
|
|
293
|
+
remove(by: Tag): this;
|
|
294
294
|
/**
|
|
295
295
|
* Removes all items with the array of tags from the collection.
|
|
296
296
|
*
|
|
297
297
|
* @param by - The tags identifying which items to remove
|
|
298
|
-
* @returns
|
|
298
|
+
* @returns The collection instance for method chaining
|
|
299
299
|
*/
|
|
300
|
-
remove(by: Tag[]):
|
|
300
|
+
remove(by: Tag[]): this;
|
|
301
301
|
/**
|
|
302
302
|
* Removes all items from the collection.
|
|
303
303
|
*/
|
|
@@ -411,7 +411,7 @@ declare class Collection<C extends CesiumCollection, I extends CesiumCollectionI
|
|
|
411
411
|
* @param by - The tag identifying which items to update
|
|
412
412
|
* @param property - The property name to set
|
|
413
413
|
* @param value - The value to set
|
|
414
|
-
* @returns The
|
|
414
|
+
* @returns The collection itself.
|
|
415
415
|
*
|
|
416
416
|
* @example
|
|
417
417
|
* // Change color of all buildings to red
|
|
@@ -239,25 +239,25 @@ declare class Collection<C extends CesiumCollection, I extends CesiumCollectionI
|
|
|
239
239
|
* @param item - The item to add to the collection
|
|
240
240
|
* @param tag - Tag to associate with this item (defaults to the collection's default tag)
|
|
241
241
|
* @param index - The index to add the item at (if supported by the collection)
|
|
242
|
-
* @returns The
|
|
242
|
+
* @returns The collection instance for method chaining
|
|
243
243
|
*
|
|
244
244
|
* @example
|
|
245
245
|
* const entity = collection.add(new Entity({ ... }), 'landmarks');
|
|
246
246
|
*/
|
|
247
|
-
add(item: I, tag?: Tag, index?: number):
|
|
247
|
+
add(item: I, tag?: Tag, index?: number): this;
|
|
248
248
|
/**
|
|
249
249
|
* Adds multiple items with the same tag to the collection.
|
|
250
250
|
*
|
|
251
251
|
* @param items - The array of items to add to the collection
|
|
252
252
|
* @param tag - Tag to associate with this item (defaults to the collection's default tag)
|
|
253
|
-
* @returns The
|
|
253
|
+
* @returns The collection instance for method chaining
|
|
254
254
|
*
|
|
255
255
|
* @example
|
|
256
256
|
* // Add multiple entities with the same tag
|
|
257
257
|
* const entities = [new Entity({ ... }), new Entity({ ... })];
|
|
258
258
|
* const addedEntities = collection.add(entities, 'buildings');
|
|
259
259
|
*/
|
|
260
|
-
add(items: I[], tag?: Tag):
|
|
260
|
+
add(items: I[], tag?: Tag): this;
|
|
261
261
|
/**
|
|
262
262
|
* Returns true if the provided item is in this collection, false otherwise.
|
|
263
263
|
*
|
|
@@ -281,23 +281,23 @@ declare class Collection<C extends CesiumCollection, I extends CesiumCollectionI
|
|
|
281
281
|
* Removes an item from the collection.
|
|
282
282
|
*
|
|
283
283
|
* @param item - The item to remove
|
|
284
|
-
* @returns
|
|
284
|
+
* @returns The collection instance for method chaining
|
|
285
285
|
*/
|
|
286
|
-
remove(item: I):
|
|
286
|
+
remove(item: I): this;
|
|
287
287
|
/**
|
|
288
288
|
* Removes all items with the specified tag from the collection.
|
|
289
289
|
*
|
|
290
290
|
* @param by - The tag identifying which items to remove
|
|
291
|
-
* @returns
|
|
291
|
+
* @returns The collection instance for method chaining
|
|
292
292
|
*/
|
|
293
|
-
remove(by: Tag):
|
|
293
|
+
remove(by: Tag): this;
|
|
294
294
|
/**
|
|
295
295
|
* Removes all items with the array of tags from the collection.
|
|
296
296
|
*
|
|
297
297
|
* @param by - The tags identifying which items to remove
|
|
298
|
-
* @returns
|
|
298
|
+
* @returns The collection instance for method chaining
|
|
299
299
|
*/
|
|
300
|
-
remove(by: Tag[]):
|
|
300
|
+
remove(by: Tag[]): this;
|
|
301
301
|
/**
|
|
302
302
|
* Removes all items from the collection.
|
|
303
303
|
*/
|
|
@@ -411,7 +411,7 @@ declare class Collection<C extends CesiumCollection, I extends CesiumCollectionI
|
|
|
411
411
|
* @param by - The tag identifying which items to update
|
|
412
412
|
* @param property - The property name to set
|
|
413
413
|
* @param value - The value to set
|
|
414
|
-
* @returns The
|
|
414
|
+
* @returns The collection itself.
|
|
415
415
|
*
|
|
416
416
|
* @example
|
|
417
417
|
* // Change color of all buildings to red
|
package/dist/collection/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunk-RXMNSDKR.js";import{c as a}from"../chunk-
|
|
1
|
+
import"../chunk-RXMNSDKR.js";import{c as a}from"../chunk-ZV7FKRP6.js";export{a as Collection};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var f=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var m=(n,t)=>{for(var i in t)f(n,i,{get:t[i],enumerable:!0})},O=(n,t,i,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of p(t))!y.call(n,s)&&s!==i&&f(n,s,{get:()=>t[s],enumerable:!(e=_(t,s))||e.enumerable});return n};var w=n=>O(f({},"__esModule",{value:!0}),n);var v={};m(v,{Highlight:()=>a,SilhouetteHighlight:()=>l,SurfaceHighlight:()=>c});module.exports=w(v);var h=require("cesium");var o=require("cesium"),l=class{_color=o.Color.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(t){this._stages=t.scene.postProcessStages,this._silhouette=o.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=o.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}show(t,i){if((0,o.defined)(t)&&!(this._currentObject===t&&this._optionsEqual(this._currentOptions,i))){this._clearHighlights();try{if(t instanceof o.Cesium3DTileFeature)this._silhouette.uniforms.color=i?.color||this._color,this._silhouette.selected.push(t);else{if(!t.model)return;this._entity=t,t.model.silhouetteSize=new o.ConstantProperty(i?.width||2),t.model.silhouetteColor=new o.ConstantProperty(i?.color||this._color)}this._currentObject=t,this._currentOptions=i?{...i}:void 0}catch(e){console.error("Failed to highlight object:",e),this._currentObject=void 0,this._currentOptions=void 0}}}_optionsEqual(t,i){return!t&&!i?!0:!t||!i?!1:t.outline===i.outline&&t.width===i.width&&o.Color.equals(t.color||this._color,i.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new o.ConstantProperty(o.Color.TRANSPARENT),this._entity.model.silhouetteSize=new o.ConstantProperty(0),this._entity=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}get color(){return this._color}set color(t){this._color=t}get currentObject(){return this._currentObject}};var r=require("cesium"),c=class{_color=r.Color.RED;_entity;_entities;_currentObject;_currentOptions;constructor(t){this._entities=t.entities,this._entity=this._entities.add(new r.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}show(t,i){if(!(!(0,r.defined)(t)||!this._entity)){if(this._currentObject===t&&this._optionsEqual(this._currentOptions,i))return this._entity;this._clearGeometries();try{if(t instanceof r.Entity&&(t.polygon||t.polyline||t.rectangle))this._update(t,i);else if(t instanceof r.GroundPrimitive)this._update(t,i);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=t,this._currentOptions=i?{...i}:void 0,this._entity.show=!0,this._entity}catch(e){console.error("Failed to highlight object:",e),this._currentObject=void 0,this._currentOptions=void 0;return}}}_optionsEqual(t,i){return!t&&!i?!0:!t||!i?!1:t.outline===i.outline&&t.width===i.width&&r.Color.equals(t.color||this._color,i.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(t,i={color:this._color,outline:!1,width:2}){if(t instanceof r.Entity){if(t.polygon)if(i.outline){let e=t.polygon.hierarchy?.getValue();if(e&&e.positions){let s;e.positions.length>0&&!r.Cartesian3.equals(e.positions[0],e.positions[e.positions.length-1])?s=[...e.positions,e.positions[0]]:s=e.positions,this._entity.polyline=new r.PolylineGraphics({positions:s,material:i.color,width:i.width||2,clampToGround:!0})}}else{let e=t.polygon.hierarchy?.getValue();e&&(this._entity.polygon=new r.PolygonGraphics({hierarchy:e,material:i.color,heightReference:r.HeightReference.CLAMP_TO_GROUND,classificationType:t.polygon.classificationType?.getValue()||r.ClassificationType.BOTH}))}else if(t.polyline){let e=t.polyline.positions?.getValue();if(e){let s=t.polyline.width?.getValue();this._entity.polyline=new r.PolylineGraphics({positions:e,material:i.color,width:s+(i.width||2),clampToGround:!0})}}else if(t.rectangle)if(i.outline){let e=t.rectangle.coordinates?.getValue();if(e){let s=[r.Cartesian3.fromRadians(e.west,e.north),r.Cartesian3.fromRadians(e.east,e.north),r.Cartesian3.fromRadians(e.east,e.south),r.Cartesian3.fromRadians(e.west,e.south),r.Cartesian3.fromRadians(e.west,e.north)];this._entity.polyline=new r.PolylineGraphics({positions:s,material:i.color,width:i.width||2,clampToGround:!0})}}else{let e=t.rectangle.coordinates?.getValue();e&&(this._entity.rectangle=new r.RectangleGraphics({coordinates:e,material:i.color,heightReference:r.HeightReference.CLAMP_TO_GROUND}))}}else if(t instanceof r.GroundPrimitive){let e=t.geometryInstances,s=Array.isArray(e)?e[0]:e;if(!s.geometry.attributes.position)return;let d=s.geometry.attributes.position.values,g=[];for(let u=0;u<d.length;u+=3)g.push(new r.Cartesian3(d[u],d[u+1],d[u+2]));i.outline?this._entity.polyline=new r.PolylineGraphics({positions:g,material:i.color,width:i.width||2,clampToGround:!0}):this._entity.polygon=new r.PolygonGraphics({hierarchy:new r.PolygonHierarchy(g),material:i.color,heightReference:r.HeightReference.CLAMP_TO_GROUND,classificationType:r.ClassificationType.BOTH})}}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}get color(){return this._color}set color(t){this._color=t}get entity(){return this._entity}get currentObject(){return this._currentObject}};var a=class n{static instances=new WeakMap;_surface;_silhouette;_color=h.Color.RED;constructor(t){this._surface=new c(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,e=n.instances.get(i);e&&(e.hide(),e._surface&&e._surface.destroy(),e._silhouette&&e._silhouette.destroy(),n.instances.delete(i))}show(t,i={color:this._color}){let e=this._getObject(t);if((0,h.defined)(e))return e instanceof h.Cesium3DTileFeature?this._silhouette.show(e,i):e instanceof h.Entity&&e.model?this._silhouette.show(e,i):this._surface.show(e,i)}_getObject(t){if((0,h.defined)(t)){if(t instanceof h.Entity||t instanceof h.Cesium3DTileFeature||t instanceof h.GroundPrimitive)return t;if(t.id instanceof h.Entity)return t.id;if(t.primitive instanceof h.GroundPrimitive)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}};
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { Entity, Cesium3DTileFeature, GroundPrimitive, Primitive, Model, Cesium3DTileset, Color, Viewer } from 'cesium';
|
|
2
|
+
|
|
3
|
+
interface IHighlight {
|
|
4
|
+
show(object: any, options?: HighlightOptions): void;
|
|
5
|
+
hide(): void;
|
|
6
|
+
destroy(): void;
|
|
7
|
+
color: Color;
|
|
8
|
+
}
|
|
9
|
+
interface HighlightOptions {
|
|
10
|
+
/** Color of the highlight */
|
|
11
|
+
color?: Color;
|
|
12
|
+
/** To apply outline style for the highlight */
|
|
13
|
+
outline?: boolean;
|
|
14
|
+
/** Outline width */
|
|
15
|
+
width?: number;
|
|
16
|
+
}
|
|
17
|
+
type PickedObject = {
|
|
18
|
+
id?: Entity;
|
|
19
|
+
primitive?: Primitive | GroundPrimitive | Model | Cesium3DTileset;
|
|
20
|
+
tileset?: Cesium3DTileset;
|
|
21
|
+
detail?: {
|
|
22
|
+
model?: Model;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
type Picked = Entity | Cesium3DTileFeature | GroundPrimitive | PickedObject;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @class
|
|
29
|
+
* Lightweight multiton highlight manager for Cesium using flyweight pattern.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```
|
|
33
|
+
* // Setup
|
|
34
|
+
* const viewer1 = new Viewer('cesiumContainer1');
|
|
35
|
+
* const viewer2 = new Viewer('cesiumContainer2');
|
|
36
|
+
*
|
|
37
|
+
* const highlighter1 = Highlight.getInstance(viewer1);
|
|
38
|
+
* const highlighter2 = Highlight.getInstance(viewer2);
|
|
39
|
+
*
|
|
40
|
+
* // This highlight only affects viewer1
|
|
41
|
+
* highlighter1.show(someEntity, { color: Color.RED });
|
|
42
|
+
*
|
|
43
|
+
* // This highlight only affects viewer2
|
|
44
|
+
* highlighter2.show(someEntity, { color: Color.BLUE });
|
|
45
|
+
*
|
|
46
|
+
* // When done with viewers
|
|
47
|
+
* Highlight.releaseInstance(viewer1);
|
|
48
|
+
* Highlight.releaseInstance(viewer2);
|
|
49
|
+
* viewer1.destroy();
|
|
50
|
+
* viewer2.destroy();
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare class Highlight {
|
|
54
|
+
private static instances;
|
|
55
|
+
private _surface;
|
|
56
|
+
private _silhouette;
|
|
57
|
+
private _color;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a new `Highlight` instance.
|
|
60
|
+
* @private Use {@link getInstance `Highlight.getInstance()`}
|
|
61
|
+
* @param viewer A viewer to create highlight entity in
|
|
62
|
+
*/
|
|
63
|
+
private constructor();
|
|
64
|
+
/**
|
|
65
|
+
* Gets or creates highlight instance from a viewer.
|
|
66
|
+
* @param viewer The viewer to get or create a new instance from.
|
|
67
|
+
*/
|
|
68
|
+
static getInstance(viewer: Viewer): Highlight;
|
|
69
|
+
/**
|
|
70
|
+
* Releases the highlight instance associated with a viewer.
|
|
71
|
+
* @param viewer The viewer whose highlight instance should be released.
|
|
72
|
+
*/
|
|
73
|
+
static releaseInstance(viewer: Viewer): void;
|
|
74
|
+
/**
|
|
75
|
+
* Highlights a picked object or a direct instance.
|
|
76
|
+
* @param picked The result of `Scene.pick()` or direct instance to be highlighted.
|
|
77
|
+
* @param options Optional style for the highlight.
|
|
78
|
+
* @see {@link HighlightOptions}
|
|
79
|
+
*/
|
|
80
|
+
show(picked: Picked, options?: HighlightOptions): void | Entity;
|
|
81
|
+
private _getObject;
|
|
82
|
+
/**
|
|
83
|
+
* Clears the current highlight effects.
|
|
84
|
+
*/
|
|
85
|
+
hide(): void;
|
|
86
|
+
/** Gets the highlight color. */
|
|
87
|
+
get color(): Color;
|
|
88
|
+
/**
|
|
89
|
+
* Sets the highlight color.
|
|
90
|
+
* @param color The new color for highlights
|
|
91
|
+
*/
|
|
92
|
+
set color(color: Color);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @class
|
|
97
|
+
* An implementation for highlighting 3D objects in Cesium.
|
|
98
|
+
*
|
|
99
|
+
* **Supported Object Types:**
|
|
100
|
+
* - `Entity` with model graphics. (adjustable outline width)
|
|
101
|
+
* - `Cesium3DTileset` instances. (fixed outline width)
|
|
102
|
+
*
|
|
103
|
+
* Currently supports outline style only.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const viewer = new Viewer("cesiumContainer");
|
|
108
|
+
* const silhouetteHighlight = new SilhouetteHighlight(viewer);
|
|
109
|
+
*
|
|
110
|
+
* // Highlight an object
|
|
111
|
+
* const entity = viewer.entities.add(new Entity({
|
|
112
|
+
* model: new ModelGraphics(),
|
|
113
|
+
* }));
|
|
114
|
+
* silhouetteHighlight.show(entity);
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
declare class SilhouetteHighlight implements IHighlight {
|
|
118
|
+
private _color;
|
|
119
|
+
private _silhouette;
|
|
120
|
+
private _composite;
|
|
121
|
+
private _stages;
|
|
122
|
+
private _entity?;
|
|
123
|
+
private _currentObject;
|
|
124
|
+
private _currentOptions;
|
|
125
|
+
/**
|
|
126
|
+
* Creates a new `Silhouette` instance.
|
|
127
|
+
* @param viewer A viewer to create highlight silhouette in
|
|
128
|
+
*/
|
|
129
|
+
constructor(viewer: Viewer);
|
|
130
|
+
/**
|
|
131
|
+
* Highlights a picked `Cesium3DTileset` by updating silhouette composite.
|
|
132
|
+
* @param object The object to be highlighted.
|
|
133
|
+
* @param options Optional style for the highlight.
|
|
134
|
+
*/
|
|
135
|
+
show(object: Cesium3DTileFeature, options?: HighlightOptions): void;
|
|
136
|
+
/**
|
|
137
|
+
* Highlights a picked `Entity` by updating the model properties.
|
|
138
|
+
* @param object The object to be highlighted.
|
|
139
|
+
* @param options Optional style for the highlight.
|
|
140
|
+
*/
|
|
141
|
+
show(object: Entity, options?: HighlightOptions): void;
|
|
142
|
+
/**
|
|
143
|
+
* Compares two HighlightOptions objects for equality
|
|
144
|
+
* @private
|
|
145
|
+
*/
|
|
146
|
+
private _optionsEqual;
|
|
147
|
+
/**
|
|
148
|
+
* Clears all current highlights
|
|
149
|
+
* @private
|
|
150
|
+
*/
|
|
151
|
+
private _clearHighlights;
|
|
152
|
+
/** Clears the current highlight */
|
|
153
|
+
hide(): void;
|
|
154
|
+
/** Clean up the instances */
|
|
155
|
+
destroy(): void;
|
|
156
|
+
/** Gets the highlight color. */
|
|
157
|
+
get color(): Color;
|
|
158
|
+
/** Sets the highlight color. */
|
|
159
|
+
set color(color: Color);
|
|
160
|
+
/** Gets the currently highlighted object */
|
|
161
|
+
get currentObject(): Cesium3DTileFeature | Entity | undefined;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* @class
|
|
166
|
+
* A flyweight implementation for highlighting 2D surface objects in Cesium.
|
|
167
|
+
*
|
|
168
|
+
* This class provides highlighting for ground-clamped geometries (polygons, polylines, rectangles)
|
|
169
|
+
*
|
|
170
|
+
* **Supported Geometry Types:**
|
|
171
|
+
* - `Entity` with polygon, polyline, or rectangle graphics
|
|
172
|
+
* - `GroundPrimitive` instances
|
|
173
|
+
*
|
|
174
|
+
* **Highlighting Modes:**
|
|
175
|
+
* - **Fill mode** (default): Creates a filled geometry using the original shape
|
|
176
|
+
* - **Outline mode**: Creates a polyline outline of the original geometry
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* // Basic usage
|
|
181
|
+
* const viewer = new Viewer('cesiumContainer');
|
|
182
|
+
* const surfaceHighlight = new SurfaceHighlight(viewer);
|
|
183
|
+
*
|
|
184
|
+
* // Highlight an entity with default red fill
|
|
185
|
+
* const entity = viewer.entities.add(new Entity({
|
|
186
|
+
* polygon: {
|
|
187
|
+
* hierarchy: Cartesian3.fromDegreesArray([-75, 35, -74, 35, -74, 36, -75, 36]),
|
|
188
|
+
* material: Color.BLUE
|
|
189
|
+
* }
|
|
190
|
+
* }));
|
|
191
|
+
* surfaceHighlight.show(entity);
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
declare class SurfaceHighlight implements IHighlight {
|
|
195
|
+
private _color;
|
|
196
|
+
private _entity;
|
|
197
|
+
private _entities;
|
|
198
|
+
private _currentObject;
|
|
199
|
+
private _currentOptions;
|
|
200
|
+
/**
|
|
201
|
+
* Creates a new `SurfaceHighlight` instance.
|
|
202
|
+
* @param viewer A viewer to create highlight entity in
|
|
203
|
+
*/
|
|
204
|
+
constructor(viewer: Viewer);
|
|
205
|
+
/**
|
|
206
|
+
* Highlights a picked object by updating the reusable entity
|
|
207
|
+
* @param object The object to be highlighted.
|
|
208
|
+
* @param options Optional style for the highlight.
|
|
209
|
+
* @see {@link HighlightOptions}
|
|
210
|
+
*/
|
|
211
|
+
show(object: Entity | GroundPrimitive, options?: HighlightOptions): Entity | undefined;
|
|
212
|
+
/**
|
|
213
|
+
* Compares two HighlightOptions objects for equality
|
|
214
|
+
* @private
|
|
215
|
+
*/
|
|
216
|
+
private _optionsEqual;
|
|
217
|
+
/**
|
|
218
|
+
* Removes all geometry properties from the highlight entity
|
|
219
|
+
* @private
|
|
220
|
+
*/
|
|
221
|
+
private _clearGeometries;
|
|
222
|
+
/**
|
|
223
|
+
* Updates the highlight entity from an Entity object
|
|
224
|
+
* @private
|
|
225
|
+
*/
|
|
226
|
+
private _update;
|
|
227
|
+
/**
|
|
228
|
+
* Clears the current highlight
|
|
229
|
+
*/
|
|
230
|
+
hide(): void;
|
|
231
|
+
/** Clean up the instances */
|
|
232
|
+
destroy(): void;
|
|
233
|
+
/** Gets the highlight color. */
|
|
234
|
+
get color(): Color;
|
|
235
|
+
/** Sets the highlight color. */
|
|
236
|
+
set color(color: Color);
|
|
237
|
+
/** Gets the highlight entity */
|
|
238
|
+
get entity(): Entity;
|
|
239
|
+
/** Gets the currently highlighted object */
|
|
240
|
+
get currentObject(): Entity | GroundPrimitive | undefined;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export { Highlight, type HighlightOptions, type IHighlight, type Picked, type PickedObject, SilhouetteHighlight, SurfaceHighlight };
|