@juun-roh/cesium-utils 0.4.1 → 0.4.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/README.md CHANGED
@@ -1,18 +1,20 @@
1
- # Cesium Utils
2
-
3
- [![GitHub](https://img.shields.io/badge/GitHub-%23121011.svg?logo=github&logoColor=white)](https://github.com/juunie-roh/cesium-utils)
4
- [![npm version](https://img.shields.io/npm/v/@juun-roh/cesium-utils.svg?logo=npm&logoColor=fff&color=CB3837)](https://www.npmjs.com/package/@juun-roh/cesium-utils)
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?logo=opensourceinitiative&logoColor=fff)](https://opensource.org/licenses/MIT)
6
- [![Documentation](https://img.shields.io/badge/docs-typedoc-blue?logo=typescript&logoColor=fff&color=3178C6)](https://juunie-roh.github.io/cesium-utils/)
1
+ # cesium-utils
7
2
 
3
+ [![NPM Version](https://img.shields.io/npm/v/%40juun-roh%2Fcesium-utils?logo=npm&logoColor=fff&color=168eff)](https://www.npmjs.com/package/@juun-roh/cesium-utils)
8
4
  [![Build Status](https://img.shields.io/github/actions/workflow/status/juunie-roh/cesium-utils/release-and-publish.yml?logo=githubactions&logoColor=fff)](https://github.com/juunie-roh/cesium-utils/actions)
9
5
  [![Changelog](https://img.shields.io/badge/changelog-releases-blue?logo=git&logoColor=fff&color=green)](https://github.com/juunie-roh/cesium-utils/releases)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?logo=opensourceinitiative&logoColor=fff)](https://opensource.org/licenses/MIT)
10
7
 
11
- TypeScript utility library for Cesium.js providing hybrid terrain providers, entity collection tagging, and visual highlighting systems.
8
+ TypeScript utilities for [CesiumJS](https://cesium.com/cesiumjs/).
12
9
 
13
- > **Note**: The `HybridTerrainProvider` from this library is submitted to Cesium ([#12822](https://github.com/CesiumGS/cesium/pull/12822)).
10
+ - **HybridTerrainProvider** Combine multiple terrain sources by region
11
+ - **Collection** — Tag, filter, and batch-operate entity collections
12
+ - **Highlight** — Visual feedback for picked objects
13
+ - **Sunlight** (Experimental) — Shadow analysis with ray-casting ⚠️ Uses internal APIs
14
14
 
15
- [📚 Documentation](https://juunie-roh.github.io/cesium-utils/) [📦 NPM](https://www.npmjs.com/package/@juun-roh/cesium-utils) • [▶️ Demo](https://juun.vercel.app/cesium-utils)
15
+ > `HybridTerrainProvider` is submitted to Cesium ([#12822](https://github.com/CesiumGS/cesium/pull/12822))
16
+
17
+ [📚 Documentation](https://juunie-roh.github.io/cesium-utils/) · [▶️ Demo](https://juun.vercel.app/cesium-utils) · [📦 NPM](https://www.npmjs.com/package/@juun-roh/cesium-utils)
16
18
 
17
19
  ## Installation
18
20
 
@@ -20,104 +22,25 @@ TypeScript utility library for Cesium.js providing hybrid terrain providers, ent
20
22
  npm install @juun-roh/cesium-utils cesium
21
23
  ```
22
24
 
23
- ## Usage
24
-
25
- ### HybridTerrainProvider
26
-
27
- Combine multiple terrain providers for different geographic regions using tile coordinates:
28
-
29
- ```typescript
30
- import { HybridTerrainProvider } from "@juun-roh/cesium-utils";
31
-
32
- const tiles = new Map();
33
- tiles.set(13, { x: [13963, 13967], y: [2389, 2393] });
34
-
35
- const terrainProvider = new HybridTerrainProvider({
36
- regions: [{
37
- provider: await CesiumTerrainProvider.fromUrl("custom-terrain-url"),
38
- tiles
39
- }],
40
- defaultProvider: worldTerrain
41
- });
42
-
43
- viewer.terrainProvider = terrainProvider;
44
- ```
45
-
46
- ### Collection
47
-
48
- Tagged entity collections with filtering capabilities:
49
-
50
- ```typescript
51
- import { Collection } from "@juun-roh/cesium-utils";
52
-
53
- const buildings = new Collection(viewer.entities, "buildings");
54
- buildings.add({ position: coords, model: buildingModel });
55
- buildings.show = false; // Hide all buildings
56
- ```
57
-
58
- ### Entity Highlighting
59
-
60
- Visual highlighting with silhouette and surface effects:
61
-
62
- ```typescript
63
- import { SilhouetteHighlight } from "@juun-roh/cesium-utils";
64
-
65
- const highlight = new SilhouetteHighlight(viewer, {
66
- color: Color.YELLOW,
67
- size: 2.0
68
- });
69
- highlight.add(selectedEntity);
70
- ```
71
-
72
- ## Modules
25
+ ## Compatibility
73
26
 
74
- | Module | Description |
75
- |--------|-------------|
76
- | `HybridTerrainProvider` | Combine multiple terrain providers by geographic region |
77
- | `Collection` | Tagged entity collections with filtering |
78
- | `SilhouetteHighlight` | Silhouette highlighting effects |
79
- | `SurfaceHighlight` | Surface glow highlighting effects |
80
- | `cloneViewer` | Duplicate viewer configurations |
81
- | `syncCamera` | Synchronize cameras between viewers |
27
+ | Dependency | Version |
28
+ | ---------- | ------- |
29
+ | cesium | ^1.133.0 |
82
30
 
83
- ## Import Options
31
+ Tree-shakable imports available:
84
32
 
85
33
  ```typescript
86
- // Tree-shakable imports (recommended)
34
+ // import holistically from main module
35
+ import { HybridTerrainProvider, Collection } from "@juun-roh/cesium-utils";
36
+ // import from separate modules
87
37
  import { HybridTerrainProvider } from "@juun-roh/cesium-utils/terrain";
88
38
  import { Collection } from "@juun-roh/cesium-utils/collection";
89
- import { SilhouetteHighlight } from "@juun-roh/cesium-utils/highlight";
90
-
91
- // Main package imports
92
- import { Collection, HybridTerrainProvider, SilhouetteHighlight } from "@juun-roh/cesium-utils";
93
- ```
94
-
95
- ## Development
96
-
97
- ```bash
98
- pnpm install # Install dependencies
99
- pnpm build # Build library
100
- pnpm test # Run tests
101
- pnpm dev # Start demo server
102
- ```
103
-
104
- ### Development Utilities
105
-
106
- Additional utilities for advanced usage:
107
-
108
- ```typescript
109
- import { Deprecate, TerrainVisualizer, isGetterOnly } from "@juun-roh/cesium-utils/dev";
110
- ```
111
-
112
- ### Experimental Features
113
-
114
- ⚠️ **Warning**: Experimental features use Cesium's internal APIs and may break in future versions.
115
-
116
- ```typescript
117
- import Sunlight from "@juun-roh/cesium-utils/experimental/sunlight";
39
+ import { Highlight } from "@juun-roh/cesium-utils/highlight";
118
40
 
119
- const sunlight = new Sunlight(viewer);
120
- const result = sunlight.analyze(point, JulianDate.now());
41
+ // Not exported in main module, must import explicitly
42
+ import { TerrainVisualizer } from "@juun-roh/cesium-utils/terrain/dev";
43
+ import { Sunlight } from "@juun-roh/cesium-utils/experimental";
121
44
  ```
122
45
 
123
46
  ## License
@@ -0,0 +1 @@
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 a};
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var O=(a,e)=>{for(var t in e)g(a,t,{get:e[t],enumerable:!0})},S=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of E(e))!w.call(a,i)&&i!==t&&g(a,i,{get:()=>e[i],enumerable:!(r=x(e,i))||r.enumerable});return a};var M=a=>S(g({},"__esModule",{value:!0}),a);var A={};O(A,{Collection:()=>I});module.exports=M(A);var d=require("cesium");var _;(c=>{let a=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(l,n={}){if(!e)return;let{once:h=!0,prefix:s="[DEPRECATED]",includeStack:u=!0,removeInVersion:m}=n;if(h&&a.has(l))return;let f=`${s} ${l}`;m&&(f+=` This feature will be removed in ${m}.`),typeof console<"u"&&console.warn&&(u?(console.warn(f),console.trace("Deprecation stack trace:")):console.warn(f)),h&&a.add(l)}c.warn=t;function r(l,n,h={}){let s=((...u)=>(t(n,h),l(...u)));return Object.defineProperty(s,"name",{value:l.name,configurable:!0}),s}c.deprecate=r;function i(){a.clear()}c.clear=i;function o(){return a.size}c.getWarningCount=o;function v(l){return a.has(l)}c.hasShown=v})(_||={});var C=_;var L=require("cesium");var P=require("cesium");var T=require("cesium"),y=class a{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new T.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,t,r){return this._defaultProvider.loadTileDataAvailability(e,t,r)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,r,i){if(this._ready){for(let o of this._regions)if(a.TerrainRegion.contains(o,e,t,r))return o.provider.requestTileGeometry(e,t,r,i);return this._defaultProvider.getTileDataAvailable(e,t,r)?this._defaultProvider.requestTileGeometry(e,t,r,i):this._fallbackProvider.requestTileGeometry(e,t,r,i)}}getTileDataAvailable(e,t,r){for(let i of this._regions)if(a.TerrainRegion.contains(i,e,t,r))return!0;return this._defaultProvider.getTileDataAvailable(e,t,r)}};(t=>{function a(r,i,o){return new t({regions:r.map(v=>({...v})),defaultProvider:i,fallbackProvider:o})}t.fromTileRanges=a;let e;(i=>{function r(o,v,c,l){if(o.levels&&!o.levels.includes(l))return!1;if(o.tiles){let n=o.tiles.get(l);if(!n)return!1;let[h,s]=Array.isArray(n.x)?n.x:[n.x,n.x],[u,m]=Array.isArray(n.y)?n.y:[n.y,n.y];return v>=h&&v<=s&&c>=u&&c<=m}return!1}i.contains=r})(e=t.TerrainRegion||={})})(y||={});function p(a,e){let t=!1,r=Object.getOwnPropertyDescriptor(a,e);if(!r){let i=Object.getPrototypeOf(a);for(;i&&!r;)r=Object.getOwnPropertyDescriptor(i,e),i=Object.getPrototypeOf(i)}return r&&r.get&&!r.set&&(t=!0),t}var X=C.deprecate;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]()}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof d.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get tags(){return Array.from(this._tagMap.keys())}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,r){return Array.isArray(e)?e.forEach(i=>{this.add(i,t)}):(Object.defineProperty(e,a.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})),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 r of e)this.remove(r)}let t=this.get(e);if(t.length===0)return this;for(let r of t)this.remove(r);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 r=this.get(e);for(let i of r)this._removeFromTagMap(i),Object.defineProperty(i,a.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,d.defined)(r.show)&&(r.show=!0);return this}hide(e){let t=this.get(e);for(let r of t)(0,d.defined)(r.show)&&(r.show=!1);return this}toggle(e){let t=this.get(e);for(let r of t)(0,d.defined)(r.show)&&(r.show=!r.show);return this}setProperty(e,t,r=this.tag){let i=this.get(r),o=e.split("."),v=["__proto__","constructor","prototype"];for(let c of i){let l=!1;for(let s of o)if(v.includes(s)){l=!0;break}if(l)continue;let n=c,h=0;for(;h<o.length-1;h++){let s=o[h];if(!(s in n)||(n=n[s],!n||typeof n!="object"))break}if(h===o.length-1){let s=o[o.length-1];if(s in n&&typeof n[s]!="function"){if(p(n,s))throw Error(`Cannot set read-only property '${e}' on ${c.constructor.name}`);n[s]=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)}_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[a.symbol],r=this._tagMap.get(t);r&&(r.delete(e),r.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof d.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof d.PrimitiveCollection?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof d.DataSourceCollection?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof d.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}},I=b;
1
+ "use strict";var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var g=(s,e)=>{for(var t in e)c(s,t,{get:e[t],enumerable:!0})},C=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!f.call(s,n)&&n!==t&&c(s,n,{get:()=>e[n],enumerable:!(i=m(e,n))||i.enumerable});return s};var _=s=>C(c({},"__esModule",{value:!0}),s);var T={};g(T,{Collection:()=>p});module.exports=_(T);var a=require("cesium");function h(s,e){let t=!1,i=Object.getOwnPropertyDescriptor(s,e);if(!i){let n=Object.getPrototypeOf(s);for(;n&&!i;)i=Object.getOwnPropertyDescriptor(n,e),n=Object.getPrototypeOf(n)}return i&&i.get&&!i.set&&(t=!0),t}function d(s,e,t){let i=e.split(".");for(let l of i)if(v(l))return{success:!1,reason:"dangerous-property",message:`Property path contains dangerous property name: "${l}"`};let n=s,r=0;for(;r<i.length-1;r++){let l=i[r];if(!n||typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,l))return{success:!1,reason:"invalid-path",message:`Property path "${e}" does not exist or contains inherited properties`};if(n=n[l],!n||typeof n!="object"||n===Object.prototype)return{success:!1,reason:"invalid-path",message:`Cannot traverse path "${e}" - reached non-object or prototype`}}if(r!==i.length-1)return{success:!1,reason:"invalid-path",message:`Failed to traverse property path "${e}"`};let o=i[i.length-1];if(v(o))return{success:!1,reason:"dangerous-property",message:`Cannot set dangerous property "${o}"`};if(!n||typeof n!="object"||n===Object.prototype)return{success:!1,reason:"invalid-path",message:"Cannot set property on invalid target"};if(o in n){if(typeof n[o]=="function")return{success:!1,reason:"function-property",message:`Cannot set function property "${o}"`};if(h(n,o))return{success:!1,reason:"read-only",message:`Cannot set read-only property "${e}"`}}return n[o]=t,{success:!0}}var b=["__proto__","constructor","prototype"];function v(s){return b.includes(s)}var u=class s{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 a.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get tags(){return Array.from(this._tagMap.keys())}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(n=>{this.add(n,t)}):(Object.defineProperty(e,s.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),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,s.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)(0,a.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,a.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,a.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let n=this.get(i);for(let r of n){let o=d(r,e,t);if(!o.success&&o.reason==="read-only")throw Error(`Cannot set read-only property '${e}' on ${r.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,r)=>e(n,r))}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(r=>r(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[s.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 a.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof a.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 a.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 a.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}},p=u;
@@ -1,5 +1,37 @@
1
1
  import { DataSourceCollection, EntityCollection, ImageryLayerCollection, PrimitiveCollection, Billboard, Cesium3DTileset, GroundPrimitive, Label, PointPrimitive, Polyline, Primitive, DataSource, Entity, ImageryLayer } from 'cesium';
2
- import { a as NestedKeyOf, b as NestedValueOf } from '../type-check-C17vkHMg.cjs';
2
+
3
+ /**
4
+ * Represents a path to any nested property in an object, using dot notation.
5
+ *
6
+ * The `(keyof T & string)` portion provides top-level key hints in autocomplete,
7
+ * while `(string & {})` allows any string input to pass through.
8
+ *
9
+ * Actual path validation is delegated to {@link NestedValueOf}, which returns `never`
10
+ * for invalid paths — causing a type error on the corresponding value parameter.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * function f<Path extends NestedKeyOf<Obj>>(
15
+ * key: Path,
16
+ * value: NestedValueOf<Obj, Path> // ← validation happens here
17
+ * ) {}
18
+ *
19
+ * f("a.b.c", 123); // ✅ valid path, correct value type
20
+ * f("invalid.path", 1); // ❌ NestedValueOf returns never
21
+ * ```
22
+ */
23
+ type NestedKeyOf<T extends object> = (keyof T & string) | (string & {});
24
+ /**
25
+ * Extracts the type of a nested property from a property path string.
26
+ *
27
+ * @template ObjectType - The object type to extract the value type from
28
+ * @template Path - The property path string (e.g., "a.b.c")
29
+ *
30
+ * @example
31
+ * type Value = NestedValueOf<{ a: { b: number } }, "a.b">
32
+ * // Result: number
33
+ */
34
+ type NestedValueOf<ObjectType, Path extends string> = Path extends `${infer Cur}.${infer Rest}` ? Cur extends keyof ObjectType ? NonNullable<ObjectType[Cur]> extends Function | ((...args: any[]) => any) ? never : NestedValueOf<NonNullable<ObjectType[Cur]>, Rest> : never : Path extends keyof ObjectType ? NonNullable<ObjectType[Path]> extends Function | ((...args: any[]) => any) ? never : ObjectType[Path] : never;
3
35
 
4
36
  /**
5
37
  * @class
@@ -10,6 +42,8 @@ import { a as NestedKeyOf, b as NestedValueOf } from '../type-check-C17vkHMg.cjs
10
42
  * @template C - The type of Cesium collection (e.g., EntityCollection, PrimitiveCollection)
11
43
  * @template I - The type of items in the collection (e.g., Entity, Primitive)
12
44
  *
45
+ * @see [Collection Demo](https://juun.vercel.app/cesium-utils/collection)
46
+ *
13
47
  * @example
14
48
  * // Example 1: Managing Complex Scene with Multiple Object Types
15
49
  * class SceneOrganizer {
@@ -1,5 +1,37 @@
1
1
  import { DataSourceCollection, EntityCollection, ImageryLayerCollection, PrimitiveCollection, Billboard, Cesium3DTileset, GroundPrimitive, Label, PointPrimitive, Polyline, Primitive, DataSource, Entity, ImageryLayer } from 'cesium';
2
- import { a as NestedKeyOf, b as NestedValueOf } from '../type-check-C17vkHMg.js';
2
+
3
+ /**
4
+ * Represents a path to any nested property in an object, using dot notation.
5
+ *
6
+ * The `(keyof T & string)` portion provides top-level key hints in autocomplete,
7
+ * while `(string & {})` allows any string input to pass through.
8
+ *
9
+ * Actual path validation is delegated to {@link NestedValueOf}, which returns `never`
10
+ * for invalid paths — causing a type error on the corresponding value parameter.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * function f<Path extends NestedKeyOf<Obj>>(
15
+ * key: Path,
16
+ * value: NestedValueOf<Obj, Path> // ← validation happens here
17
+ * ) {}
18
+ *
19
+ * f("a.b.c", 123); // ✅ valid path, correct value type
20
+ * f("invalid.path", 1); // ❌ NestedValueOf returns never
21
+ * ```
22
+ */
23
+ type NestedKeyOf<T extends object> = (keyof T & string) | (string & {});
24
+ /**
25
+ * Extracts the type of a nested property from a property path string.
26
+ *
27
+ * @template ObjectType - The object type to extract the value type from
28
+ * @template Path - The property path string (e.g., "a.b.c")
29
+ *
30
+ * @example
31
+ * type Value = NestedValueOf<{ a: { b: number } }, "a.b">
32
+ * // Result: number
33
+ */
34
+ type NestedValueOf<ObjectType, Path extends string> = Path extends `${infer Cur}.${infer Rest}` ? Cur extends keyof ObjectType ? NonNullable<ObjectType[Cur]> extends Function | ((...args: any[]) => any) ? never : NestedValueOf<NonNullable<ObjectType[Cur]>, Rest> : never : Path extends keyof ObjectType ? NonNullable<ObjectType[Path]> extends Function | ((...args: any[]) => any) ? never : ObjectType[Path] : never;
3
35
 
4
36
  /**
5
37
  * @class
@@ -10,6 +42,8 @@ import { a as NestedKeyOf, b as NestedValueOf } from '../type-check-C17vkHMg.js'
10
42
  * @template C - The type of Cesium collection (e.g., EntityCollection, PrimitiveCollection)
11
43
  * @template I - The type of items in the collection (e.g., Entity, Primitive)
12
44
  *
45
+ * @see [Collection Demo](https://juun.vercel.app/cesium-utils/collection)
46
+ *
13
47
  * @example
14
48
  * // Example 1: Managing Complex Scene with Multiple Object Types
15
49
  * class SceneOrganizer {
@@ -1 +1 @@
1
- import{a}from"../chunk-L62HNMU7.js";import"../chunk-R5KTUXEL.js";import"../chunk-XHMLNB5Q.js";export{a as Collection};
1
+ import{a}from"../chunk-WTOAUTEK.js";export{a as Collection};
@@ -1 +1 @@
1
- "use strict";var P=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var E=(o,e)=>{for(var r in e)P(o,r,{get:e[r],enumerable:!0})},R=(o,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of O(e))!I.call(o,t)&&t!==r&&P(o,t,{get:()=>e[t],enumerable:!(i=L(e,t))||i.enumerable});return o};var j=o=>R(P({},"__esModule",{value:!0}),o);var S={};E(S,{Deprecate:()=>_,TerrainVisualizer:()=>p,deprecate:()=>A,isGetterOnly:()=>w});module.exports=j(S);var T;(d=>{let o=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function r(s,n={}){if(!e)return;let{once:c=!0,prefix:v="[DEPRECATED]",includeStack:h=!0,removeInVersion:f}=n;if(c&&o.has(s))return;let g=`${v} ${s}`;f&&(g+=` This feature will be removed in ${f}.`),typeof console<"u"&&console.warn&&(h?(console.warn(g),console.trace("Deprecation stack trace:")):console.warn(g)),c&&o.add(s)}d.warn=r;function i(s,n,c={}){let v=((...h)=>(r(n,c),s(...h)));return Object.defineProperty(v,"name",{value:s.name,configurable:!0}),v}d.deprecate=i;function t(){o.clear()}d.clear=t;function a(){return o.size}d.getWarningCount=a;function l(s){return o.has(s)}d.hasShown=l})(T||={});var _=T;var u=require("cesium");var y=require("cesium");var C=require("cesium"),m=class o{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new C.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,r,i){return this._defaultProvider.loadTileDataAvailability(e,r,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,r,i,t){if(this._ready){for(let a of this._regions)if(o.TerrainRegion.contains(a,e,r,i))return a.provider.requestTileGeometry(e,r,i,t);return this._defaultProvider.getTileDataAvailable(e,r,i)?this._defaultProvider.requestTileGeometry(e,r,i,t):this._fallbackProvider.requestTileGeometry(e,r,i,t)}}getTileDataAvailable(e,r,i){for(let t of this._regions)if(o.TerrainRegion.contains(t,e,r,i))return!0;return this._defaultProvider.getTileDataAvailable(e,r,i)}};(r=>{function o(i,t,a){return new r({regions:i.map(l=>({...l})),defaultProvider:t,fallbackProvider:a})}r.fromTileRanges=o;let e;(t=>{function i(a,l,d,s){if(a.levels&&!a.levels.includes(s))return!1;if(a.tiles){let n=a.tiles.get(s);if(!n)return!1;let[c,v]=Array.isArray(n.x)?n.x:[n.x,n.x],[h,f]=Array.isArray(n.y)?n.y:[n.y,n.y];return l>=c&&l<=v&&d>=h&&d<=f}return!1}t.contains=i})(e=r.TerrainRegion||={})})(m||={});var x=m;var b=class extends y.GridImageryProvider{_terrainProvider;_colors;constructor(e){let{terrainProvider:r,colors:i,...t}=e;super(t),this._terrainProvider=r,this._colors=i}requestImage(e,r,i){for(let t of this._terrainProvider.regions)if(this._isInRegionOrUpsampled(t,e,r,i))return this._createCanvasElement(this._colors.get("custom")||y.Color.RED);return this._terrainProvider.defaultProvider.getTileDataAvailable(e,r,i)?this._createCanvasElement(this._colors.get("default")||y.Color.BLUE):this._createCanvasElement(this._colors.get("fallback")||y.Color.GRAY)}_isInRegionOrUpsampled(e,r,i,t){let a=r,l=i,d=t;for(;d>=0;){if(x.TerrainRegion.contains(e,a,l,d))return!0;if(d===0)break;d--,a=Math.floor(a/2),l=Math.floor(l/2)}return!1}_createCanvasElement(e){let r=document.createElement("canvas");r.width=256,r.height=256;let i=r.getContext("2d"),t=e.withAlpha(.3).toCssColorString();if(!i)throw new Error("canvas context undefined");return i.fillStyle=t,i.fillRect(0,0,256,256),Promise.resolve(r)}};var p=class{_viewer;_terrainProvider;_visible=!1;_tileCoordinatesLayer;_hybridImageryLayer;_colors=new Map([["custom",u.Color.RED],["default",u.Color.BLUE],["fallback",u.Color.GRAY],["grid",u.Color.YELLOW]]);constructor(e,r){this._viewer=e,this._terrainProvider=r.terrainProvider,r.colors&&Object.entries(r.colors).forEach(([i,t])=>{this._colors.set(i,t)}),r.tile!==void 0&&r.tile&&this.show()}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){let e=this._visible,r=!!this._tileCoordinatesLayer,i=this._hybridImageryLayer?.alpha??.5;this.clear(),e&&this.show({showTileCoordinates:r,alpha:i})}clear(){this.hide()}show(e){if(!this._terrainProvider)return;let r=e?.showTileCoordinates??!0,i=e?.alpha??.5;r&&this._ensureTileCoordinatesLayer(),this.showImageryOverlay(i),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new u.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:u.Color.YELLOW})))}hide(){this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this.hideImageryOverlay(),this._visible=!1}setColors(e){Object.entries(e).forEach(([r,i])=>{this._colors.set(r,i)}),this.update()}showImageryOverlay(e=.5){this._hybridImageryLayer&&this._viewer.imageryLayers.remove(this._hybridImageryLayer);let r=new b({terrainProvider:this._terrainProvider,colors:this._colors,tilingScheme:this._terrainProvider.tilingScheme});this._hybridImageryLayer=this._viewer.imageryLayers.addImageryProvider(r),this._hybridImageryLayer.alpha=e,console.log("HybridImageryProvider overlay enabled")}hideImageryOverlay(){this._hybridImageryLayer&&(this._viewer.imageryLayers.remove(this._hybridImageryLayer),this._hybridImageryLayer=void 0,console.log("HybridImageryProvider overlay disabled"))}showTileCoordinates(){this._ensureTileCoordinatesLayer()}hideTileCoordinates(){this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0)}setAlpha(e){this._hybridImageryLayer&&(this._hybridImageryLayer.alpha=e)}flyTo(e,r){this._viewer.camera.flyTo({destination:e,...r,complete:()=>{this._visible&&this.update()}})}get tileCoordinatesVisible(){return!!this._tileCoordinatesLayer}get visible(){return this._visible}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};function w(o,e){let r=!1,i=Object.getOwnPropertyDescriptor(o,e);if(!i){let t=Object.getPrototypeOf(o);for(;t&&!i;)i=Object.getOwnPropertyDescriptor(t,e),t=Object.getPrototypeOf(t)}return i&&i.get&&!i.set&&(r=!0),r}var A=_.deprecate;
1
+ "use strict";var f=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var b=(e,n)=>{for(var t in n)f(e,t,{get:n[t],enumerable:!0})},m=(e,n,t,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of w(n))!T.call(e,o)&&o!==t&&f(e,o,{get:()=>n[o],enumerable:!(c=g(n,o))||c.enumerable});return e};var E=e=>m(f({},"__esModule",{value:!0}),e);var v={};b(v,{Deprecate:()=>l,deprecate:()=>S});module.exports=E(v);var x;(D=>{let e=new Set,n=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(r,s={}){if(!n)return;let{once:i=!0,prefix:a="[DEPRECATED]",includeStack:p=!0,removeInVersion:d}=s;if(i&&e.has(r))return;let u=`${a} ${r}`;d&&(u+=` This feature will be removed in ${d}.`),typeof console<"u"&&console.warn&&(p?(console.warn(u),console.trace("Deprecation stack trace:")):console.warn(u)),i&&e.add(r)}D.warn=t;function c(r,s,i={}){let a=((...p)=>(t(s,i),r(...p)));return Object.defineProperty(a,"name",{value:r.name,configurable:!0}),a}D.deprecate=c;function o(){e.clear()}D.clear=o;function I(){return e.size}D.getWarningCount=I;function h(r){return e.has(r)}D.hasShown=h})(x||={});var l=x;var S=l.deprecate;
@@ -1,7 +1,3 @@
1
- import { Viewer, Color, Rectangle } from 'cesium';
2
- import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-Th8n2hZ1.cjs';
3
- export { a as NestedKeyOf, b as NestedValueOf, N as NonFunction, i as isGetterOnly } from '../type-check-C17vkHMg.cjs';
4
-
5
1
  /**
6
2
  * Utility for managing deprecation warnings in the cesium-utils library.
7
3
  * Provides runtime warnings to help developers identify deprecated API usage.
@@ -97,127 +93,6 @@ declare namespace Deprecate {
97
93
  function hasShown(message: string): boolean;
98
94
  }
99
95
 
100
- /**
101
- * @class
102
- * Utility class for visualizing terrain provider boundaries and debugging terrain loading.
103
- */
104
- declare class TerrainVisualizer {
105
- private _viewer;
106
- private _terrainProvider;
107
- private _visible;
108
- private _tileCoordinatesLayer;
109
- private _hybridImageryLayer;
110
- private _colors;
111
- /**
112
- * Creates a new `TerrainVisualizer`.
113
- * @param viewer The Cesium viewer instance
114
- * @param options {@link TerrainVisualizer.ConstructorOptions}
115
- */
116
- constructor(viewer: Viewer, options: TerrainVisualizer.ConstructorOptions);
117
- /**
118
- * Sets the terrain provider to visualize.
119
- * @param terrainProvider The terrain provider to visualize.
120
- */
121
- setTerrainProvider(terrainProvider: HybridTerrainProvider): void;
122
- /**
123
- * Updates all active visualizations.
124
- */
125
- update(): void;
126
- /**
127
- * Clears all visualizations.
128
- */
129
- clear(): void;
130
- /**
131
- * Shows terrain visualization using HybridImageryProvider.
132
- * Optionally adds tile coordinate grid overlay.
133
- * @param options Visualization options
134
- */
135
- show(options?: {
136
- /** Show tile coordinate labels. Default: true */
137
- showTileCoordinates?: boolean;
138
- /** Transparency level (0-1). Default: 0.5 */
139
- alpha?: number;
140
- }): void;
141
- private _ensureTileCoordinatesLayer;
142
- /**
143
- * Hides the terrain visualization.
144
- */
145
- hide(): void;
146
- /**
147
- * Sets the colors used for visualization.
148
- * @param colors Map of role names to colors
149
- */
150
- setColors(colors: Record<string, Color>): void;
151
- /**
152
- * Shows terrain regions using HybridImageryProvider (performant, global coverage).
153
- * This replaces the entity-based approach with an imagery layer.
154
- * @param alpha Transparency level (0-1), default 0.5
155
- */
156
- showImageryOverlay(alpha?: number): void;
157
- /**
158
- * Hides the imagery overlay.
159
- */
160
- hideImageryOverlay(): void;
161
- /**
162
- * Shows tile coordinate grid overlay.
163
- */
164
- showTileCoordinates(): void;
165
- /**
166
- * Hides tile coordinate grid overlay.
167
- */
168
- hideTileCoordinates(): void;
169
- /**
170
- * Sets the transparency of the imagery overlay.
171
- * @param alpha Transparency level (0-1), where 0 is fully transparent and 1 is fully opaque
172
- */
173
- setAlpha(alpha: number): void;
174
- /**
175
- * Flies the camera to focus on a rectangle.
176
- * @param rectangle The rectangle to focus on.
177
- * @param options {@link Viewer.flyTo}
178
- */
179
- flyTo(rectangle: Rectangle, options?: {
180
- duration?: number;
181
- }): void;
182
- /** Whether tile coordinates are currently visible. */
183
- get tileCoordinatesVisible(): boolean;
184
- /** Whether the grid is currently visible. */
185
- get visible(): boolean;
186
- /** The viewer used in the visualizer */
187
- get viewer(): Viewer;
188
- /** The colors used in the visualizer */
189
- get colors(): Map<string, Color>;
190
- /** The hybrid terrain instance used in the visualizer */
191
- get terrainProvider(): HybridTerrainProvider;
192
- }
193
- /**
194
- * @namespace
195
- * Contains types, utility functions, and constants for terrain visualization.
196
- */
197
- declare namespace TerrainVisualizer {
198
- /** Initialization options for `TerrainVisualizer` constructor. */
199
- interface ConstructorOptions {
200
- /** Colors to use for different visualization elements */
201
- colors?: Record<string, Color>;
202
- /** Whether to show tile grid initially. */
203
- tile?: boolean;
204
- /** Initial zoom level to use for visualizations. */
205
- activeLevel?: number;
206
- /** Terrain provider to visualize. */
207
- terrainProvider: HybridTerrainProvider;
208
- }
209
- /** Options for {@link TerrainVisualizer.visualize} */
210
- interface Options {
211
- color?: Color;
212
- show?: boolean;
213
- maxTilesToShow?: number;
214
- levels?: number[];
215
- tag?: string;
216
- alpha?: number;
217
- tileAlpha?: number;
218
- }
219
- }
220
-
221
96
  declare const deprecate: typeof Deprecate.deprecate;
222
97
 
223
- export { Deprecate, TerrainVisualizer, deprecate };
98
+ export { Deprecate, deprecate };
@@ -1,7 +1,3 @@
1
- import { Viewer, Color, Rectangle } from 'cesium';
2
- import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-Th8n2hZ1.js';
3
- export { a as NestedKeyOf, b as NestedValueOf, N as NonFunction, i as isGetterOnly } from '../type-check-C17vkHMg.js';
4
-
5
1
  /**
6
2
  * Utility for managing deprecation warnings in the cesium-utils library.
7
3
  * Provides runtime warnings to help developers identify deprecated API usage.
@@ -97,127 +93,6 @@ declare namespace Deprecate {
97
93
  function hasShown(message: string): boolean;
98
94
  }
99
95
 
100
- /**
101
- * @class
102
- * Utility class for visualizing terrain provider boundaries and debugging terrain loading.
103
- */
104
- declare class TerrainVisualizer {
105
- private _viewer;
106
- private _terrainProvider;
107
- private _visible;
108
- private _tileCoordinatesLayer;
109
- private _hybridImageryLayer;
110
- private _colors;
111
- /**
112
- * Creates a new `TerrainVisualizer`.
113
- * @param viewer The Cesium viewer instance
114
- * @param options {@link TerrainVisualizer.ConstructorOptions}
115
- */
116
- constructor(viewer: Viewer, options: TerrainVisualizer.ConstructorOptions);
117
- /**
118
- * Sets the terrain provider to visualize.
119
- * @param terrainProvider The terrain provider to visualize.
120
- */
121
- setTerrainProvider(terrainProvider: HybridTerrainProvider): void;
122
- /**
123
- * Updates all active visualizations.
124
- */
125
- update(): void;
126
- /**
127
- * Clears all visualizations.
128
- */
129
- clear(): void;
130
- /**
131
- * Shows terrain visualization using HybridImageryProvider.
132
- * Optionally adds tile coordinate grid overlay.
133
- * @param options Visualization options
134
- */
135
- show(options?: {
136
- /** Show tile coordinate labels. Default: true */
137
- showTileCoordinates?: boolean;
138
- /** Transparency level (0-1). Default: 0.5 */
139
- alpha?: number;
140
- }): void;
141
- private _ensureTileCoordinatesLayer;
142
- /**
143
- * Hides the terrain visualization.
144
- */
145
- hide(): void;
146
- /**
147
- * Sets the colors used for visualization.
148
- * @param colors Map of role names to colors
149
- */
150
- setColors(colors: Record<string, Color>): void;
151
- /**
152
- * Shows terrain regions using HybridImageryProvider (performant, global coverage).
153
- * This replaces the entity-based approach with an imagery layer.
154
- * @param alpha Transparency level (0-1), default 0.5
155
- */
156
- showImageryOverlay(alpha?: number): void;
157
- /**
158
- * Hides the imagery overlay.
159
- */
160
- hideImageryOverlay(): void;
161
- /**
162
- * Shows tile coordinate grid overlay.
163
- */
164
- showTileCoordinates(): void;
165
- /**
166
- * Hides tile coordinate grid overlay.
167
- */
168
- hideTileCoordinates(): void;
169
- /**
170
- * Sets the transparency of the imagery overlay.
171
- * @param alpha Transparency level (0-1), where 0 is fully transparent and 1 is fully opaque
172
- */
173
- setAlpha(alpha: number): void;
174
- /**
175
- * Flies the camera to focus on a rectangle.
176
- * @param rectangle The rectangle to focus on.
177
- * @param options {@link Viewer.flyTo}
178
- */
179
- flyTo(rectangle: Rectangle, options?: {
180
- duration?: number;
181
- }): void;
182
- /** Whether tile coordinates are currently visible. */
183
- get tileCoordinatesVisible(): boolean;
184
- /** Whether the grid is currently visible. */
185
- get visible(): boolean;
186
- /** The viewer used in the visualizer */
187
- get viewer(): Viewer;
188
- /** The colors used in the visualizer */
189
- get colors(): Map<string, Color>;
190
- /** The hybrid terrain instance used in the visualizer */
191
- get terrainProvider(): HybridTerrainProvider;
192
- }
193
- /**
194
- * @namespace
195
- * Contains types, utility functions, and constants for terrain visualization.
196
- */
197
- declare namespace TerrainVisualizer {
198
- /** Initialization options for `TerrainVisualizer` constructor. */
199
- interface ConstructorOptions {
200
- /** Colors to use for different visualization elements */
201
- colors?: Record<string, Color>;
202
- /** Whether to show tile grid initially. */
203
- tile?: boolean;
204
- /** Initial zoom level to use for visualizations. */
205
- activeLevel?: number;
206
- /** Terrain provider to visualize. */
207
- terrainProvider: HybridTerrainProvider;
208
- }
209
- /** Options for {@link TerrainVisualizer.visualize} */
210
- interface Options {
211
- color?: Color;
212
- show?: boolean;
213
- maxTilesToShow?: number;
214
- levels?: number[];
215
- tag?: string;
216
- alpha?: number;
217
- tileAlpha?: number;
218
- }
219
- }
220
-
221
96
  declare const deprecate: typeof Deprecate.deprecate;
222
97
 
223
- export { Deprecate, TerrainVisualizer, deprecate };
98
+ export { Deprecate, deprecate };
package/dist/dev/index.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d}from"../chunk-R5KTUXEL.js";import"../chunk-XHMLNB5Q.js";export{a as Deprecate,b as TerrainVisualizer,d as deprecate,c as isGetterOnly};
1
+ var s;(w=>{let n=new Set,u=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function f(e,o={}){if(!u)return;let{once:r=!0,prefix:t="[DEPRECATED]",includeStack:i=!0,removeInVersion:c}=o;if(r&&n.has(e))return;let a=`${t} ${e}`;c&&(a+=` This feature will be removed in ${c}.`),typeof console<"u"&&console.warn&&(i?(console.warn(a),console.trace("Deprecation stack trace:")):console.warn(a)),r&&n.add(e)}w.warn=f;function l(e,o,r={}){let t=((...i)=>(f(o,r),e(...i)));return Object.defineProperty(t,"name",{value:e.name,configurable:!0}),t}w.deprecate=l;function d(){n.clear()}w.clear=d;function x(){return n.size}w.getWarningCount=x;function g(e){return n.has(e)}w.hasShown=g})(s||={});var p=s;var m=p.deprecate;export{p as Deprecate,m as deprecate};
@@ -1 +1 @@
1
- "use strict";var y=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var w=(o,t)=>{for(var i in t)y(o,i,{get:t[i],enumerable:!0})},S=(o,t,i,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of p(t))!_.call(o,n)&&n!==i&&y(o,n,{get:()=>t[n],enumerable:!(e=g(t,n))||e.enumerable});return o};var m=o=>S(y({},"__esModule",{value:!0}),o);var b={};w(b,{Sunlight:()=>d});module.exports=m(b);var r=require("cesium"),s=require("cesium"),c=class{_sunPositionWC;_sunDirectionWC;_viewer;_analyzing=!1;_pointEntityId;_debugEntityIds=[];constructor(t){let{sunPositionWC:i,sunDirectionWC:e}=t.scene.context.uniformState;this._sunPositionWC=i,this._sunDirectionWC=e,this._viewer=t}get sunPositionWC(){return this._sunPositionWC}get sunDirectionWC(){return this._sunDirectionWC}get isAnalyzing(){return this._analyzing}getVirtualSunPosition(t,i=1e3){let e=s.Cartesian3.normalize(s.Cartesian3.subtract(this._sunPositionWC,t,new s.Cartesian3),new s.Cartesian3);return s.Cartesian3.multiplyByScalar(e,i,e),s.Cartesian3.add(t,e,new s.Cartesian3)}analyze(t,i,e){let n=this._viewer.clock.currentTime.clone();this._viewer.entities.add(this._createPointEntity(t,e?.debugShowPoints,e?.errorBoundary)),this._analyzing=!0;try{return i instanceof s.JulianDate?this._analyzeSingleTime(t,i,e):this._analyzeTimeRange(t,i,e)}finally{this._viewer.clock.currentTime=n,this._viewer.scene.render(),this._analyzing=!1,this._pointEntityId&&!e?.debugShowPoints&&this._viewer.entities.removeById(this._pointEntityId)}}clear(){this._debugEntityIds.forEach(t=>this._viewer.entities.removeById(t)),this._debugEntityIds=[],this._pointEntityId&&this._viewer.entities.removeById(this._pointEntityId)}_createPointEntity(t,i,e){let n=new r.Entity({point:{show:i,color:r.Color.RED.withAlpha(.5),pixelSize:e??5},position:t});return this._pointEntityId=n.id,n}_analyzeSingleTime(t,i,e){this._viewer.clock.currentTime=i,this._viewer.scene.render();let n=new r.Ray(this.getVirtualSunPosition(t),this._sunDirectionWC);if(e?.debugShowRays){let a=new r.Entity({polyline:{positions:[this.getVirtualSunPosition(t),t],width:10,material:r.Color.YELLOW.withAlpha(.5)}});this._debugEntityIds.push(a.id),this._viewer.entities.add(a)}let{object:l,position:u}=this._viewer.scene.pickFromRay(n,this._getExcludedObjects(e?.objectsToExclude),2),h=l instanceof r.Entity&&l.id===this._pointEntityId;if(e?.debugShowPoints&&u){let a=new r.Entity({point:{show:!0,pixelSize:5},position:u});this._debugEntityIds.push(a.id),this._viewer.entities.add(a)}return{timestamp:i.toString(),result:h}}_analyzeTimeRange(t,i,e){let n=[],{start:l,end:u,step:h}=i,a=l.clone();for(;s.JulianDate.compare(a,u)<=0;)n.push(this._analyzeSingleTime(t,a,e)),s.JulianDate.addSeconds(a,h,a);return n}_getExcludedObjects(t){return[...this._debugEntityIds.map(i=>this._viewer.entities.getById(i)).filter(Boolean),...t??[]]}},d=c;
1
+ "use strict";var c=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var g=(a,e)=>{for(var i in e)c(a,i,{get:e[i],enumerable:!0})},m=(a,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of d(e))!_.call(a,s)&&s!==i&&c(a,s,{get:()=>e[s],enumerable:!(n=p(e,s))||n.enumerable});return a};var w=a=>m(c({},"__esModule",{value:!0}),a);var S={};g(S,{Sunlight:()=>h});module.exports=w(S);var t=require("cesium"),l=class a{_uniformState;_viewer;_analyzing=!1;_pointEntityId;_objectsToExclude=[];_polylines;_points;constructor(e){this._uniformState=e.scene.context.uniformState,this._viewer=e,this._polylines=e.scene.primitives.add(new t.PolylineCollection),this._points=new t.EntityCollection,e.entities.add(this._points)}get sunPositionWC(){return this._uniformState._sunPositionWC}get sunDirectionWC(){return this._uniformState._sunDirectionWC}get isAnalyzing(){return this._analyzing}virtualSun(e,i=1e4){let n=t.Cartesian3.normalize(t.Cartesian3.subtract(this.sunPositionWC,e,new t.Cartesian3),new t.Cartesian3);return t.Cartesian3.multiplyByScalar(n,i,n),{position:t.Cartesian3.add(e,n,new t.Cartesian3),direction:t.Cartesian3.normalize(t.Cartesian3.subtract(e,this.sunPositionWC,new t.Cartesian3),new t.Cartesian3)}}async analyze(e,i,n){if(!this._pointEntityId)throw new Error("Analyze error boundary hasn't been set. Create Error boundary entity first using createDetectionEllipsoid first.");let s=this._viewer.clock.currentTime.clone();this._analyzing=!0;try{return i instanceof t.JulianDate?await this._analyzeSingleTime(e,i,n):await this._analyzeTimeRange(e,i,n)}finally{this._viewer.clock.currentTime=s,this._viewer.scene.render(),this._analyzing=!1}}clear(){this._objectsToExclude=[],this._points.values.length>0&&this._points.removeAll(),this._polylines.length>0&&this._polylines.removeAll()}setTargetPoint(e,i,n,s=t.Color.LIMEGREEN.withAlpha(.8)){this._pointEntityId&&this._viewer.entities.removeById(this._pointEntityId);let r=n??3,o=this._viewer.entities.add(new t.Entity({ellipsoid:{show:i,radii:new t.Cartesian3(r,r,r),material:i?s:void 0,fill:!0},position:e,id:a.DETECTION_ELLIPSOID_ID}));return this._pointEntityId=o.id,this._viewer.scene.render(),o}async _analyzeSingleTime(e,i,n){this._viewer.clock.currentTime=i,this._viewer.scene.render(i);let s=[e,this.virtualSun(e).position];if(n?.debugShowRays){let o=this._polylines.add({show:!0,positions:s,width:5,material:new t.Material({fabric:{type:"Color",uniforms:{color:t.Color.YELLOW.withAlpha(.5)}}})});this._objectsToExclude.push(o)}let r=await this._pick(e,n?.objectsToExclude);return{timestamp:i.toString(),result:r?r.object?.id?.id===this._pointEntityId:!1}}async _analyzeTimeRange(e,i,n){let s=[],{start:r,end:o,step:y}=i,u=r.clone();for(;t.JulianDate.compare(u,o)<=0;)s.push(await this._analyzeSingleTime(e,u,n)),t.JulianDate.addSeconds(u,y,u);return s}async _pick(e,i,n=.1){let{position:s,direction:r}=this.virtualSun(e),o=new t.Ray(s,r);return await this._viewer.scene.pickFromRayMostDetailed(o,this._getExcludedObjects(i),n)}_getExcludedObjects(e){return[...this._objectsToExclude,...e??[]]}};(e=>e.DETECTION_ELLIPSOID_ID="sunlight-detection-ellipsoid")(l||={});var h=l;