@juun-roh/cesium-utils 0.4.3 → 0.4.4
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/collection/index.js +1 -1
- package/dist/highlight/index.js +1 -1
- package/dist/index.d.cts +1312 -6
- package/dist/index.d.ts +1312 -6
- package/dist/index.js +1 -1
- package/dist/terrain/dev/index.js +1 -1
- package/dist/terrain/index.js +1 -1
- package/dist/viewer/index.js +1 -1
- package/package.json +81 -41
- package/dist/chunk-6I6OKECI.js +0 -0
- package/dist/chunk-PSCNWZUR.js +0 -1
- package/dist/chunk-WTOAUTEK.js +0 -1
- package/dist/chunk-XHMLNB5Q.js +0 -1
- package/dist/chunk-Z2COOTT4.js +0 -1
- package/dist/collection/index.d.cts +0 -553
- package/dist/collection/index.d.ts +0 -553
- package/dist/dev/index.d.cts +0 -98
- package/dist/dev/index.d.ts +0 -98
- package/dist/experimental/index.d.cts +0 -105
- package/dist/experimental/index.d.ts +0 -105
- package/dist/highlight/index.d.cts +0 -245
- package/dist/highlight/index.d.ts +0 -245
- package/dist/hybrid-terrain-provider-Th8n2hZ1.d.cts +0 -180
- package/dist/hybrid-terrain-provider-Th8n2hZ1.d.ts +0 -180
- package/dist/terrain/dev/index.d.cts +0 -125
- package/dist/terrain/dev/index.d.ts +0 -125
- package/dist/terrain/index.d.cts +0 -8
- package/dist/terrain/index.d.ts +0 -8
- package/dist/viewer/index.d.cts +0 -19
- package/dist/viewer/index.d.ts +0 -19
package/dist/collection/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{DataSourceCollection as m,defined as h,EntityCollection as v,ImageryLayerCollection as y,PrimitiveCollection as f}from"cesium";function l(a,e){let t=!1,i=Object.getOwnPropertyDescriptor(a,e);if(!i){let n=Object.getPrototypeOf(a);for(;n&&!i;)i=Object.getOwnPropertyDescriptor(n,e),n=Object.getPrototypeOf(n)}return i&&i.get&&!i.set&&(t=!0),t}function c(a,e,t){let i=e.split(".");for(let o of i)if(u(o))return{success:!1,reason:"dangerous-property",message:`Property path contains dangerous property name: "${o}"`};let n=a,s=0;for(;s<i.length-1;s++){let o=i[s];if(!n||typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,o))return{success:!1,reason:"invalid-path",message:`Property path "${e}" does not exist or contains inherited properties`};if(n=n[o],!n||typeof n!="object"||n===Object.prototype)return{success:!1,reason:"invalid-path",message:`Cannot traverse path "${e}" - reached non-object or prototype`}}if(s!==i.length-1)return{success:!1,reason:"invalid-path",message:`Failed to traverse property path "${e}"`};let r=i[i.length-1];if(u(r))return{success:!1,reason:"dangerous-property",message:`Cannot set dangerous property "${r}"`};if(!n||typeof n!="object"||n===Object.prototype)return{success:!1,reason:"invalid-path",message:"Cannot set property on invalid target"};if(r in n){if(typeof n[r]=="function")return{success:!1,reason:"function-property",message:`Cannot set function property "${r}"`};if(l(n,r))return{success:!1,reason:"read-only",message:`Cannot set read-only property "${e}"`}}return n[r]=t,{success:!0}}var p=["__proto__","constructor","prototype"];function u(a){return p.includes(a)}var d=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]()}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof v)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get tags(){return Array.from(this._tagMap.keys())}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(n=>{this.add(n,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(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}update(e,t){let i=this.get(e);for(let n of i)this._removeFromTagMap(n),Object.defineProperty(n,a.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(n,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)h(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)h(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)h(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let n=this.get(i);for(let s of n){let r=c(s,e,t);if(!r.success&&r.reason==="read-only")throw Error(`Cannot set read-only property '${e}' on ${s.constructor.name}`)}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((n,s)=>e(n,s))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}_emit(e,t){let i=this._eventListeners.get(e);if(i){let n={type:e,...t};i.forEach(s=>s(n))}}_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 v?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof f?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof m?(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 y&&(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)))}},g=d;export{g as Collection};
|
package/dist/highlight/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Cesium3DTileFeature as P,Color as R,defined as H,Entity as p,GroundPrimitive as E}from"cesium";import{Cesium3DTileFeature as T,Color as f,ConstantProperty as u,defined as G,PostProcessStageLibrary as m}from"cesium";var s=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)}get color(){return this._color}set color(t){this._color=t}get currentObject(){return this._currentObject}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}}}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(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)}};import{Cartesian3 as o,ClassificationType as v,Color as O,defined as S,Entity as g,GroundPrimitive as w,HeightReference as _,PolygonGraphics as C,PolygonHierarchy as b,PolylineGraphics as a,RectangleGraphics as D}from"cesium";var l=class{_color=O.RED;_entity;_entities;_currentObject;_currentOptions;constructor(t){this._entities=t.entities,this._entity=this._entities.add(new g({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}get color(){return this._color}set color(t){this._color=t}get entity(){return this._entity}get currentObject(){return this._currentObject}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 g&&(t.polygon||t.polyline||t.rectangle))this._update(t,i);else if(t instanceof w)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}}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(t,i){return!t&&!i?!0:!t||!i?!1:t.outline===i.outline&&t.width===i.width&&O.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 g){if(t.polygon)if(i.outline){let e=t.polygon.hierarchy?.getValue();if(e&&e.positions){let r;e.positions.length>0&&!o.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:_.CLAMP_TO_GROUND,classificationType:t.polygon.classificationType?.getValue()||v.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=[o.fromRadians(e.west,e.north),o.fromRadians(e.east,e.north),o.fromRadians(e.east,e.south),o.fromRadians(e.west,e.south),o.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 D({coordinates:e,material:i.color,heightReference:_.CLAMP_TO_GROUND}))}}else if(t instanceof w){let e=t.geometryInstances,r=Array.isArray(e)?e[0]:e;if(!r.geometry.attributes.position)return;let c=r.geometry.attributes.position.values,d=[];for(let h=0;h<c.length;h+=3)d.push(new o(c[h],c[h+1],c[h+2]));i.outline?this._entity.polyline=new a({positions:d,material:i.color,width:i.width||2,clampToGround:!0}):this._entity.polygon=new C({hierarchy:new b(d),material:i.color,heightReference:_.CLAMP_TO_GROUND,classificationType:v.BOTH})}}};var y=class n{static instances=new WeakMap;_surface;_silhouette;_color=R.RED;constructor(t){this._surface=new l(t),this._silhouette=new s(t),this._surface.color=this._color,this._silhouette.color=this._color}get color(){return this._color}set color(t){this._color=t,this._surface.color=t,this._silhouette.color=t}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 p&&e.model?this._silhouette.show(e,i):this._surface.show(e,i)}_getObject(t){if(H(t)){if(t instanceof p||t instanceof P||t instanceof E)return t;if(t.id instanceof p)return t.id;if(t.primitive instanceof E)return t.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}},V=y;export{V as Highlight,s as SilhouetteHighlight,l as SurfaceHighlight};
|