@juun-roh/cesium-utils 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -100
- package/dist/chunk-WTOAUTEK.js +1 -0
- package/dist/collection/index.cjs +1 -1
- package/dist/collection/index.d.cts +35 -1
- package/dist/collection/index.d.ts +35 -1
- package/dist/collection/index.js +1 -1
- package/dist/dev/index.cjs +1 -1
- package/dist/dev/index.d.cts +1 -126
- package/dist/dev/index.d.ts +1 -126
- package/dist/dev/index.js +1 -1
- package/dist/experimental/index.cjs +1 -1
- package/dist/experimental/index.d.cts +22 -12
- package/dist/experimental/index.d.ts +22 -12
- package/dist/experimental/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/terrain/dev/index.cjs +1 -0
- package/dist/terrain/dev/index.d.cts +125 -0
- package/dist/terrain/dev/index.d.ts +125 -0
- package/dist/terrain/dev/index.js +1 -0
- package/package.json +41 -31
- package/dist/chunk-L62HNMU7.js +0 -1
- package/dist/chunk-R5KTUXEL.js +0 -1
- package/dist/type-check-C17vkHMg.d.cts +0 -46
- package/dist/type-check-C17vkHMg.d.ts +0 -46
package/README.md
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
[](https://github.com/juunie-roh/cesium-utils)
|
|
4
|
-
[](https://www.npmjs.com/package/@juun-roh/cesium-utils)
|
|
5
|
-
[](https://opensource.org/licenses/MIT)
|
|
6
|
-
[](https://juunie-roh.github.io/cesium-utils/)
|
|
1
|
+
# cesium-utils
|
|
7
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@juun-roh/cesium-utils)
|
|
8
4
|
[](https://github.com/juunie-roh/cesium-utils/actions)
|
|
9
5
|
[](https://github.com/juunie-roh/cesium-utils/releases)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
10
7
|
|
|
11
|
-
TypeScript
|
|
8
|
+
TypeScript utilities for [CesiumJS](https://cesium.com/cesiumjs/).
|
|
12
9
|
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
|
75
|
-
|
|
76
|
-
|
|
|
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
|
-
|
|
31
|
+
Tree-shakable imports available:
|
|
84
32
|
|
|
85
33
|
```typescript
|
|
86
|
-
//
|
|
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 {
|
|
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
|
-
|
|
120
|
-
|
|
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
|
|
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
|
-
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a path to any nested property in an object, using dot notation.
|
|
5
|
+
*
|
|
6
|
+
* The `(keyof T & string)` portion provides top-level key hints in autocomplete,
|
|
7
|
+
* while `(string & {})` allows any string input to pass through.
|
|
8
|
+
*
|
|
9
|
+
* Actual path validation is delegated to {@link NestedValueOf}, which returns `never`
|
|
10
|
+
* for invalid paths — causing a type error on the corresponding value parameter.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* function f<Path extends NestedKeyOf<Obj>>(
|
|
15
|
+
* key: Path,
|
|
16
|
+
* value: NestedValueOf<Obj, Path> // ← validation happens here
|
|
17
|
+
* ) {}
|
|
18
|
+
*
|
|
19
|
+
* f("a.b.c", 123); // ✅ valid path, correct value type
|
|
20
|
+
* f("invalid.path", 1); // ❌ NestedValueOf returns never
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
type NestedKeyOf<T extends object> = (keyof T & string) | (string & {});
|
|
24
|
+
/**
|
|
25
|
+
* Extracts the type of a nested property from a property path string.
|
|
26
|
+
*
|
|
27
|
+
* @template ObjectType - The object type to extract the value type from
|
|
28
|
+
* @template Path - The property path string (e.g., "a.b.c")
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* type Value = NestedValueOf<{ a: { b: number } }, "a.b">
|
|
32
|
+
* // Result: number
|
|
33
|
+
*/
|
|
34
|
+
type NestedValueOf<ObjectType, Path extends string> = Path extends `${infer Cur}.${infer Rest}` ? Cur extends keyof ObjectType ? NonNullable<ObjectType[Cur]> extends Function | ((...args: any[]) => any) ? never : NestedValueOf<NonNullable<ObjectType[Cur]>, Rest> : never : Path extends keyof ObjectType ? NonNullable<ObjectType[Path]> extends Function | ((...args: any[]) => any) ? never : ObjectType[Path] : never;
|
|
3
35
|
|
|
4
36
|
/**
|
|
5
37
|
* @class
|
|
@@ -10,6 +42,8 @@ import { a as NestedKeyOf, b as NestedValueOf } from '../type-check-C17vkHMg.cjs
|
|
|
10
42
|
* @template C - The type of Cesium collection (e.g., EntityCollection, PrimitiveCollection)
|
|
11
43
|
* @template I - The type of items in the collection (e.g., Entity, Primitive)
|
|
12
44
|
*
|
|
45
|
+
* @see [Collection Demo](https://juun.vercel.app/cesium-utils/collection)
|
|
46
|
+
*
|
|
13
47
|
* @example
|
|
14
48
|
* // Example 1: Managing Complex Scene with Multiple Object Types
|
|
15
49
|
* class SceneOrganizer {
|
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
import { DataSourceCollection, EntityCollection, ImageryLayerCollection, PrimitiveCollection, Billboard, Cesium3DTileset, GroundPrimitive, Label, PointPrimitive, Polyline, Primitive, DataSource, Entity, ImageryLayer } from 'cesium';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a path to any nested property in an object, using dot notation.
|
|
5
|
+
*
|
|
6
|
+
* The `(keyof T & string)` portion provides top-level key hints in autocomplete,
|
|
7
|
+
* while `(string & {})` allows any string input to pass through.
|
|
8
|
+
*
|
|
9
|
+
* Actual path validation is delegated to {@link NestedValueOf}, which returns `never`
|
|
10
|
+
* for invalid paths — causing a type error on the corresponding value parameter.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* function f<Path extends NestedKeyOf<Obj>>(
|
|
15
|
+
* key: Path,
|
|
16
|
+
* value: NestedValueOf<Obj, Path> // ← validation happens here
|
|
17
|
+
* ) {}
|
|
18
|
+
*
|
|
19
|
+
* f("a.b.c", 123); // ✅ valid path, correct value type
|
|
20
|
+
* f("invalid.path", 1); // ❌ NestedValueOf returns never
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
type NestedKeyOf<T extends object> = (keyof T & string) | (string & {});
|
|
24
|
+
/**
|
|
25
|
+
* Extracts the type of a nested property from a property path string.
|
|
26
|
+
*
|
|
27
|
+
* @template ObjectType - The object type to extract the value type from
|
|
28
|
+
* @template Path - The property path string (e.g., "a.b.c")
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* type Value = NestedValueOf<{ a: { b: number } }, "a.b">
|
|
32
|
+
* // Result: number
|
|
33
|
+
*/
|
|
34
|
+
type NestedValueOf<ObjectType, Path extends string> = Path extends `${infer Cur}.${infer Rest}` ? Cur extends keyof ObjectType ? NonNullable<ObjectType[Cur]> extends Function | ((...args: any[]) => any) ? never : NestedValueOf<NonNullable<ObjectType[Cur]>, Rest> : never : Path extends keyof ObjectType ? NonNullable<ObjectType[Path]> extends Function | ((...args: any[]) => any) ? never : ObjectType[Path] : never;
|
|
3
35
|
|
|
4
36
|
/**
|
|
5
37
|
* @class
|
|
@@ -10,6 +42,8 @@ import { a as NestedKeyOf, b as NestedValueOf } from '../type-check-C17vkHMg.js'
|
|
|
10
42
|
* @template C - The type of Cesium collection (e.g., EntityCollection, PrimitiveCollection)
|
|
11
43
|
* @template I - The type of items in the collection (e.g., Entity, Primitive)
|
|
12
44
|
*
|
|
45
|
+
* @see [Collection Demo](https://juun.vercel.app/cesium-utils/collection)
|
|
46
|
+
*
|
|
13
47
|
* @example
|
|
14
48
|
* // Example 1: Managing Complex Scene with Multiple Object Types
|
|
15
49
|
* class SceneOrganizer {
|
package/dist/collection/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-WTOAUTEK.js";export{a as Collection};
|
package/dist/dev/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var b=(e,n)=>{for(var t in n)f(e,t,{get:n[t],enumerable:!0})},m=(e,n,t,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of w(n))!T.call(e,o)&&o!==t&&f(e,o,{get:()=>n[o],enumerable:!(c=g(n,o))||c.enumerable});return e};var E=e=>m(f({},"__esModule",{value:!0}),e);var v={};b(v,{Deprecate:()=>l,deprecate:()=>S});module.exports=E(v);var x;(D=>{let e=new Set,n=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(r,s={}){if(!n)return;let{once:i=!0,prefix:a="[DEPRECATED]",includeStack:p=!0,removeInVersion:d}=s;if(i&&e.has(r))return;let u=`${a} ${r}`;d&&(u+=` This feature will be removed in ${d}.`),typeof console<"u"&&console.warn&&(p?(console.warn(u),console.trace("Deprecation stack trace:")):console.warn(u)),i&&e.add(r)}D.warn=t;function c(r,s,i={}){let a=((...p)=>(t(s,i),r(...p)));return Object.defineProperty(a,"name",{value:r.name,configurable:!0}),a}D.deprecate=c;function o(){e.clear()}D.clear=o;function I(){return e.size}D.getWarningCount=I;function h(r){return e.has(r)}D.hasShown=h})(x||={});var l=x;var S=l.deprecate;
|
package/dist/dev/index.d.cts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { Viewer, Color, Rectangle } from 'cesium';
|
|
2
|
-
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-Th8n2hZ1.cjs';
|
|
3
|
-
export { a as NestedKeyOf, b as NestedValueOf, N as NonFunction, i as isGetterOnly } from '../type-check-C17vkHMg.cjs';
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
* Utility for managing deprecation warnings in the cesium-utils library.
|
|
7
3
|
* Provides runtime warnings to help developers identify deprecated API usage.
|
|
@@ -97,127 +93,6 @@ declare namespace Deprecate {
|
|
|
97
93
|
function hasShown(message: string): boolean;
|
|
98
94
|
}
|
|
99
95
|
|
|
100
|
-
/**
|
|
101
|
-
* @class
|
|
102
|
-
* Utility class for visualizing terrain provider boundaries and debugging terrain loading.
|
|
103
|
-
*/
|
|
104
|
-
declare class TerrainVisualizer {
|
|
105
|
-
private _viewer;
|
|
106
|
-
private _terrainProvider;
|
|
107
|
-
private _visible;
|
|
108
|
-
private _tileCoordinatesLayer;
|
|
109
|
-
private _hybridImageryLayer;
|
|
110
|
-
private _colors;
|
|
111
|
-
/**
|
|
112
|
-
* Creates a new `TerrainVisualizer`.
|
|
113
|
-
* @param viewer The Cesium viewer instance
|
|
114
|
-
* @param options {@link TerrainVisualizer.ConstructorOptions}
|
|
115
|
-
*/
|
|
116
|
-
constructor(viewer: Viewer, options: TerrainVisualizer.ConstructorOptions);
|
|
117
|
-
/**
|
|
118
|
-
* Sets the terrain provider to visualize.
|
|
119
|
-
* @param terrainProvider The terrain provider to visualize.
|
|
120
|
-
*/
|
|
121
|
-
setTerrainProvider(terrainProvider: HybridTerrainProvider): void;
|
|
122
|
-
/**
|
|
123
|
-
* Updates all active visualizations.
|
|
124
|
-
*/
|
|
125
|
-
update(): void;
|
|
126
|
-
/**
|
|
127
|
-
* Clears all visualizations.
|
|
128
|
-
*/
|
|
129
|
-
clear(): void;
|
|
130
|
-
/**
|
|
131
|
-
* Shows terrain visualization using HybridImageryProvider.
|
|
132
|
-
* Optionally adds tile coordinate grid overlay.
|
|
133
|
-
* @param options Visualization options
|
|
134
|
-
*/
|
|
135
|
-
show(options?: {
|
|
136
|
-
/** Show tile coordinate labels. Default: true */
|
|
137
|
-
showTileCoordinates?: boolean;
|
|
138
|
-
/** Transparency level (0-1). Default: 0.5 */
|
|
139
|
-
alpha?: number;
|
|
140
|
-
}): void;
|
|
141
|
-
private _ensureTileCoordinatesLayer;
|
|
142
|
-
/**
|
|
143
|
-
* Hides the terrain visualization.
|
|
144
|
-
*/
|
|
145
|
-
hide(): void;
|
|
146
|
-
/**
|
|
147
|
-
* Sets the colors used for visualization.
|
|
148
|
-
* @param colors Map of role names to colors
|
|
149
|
-
*/
|
|
150
|
-
setColors(colors: Record<string, Color>): void;
|
|
151
|
-
/**
|
|
152
|
-
* Shows terrain regions using HybridImageryProvider (performant, global coverage).
|
|
153
|
-
* This replaces the entity-based approach with an imagery layer.
|
|
154
|
-
* @param alpha Transparency level (0-1), default 0.5
|
|
155
|
-
*/
|
|
156
|
-
showImageryOverlay(alpha?: number): void;
|
|
157
|
-
/**
|
|
158
|
-
* Hides the imagery overlay.
|
|
159
|
-
*/
|
|
160
|
-
hideImageryOverlay(): void;
|
|
161
|
-
/**
|
|
162
|
-
* Shows tile coordinate grid overlay.
|
|
163
|
-
*/
|
|
164
|
-
showTileCoordinates(): void;
|
|
165
|
-
/**
|
|
166
|
-
* Hides tile coordinate grid overlay.
|
|
167
|
-
*/
|
|
168
|
-
hideTileCoordinates(): void;
|
|
169
|
-
/**
|
|
170
|
-
* Sets the transparency of the imagery overlay.
|
|
171
|
-
* @param alpha Transparency level (0-1), where 0 is fully transparent and 1 is fully opaque
|
|
172
|
-
*/
|
|
173
|
-
setAlpha(alpha: number): void;
|
|
174
|
-
/**
|
|
175
|
-
* Flies the camera to focus on a rectangle.
|
|
176
|
-
* @param rectangle The rectangle to focus on.
|
|
177
|
-
* @param options {@link Viewer.flyTo}
|
|
178
|
-
*/
|
|
179
|
-
flyTo(rectangle: Rectangle, options?: {
|
|
180
|
-
duration?: number;
|
|
181
|
-
}): void;
|
|
182
|
-
/** Whether tile coordinates are currently visible. */
|
|
183
|
-
get tileCoordinatesVisible(): boolean;
|
|
184
|
-
/** Whether the grid is currently visible. */
|
|
185
|
-
get visible(): boolean;
|
|
186
|
-
/** The viewer used in the visualizer */
|
|
187
|
-
get viewer(): Viewer;
|
|
188
|
-
/** The colors used in the visualizer */
|
|
189
|
-
get colors(): Map<string, Color>;
|
|
190
|
-
/** The hybrid terrain instance used in the visualizer */
|
|
191
|
-
get terrainProvider(): HybridTerrainProvider;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* @namespace
|
|
195
|
-
* Contains types, utility functions, and constants for terrain visualization.
|
|
196
|
-
*/
|
|
197
|
-
declare namespace TerrainVisualizer {
|
|
198
|
-
/** Initialization options for `TerrainVisualizer` constructor. */
|
|
199
|
-
interface ConstructorOptions {
|
|
200
|
-
/** Colors to use for different visualization elements */
|
|
201
|
-
colors?: Record<string, Color>;
|
|
202
|
-
/** Whether to show tile grid initially. */
|
|
203
|
-
tile?: boolean;
|
|
204
|
-
/** Initial zoom level to use for visualizations. */
|
|
205
|
-
activeLevel?: number;
|
|
206
|
-
/** Terrain provider to visualize. */
|
|
207
|
-
terrainProvider: HybridTerrainProvider;
|
|
208
|
-
}
|
|
209
|
-
/** Options for {@link TerrainVisualizer.visualize} */
|
|
210
|
-
interface Options {
|
|
211
|
-
color?: Color;
|
|
212
|
-
show?: boolean;
|
|
213
|
-
maxTilesToShow?: number;
|
|
214
|
-
levels?: number[];
|
|
215
|
-
tag?: string;
|
|
216
|
-
alpha?: number;
|
|
217
|
-
tileAlpha?: number;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
96
|
declare const deprecate: typeof Deprecate.deprecate;
|
|
222
97
|
|
|
223
|
-
export { Deprecate,
|
|
98
|
+
export { Deprecate, deprecate };
|
package/dist/dev/index.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { Viewer, Color, Rectangle } from 'cesium';
|
|
2
|
-
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-Th8n2hZ1.js';
|
|
3
|
-
export { a as NestedKeyOf, b as NestedValueOf, N as NonFunction, i as isGetterOnly } from '../type-check-C17vkHMg.js';
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
* Utility for managing deprecation warnings in the cesium-utils library.
|
|
7
3
|
* Provides runtime warnings to help developers identify deprecated API usage.
|
|
@@ -97,127 +93,6 @@ declare namespace Deprecate {
|
|
|
97
93
|
function hasShown(message: string): boolean;
|
|
98
94
|
}
|
|
99
95
|
|
|
100
|
-
/**
|
|
101
|
-
* @class
|
|
102
|
-
* Utility class for visualizing terrain provider boundaries and debugging terrain loading.
|
|
103
|
-
*/
|
|
104
|
-
declare class TerrainVisualizer {
|
|
105
|
-
private _viewer;
|
|
106
|
-
private _terrainProvider;
|
|
107
|
-
private _visible;
|
|
108
|
-
private _tileCoordinatesLayer;
|
|
109
|
-
private _hybridImageryLayer;
|
|
110
|
-
private _colors;
|
|
111
|
-
/**
|
|
112
|
-
* Creates a new `TerrainVisualizer`.
|
|
113
|
-
* @param viewer The Cesium viewer instance
|
|
114
|
-
* @param options {@link TerrainVisualizer.ConstructorOptions}
|
|
115
|
-
*/
|
|
116
|
-
constructor(viewer: Viewer, options: TerrainVisualizer.ConstructorOptions);
|
|
117
|
-
/**
|
|
118
|
-
* Sets the terrain provider to visualize.
|
|
119
|
-
* @param terrainProvider The terrain provider to visualize.
|
|
120
|
-
*/
|
|
121
|
-
setTerrainProvider(terrainProvider: HybridTerrainProvider): void;
|
|
122
|
-
/**
|
|
123
|
-
* Updates all active visualizations.
|
|
124
|
-
*/
|
|
125
|
-
update(): void;
|
|
126
|
-
/**
|
|
127
|
-
* Clears all visualizations.
|
|
128
|
-
*/
|
|
129
|
-
clear(): void;
|
|
130
|
-
/**
|
|
131
|
-
* Shows terrain visualization using HybridImageryProvider.
|
|
132
|
-
* Optionally adds tile coordinate grid overlay.
|
|
133
|
-
* @param options Visualization options
|
|
134
|
-
*/
|
|
135
|
-
show(options?: {
|
|
136
|
-
/** Show tile coordinate labels. Default: true */
|
|
137
|
-
showTileCoordinates?: boolean;
|
|
138
|
-
/** Transparency level (0-1). Default: 0.5 */
|
|
139
|
-
alpha?: number;
|
|
140
|
-
}): void;
|
|
141
|
-
private _ensureTileCoordinatesLayer;
|
|
142
|
-
/**
|
|
143
|
-
* Hides the terrain visualization.
|
|
144
|
-
*/
|
|
145
|
-
hide(): void;
|
|
146
|
-
/**
|
|
147
|
-
* Sets the colors used for visualization.
|
|
148
|
-
* @param colors Map of role names to colors
|
|
149
|
-
*/
|
|
150
|
-
setColors(colors: Record<string, Color>): void;
|
|
151
|
-
/**
|
|
152
|
-
* Shows terrain regions using HybridImageryProvider (performant, global coverage).
|
|
153
|
-
* This replaces the entity-based approach with an imagery layer.
|
|
154
|
-
* @param alpha Transparency level (0-1), default 0.5
|
|
155
|
-
*/
|
|
156
|
-
showImageryOverlay(alpha?: number): void;
|
|
157
|
-
/**
|
|
158
|
-
* Hides the imagery overlay.
|
|
159
|
-
*/
|
|
160
|
-
hideImageryOverlay(): void;
|
|
161
|
-
/**
|
|
162
|
-
* Shows tile coordinate grid overlay.
|
|
163
|
-
*/
|
|
164
|
-
showTileCoordinates(): void;
|
|
165
|
-
/**
|
|
166
|
-
* Hides tile coordinate grid overlay.
|
|
167
|
-
*/
|
|
168
|
-
hideTileCoordinates(): void;
|
|
169
|
-
/**
|
|
170
|
-
* Sets the transparency of the imagery overlay.
|
|
171
|
-
* @param alpha Transparency level (0-1), where 0 is fully transparent and 1 is fully opaque
|
|
172
|
-
*/
|
|
173
|
-
setAlpha(alpha: number): void;
|
|
174
|
-
/**
|
|
175
|
-
* Flies the camera to focus on a rectangle.
|
|
176
|
-
* @param rectangle The rectangle to focus on.
|
|
177
|
-
* @param options {@link Viewer.flyTo}
|
|
178
|
-
*/
|
|
179
|
-
flyTo(rectangle: Rectangle, options?: {
|
|
180
|
-
duration?: number;
|
|
181
|
-
}): void;
|
|
182
|
-
/** Whether tile coordinates are currently visible. */
|
|
183
|
-
get tileCoordinatesVisible(): boolean;
|
|
184
|
-
/** Whether the grid is currently visible. */
|
|
185
|
-
get visible(): boolean;
|
|
186
|
-
/** The viewer used in the visualizer */
|
|
187
|
-
get viewer(): Viewer;
|
|
188
|
-
/** The colors used in the visualizer */
|
|
189
|
-
get colors(): Map<string, Color>;
|
|
190
|
-
/** The hybrid terrain instance used in the visualizer */
|
|
191
|
-
get terrainProvider(): HybridTerrainProvider;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* @namespace
|
|
195
|
-
* Contains types, utility functions, and constants for terrain visualization.
|
|
196
|
-
*/
|
|
197
|
-
declare namespace TerrainVisualizer {
|
|
198
|
-
/** Initialization options for `TerrainVisualizer` constructor. */
|
|
199
|
-
interface ConstructorOptions {
|
|
200
|
-
/** Colors to use for different visualization elements */
|
|
201
|
-
colors?: Record<string, Color>;
|
|
202
|
-
/** Whether to show tile grid initially. */
|
|
203
|
-
tile?: boolean;
|
|
204
|
-
/** Initial zoom level to use for visualizations. */
|
|
205
|
-
activeLevel?: number;
|
|
206
|
-
/** Terrain provider to visualize. */
|
|
207
|
-
terrainProvider: HybridTerrainProvider;
|
|
208
|
-
}
|
|
209
|
-
/** Options for {@link TerrainVisualizer.visualize} */
|
|
210
|
-
interface Options {
|
|
211
|
-
color?: Color;
|
|
212
|
-
show?: boolean;
|
|
213
|
-
maxTilesToShow?: number;
|
|
214
|
-
levels?: number[];
|
|
215
|
-
tag?: string;
|
|
216
|
-
alpha?: number;
|
|
217
|
-
tileAlpha?: number;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
96
|
declare const deprecate: typeof Deprecate.deprecate;
|
|
222
97
|
|
|
223
|
-
export { Deprecate,
|
|
98
|
+
export { Deprecate, deprecate };
|
package/dist/dev/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var s;(w=>{let n=new Set,u=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function f(e,o={}){if(!u)return;let{once:r=!0,prefix:t="[DEPRECATED]",includeStack:i=!0,removeInVersion:c}=o;if(r&&n.has(e))return;let a=`${t} ${e}`;c&&(a+=` This feature will be removed in ${c}.`),typeof console<"u"&&console.warn&&(i?(console.warn(a),console.trace("Deprecation stack trace:")):console.warn(a)),r&&n.add(e)}w.warn=f;function l(e,o,r={}){let t=((...i)=>(f(o,r),e(...i)));return Object.defineProperty(t,"name",{value:e.name,configurable:!0}),t}w.deprecate=l;function d(){n.clear()}w.clear=d;function x(){return n.size}w.getWarningCount=x;function g(e){return n.has(e)}w.hasShown=g})(s||={});var p=s;var m=p.deprecate;export{p as Deprecate,m as deprecate};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
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;
|