@juun-roh/cesium-utils 0.4.0 → 0.4.2

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 y=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var S=(a,e)=>{for(var r in e)y(a,r,{get:e[r],enumerable:!0})},M=(a,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of w(e))!x.call(a,i)&&i!==r&&y(a,i,{get:()=>e[i],enumerable:!(t=E(e,i))||t.enumerable});return a};var A=a=>M(y({},"__esModule",{value:!0}),a);var O={};S(O,{Collection:()=>I});module.exports=A(O);var s=require("cesium");var _;(g=>{let a=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function r(l,o={}){if(!e)return;let{once:d=!0,prefix:h="[DEPRECATED]",includeStack:c=!0,removeInVersion:u}=o;if(d&&a.has(l))return;let f=`${h} ${l}`;u&&(f+=` This feature will be removed in ${u}.`),typeof console<"u"&&console.warn&&(c?(console.warn(f),console.trace("Deprecation stack trace:")):console.warn(f)),d&&a.add(l)}g.warn=r;function t(l,o,d={}){let h=((...c)=>(r(o,d),l(...c)));return Object.defineProperty(h,"name",{value:l.name,configurable:!0}),h}g.deprecate=t;function i(){a.clear()}g.clear=i;function n(){return a.size}g.getWarningCount=n;function v(l){return a.has(l)}g.hasShown=v})(_||={});var C=_;var L=require("cesium");var P=require("cesium");var T=require("cesium"),m=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,r,t){return this._defaultProvider.loadTileDataAvailability(e,r,t)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,r,t,i){if(this._ready){for(let n of this._regions)if(a.TerrainRegion.contains(n,e,r,t))return n.provider.requestTileGeometry(e,r,t,i);return this._defaultProvider.getTileDataAvailable(e,r,t)?this._defaultProvider.requestTileGeometry(e,r,t,i):this._fallbackProvider.requestTileGeometry(e,r,t,i)}}getTileDataAvailable(e,r,t){for(let i of this._regions)if(a.TerrainRegion.contains(i,e,r,t))return!0;return this._defaultProvider.getTileDataAvailable(e,r,t)}};(r=>{function a(t,i,n){return new r({regions:t.map(v=>({...v})),defaultProvider:i,fallbackProvider:n})}r.fromTileRanges=a;let e;(i=>{function t(n,v,g,l){if(n.levels&&!n.levels.includes(l))return!1;if(n.tiles){let o=n.tiles.get(l);if(!o)return!1;let[d,h]=Array.isArray(o.x)?o.x:[o.x,o.x],[c,u]=Array.isArray(o.y)?o.y:[o.y,o.y];return v>=d&&v<=h&&g>=c&&g<=u}return!1}i.contains=t})(e=r.TerrainRegion||={})})(m||={});function p(a,e){let r=!1,t=Object.getOwnPropertyDescriptor(a,e);if(!t){let i=Object.getPrototypeOf(a);for(;i&&!t;)t=Object.getOwnPropertyDescriptor(i,e),i=Object.getPrototypeOf(i)}return t&&t.get&&!t.set&&(r=!0),r}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:r}){this.tag=r||"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 s.EntityCollection)e=this.collection.values;else{e=[];for(let r=0;r<this.collection.length;r++)e.push(this.collection.get(r))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get tags(){return Array.from(this._tagMap.keys())}addEventListener(e,r){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(r),this}removeEventListener(e,r){return this._eventListeners.get(e)?.delete(r),this}add(e,r=this.tag,t){return Array.isArray(e)?e.forEach(i=>{this.add(i,r)}):(Object.defineProperty(e,a.symbol,{value:r,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,t),this._addToTagMap(e,r),this._invalidateCache(),this._emit("add",{items:[e],tag:r})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let r=this._tagMap.get(e);return!!r&&r.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 t of e)this.remove(t)}let r=this.get(e);if(r.length===0)return this;for(let t of r)this.remove(t);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 r=this._tagMap.get(e);return r?Array.from(r):[]}first(e){let r=this._tagMap.get(e);if(r&&r.size>0)return r.values().next().value}update(e,r){let t=this.get(e);for(let i of t)this._removeFromTagMap(i),Object.defineProperty(i,a.symbol,{value:r,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(i,r);return t.length>0&&this._emit("update",{items:t,tag:r}),t.length}show(e){let r=this.get(e);for(let t of r)(0,s.defined)(t.show)&&(t.show=!0);return this}hide(e){let r=this.get(e);for(let t of r)(0,s.defined)(t.show)&&(t.show=!1);return this}toggle(e){let r=this.get(e);for(let t of r)(0,s.defined)(t.show)&&(t.show=!t.show);return this}setProperty(e,r,t=this.tag){let i=this.get(t);for(let n of i)if(e in n&&typeof n[e]!="function"){if(p(n,e))throw Error(`Cannot set read-only property '${String(e)}' on ${n.constructor.name}`);n[e]=r}return this}filter(e,r){return(r?this.get(r):this.values).filter(e)}forEach(e,r){(r?this.get(r):this.values).forEach((i,n)=>e(i,n))}map(e,r){return(r?this.get(r):this.values).map(e)}find(e,r){return(r?this.get(r):this.values).find(e)}_emit(e,r){let t=this._eventListeners.get(e);if(t){let i={type:e,...r};t.forEach(n=>n(i))}}_addToTagMap(e,r){this._tagMap.has(r)||this._tagMap.set(r,new Set),this._tagMap.get(r)?.add(e)}_removeFromTagMap(e){let r=e[a.symbol],t=this._tagMap.get(r);t&&(t.delete(e),t.size===0&&this._tagMap.delete(r))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof s.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof s.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 s.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 s.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 { N as NonFunction } from '../type-check-B-zGL1Ne.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 { N as NonFunction } from '../type-check-B-zGL1Ne.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 {
@@ -346,10 +380,11 @@ declare class Collection<C extends Collection.Base, I extends Collection.ItemFor
346
380
  toggle(by: Collection.Tag): this;
347
381
  /**
348
382
  * Sets a property value on all items with the specified tag.
383
+ * Supports nested property paths using dot notation (e.g., 'billboard.scale').
349
384
  *
350
- * @template K - A type
385
+ * @template Path - A nested property path type
351
386
  *
352
- * @param property - The property name to set
387
+ * @param property - The property name or nested path to set (e.g., 'name' or 'billboard.scale')
353
388
  * @param value - The value to set
354
389
  * @param by - The tag identifying which items to update
355
390
  * @returns The collection itself.
@@ -357,8 +392,12 @@ declare class Collection<C extends Collection.Base, I extends Collection.ItemFor
357
392
  * @example
358
393
  * // Change color of all buildings to red
359
394
  * collection.setProperty('color', Color.RED, 'buildings');
395
+ *
396
+ * @example
397
+ * // Change billboard scale using nested path
398
+ * collection.setProperty('billboard.scale', 2.0, 'buildings');
360
399
  */
361
- setProperty<K extends NonFunction<I>>(property: K, value: I[K], by?: Collection.Tag): this;
400
+ setProperty<Path extends NestedKeyOf<I>>(property: Path, value: NestedValueOf<I, Path>, by?: Collection.Tag): this;
362
401
  /**
363
402
  * Filters items in the collection based on a predicate function.
364
403
  * Optionally only filters items with a specific tag.
@@ -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 { N as NonFunction } from '../type-check-B-zGL1Ne.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 { N as NonFunction } from '../type-check-B-zGL1Ne.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 {
@@ -346,10 +380,11 @@ declare class Collection<C extends Collection.Base, I extends Collection.ItemFor
346
380
  toggle(by: Collection.Tag): this;
347
381
  /**
348
382
  * Sets a property value on all items with the specified tag.
383
+ * Supports nested property paths using dot notation (e.g., 'billboard.scale').
349
384
  *
350
- * @template K - A type
385
+ * @template Path - A nested property path type
351
386
  *
352
- * @param property - The property name to set
387
+ * @param property - The property name or nested path to set (e.g., 'name' or 'billboard.scale')
353
388
  * @param value - The value to set
354
389
  * @param by - The tag identifying which items to update
355
390
  * @returns The collection itself.
@@ -357,8 +392,12 @@ declare class Collection<C extends Collection.Base, I extends Collection.ItemFor
357
392
  * @example
358
393
  * // Change color of all buildings to red
359
394
  * collection.setProperty('color', Color.RED, 'buildings');
395
+ *
396
+ * @example
397
+ * // Change billboard scale using nested path
398
+ * collection.setProperty('billboard.scale', 2.0, 'buildings');
360
399
  */
361
- setProperty<K extends NonFunction<I>>(property: K, value: I[K], by?: Collection.Tag): this;
400
+ setProperty<Path extends NestedKeyOf<I>>(property: Path, value: NestedValueOf<I, Path>, by?: Collection.Tag): this;
362
401
  /**
363
402
  * Filters items in the collection based on a predicate function.
364
403
  * Optionally only filters items with a specific tag.
@@ -1 +1 @@
1
- import{a}from"../chunk-VWM3HSEI.js";import"../chunk-ZXZ7TVB3.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 _=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var E=(o,e)=>{for(var r in e)_(o,r,{get:e[r],enumerable:!0})},R=(o,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of I(e))!O.call(o,t)&&t!==r&&_(o,t,{get:()=>e[t],enumerable:!(i=x(e,t))||i.enumerable});return o};var A=o=>R(_({},"__esModule",{value:!0}),o);var M={};E(M,{Deprecate:()=>P,TerrainVisualizer:()=>g,deprecate:()=>S,isGetterOnly:()=>L});module.exports=A(M);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:v=!0,prefix:c="[DEPRECATED]",includeStack:m=!0,removeInVersion:b}=n;if(v&&o.has(s))return;let p=`${c} ${s}`;b&&(p+=` This feature will be removed in ${b}.`),typeof console<"u"&&console.warn&&(m?(console.warn(p),console.trace("Deprecation stack trace:")):console.warn(p)),v&&o.add(s)}d.warn=r;function i(s,n,v={}){let c=((...m)=>(r(n,v),s(...m)));return Object.defineProperty(c,"name",{value:s.name,configurable:!0}),c}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 P=T;var u=require("cesium");var h=require("cesium");var C=require("cesium"),y=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[v,c]=Array.isArray(n.x)?n.x:[n.x,n.x],[m,b]=Array.isArray(n.y)?n.y:[n.y,n.y];return l>=v&&l<=c&&d>=m&&d<=b}return!1}t.contains=i})(e=r.TerrainRegion||={})})(y||={});var w=y;var f=class extends h.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")||h.Color.RED);return this._terrainProvider.defaultProvider.getTileDataAvailable(e,r,i)?this._createCanvasElement(this._colors.get("default")||h.Color.BLUE):this._createCanvasElement(this._colors.get("fallback")||h.Color.GRAY)}_isInRegionOrUpsampled(e,r,i,t){let a=r,l=i,d=t;for(;d>=0;){if(w.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 g=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 f({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 L(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 S=P.deprecate;
1
+ "use strict";var p=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var E=(a,e)=>{for(var r in e)p(a,r,{get:e[r],enumerable:!0})},R=(a,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of x(e))!I.call(a,t)&&t!==r&&p(a,t,{get:()=>e[t],enumerable:!(i=L(e,t))||i.enumerable});return a};var A=a=>R(p({},"__esModule",{value:!0}),a);var O={};E(O,{Deprecate:()=>P,TerrainVisualizer:()=>g,deprecate:()=>S});module.exports=A(O);var T;(d=>{let a=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function r(s,n={}){if(!e)return;let{once:v=!0,prefix:h="[DEPRECATED]",includeStack:m=!0,removeInVersion:f}=n;if(v&&a.has(s))return;let _=`${h} ${s}`;f&&(_+=` This feature will be removed in ${f}.`),typeof console<"u"&&console.warn&&(m?(console.warn(_),console.trace("Deprecation stack trace:")):console.warn(_)),v&&a.add(s)}d.warn=r;function i(s,n,v={}){let h=((...m)=>(r(n,v),s(...m)));return Object.defineProperty(h,"name",{value:s.name,configurable:!0}),h}d.deprecate=i;function t(){a.clear()}d.clear=t;function o(){return a.size}d.getWarningCount=o;function l(s){return a.has(s)}d.hasShown=l})(T||={});var P=T;var u=require("cesium");var c=require("cesium");var C=require("cesium"),y=class a{_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 o of this._regions)if(a.TerrainRegion.contains(o,e,r,i))return o.provider.requestTileGeometry(e,r,i,t);return this._defaultProvider.getTileDataAvailable(e,r,i)?this._defaultProvider.requestTileGeometry(e,r,i,t):this._fallbackProvider.requestTileGeometry(e,r,i,t)}}getTileDataAvailable(e,r,i){for(let t of this._regions)if(a.TerrainRegion.contains(t,e,r,i))return!0;return this._defaultProvider.getTileDataAvailable(e,r,i)}};(r=>{function a(i,t,o){return new r({regions:i.map(l=>({...l})),defaultProvider:t,fallbackProvider:o})}r.fromTileRanges=a;let e;(t=>{function i(o,l,d,s){if(o.levels&&!o.levels.includes(s))return!1;if(o.tiles){let n=o.tiles.get(s);if(!n)return!1;let[v,h]=Array.isArray(n.x)?n.x:[n.x,n.x],[m,f]=Array.isArray(n.y)?n.y:[n.y,n.y];return l>=v&&l<=h&&d>=m&&d<=f}return!1}t.contains=i})(e=r.TerrainRegion||={})})(y||={});var w=y;var b=class extends c.GridImageryProvider{_terrainProvider;_colors;constructor(e){let{terrainProvider:r,colors:i,...t}=e;super(t),this._terrainProvider=r,this._colors=i}requestImage(e,r,i){for(let t of this._terrainProvider.regions)if(this._isInRegionOrUpsampled(t,e,r,i))return this._createCanvasElement(this._colors.get("custom")||c.Color.RED);return this._terrainProvider.defaultProvider.getTileDataAvailable(e,r,i)?this._createCanvasElement(this._colors.get("default")||c.Color.BLUE):this._createCanvasElement(this._colors.get("fallback")||c.Color.GRAY)}_isInRegionOrUpsampled(e,r,i,t){let o=r,l=i,d=t;for(;d>=0;){if(w.TerrainRegion.contains(e,o,l,d))return!0;if(d===0)break;d--,o=Math.floor(o/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 g=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}};var S=P.deprecate;
@@ -1,6 +1,5 @@
1
1
  import { Viewer, Color, Rectangle } from 'cesium';
2
2
  import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-Th8n2hZ1.cjs';
3
- export { N as NonFunction, i as isGetterOnly } from '../type-check-B-zGL1Ne.cjs';
4
3
 
5
4
  /**
6
5
  * Utility for managing deprecation warnings in the cesium-utils library.
@@ -1,6 +1,5 @@
1
1
  import { Viewer, Color, Rectangle } from 'cesium';
2
2
  import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-Th8n2hZ1.js';
3
- export { N as NonFunction, i as isGetterOnly } from '../type-check-B-zGL1Ne.js';
4
3
 
5
4
  /**
6
5
  * Utility for managing deprecation warnings in the cesium-utils library.
package/dist/dev/index.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d}from"../chunk-ZXZ7TVB3.js";import"../chunk-XHMLNB5Q.js";export{a as Deprecate,b as TerrainVisualizer,d as deprecate,c as isGetterOnly};
1
+ import{a as _}from"../chunk-XHMLNB5Q.js";var b;(n=>{let a=new Set,r=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function e(o,y={}){if(!r)return;let{once:c=!0,prefix:v="[DEPRECATED]",includeStack:m=!0,removeInVersion:f}=y;if(c&&a.has(o))return;let u=`${v} ${o}`;f&&(u+=` This feature will be removed in ${f}.`),typeof console<"u"&&console.warn&&(m?(console.warn(u),console.trace("Deprecation stack trace:")):console.warn(u)),c&&a.add(o)}n.warn=e;function i(o,y,c={}){let v=((...m)=>(e(y,c),o(...m)));return Object.defineProperty(v,"name",{value:o.name,configurable:!0}),v}n.deprecate=i;function t(){a.clear()}n.clear=t;function d(){return a.size}n.getWarningCount=d;function h(o){return a.has(o)}n.hasShown=h})(b||={});var C=b;import{Color as l,TileCoordinatesImageryProvider as L}from"cesium";import{Color as g,GridImageryProvider as w}from"cesium";var s=class extends w{_terrainProvider;_colors;constructor(r){let{terrainProvider:e,colors:i,...t}=r;super(t),this._terrainProvider=e,this._colors=i}requestImage(r,e,i){for(let t of this._terrainProvider.regions)if(this._isInRegionOrUpsampled(t,r,e,i))return this._createCanvasElement(this._colors.get("custom")||g.RED);return this._terrainProvider.defaultProvider.getTileDataAvailable(r,e,i)?this._createCanvasElement(this._colors.get("default")||g.BLUE):this._createCanvasElement(this._colors.get("fallback")||g.GRAY)}_isInRegionOrUpsampled(r,e,i,t){let d=e,h=i,n=t;for(;n>=0;){if(_.TerrainRegion.contains(r,d,h,n))return!0;if(n===0)break;n--,d=Math.floor(d/2),h=Math.floor(h/2)}return!1}_createCanvasElement(r){let e=document.createElement("canvas");e.width=256,e.height=256;let i=e.getContext("2d"),t=r.withAlpha(.3).toCssColorString();if(!i)throw new Error("canvas context undefined");return i.fillStyle=t,i.fillRect(0,0,256,256),Promise.resolve(e)}};var p=class{_viewer;_terrainProvider;_visible=!1;_tileCoordinatesLayer;_hybridImageryLayer;_colors=new Map([["custom",l.RED],["default",l.BLUE],["fallback",l.GRAY],["grid",l.YELLOW]]);constructor(r,e){this._viewer=r,this._terrainProvider=e.terrainProvider,e.colors&&Object.entries(e.colors).forEach(([i,t])=>{this._colors.set(i,t)}),e.tile!==void 0&&e.tile&&this.show()}setTerrainProvider(r){this._terrainProvider=r,this.update()}update(){let r=this._visible,e=!!this._tileCoordinatesLayer,i=this._hybridImageryLayer?.alpha??.5;this.clear(),r&&this.show({showTileCoordinates:e,alpha:i})}clear(){this.hide()}show(r){if(!this._terrainProvider)return;let e=r?.showTileCoordinates??!0,i=r?.alpha??.5;e&&this._ensureTileCoordinatesLayer(),this.showImageryOverlay(i),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new L({tilingScheme:this._terrainProvider.tilingScheme,color:l.YELLOW})))}hide(){this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this.hideImageryOverlay(),this._visible=!1}setColors(r){Object.entries(r).forEach(([e,i])=>{this._colors.set(e,i)}),this.update()}showImageryOverlay(r=.5){this._hybridImageryLayer&&this._viewer.imageryLayers.remove(this._hybridImageryLayer);let e=new s({terrainProvider:this._terrainProvider,colors:this._colors,tilingScheme:this._terrainProvider.tilingScheme});this._hybridImageryLayer=this._viewer.imageryLayers.addImageryProvider(e),this._hybridImageryLayer.alpha=r,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(r){this._hybridImageryLayer&&(this._hybridImageryLayer.alpha=r)}flyTo(r,e){this._viewer.camera.flyTo({destination:r,...e,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}};var D=C.deprecate;export{C as Deprecate,p as TerrainVisualizer,D as deprecate};
@@ -1 +1 @@
1
- "use strict";var y=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var S=(r,t)=>{for(var i in t)y(r,i,{get:t[i],enumerable:!0})},m=(r,t,i,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of _(t))!w.call(r,n)&&n!==i&&y(r,n,{get:()=>t[n],enumerable:!(e=p(t,n))||e.enumerable});return r};var v=r=>m(y({},"__esModule",{value:!0}),r);var b={};S(b,{Sunlight:()=>g});module.exports=v(b);var a=require("cesium"),s=require("cesium"),d=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 a.Entity({point:{show:i,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 a.Ray(this.getVirtualSunPosition(t),this._sunDirectionWC);if(e?.debugShowRays){let l=new a.Entity({polyline:{positions:[this.getVirtualSunPosition(t),t],width:10,material:a.Color.YELLOW.withAlpha(.5)}});this._debugEntityIds.push(l.id),this._viewer.entities.add(l)}let u=this._viewer.scene.picking,{object:h,position:c}=u.pickFromRay(u,this._viewer.scene,n,this._getExcludedObjects(e?.objectsToExclude)),o=h instanceof a.Entity&&h.id===this._pointEntityId;if(e?.debugShowPoints&&c){let l=new a.Entity({point:{show:!0,pixelSize:5},position:c});this._debugEntityIds.push(l.id),this._viewer.entities.add(l)}return{timestamp:i.toString(),result:o}}_analyzeTimeRange(t,i,e){let n=[],{start:u,end:h,step:c}=i,o=u.clone();for(;s.JulianDate.compare(o,h)<=0;)n.push(this._analyzeSingleTime(t,o,e)),s.JulianDate.addSeconds(o,c,o);return n}_getExcludedObjects(t){return[...this._debugEntityIds.map(i=>this._viewer.entities.getById(i)).filter(Boolean),...t??[]]}},g=d;
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;
@@ -1,4 +1,4 @@
1
- import { Viewer, Cartesian3, JulianDate } from 'cesium';
1
+ import { Viewer, Cartesian3, JulianDate, Color, Entity } from 'cesium';
2
2
 
3
3
  /**
4
4
  * @since Cesium 1.132.0
@@ -15,12 +15,13 @@ import { Viewer, Cartesian3, JulianDate } from 'cesium';
15
15
  * ```
16
16
  */
17
17
  declare class Sunlight {
18
- private _sunPositionWC;
19
- private _sunDirectionWC;
18
+ private _uniformState;
20
19
  private _viewer;
21
20
  private _analyzing;
22
21
  private _pointEntityId?;
23
- private _debugEntityIds;
22
+ private _objectsToExclude;
23
+ private _polylines;
24
+ private _points;
24
25
  constructor(viewer: Viewer);
25
26
  /** The sun position in 3D world coordinates at the current scene time. */
26
27
  get sunPositionWC(): Cartesian3;
@@ -29,42 +30,51 @@ declare class Sunlight {
29
30
  /** Whether sunlight analysis is currently in progress. */
30
31
  get isAnalyzing(): boolean;
31
32
  /**
32
- * Gets a virtual position of the sun to reduce calculation overhead.
33
+ * Gets virtual position and direction of the sun to reduce calculation overhead.
33
34
  *
34
35
  * @param from target point to start from
35
- * @param radius virtual distance between target point and the sun. Defaults to 1000 (1km)
36
+ * @param radius virtual distance between target point and the sun. Defaults to 10000 (10km)
36
37
  */
37
- getVirtualSunPosition(from: Cartesian3, radius?: number): Cartesian3;
38
+ virtualSun(from: Cartesian3, radius?: number): {
39
+ position: Cartesian3;
40
+ direction: Cartesian3;
41
+ };
38
42
  /**
39
43
  * Analyze the sunlight acceptance from a given point at a given time.
40
44
  * @param from target point to analyze
41
45
  * @param at time to analyze
42
46
  * @param options {@link Sunlight.AnalyzeOptions}
43
47
  */
44
- analyze(from: Cartesian3, at: JulianDate, options?: Sunlight.AnalyzeOptions): Sunlight.AnalysisResult;
48
+ analyze(from: Cartesian3, at: JulianDate, options?: Sunlight.AnalyzeOptions): Promise<Sunlight.AnalysisResult>;
45
49
  /**
46
50
  * Analyze the sunlight acceptance from a given point at a given time range.
47
51
  * @param from target point to analyze
48
52
  * @param range time range to analyze
49
53
  * @param options {@link Sunlight.AnalyzeOptions}
50
54
  */
51
- analyze(from: Cartesian3, range: Sunlight.TimeRange, options?: Sunlight.AnalyzeOptions): Sunlight.AnalysisResult[];
55
+ analyze(from: Cartesian3, range: Sunlight.TimeRange, options?: Sunlight.AnalyzeOptions): Promise<Sunlight.AnalysisResult[]>;
52
56
  /**
53
57
  * Remove all instances created for debug purpose
54
58
  */
55
59
  clear(): void;
56
60
  /**
57
- * Create a point entity for collision detection
61
+ * Create an ellipsoid entity for ray collision detection to complement cesium's native click event accuracy
58
62
  * @param at where to create the entity
59
63
  * @param show whether to show point entity
60
64
  * @param errorBoundary size of the point entity for error tolerance
61
65
  */
62
- private _createPointEntity;
66
+ setTargetPoint(at: Cartesian3, show?: boolean, errorBoundary?: number, color?: Color): Entity;
63
67
  private _analyzeSingleTime;
64
68
  private _analyzeTimeRange;
69
+ /**
70
+ * @returns A promise tht resolves to an object containing the object and position of the first intersection.
71
+ * @see https://github.com/CesiumGS/cesium/blob/1.136/packages/engine/Source/Scene/Scene.js#L4868
72
+ */
73
+ private _pick;
65
74
  private _getExcludedObjects;
66
75
  }
67
76
  declare namespace Sunlight {
77
+ const DETECTION_ELLIPSOID_ID = "sunlight-detection-ellipsoid";
68
78
  /** for time-range analysis */
69
79
  interface TimeRange {
70
80
  /** When to start analysis */
@@ -88,7 +98,7 @@ declare namespace Sunlight {
88
98
  /** ISO time string */
89
99
  timestamp: string;
90
100
  /** Whether the sunlight has reached */
91
- result: boolean;
101
+ result: boolean | any;
92
102
  }
93
103
  }
94
104
 
@@ -1,4 +1,4 @@
1
- import { Viewer, Cartesian3, JulianDate } from 'cesium';
1
+ import { Viewer, Cartesian3, JulianDate, Color, Entity } from 'cesium';
2
2
 
3
3
  /**
4
4
  * @since Cesium 1.132.0
@@ -15,12 +15,13 @@ import { Viewer, Cartesian3, JulianDate } from 'cesium';
15
15
  * ```
16
16
  */
17
17
  declare class Sunlight {
18
- private _sunPositionWC;
19
- private _sunDirectionWC;
18
+ private _uniformState;
20
19
  private _viewer;
21
20
  private _analyzing;
22
21
  private _pointEntityId?;
23
- private _debugEntityIds;
22
+ private _objectsToExclude;
23
+ private _polylines;
24
+ private _points;
24
25
  constructor(viewer: Viewer);
25
26
  /** The sun position in 3D world coordinates at the current scene time. */
26
27
  get sunPositionWC(): Cartesian3;
@@ -29,42 +30,51 @@ declare class Sunlight {
29
30
  /** Whether sunlight analysis is currently in progress. */
30
31
  get isAnalyzing(): boolean;
31
32
  /**
32
- * Gets a virtual position of the sun to reduce calculation overhead.
33
+ * Gets virtual position and direction of the sun to reduce calculation overhead.
33
34
  *
34
35
  * @param from target point to start from
35
- * @param radius virtual distance between target point and the sun. Defaults to 1000 (1km)
36
+ * @param radius virtual distance between target point and the sun. Defaults to 10000 (10km)
36
37
  */
37
- getVirtualSunPosition(from: Cartesian3, radius?: number): Cartesian3;
38
+ virtualSun(from: Cartesian3, radius?: number): {
39
+ position: Cartesian3;
40
+ direction: Cartesian3;
41
+ };
38
42
  /**
39
43
  * Analyze the sunlight acceptance from a given point at a given time.
40
44
  * @param from target point to analyze
41
45
  * @param at time to analyze
42
46
  * @param options {@link Sunlight.AnalyzeOptions}
43
47
  */
44
- analyze(from: Cartesian3, at: JulianDate, options?: Sunlight.AnalyzeOptions): Sunlight.AnalysisResult;
48
+ analyze(from: Cartesian3, at: JulianDate, options?: Sunlight.AnalyzeOptions): Promise<Sunlight.AnalysisResult>;
45
49
  /**
46
50
  * Analyze the sunlight acceptance from a given point at a given time range.
47
51
  * @param from target point to analyze
48
52
  * @param range time range to analyze
49
53
  * @param options {@link Sunlight.AnalyzeOptions}
50
54
  */
51
- analyze(from: Cartesian3, range: Sunlight.TimeRange, options?: Sunlight.AnalyzeOptions): Sunlight.AnalysisResult[];
55
+ analyze(from: Cartesian3, range: Sunlight.TimeRange, options?: Sunlight.AnalyzeOptions): Promise<Sunlight.AnalysisResult[]>;
52
56
  /**
53
57
  * Remove all instances created for debug purpose
54
58
  */
55
59
  clear(): void;
56
60
  /**
57
- * Create a point entity for collision detection
61
+ * Create an ellipsoid entity for ray collision detection to complement cesium's native click event accuracy
58
62
  * @param at where to create the entity
59
63
  * @param show whether to show point entity
60
64
  * @param errorBoundary size of the point entity for error tolerance
61
65
  */
62
- private _createPointEntity;
66
+ setTargetPoint(at: Cartesian3, show?: boolean, errorBoundary?: number, color?: Color): Entity;
63
67
  private _analyzeSingleTime;
64
68
  private _analyzeTimeRange;
69
+ /**
70
+ * @returns A promise tht resolves to an object containing the object and position of the first intersection.
71
+ * @see https://github.com/CesiumGS/cesium/blob/1.136/packages/engine/Source/Scene/Scene.js#L4868
72
+ */
73
+ private _pick;
65
74
  private _getExcludedObjects;
66
75
  }
67
76
  declare namespace Sunlight {
77
+ const DETECTION_ELLIPSOID_ID = "sunlight-detection-ellipsoid";
68
78
  /** for time-range analysis */
69
79
  interface TimeRange {
70
80
  /** When to start analysis */
@@ -88,7 +98,7 @@ declare namespace Sunlight {
88
98
  /** ISO time string */
89
99
  timestamp: string;
90
100
  /** Whether the sunlight has reached */
91
- result: boolean;
101
+ result: boolean | any;
92
102
  }
93
103
  }
94
104
 
@@ -1 +1 @@
1
- import{Color as d,Entity as h,Ray as g}from"cesium";import{Cartesian3 as s,JulianDate as c}from"cesium";var y=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.normalize(s.subtract(this._sunPositionWC,t,new s),new s);return s.multiplyByScalar(e,i,e),s.add(t,e,new s)}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 c?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 h({point:{show:i,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 g(this.getVirtualSunPosition(t),this._sunDirectionWC);if(e?.debugShowRays){let r=new h({polyline:{positions:[this.getVirtualSunPosition(t),t],width:10,material:d.YELLOW.withAlpha(.5)}});this._debugEntityIds.push(r.id),this._viewer.entities.add(r)}let o=this._viewer.scene.picking,{object:l,position:u}=o.pickFromRay(o,this._viewer.scene,n,this._getExcludedObjects(e?.objectsToExclude)),a=l instanceof h&&l.id===this._pointEntityId;if(e?.debugShowPoints&&u){let r=new h({point:{show:!0,pixelSize:5},position:u});this._debugEntityIds.push(r.id),this._viewer.entities.add(r)}return{timestamp:i.toString(),result:a}}_analyzeTimeRange(t,i,e){let n=[],{start:o,end:l,step:u}=i,a=o.clone();for(;c.compare(a,l)<=0;)n.push(this._analyzeSingleTime(t,a,e)),c.addSeconds(a,u,a);return n}_getExcludedObjects(t){return[...this._debugEntityIds.map(i=>this._viewer.entities.getById(i)).filter(Boolean),...t??[]]}},p=y;export{p as Sunlight};
1
+ import{Cartesian3 as n,Color as h,Entity as p,EntityCollection as d,JulianDate as u,Material as _,PolylineCollection as g,Ray as m}from"cesium";var o=class c{_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 g),this._points=new d,e.entities.add(this._points)}get sunPositionWC(){return this._uniformState._sunPositionWC}get sunDirectionWC(){return this._uniformState._sunDirectionWC}get isAnalyzing(){return this._analyzing}virtualSun(e,t=1e4){let i=n.normalize(n.subtract(this.sunPositionWC,e,new n),new n);return n.multiplyByScalar(i,t,i),{position:n.add(e,i,new n),direction:n.normalize(n.subtract(e,this.sunPositionWC,new n),new n)}}async analyze(e,t,i){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 t instanceof u?await this._analyzeSingleTime(e,t,i):await this._analyzeTimeRange(e,t,i)}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,t,i,s=h.LIMEGREEN.withAlpha(.8)){this._pointEntityId&&this._viewer.entities.removeById(this._pointEntityId);let a=i??3,r=this._viewer.entities.add(new p({ellipsoid:{show:t,radii:new n(a,a,a),material:t?s:void 0,fill:!0},position:e,id:c.DETECTION_ELLIPSOID_ID}));return this._pointEntityId=r.id,this._viewer.scene.render(),r}async _analyzeSingleTime(e,t,i){this._viewer.clock.currentTime=t,this._viewer.scene.render(t);let s=[e,this.virtualSun(e).position];if(i?.debugShowRays){let r=this._polylines.add({show:!0,positions:s,width:5,material:new _({fabric:{type:"Color",uniforms:{color:h.YELLOW.withAlpha(.5)}}})});this._objectsToExclude.push(r)}let a=await this._pick(e,i?.objectsToExclude);return{timestamp:t.toString(),result:a?a.object?.id?.id===this._pointEntityId:!1}}async _analyzeTimeRange(e,t,i){let s=[],{start:a,end:r,step:y}=t,l=a.clone();for(;u.compare(l,r)<=0;)s.push(await this._analyzeSingleTime(e,l,i)),u.addSeconds(l,y,l);return s}async _pick(e,t,i=.1){let{position:s,direction:a}=this.virtualSun(e),r=new m(s,a);return await this._viewer.scene.pickFromRayMostDetailed(r,this._getExcludedObjects(t),i)}_getExcludedObjects(e){return[...this._objectsToExclude,...e??[]]}};(e=>e.DETECTION_ELLIPSOID_ID="sunlight-detection-ellipsoid")(o||={});var w=o;export{w as Sunlight};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var w=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var B=(r,e)=>{for(var t in e)w(r,t,{get:e[t],enumerable:!0})},W=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of j(e))!F.call(r,n)&&n!==t&&w(r,n,{get:()=>e[n],enumerable:!(i=V(e,n))||i.enumerable});return r};var q=r=>W(w({},"__esModule",{value:!0}),r);var N={};B(N,{Collection:()=>L,Highlight:()=>I,HybridTerrainProvider:()=>T,SilhouetteHighlight:()=>v,SurfaceHighlight:()=>g,cloneViewer:()=>H,syncCamera:()=>C});module.exports=q(N);var m=require("cesium");var R;(u=>{let r=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(s,d={}){if(!e)return;let{once:f=!0,prefix:p="[DEPRECATED]",includeStack:y=!0,removeInVersion:b}=d;if(f&&r.has(s))return;let P=`${p} ${s}`;b&&(P+=` This feature will be removed in ${b}.`),typeof console<"u"&&console.warn&&(y?(console.warn(P),console.trace("Deprecation stack trace:")):console.warn(P)),f&&r.add(s)}u.warn=t;function i(s,d,f={}){let p=((...y)=>(t(d,f),s(...y)));return Object.defineProperty(p,"name",{value:s.name,configurable:!0}),p}u.deprecate=i;function n(){r.clear()}u.clear=n;function a(){return r.size}u.getWarningCount=a;function c(s){return r.has(s)}u.hasShown=c})(R||={});var A=R;var G=require("cesium");var D=require("cesium");var M=require("cesium"),_=class r{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new M.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._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,i){return this._defaultProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,i,n){if(this._ready){for(let a of this._regions)if(r.TerrainRegion.contains(a,e,t,i))return a.provider.requestTileGeometry(e,t,i,n);return this._defaultProvider.getTileDataAvailable(e,t,i)?this._defaultProvider.requestTileGeometry(e,t,i,n):this._fallbackProvider.requestTileGeometry(e,t,i,n)}}getTileDataAvailable(e,t,i){for(let n of this._regions)if(r.TerrainRegion.contains(n,e,t,i))return!0;return this._defaultProvider.getTileDataAvailable(e,t,i)}};(t=>{function r(i,n,a){return new t({regions:i.map(c=>({...c})),defaultProvider:n,fallbackProvider:a})}t.fromTileRanges=r;let e;(n=>{function i(a,c,u,s){if(a.levels&&!a.levels.includes(s))return!1;if(a.tiles){let d=a.tiles.get(s);if(!d)return!1;let[f,p]=Array.isArray(d.x)?d.x:[d.x,d.x],[y,b]=Array.isArray(d.y)?d.y:[d.y,d.y];return c>=f&&c<=p&&u>=y&&u<=b}return!1}n.contains=i})(e=t.TerrainRegion||={})})(_||={});var T=_;function E(r,e){let t=!1,i=Object.getOwnPropertyDescriptor(r,e);if(!i){let n=Object.getPrototypeOf(r);for(;n&&!i;)i=Object.getOwnPropertyDescriptor(n,e),n=Object.getPrototypeOf(n)}return i&&i.get&&!i.set&&(t=!0),t}var se=A.deprecate;var O=class r{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof m.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get tags(){return Array.from(this._tagMap.keys())}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(n=>{this.add(n,t)}):(Object.defineProperty(e,r.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,r.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,m.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,m.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,m.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let n=this.get(i);for(let a of n)if(e in a&&typeof a[e]!="function"){if(E(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((n,a)=>e(n,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)}_emit(e,t){let i=this._eventListeners.get(e);if(i){let n={type:e,...t};i.forEach(a=>a(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[r.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof m.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof m.PrimitiveCollection?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof m.DataSourceCollection?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof m.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}},L=O;var h=require("cesium");var l=require("cesium"),v=class{_color=l.Color.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=l.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=l.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}show(e,t){if((0,l.defined)(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{if(e instanceof l.Cesium3DTileFeature)this._silhouette.uniforms.color=t?.color||this._color,this._silhouette.selected.push(e);else{if(!e.model)return;this._entity=e,e.model.silhouetteSize=new l.ConstantProperty(t?.width||2),e.model.silhouetteColor=new l.ConstantProperty(t?.color||this._color)}this._currentObject=e,this._currentOptions=t?{...t}:void 0}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0}}}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&l.Color.equals(e.color||this._color,t.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new l.ConstantProperty(l.Color.TRANSPARENT),this._entity.model.silhouetteSize=new l.ConstantProperty(0),this._entity=void 0)}};var o=require("cesium"),g=class{_color=o.Color.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new o.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}show(e,t){if(!(!(0,o.defined)(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof o.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof o.GroundPrimitive)this._update(e,t);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=e,this._currentOptions=t?{...t}:void 0,this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0;return}}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&o.Color.equals(e.color||this._color,t.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof o.Entity){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let n;i.positions.length>0&&!o.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?n=[...i.positions,i.positions[0]]:n=i.positions,this._entity.polyline=new o.PolylineGraphics({positions:n,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new o.PolygonGraphics({hierarchy:i,material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||o.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let n=e.polyline.width?.getValue();this._entity.polyline=new o.PolylineGraphics({positions:i,material:t.color,width:n+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let n=[o.Cartesian3.fromRadians(i.west,i.north),o.Cartesian3.fromRadians(i.east,i.north),o.Cartesian3.fromRadians(i.east,i.south),o.Cartesian3.fromRadians(i.west,i.south),o.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new o.PolylineGraphics({positions:n,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new o.RectangleGraphics({coordinates:i,material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND}))}}else if(e instanceof o.GroundPrimitive){let i=e.geometryInstances,n=Array.isArray(i)?i[0]:i;if(!n.geometry.attributes.position)return;let a=n.geometry.attributes.position.values,c=[];for(let u=0;u<a.length;u+=3)c.push(new o.Cartesian3(a[u],a[u+1],a[u+2]));t.outline?this._entity.polyline=new o.PolylineGraphics({positions:c,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new o.PolygonGraphics({hierarchy:new o.PolygonHierarchy(c),material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND,classificationType:o.ClassificationType.BOTH})}}};var x=class r{static instances=new WeakMap;_surface;_silhouette;_color=h.Color.RED;constructor(e){this._surface=new g(e),this._silhouette=new v(e),this._surface.color=this._color,this._silhouette.color=this._color}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}static getInstance(e){let t=e.container;return r.instances.has(t)||r.instances.set(t,new r(e)),r.instances.get(t)}static releaseInstance(e){let t=e.container,i=r.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),r.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if((0,h.defined)(i))return i instanceof h.Cesium3DTileFeature?this._silhouette.show(i,t):i instanceof h.Entity&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if((0,h.defined)(e)){if(e instanceof h.Entity||e instanceof h.Cesium3DTileFeature||e instanceof h.GroundPrimitive)return e;if(e.id instanceof h.Entity)return e.id;if(e.primitive instanceof h.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}},I=x;var k=require("cesium");var S=require("cesium");function C(r,e){if((0,S.defined)(r)&&(0,S.defined)(e)){let{camera:t}=r;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}function H(r,e,t){let i={baseLayerPicker:r.baseLayerPicker!==void 0,geocoder:r.geocoder!==void 0,homeButton:r.homeButton!==void 0,sceneModePicker:r.sceneModePicker!==void 0,timeline:r.timeline!==void 0,navigationHelpButton:r.navigationHelpButton!==void 0,animation:r.animation!==void 0,fullscreenButton:r.fullscreenButton!==void 0,shouldAnimate:r.clock.shouldAnimate,terrainProvider:r.terrainProvider,requestRenderMode:r.scene.requestRenderMode,infoBox:r.infoBox!==void 0},n=new k.Viewer(e,{...i,...t});C(r,n);let a=r.imageryLayers;n.imageryLayers.removeAll();for(let s=0;s<a.length;s++){let d=a.get(s);n.imageryLayers.addImageryProvider(d.imageryProvider,s)}n.clock.startTime=r.clock.startTime.clone(),n.clock.stopTime=r.clock.stopTime.clone(),n.clock.currentTime=r.clock.currentTime.clone(),n.clock.multiplier=r.clock.multiplier,n.clock.clockStep=r.clock.clockStep,n.clock.clockRange=r.clock.clockRange,n.clock.shouldAnimate=r.clock.shouldAnimate,n.scene.globe.enableLighting=r.scene.globe.enableLighting,n.scene.globe.depthTestAgainstTerrain=r.scene.globe.depthTestAgainstTerrain,n.scene.screenSpaceCameraController.enableCollisionDetection=r.scene.screenSpaceCameraController.enableCollisionDetection;let c=r.scene.screenSpaceCameraController.tiltEventTypes;c&&(n.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(c)?[...c]:c);let u=r.scene.screenSpaceCameraController.zoomEventTypes;return u&&(n.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(u)?[...u]:u),n}
1
+ "use strict";var y=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var G=(n,e)=>{for(var t in e)y(n,t,{get:e[t],enumerable:!0})},V=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of D(e))!k.call(n,r)&&r!==t&&y(n,r,{get:()=>e[r],enumerable:!(i=j(e,r))||i.enumerable});return n};var F=n=>V(y({},"__esModule",{value:!0}),n);var B={};G(B,{Collection:()=>T,Highlight:()=>O,HybridTerrainProvider:()=>w,SilhouetteHighlight:()=>m,SurfaceHighlight:()=>p,cloneViewer:()=>x,syncCamera:()=>v});module.exports=F(B);var d=require("cesium");function _(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}function C(n,e,t){let i=e.split(".");for(let l of i)if(S(l))return{success:!1,reason:"dangerous-property",message:`Property path contains dangerous property name: "${l}"`};let r=n,s=0;for(;s<i.length-1;s++){let l=i[s];if(!r||typeof r!="object"||!Object.prototype.hasOwnProperty.call(r,l))return{success:!1,reason:"invalid-path",message:`Property path "${e}" does not exist or contains inherited properties`};if(r=r[l],!r||typeof r!="object"||r===Object.prototype)return{success:!1,reason:"invalid-path",message:`Cannot traverse path "${e}" - reached non-object or prototype`}}if(s!==i.length-1)return{success:!1,reason:"invalid-path",message:`Failed to traverse property path "${e}"`};let a=i[i.length-1];if(S(a))return{success:!1,reason:"dangerous-property",message:`Cannot set dangerous property "${a}"`};if(!r||typeof r!="object"||r===Object.prototype)return{success:!1,reason:"invalid-path",message:"Cannot set property on invalid target"};if(a in r){if(typeof r[a]=="function")return{success:!1,reason:"function-property",message:`Cannot set function property "${a}"`};if(_(r,a))return{success:!1,reason:"read-only",message:`Cannot set read-only property "${e}"`}}return r[a]=t,{success:!0}}var N=["__proto__","constructor","prototype"];function S(n){return N.includes(n)}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]()}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof d.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get tags(){return Array.from(this._tagMap.keys())}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,d.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,d.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,d.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let s of r){let a=C(s,e,t);if(!a.success&&a.reason==="read-only")throw Error(`Cannot set read-only property '${e}' on ${s.constructor.name}`)}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,s)=>e(r,s))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(s=>s(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof d.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof d.PrimitiveCollection?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof d.DataSourceCollection?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof d.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}},T=b;var h=require("cesium");var c=require("cesium"),m=class{_color=c.Color.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=c.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=c.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}show(e,t){if((0,c.defined)(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{if(e instanceof c.Cesium3DTileFeature)this._silhouette.uniforms.color=t?.color||this._color,this._silhouette.selected.push(e);else{if(!e.model)return;this._entity=e,e.model.silhouetteSize=new c.ConstantProperty(t?.width||2),e.model.silhouetteColor=new c.ConstantProperty(t?.color||this._color)}this._currentObject=e,this._currentOptions=t?{...t}:void 0}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0}}}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&c.Color.equals(e.color||this._color,t.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new c.ConstantProperty(c.Color.TRANSPARENT),this._entity.model.silhouetteSize=new c.ConstantProperty(0),this._entity=void 0)}};var o=require("cesium"),p=class{_color=o.Color.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new o.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}show(e,t){if(!(!(0,o.defined)(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof o.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof o.GroundPrimitive)this._update(e,t);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=e,this._currentOptions=t?{...t}:void 0,this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0;return}}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&o.Color.equals(e.color||this._color,t.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof o.Entity){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let r;i.positions.length>0&&!o.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new o.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new o.PolygonGraphics({hierarchy:i,material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||o.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let r=e.polyline.width?.getValue();this._entity.polyline=new o.PolylineGraphics({positions:i,material:t.color,width:r+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let r=[o.Cartesian3.fromRadians(i.west,i.north),o.Cartesian3.fromRadians(i.east,i.north),o.Cartesian3.fromRadians(i.east,i.south),o.Cartesian3.fromRadians(i.west,i.south),o.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new o.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new o.RectangleGraphics({coordinates:i,material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND}))}}else if(e instanceof o.GroundPrimitive){let i=e.geometryInstances,r=Array.isArray(i)?i[0]:i;if(!r.geometry.attributes.position)return;let s=r.geometry.attributes.position.values,a=[];for(let l=0;l<s.length;l+=3)a.push(new o.Cartesian3(s[l],s[l+1],s[l+2]));t.outline?this._entity.polyline=new o.PolylineGraphics({positions:a,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new o.PolygonGraphics({hierarchy:new o.PolygonHierarchy(a),material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND,classificationType:o.ClassificationType.BOTH})}}};var P=class n{static instances=new WeakMap;_surface;_silhouette;_color=h.Color.RED;constructor(e){this._surface=new p(e),this._silhouette=new m(e),this._surface.color=this._color,this._silhouette.color=this._color}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,i=n.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),n.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if((0,h.defined)(i))return i instanceof h.Cesium3DTileFeature?this._silhouette.show(i,t):i instanceof h.Entity&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if((0,h.defined)(e)){if(e instanceof h.Entity||e instanceof h.Cesium3DTileFeature||e instanceof h.GroundPrimitive)return e;if(e.id instanceof h.Entity)return e.id;if(e.primitive instanceof h.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}},O=P;var R=require("cesium"),g=class n{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new R.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,i){return this._defaultProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,i,r){if(this._ready){for(let s of this._regions)if(n.TerrainRegion.contains(s,e,t,i))return s.provider.requestTileGeometry(e,t,i,r);return this._defaultProvider.getTileDataAvailable(e,t,i)?this._defaultProvider.requestTileGeometry(e,t,i,r):this._fallbackProvider.requestTileGeometry(e,t,i,r)}}getTileDataAvailable(e,t,i){for(let r of this._regions)if(n.TerrainRegion.contains(r,e,t,i))return!0;return this._defaultProvider.getTileDataAvailable(e,t,i)}};(t=>{function n(i,r,s){return new t({regions:i.map(a=>({...a})),defaultProvider:r,fallbackProvider:s})}t.fromTileRanges=n;let e;(r=>{function i(s,a,l,f){if(s.levels&&!s.levels.includes(f))return!1;if(s.tiles){let u=s.tiles.get(f);if(!u)return!1;let[I,L]=Array.isArray(u.x)?u.x:[u.x,u.x],[A,M]=Array.isArray(u.y)?u.y:[u.y,u.y];return a>=I&&a<=L&&l>=A&&l<=M}return!1}r.contains=i})(e=t.TerrainRegion||={})})(g||={});var w=g;var H=require("cesium");var E=require("cesium");function v(n,e){if((0,E.defined)(n)&&(0,E.defined)(e)){let{camera:t}=n;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}function x(n,e,t){let i={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},r=new H.Viewer(e,{...i,...t});v(n,r);let s=n.imageryLayers;r.imageryLayers.removeAll();for(let f=0;f<s.length;f++){let u=s.get(f);r.imageryLayers.addImageryProvider(u.imageryProvider,f)}r.clock.startTime=n.clock.startTime.clone(),r.clock.stopTime=n.clock.stopTime.clone(),r.clock.currentTime=n.clock.currentTime.clone(),r.clock.multiplier=n.clock.multiplier,r.clock.clockStep=n.clock.clockStep,r.clock.clockRange=n.clock.clockRange,r.clock.shouldAnimate=n.clock.shouldAnimate,r.scene.globe.enableLighting=n.scene.globe.enableLighting,r.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,r.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let a=n.scene.screenSpaceCameraController.tiltEventTypes;a&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(a)?[...a]:a);let l=n.scene.screenSpaceCameraController.zoomEventTypes;return l&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(l)?[...l]:l),r}
package/dist/index.d.cts CHANGED
@@ -4,4 +4,3 @@ export { TerrainOptions, TerrainRegion, TerrainTiles } from './terrain/index.cjs
4
4
  export { cloneViewer, syncCamera } from './viewer/index.cjs';
5
5
  export { H as HybridTerrainProvider } from './hybrid-terrain-provider-Th8n2hZ1.cjs';
6
6
  import 'cesium';
7
- import './type-check-B-zGL1Ne.cjs';
package/dist/index.d.ts CHANGED
@@ -4,4 +4,3 @@ export { TerrainOptions, TerrainRegion, TerrainTiles } from './terrain/index.js'
4
4
  export { cloneViewer, syncCamera } from './viewer/index.js';
5
5
  export { H as HybridTerrainProvider } from './hybrid-terrain-provider-Th8n2hZ1.js';
6
6
  import 'cesium';
7
- import './type-check-B-zGL1Ne.js';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as e}from"./chunk-VWM3HSEI.js";import"./chunk-ZXZ7TVB3.js";import{a as i,b as o,c as t}from"./chunk-PSCNWZUR.js";import"./chunk-6I6OKECI.js";import{a as r}from"./chunk-XHMLNB5Q.js";import{a as p,b as m}from"./chunk-Z2COOTT4.js";export{e as Collection,t as Highlight,r as HybridTerrainProvider,i as SilhouetteHighlight,o as SurfaceHighlight,m as cloneViewer,p as syncCamera};
1
+ import{a as r}from"./chunk-WTOAUTEK.js";import{a as e,b as i,c as o}from"./chunk-PSCNWZUR.js";import"./chunk-6I6OKECI.js";import{a as t}from"./chunk-XHMLNB5Q.js";import{a as p,b as m}from"./chunk-Z2COOTT4.js";export{r as Collection,o as Highlight,t as HybridTerrainProvider,e as SilhouetteHighlight,i as SurfaceHighlight,m as cloneViewer,p as syncCamera};
package/package.json CHANGED
@@ -1,26 +1,31 @@
1
1
  {
2
2
  "name": "@juun-roh/cesium-utils",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Solve common Cesium.js challenges: combine multiple terrain sources, tag and filter entity collections, and add visual highlights.",
5
5
  "keywords": [
6
6
  "cesium",
7
7
  "cesiumjs",
8
- "cesium-terrain-provider",
9
- "cesium-entity-collection",
10
- "cesium-highlight",
8
+ "typescript",
11
9
  "cesium-utils",
12
10
  "hybrid-terrain-provider",
13
11
  "multiple-terrain-sources",
12
+ "terrain-switching",
13
+ "cesium-terrain-provider",
14
14
  "entity-tagging",
15
+ "entity-grouping",
15
16
  "entity-filtering",
16
- "cesium-collection-utilities",
17
- "terrain-provider-hybrid",
18
- "cesium-entity-tagging",
19
- "cesium-terrain-hybrid",
17
+ "batch-operations",
18
+ "cesium-entity-collection",
19
+ "primitive-collection",
20
+ "cesium-layer-management",
21
+ "cesium-highlight",
22
+ "cesium-silhouette",
23
+ "3d-tiles-highlight",
24
+ "entity-selection",
20
25
  "3d-gis",
21
26
  "geospatial",
22
27
  "webgl",
23
- "mapping",
28
+ "virtual-globe",
24
29
  "3d-visualization"
25
30
  ],
26
31
  "repository": {
@@ -99,10 +104,10 @@
99
104
  "@commitlint/format": "^20.2.0",
100
105
  "@commitlint/types": "^20.2.0",
101
106
  "@eslint/js": "^9.39.2",
102
- "@types/node": "^24.10.4",
103
- "@typescript-eslint/eslint-plugin": "^8.49.0",
104
- "@typescript-eslint/parser": "^8.49.0",
105
- "@vitest/coverage-v8": "^4.0.15",
107
+ "@types/node": "^25.0.3",
108
+ "@typescript-eslint/eslint-plugin": "^8.50.1",
109
+ "@typescript-eslint/parser": "^8.50.1",
110
+ "@vitest/coverage-v8": "^4.0.16",
106
111
  "cesium": "^1.136.0",
107
112
  "eslint": "^9.39.2",
108
113
  "eslint-plugin-jsdoc": "^61.5.0",
@@ -110,17 +115,18 @@
110
115
  "eslint-plugin-simple-import-sort": "^12.1.1",
111
116
  "eslint-plugin-unused-imports": "^4.3.0",
112
117
  "husky": "^9.1.7",
113
- "jsdom": "^27.3.0",
118
+ "jsdom": "^27.4.0",
114
119
  "rimraf": "^6.1.2",
115
120
  "tsup": "^8.5.1",
116
121
  "typedoc": "^0.28.15",
117
122
  "typescript": "^5.9.3",
118
- "vite": "^7.2.7",
119
- "vitest": "^4.0.15"
123
+ "vite": "^7.3.0",
124
+ "vitest": "^4.0.16"
120
125
  },
121
126
  "scripts": {
122
127
  "build": "tsup",
123
128
  "build:dev": "tsup --watch",
129
+ "check-types": "tsc -p ./tsconfig.json --noEmit",
124
130
  "clean": "rimraf dist",
125
131
  "lint": "eslint .",
126
132
  "ci:publish": "pnpm build && pnpm publish --no-git-checks",
@@ -1 +0,0 @@
1
- import{c as l}from"./chunk-ZXZ7TVB3.js";import{DataSourceCollection as d,defined as o,EntityCollection as h,ImageryLayerCollection as v,PrimitiveCollection as c}from"cesium";var r=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 h)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(a=>{this.add(a,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 a of i)this._removeFromTagMap(a),Object.defineProperty(a,s.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(a,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)o(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)o(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)o(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let a=this.get(i);for(let n of a)if(e in n&&typeof n[e]!="function"){if(l(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((a,n)=>e(a,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)}_emit(e,t){let i=this._eventListeners.get(e);if(i){let a={type:e,...t};i.forEach(n=>n(a))}}_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 h?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof c?(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?(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 v&&(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)))}},m=r;export{m as a};
@@ -1 +0,0 @@
1
- import{a as b}from"./chunk-XHMLNB5Q.js";var _;(n=>{let o=new Set,r=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function e(a,v={}){if(!r)return;let{once:h=!0,prefix:y="[DEPRECATED]",includeStack:m=!0,removeInVersion:g}=v;if(h&&o.has(a))return;let u=`${y} ${a}`;g&&(u+=` This feature will be removed in ${g}.`),typeof console<"u"&&console.warn&&(m?(console.warn(u),console.trace("Deprecation stack trace:")):console.warn(u)),h&&o.add(a)}n.warn=e;function i(a,v,h={}){let y=((...m)=>(e(v,h),a(...m)));return Object.defineProperty(y,"name",{value:a.name,configurable:!0}),y}n.deprecate=i;function t(){o.clear()}n.clear=t;function d(){return o.size}n.getWarningCount=d;function c(a){return o.has(a)}n.hasShown=c})(_||={});var C=_;import{Color as l,TileCoordinatesImageryProvider as P}from"cesium";import{Color as p,GridImageryProvider as w}from"cesium";var s=class extends w{_terrainProvider;_colors;constructor(r){let{terrainProvider:e,colors:i,...t}=r;super(t),this._terrainProvider=e,this._colors=i}requestImage(r,e,i){for(let t of this._terrainProvider.regions)if(this._isInRegionOrUpsampled(t,r,e,i))return this._createCanvasElement(this._colors.get("custom")||p.RED);return this._terrainProvider.defaultProvider.getTileDataAvailable(r,e,i)?this._createCanvasElement(this._colors.get("default")||p.BLUE):this._createCanvasElement(this._colors.get("fallback")||p.GRAY)}_isInRegionOrUpsampled(r,e,i,t){let d=e,c=i,n=t;for(;n>=0;){if(b.TerrainRegion.contains(r,d,c,n))return!0;if(n===0)break;n--,d=Math.floor(d/2),c=Math.floor(c/2)}return!1}_createCanvasElement(r){let e=document.createElement("canvas");e.width=256,e.height=256;let i=e.getContext("2d"),t=r.withAlpha(.3).toCssColorString();if(!i)throw new Error("canvas context undefined");return i.fillStyle=t,i.fillRect(0,0,256,256),Promise.resolve(e)}};var f=class{_viewer;_terrainProvider;_visible=!1;_tileCoordinatesLayer;_hybridImageryLayer;_colors=new Map([["custom",l.RED],["default",l.BLUE],["fallback",l.GRAY],["grid",l.YELLOW]]);constructor(r,e){this._viewer=r,this._terrainProvider=e.terrainProvider,e.colors&&Object.entries(e.colors).forEach(([i,t])=>{this._colors.set(i,t)}),e.tile!==void 0&&e.tile&&this.show()}setTerrainProvider(r){this._terrainProvider=r,this.update()}update(){let r=this._visible,e=!!this._tileCoordinatesLayer,i=this._hybridImageryLayer?.alpha??.5;this.clear(),r&&this.show({showTileCoordinates:e,alpha:i})}clear(){this.hide()}show(r){if(!this._terrainProvider)return;let e=r?.showTileCoordinates??!0,i=r?.alpha??.5;e&&this._ensureTileCoordinatesLayer(),this.showImageryOverlay(i),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new P({tilingScheme:this._terrainProvider.tilingScheme,color:l.YELLOW})))}hide(){this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this.hideImageryOverlay(),this._visible=!1}setColors(r){Object.entries(r).forEach(([e,i])=>{this._colors.set(e,i)}),this.update()}showImageryOverlay(r=.5){this._hybridImageryLayer&&this._viewer.imageryLayers.remove(this._hybridImageryLayer);let e=new s({terrainProvider:this._terrainProvider,colors:this._colors,tilingScheme:this._terrainProvider.tilingScheme});this._hybridImageryLayer=this._viewer.imageryLayers.addImageryProvider(e),this._hybridImageryLayer.alpha=r,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(r){this._hybridImageryLayer&&(this._hybridImageryLayer.alpha=r)}flyTo(r,e){this._viewer.camera.flyTo({destination:r,...e,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 L(o,r){let e=!1,i=Object.getOwnPropertyDescriptor(o,r);if(!i){let t=Object.getPrototypeOf(o);for(;t&&!i;)i=Object.getOwnPropertyDescriptor(t,r),t=Object.getPrototypeOf(t)}return i&&i.get&&!i.set&&(e=!0),e}var G=C.deprecate;export{C as a,f as b,L as c,G as d};
@@ -1,16 +0,0 @@
1
- /**
2
- * Runtime type validator to identify the non-function property.
3
- */
4
- type NonFunction<T> = {
5
- [K in keyof T]: T[K] extends Function ? never : K;
6
- }[keyof T];
7
- /**
8
- * Examine the property descriptors at runtime
9
- * to detect properties that only have getters.
10
- * (read-only accessor properties)
11
- * @param o The object to examine.
12
- * @param k The key value of the property.
13
- */
14
- declare function isGetterOnly(o: object, k: string | number | symbol): boolean;
15
-
16
- export { type NonFunction as N, isGetterOnly as i };
@@ -1,16 +0,0 @@
1
- /**
2
- * Runtime type validator to identify the non-function property.
3
- */
4
- type NonFunction<T> = {
5
- [K in keyof T]: T[K] extends Function ? never : K;
6
- }[keyof T];
7
- /**
8
- * Examine the property descriptors at runtime
9
- * to detect properties that only have getters.
10
- * (read-only accessor properties)
11
- * @param o The object to examine.
12
- * @param k The key value of the property.
13
- */
14
- declare function isGetterOnly(o: object, k: string | number | symbol): boolean;
15
-
16
- export { type NonFunction as N, isGetterOnly as i };