@juun-roh/cesium-utils 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-3LRWGBW3.js +1 -0
- package/dist/chunk-DOPMSVYJ.js +1 -0
- package/dist/collection/index.cjs +1 -1
- package/dist/collection/index.d.cts +110 -67
- package/dist/collection/index.d.ts +110 -67
- package/dist/collection/index.js +1 -1
- package/dist/{hybrid-terrain-provider-C6aXdtyo.d.cts → hybrid-terrain-provider-Cp_rA9j4.d.cts} +22 -113
- package/dist/{hybrid-terrain-provider-C6aXdtyo.d.ts → hybrid-terrain-provider-Cp_rA9j4.d.ts} +22 -113
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/terrain/index.cjs +1 -1
- package/dist/terrain/index.d.cts +25 -8
- package/dist/terrain/index.d.ts +25 -8
- package/dist/terrain/index.js +1 -1
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.cts +132 -5
- package/dist/utils/index.d.ts +132 -5
- package/dist/utils/index.js +1 -1
- package/package.json +6 -7
- package/dist/chunk-C52KJ2WP.js +0 -1
- package/dist/chunk-HC6YX7RQ.js +0 -1
- package/dist/sync-camera-CFIMO7Ut.d.cts +0 -133
- package/dist/sync-camera-DHUVJ-Fl.d.ts +0 -133
package/dist/{hybrid-terrain-provider-C6aXdtyo.d.ts → hybrid-terrain-provider-Cp_rA9j4.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Request, TerrainData, Credit, TerrainProvider, Rectangle, CesiumTerrainProvider, TilingScheme, TileAvailability } from 'cesium';
|
|
2
2
|
|
|
3
3
|
/** A range of tiles from `start` to `end` */
|
|
4
4
|
type TileRange = {
|
|
@@ -13,90 +13,6 @@ type TileRange = {
|
|
|
13
13
|
y: number;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
-
/** A `TileRange` map with specific levels as their keys. */
|
|
17
|
-
type TileRanges = Map<number, TileRange>;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @class
|
|
21
|
-
* Defines the geographic boundaries for a terrain area and handles tile availability checks.
|
|
22
|
-
*/
|
|
23
|
-
declare class TerrainBounds {
|
|
24
|
-
private _rectangle;
|
|
25
|
-
private _tilingScheme;
|
|
26
|
-
private _tileRanges;
|
|
27
|
-
private _levels;
|
|
28
|
-
/**
|
|
29
|
-
* Creates a new instance of TerrainBounds.
|
|
30
|
-
* @param options {@link TerrainBounds.ConstructorOptions}
|
|
31
|
-
* @param tilingScheme (optional) The tiling scheme to use for coordinate calculations.
|
|
32
|
-
*/
|
|
33
|
-
constructor(options: TerrainBounds.ConstructorOptions, tilingScheme?: TilingScheme);
|
|
34
|
-
/**
|
|
35
|
-
* Checks if the specified tile coordinates are within the bounds.
|
|
36
|
-
* @param x The tile X coordinate.
|
|
37
|
-
* @param y The tile Y coordinate.
|
|
38
|
-
* @param level The tile level.
|
|
39
|
-
* @returns `true` if the tile is within bounds, `false` otherwise.
|
|
40
|
-
*/
|
|
41
|
-
contains(x: number, y: number, level: number): boolean;
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
* Configures a terrain provider's availability based on these bounds.
|
|
45
|
-
* @see WARNING This method is accessing private property of {@link https://cesium.com/learn/csiumjs/ref-doc/TileAvailability.html `TileAvailability`}.
|
|
46
|
-
* @param provider The terrain provider to configure.
|
|
47
|
-
*/
|
|
48
|
-
configureAvailability(provider: TerrainProvider): void;
|
|
49
|
-
/**
|
|
50
|
-
* Gets the rectangle representing these bounds.
|
|
51
|
-
*/
|
|
52
|
-
get rectangle(): Rectangle;
|
|
53
|
-
/** Gets the tiling scheme used by these bounds. */
|
|
54
|
-
get tilingScheme(): TilingScheme;
|
|
55
|
-
/** Gets the tile ranges defined for these bounds. */
|
|
56
|
-
get tileRanges(): TileRanges;
|
|
57
|
-
/** Gets the levels for which tile ranges are defined. */
|
|
58
|
-
get levels(): Set<number>;
|
|
59
|
-
/**
|
|
60
|
-
* Calculates a bounding rectangle that encompasses all the specified tile ranges.
|
|
61
|
-
* @private
|
|
62
|
-
*/
|
|
63
|
-
private _calculateRectangleFromTileRanges;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* @namespace
|
|
67
|
-
* Contains types and factory methods for creating `TerrainBounds` instances.
|
|
68
|
-
*/
|
|
69
|
-
declare namespace TerrainBounds {
|
|
70
|
-
/** Initialization options for Terrain Bounds constructor */
|
|
71
|
-
interface ConstructorOptions {
|
|
72
|
-
/** Type of bounds definition. */
|
|
73
|
-
type: 'tileRange' | 'rectangle';
|
|
74
|
-
/**
|
|
75
|
-
* Tile ranges by level when using tileRange type.
|
|
76
|
-
* Keys are zoom levels, values define the range of tiles at that level.
|
|
77
|
-
* Can be provided either as a Map or as a plain object with numeric keys.
|
|
78
|
-
*/
|
|
79
|
-
tileRanges?: Map<number, TileRange> | Record<string | number, TileRange>;
|
|
80
|
-
/** Rectangle bounds when using rectangle type. */
|
|
81
|
-
rectangle?: Rectangle;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Creates `TerrainBounds` from tile coordinates at a specific level.
|
|
85
|
-
* @param x The tile X coordinate.
|
|
86
|
-
* @param y The tile Y coordinate.
|
|
87
|
-
* @param level The tile level.
|
|
88
|
-
* @param tilingScheme The tiling scheme to use.
|
|
89
|
-
* @returns A new `TerrainBounds` instance for the specified tile.
|
|
90
|
-
*/
|
|
91
|
-
function fromTile(x: number, y: number, level: number, tilingScheme?: TilingScheme): TerrainBounds;
|
|
92
|
-
/**
|
|
93
|
-
* Creates `TerrainBounds` from a rectangle.
|
|
94
|
-
* @param rectangle The rectangle defining the bounds.
|
|
95
|
-
* @param tilingScheme The tiling scheme to use.
|
|
96
|
-
* @returns A new `TerrainBounds` instance for the specified rectangle.
|
|
97
|
-
*/
|
|
98
|
-
function fromRectangle(rectangle: Rectangle, tilingScheme?: TilingScheme): TerrainBounds;
|
|
99
|
-
}
|
|
100
16
|
|
|
101
17
|
/**
|
|
102
18
|
* @class
|
|
@@ -105,25 +21,22 @@ declare namespace TerrainBounds {
|
|
|
105
21
|
*/
|
|
106
22
|
declare class TerrainArea {
|
|
107
23
|
private _provider;
|
|
108
|
-
private
|
|
109
|
-
private
|
|
24
|
+
private _rectangle;
|
|
25
|
+
private _tileRanges;
|
|
110
26
|
private _ready;
|
|
111
27
|
private _credit;
|
|
112
28
|
private _isCustom;
|
|
113
29
|
/**
|
|
114
30
|
* Creates a new instance of `TerrainArea`.
|
|
115
31
|
* @param options Object describing initialization options
|
|
116
|
-
* @private Use {@link TerrainArea.create} instead.
|
|
117
32
|
*/
|
|
118
|
-
|
|
33
|
+
constructor(options: TerrainArea.ConstructorOptions);
|
|
119
34
|
/**
|
|
120
|
-
*
|
|
121
|
-
* @param
|
|
122
|
-
* @
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* @see {@link TerrainBounds.contains}
|
|
35
|
+
* Checks if the specified tile coordinates are within the bounds.
|
|
36
|
+
* @param x The tile X coordinate.
|
|
37
|
+
* @param y The tile Y coordinate.
|
|
38
|
+
* @param level The tile level.
|
|
39
|
+
* @returns `true` if the tile is within bounds, `false` otherwise.
|
|
127
40
|
*/
|
|
128
41
|
contains(x: number, y: number, level: number): boolean;
|
|
129
42
|
/**
|
|
@@ -151,11 +64,11 @@ declare class TerrainArea {
|
|
|
151
64
|
/** Gets the credit associated with this terrain area. */
|
|
152
65
|
get credit(): string | Credit;
|
|
153
66
|
/** Gets the terrain provider for this terrain area. */
|
|
154
|
-
get provider(): TerrainProvider
|
|
155
|
-
/** Gets
|
|
156
|
-
get
|
|
157
|
-
/** Gets
|
|
158
|
-
get
|
|
67
|
+
get provider(): TerrainProvider;
|
|
68
|
+
/** Gets available tile ranges with zoom levels set with this terrain area. */
|
|
69
|
+
get tileRanges(): Map<number, TileRange>;
|
|
70
|
+
/** Gets the rectangle representing this terrain area. */
|
|
71
|
+
get rectangle(): Rectangle;
|
|
159
72
|
/** Gets if this terrain area is ready. */
|
|
160
73
|
get ready(): boolean;
|
|
161
74
|
}
|
|
@@ -167,14 +80,12 @@ declare namespace TerrainArea {
|
|
|
167
80
|
/** Initialization options for `TerrainArea` constructor. */
|
|
168
81
|
interface ConstructorOptions {
|
|
169
82
|
/** The terrain provider for this area or a URL to create one from. */
|
|
170
|
-
provider: TerrainProvider
|
|
171
|
-
/** The geographic bounds of this terrain area. */
|
|
172
|
-
bounds: TerrainBounds | TerrainBounds.ConstructorOptions;
|
|
83
|
+
provider: TerrainProvider;
|
|
173
84
|
/**
|
|
174
|
-
*
|
|
175
|
-
*
|
|
85
|
+
* Tile ranges by level when using tileRange type.
|
|
86
|
+
* Keys are zoom levels, values define the range of tiles at that level.
|
|
176
87
|
*/
|
|
177
|
-
|
|
88
|
+
tileRanges: Map<number, TileRange>;
|
|
178
89
|
/**
|
|
179
90
|
* Credit to associate with this terrain provider.
|
|
180
91
|
* Used to identify custom terrain providers.
|
|
@@ -191,11 +102,10 @@ declare namespace TerrainArea {
|
|
|
191
102
|
* Creates a `TerrainArea` from a URL and tile ranges.
|
|
192
103
|
* @param url The URL to create the terrain provider from.
|
|
193
104
|
* @param tileRanges Tile ranges by level.
|
|
194
|
-
* @param
|
|
195
|
-
* @param credit Credit to associate with this terrain provider.
|
|
105
|
+
* @param options: Constructor options for CesiumTerrainProvider.
|
|
196
106
|
* @returns A promise resolving to a new `TerrainArea`
|
|
197
107
|
*/
|
|
198
|
-
function fromUrl(url: string, tileRanges:
|
|
108
|
+
function fromUrl(url: string, tileRanges: Map<number, TileRange>, options?: CesiumTerrainProvider.ConstructorOptions): Promise<Awaited<TerrainArea>>;
|
|
199
109
|
}
|
|
200
110
|
|
|
201
111
|
/**
|
|
@@ -336,10 +246,9 @@ declare namespace HybridTerrainProvider {
|
|
|
336
246
|
* @param customTerrainUrl URL to the custom terrain.
|
|
337
247
|
* @param baseTerrainUrl URL to the base terrain.
|
|
338
248
|
* @param tileRanges Tile ranges defining the custom terrain area.
|
|
339
|
-
* @param levels Levels to apply the custom terrain.
|
|
340
249
|
* @returns A promise resolving to a new `HybridTerrainProvider`.
|
|
341
250
|
*/
|
|
342
|
-
function createOverlay(customTerrainUrl: string, baseTerrainUrl: string, tileRanges:
|
|
251
|
+
function createOverlay(customTerrainUrl: string, baseTerrainUrl: string, tileRanges: Map<number, TileRange>): Promise<Awaited<HybridTerrainProvider>>;
|
|
343
252
|
}
|
|
344
253
|
|
|
345
|
-
export { HybridTerrainProvider as H, TerrainArea as T,
|
|
254
|
+
export { HybridTerrainProvider as H, TerrainArea as T, type TileRange as a };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var k=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var W=(n,e)=>{for(var r in e)k(n,r,{get:e[r],enumerable:!0})},$=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Y(e))!q.call(n,i)&&i!==r&&k(n,i,{get:()=>e[i],enumerable:!(t=H(e,i))||t.enumerable});return n};var U=n=>$(k({},"__esModule",{value:!0}),n);var X={};W(X,{Collection:()=>R,HybridTerrainProvider:()=>P,TerrainArea:()=>g,TerrainAreas:()=>p,TerrainBounds:()=>v,TerrainVisualizer:()=>T,cloneViewer:()=>D,syncCamera:()=>C});module.exports=U(X);var w=require("cesium");var l=require("cesium");var T=class n{_viewer;_collection;_hybridTerrain;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",l.Color.RED],["default",l.Color.BLUE],["fallback",l.Color.GRAY],["grid",l.Color.YELLOW]]);constructor(e,r){this._viewer=e,this._collection=new R({collection:e.entities,tag:n.tag.default}),r&&(r.colors&&Object.entries(r.colors).forEach(([t,i])=>{this._colors.set(t,i)}),r.tile!==void 0&&(this._visible=r.tile),r.activeLevel!==void 0&&(this._level=r.activeLevel),r.terrainProvider&&this.setTerrainProvider(r.terrainProvider))}setTerrainProvider(e){this._hybridTerrain=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.removeByTag(this._collection.getTags())}show(e=15){if(!this._hybridTerrain)return;this._collection.removeByTag(n.tag.grid),this._level=e;let r=this._hybridTerrain.tilingScheme;this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new l.TileCoordinatesImageryProvider({tilingScheme:r,color:l.Color.YELLOW})));let t=(a,s,c)=>{if(this._hybridTerrain){for(let d of this._hybridTerrain.terrainAreas)if(d.contains(a,s,c))return d.isCustom?this._colors.get("custom")||l.Color.RED:this._colors.get("default")||l.Color.BLUE;if(this._hybridTerrain.getTileDataAvailable(a,s,c))return this._colors.get("default")||l.Color.BLUE}return this._colors.get("fallback")||l.Color.TRANSPARENT},i=this._getVisibleRectangle();if(!i)return;function o(a){return a&&Number.isFinite(a.west)&&Number.isFinite(a.south)&&Number.isFinite(a.east)&&Number.isFinite(a.north)&&a.west<=a.east&&a.south<=a.north}if(!o(i)){console.warn("Invalid visible rectangle detected, skipping grid display");return}try{let a=r.positionToTileXY(l.Rectangle.northwest(i),e),s=r.positionToTileXY(l.Rectangle.southeast(i),e);if(!a||!s)return;let c=100,d=Math.min(s.x-a.x+1,c),y=Math.min(s.y-a.y+1,c);for(let m=a.x;m<=a.x+d-1;m++)for(let f=a.y;f<=a.y+y-1;f++)try{let h=r.tileXYToRectangle(m,f,e);if(!o(h)){console.warn(`Invalid rectangle for tile (${m}, ${f}, ${e}), skipping`);continue}let A=t(m,f,e),_=n.createRectangle(h,A.withAlpha(.3));_.properties?.addProperty("tileX",m),_.properties?.addProperty("tileY",f),_.properties?.addProperty("tileLevel",e),this._collection.add(_,n.tag.grid)}catch(h){console.warn(`Error creating tile (${m}, ${f}, ${e}): ${h.message}`);continue}console.log("\u{1F680} ~ TerrainVisualizer ~ showGrid ~ collection:",this._collection),this._visible=!0}catch(a){console.error("Error displaying tile grid:",a)}}hide(){this._collection.removeByTag(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([r,t])=>{this._colors.set(r,t)}),this.update()}flyTo(e,r){let{rectangle:t}=e.bounds;this._viewer.camera.flyTo({destination:t,...r,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}};(t=>{t.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(i,o){return new l.Entity({rectangle:{coordinates:i,material:o,heightReference:l.HeightReference.CLAMP_TO_GROUND}})}t.createRectangle=e;function r(i,o,a){let s=a?.tag||"terrain_area_visualization",c=a?.color||l.Color.RED,d=a?.maxTilesToShow||100,y=a?.show??!0,m=a?.alpha||.7,f=a?.tileAlpha||.2,h="provider"in i?i.bounds:i,A=new R({collection:o.entities,tag:s}),{rectangle:_}=h;if(A.add(t.createRectangle(_,c.withAlpha(m)),s),y&&h.levels.size>0){let{tilingScheme:G}=h;h.levels.forEach(B=>{let I=0,{tileRanges:F}=h;for(let[z,E]of F.entries())if(z===B)for(let x=E.start.x;x<=E.end.x&&I<d;x++)for(let S=E.start.y;S<=E.end.y&&I<d;S++){let j=G.tileXYToRectangle(x,S,B);A.add(e(j,c.withAlpha(f)),`${s}_tile`),I++}})}return A}t.visualize=r})(T||={});function M(n,e){let r=!1,t=Object.getOwnPropertyDescriptor(n,e);if(!t){let i=Object.getPrototypeOf(n);for(;i&&!t;)t=Object.getOwnPropertyDescriptor(i,e),i=Object.getPrototypeOf(i)}return t&&t.get&&!t.set&&(r=!0),r}var L=require("cesium");function C(n,e){if((0,L.defined)(n)&&(0,L.defined)(e)){let{camera:r}=n;e.camera.position=r.positionWC.clone(),e.camera.direction=r.directionWC.clone(),e.camera.up=r.upWC.clone()}}var O=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:r}){this.tag=r||"default",this.collection=e}_emit(e,r){let t=this._eventListeners.get(e);if(t){let i={type:e,...r};t.forEach(o=>o(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[n.symbol],t=this._tagMap.get(r);t&&(t.delete(e),t.size===0&&this._tagMap.delete(r))}_invalidateCache(){this._valuesCache=null}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,n.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})),e}contains(e){return this.collection.contains(e)}remove(e){let r=this.collection.remove(e);return r&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),r}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof w.EntityCollection)return this.collection.values;{let e=[];for(let r=0;r<this.collection.length;r++)e.push(this.collection.get(r));return e}}get length(){return this.values?.length||0}getByTag(e){let r=this._tagMap.get(e);return r?Array.from(r):[]}getFirstByTag(e){let r=this._tagMap.get(e);if(r&&r.size>0)return r.values().next().value}getTags(){return Array.from(this._tagMap.keys())}hasTag(e){let r=this._tagMap.get(e);return!!r&&r.size>0}updateTag(e,r){let t=this.getByTag(e);for(let i of t)this._removeFromTagMap(i),Object.defineProperty(i,n.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}removeByTag(e){let r=0;return Array.isArray(e)?e.forEach(t=>{r+=this.removeByTag(t)}):this.getByTag(e).forEach(t=>{this.remove(t)&&r++}),r}show(e){let r=this.getByTag(e),t=0;for(let i of r)(0,w.defined)(i.show)&&(i.show=!0,t++);return t}hide(e){let r=this.getByTag(e),t=0;for(let i of r)(0,w.defined)(i.show)&&(i.show=!1,t++);return t}toggle(e){let r=this.getByTag(e),t=0;for(let i of r)(0,w.defined)(i.show)&&(i.show=!i.show,t++);return t}setProperty(e,r,t=this.tag){let i=this.getByTag(t),o=0;for(let a of i)if(e in a&&typeof a[e]!="function"){if(M(a,e))throw Error(`setProperty(${a}, ${e}) failed; The property is readonly.`);a[e]=r,o++}return o}filter(e,r){return(r?this.getByTag(r):this.values).filter(e)}forEach(e,r){(r?this.getByTag(r):this.values).forEach((i,o)=>e(i,o))}},R=O;var b=require("cesium");var V=require("cesium");var u=require("cesium"),v=class{_rectangle;_tilingScheme;_tileRanges;_levels;constructor(e,r){if(this._tilingScheme=r||new u.GeographicTilingScheme,this._rectangle=new u.Rectangle,this._tileRanges=new Map,this._levels=new Set,e.type==="rectangle"&&e.rectangle)this._rectangle=u.Rectangle.clone(e.rectangle);else if(e.type==="tileRange"&&e.tileRanges)e.tileRanges instanceof Map?this._tileRanges=new Map(e.tileRanges):this._tileRanges=new Map(Object.entries(e.tileRanges).map(([t,i])=>[parseInt(t),i])),this._calculateRectangleFromTileRanges();else throw new Error("Either rectangle or tileRanges must be provided.");this._levels=new Set(Array.from(this._tileRanges.keys()))}contains(e,r,t){if(this._tileRanges.has(t)){let o=this._tileRanges.get(t);return e>=o.start.x&&e<=o.end.x&&r>=o.start.y&&r<=o.end.y}let i=this._tilingScheme.tileXYToRectangle(e,r,t);return u.Rectangle.intersection(i,this._rectangle)!==void 0}configureAvailability(e){if(e.availability){e.availability._tilingScheme&&(e.availability._tilingScheme=this._tilingScheme);for(let[r,t]of this._tileRanges.entries())e.availability.addAvailableTileRange(r,t.start.x,t.start.y,t.end.x,t.end.y)}}get rectangle(){return this._rectangle}get tilingScheme(){return this._tilingScheme}get tileRanges(){return this._tileRanges}get levels(){return this._levels}_calculateRectangleFromTileRanges(){let e=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY,o=Array.from(this._tileRanges.keys());if(o.length===0){this._rectangle=u.Rectangle.MAX_VALUE;return}let a=Math.min(...o),s=this._tileRanges.get(a);if(s){let{start:c,end:d}=s,y=this._tilingScheme.tileXYToRectangle(c.x,c.y,a),m=this._tilingScheme.tileXYToRectangle(d.x,d.y,a);e=Math.min(y.west,e),r=Math.min(m.south,r),t=Math.max(m.east,t),i=Math.max(y.north,i)}this._rectangle=new u.Rectangle(e,r,t,i)}};(r=>{function n(t,i,o,a=new u.GeographicTilingScheme){let s=new Map;return s.set(o,{start:{x:t,y:i},end:{x:t,y:i}}),new r({type:"tileRange",tileRanges:s},a)}r.fromTile=n;function e(t,i=new u.GeographicTilingScheme){return new r({type:"rectangle",rectangle:u.Rectangle.clone(t)},i)}r.fromRectangle=e})(v||={});var g=class n{_provider;_bounds;_levels;_ready=!1;_credit;_isCustom;constructor(e,r){this._bounds=e.bounds instanceof v?e.bounds:new v(e.bounds),this._levels=new Set(e.levels||[]),this._credit=e.credit||"custom",this._isCustom=e.isCustom!==void 0?e.isCustom:!0,this._provider=r,this._ready=!0,this._bounds.configureAvailability(this._provider)}static async create(e){let r;return typeof e.provider=="string"?r=await V.CesiumTerrainProvider.fromUrl(e.provider,{requestVertexNormals:!0,credit:e.credit||"custom"}):r=e.provider,new n(e,r)}contains(e,r,t){return this._levels.size>0&&!this._levels.has(t)?!1:this._bounds.contains(e,r,t)}requestTileGeometry(e,r,t,i){if(!(!this._ready||!this.contains(e,r,t)||!this._provider?.getTileDataAvailable(e,r,t)))return this._provider.requestTileGeometry(e,r,t,i)}getTileDataAvailable(e,r,t){return!this.contains(e,r,t)||!this._ready?!1:this._provider?.getTileDataAvailable(e,r,t)??!1}get isCustom(){return this._isCustom}get credit(){return this._credit}get provider(){return this._provider}get bounds(){return this._bounds}get levels(){return this._levels}get ready(){return this._ready}};(e=>{async function n(r,t,i,o="custom"){let a=new v({type:"tileRange",tileRanges:t});return await e.create({provider:r,bounds:a,levels:i||Object.keys(t).map(c=>parseInt(c)),credit:o})}e.fromUrl=n})(g||={});var p=class extends Array{async add(e){let r;return e instanceof g?r=e:r=await g.create(e),this.push(r)}remove(e){let r=this.indexOf(e);return r>=0?(this.splice(r,1),!0):!1}clear(){this.length=0}};var P=class n{_terrainAreas=new p;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e,r,t){this._terrainProvider=e,this._fallbackProvider=r,this._tilingScheme=e.tilingScheme||new b.GeographicTilingScheme,this._terrainAreas=new p(...t),this._availability=e.availability,this._ready=!0}static async create(e){try{let r;typeof e.terrainProvider=="string"?r=await b.CesiumTerrainProvider.fromUrl(e.terrainProvider,{requestVertexNormals:!0}):r=e.terrainProvider;let t;e.fallbackProvider?typeof e.fallbackProvider=="string"?t=await b.CesiumTerrainProvider.fromUrl(e.fallbackProvider,{requestVertexNormals:!0}):t=e.fallbackProvider:t=new b.EllipsoidTerrainProvider;let i=[];for(let o of e.terrainAreas){let a=await g.create(o);i.push(a)}return new n(r,t,i)}catch(r){throw console.error("Failed to initialize HybridTerrainProvider:",r),r}}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get terrainAreas(){return[...this._terrainAreas]}get defaultProvider(){return this._terrainProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._terrainProvider?.credit}get errorEvent(){return this._terrainProvider.errorEvent}get hasWaterMask(){return this._terrainProvider.hasWaterMask}get hasVertexNormals(){return this._terrainProvider.hasVertexNormals}loadTileDataAvailability(e,r,t){return this._terrainProvider.loadTileDataAvailability(e,r,t)}getLevelMaximumGeometricError(e){return this._terrainProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,r,t,i){if(this._ready){for(let o of this._terrainAreas)if(o.contains(e,r,t))return o.requestTileGeometry(e,r,t,i);return this._terrainProvider.getTileDataAvailable(e,r,t)?this._terrainProvider.requestTileGeometry(e,r,t,i):this._fallbackProvider.requestTileGeometry(e,r,t,i)}}getTileDataAvailable(e,r,t){return this._terrainAreas.forEach(i=>{if(i.contains(e,r,t)&&i.getTileDataAvailable(e,r,t))return!0}),this._terrainProvider.getTileDataAvailable(e,r,t)||!0}};(e=>{async function n(r,t,i,o){return e.create({terrainAreas:[{provider:r,bounds:{type:"tileRange",tileRanges:i},levels:o||Object.keys(i).map(a=>parseInt(a)),credit:"custom"}],terrainProvider:t,fallbackProvider:new b.EllipsoidTerrainProvider})}e.createOverlay=n})(P||={});var N=require("cesium");function D(n,e,r){let t={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},i=new N.Viewer(e,{...t,...r});C(n,i);let o=n.imageryLayers;i.imageryLayers.removeAll();for(let c=0;c<o.length;c++){let d=o.get(c);i.imageryLayers.addImageryProvider(d.imageryProvider,c)}i.clock.startTime=n.clock.startTime.clone(),i.clock.stopTime=n.clock.stopTime.clone(),i.clock.currentTime=n.clock.currentTime.clone(),i.clock.multiplier=n.clock.multiplier,i.clock.clockStep=n.clock.clockStep,i.clock.clockRange=n.clock.clockRange,i.clock.shouldAnimate=n.clock.shouldAnimate,i.scene.globe.enableLighting=n.scene.globe.enableLighting,i.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,i.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let a=n.scene.screenSpaceCameraController.tiltEventTypes;a&&(i.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(a)?[...a]:a);let s=n.scene.screenSpaceCameraController.zoomEventTypes;return s&&(i.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(s)?[...s]:s),i}
|
|
1
|
+
"use strict";var O=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var j=(n,e)=>{for(var r in e)O(n,r,{get:e[r],enumerable:!0})},q=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of H(e))!Y.call(n,i)&&i!==r&&O(n,i,{get:()=>e[i],enumerable:!(t=F(e,i))||t.enumerable});return n};var B=n=>q(O({},"__esModule",{value:!0}),n);var U={};j(U,{Collection:()=>A,HybridTerrainProvider:()=>C,TerrainArea:()=>h,TerrainAreas:()=>v,TerrainVisualizer:()=>f,cloneViewer:()=>D,computeRectangle:()=>R,isGetterOnly:()=>P,syncCamera:()=>y});module.exports=B(U);var _=require("cesium");var l=require("cesium");var f=class n{_viewer;_collection;_hybridTerrain;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",l.Color.RED],["default",l.Color.BLUE],["fallback",l.Color.GRAY],["grid",l.Color.YELLOW]]);constructor(e,r){this._viewer=e,this._collection=new A({collection:e.entities,tag:n.tag.default}),r&&(r.colors&&Object.entries(r.colors).forEach(([t,i])=>{this._colors.set(t,i)}),r.tile!==void 0&&(this._visible=r.tile),r.activeLevel!==void 0&&(this._level=r.activeLevel),r.terrainProvider&&this.setTerrainProvider(r.terrainProvider))}setTerrainProvider(e){this._hybridTerrain=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._hybridTerrain)return;this._collection.remove(n.tag.grid),this._level=e;let r=this._hybridTerrain.tilingScheme;this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new l.TileCoordinatesImageryProvider({tilingScheme:r,color:l.Color.YELLOW})));let t=(o,s,c)=>{if(this._hybridTerrain){for(let d of this._hybridTerrain.terrainAreas)if(d.contains(o,s,c))return d.isCustom?this._colors.get("custom")||l.Color.RED:this._colors.get("default")||l.Color.BLUE;if(this._hybridTerrain.getTileDataAvailable(o,s,c))return this._colors.get("default")||l.Color.BLUE}return this._colors.get("fallback")||l.Color.TRANSPARENT},i=this._getVisibleRectangle();if(!i)return;function a(o){return o&&Number.isFinite(o.west)&&Number.isFinite(o.south)&&Number.isFinite(o.east)&&Number.isFinite(o.north)&&o.west<=o.east&&o.south<=o.north}if(!a(i)){console.warn("Invalid visible rectangle detected, skipping grid display");return}try{let o=r.positionToTileXY(l.Rectangle.northwest(i),e),s=r.positionToTileXY(l.Rectangle.southeast(i),e);if(!o||!s)return;let c=100,d=Math.min(s.x-o.x+1,c),T=Math.min(s.y-o.y+1,c);for(let m=o.x;m<=o.x+d-1;m++)for(let u=o.y;u<=o.y+T-1;u++)try{let g=r.tileXYToRectangle(m,u,e);if(!a(g)){console.warn(`Invalid rectangle for tile (${m}, ${u}, ${e}), skipping`);continue}let E=t(m,u,e),b=n.createRectangle(g,E.withAlpha(.3));b.properties?.addProperty("tileX",m),b.properties?.addProperty("tileY",u),b.properties?.addProperty("tileLevel",e),this._collection.add(b,n.tag.grid)}catch(g){console.warn(`Error creating tile (${m}, ${u}, ${e}): ${g.message}`);continue}console.log("\u{1F680} ~ TerrainVisualizer ~ showGrid ~ collection:",this._collection),this._visible=!0}catch(o){console.error("Error displaying tile grid:",o)}}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([r,t])=>{this._colors.set(r,t)}),this.update()}flyTo(e,r){let{rectangle:t}=e;this._viewer.camera.flyTo({destination:t,...r,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}};(t=>{t.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(i,a){return new l.Entity({rectangle:{coordinates:i,material:a,heightReference:l.HeightReference.CLAMP_TO_GROUND}})}t.createRectangle=e;function r(i,a,o){let s=o?.tag||"terrain_area_visualization",c=o?.color||l.Color.RED,d=o?.maxTilesToShow||100,T=o?.show??!0,m=o?.alpha||.7,u=o?.tileAlpha||.2,g=new A({collection:a.entities,tag:s}),{rectangle:E}=i;if(g.add(t.createRectangle(E,c.withAlpha(m)),s),T&&i.tileRanges.size>0){let{tilingScheme:b}=i.provider,x=0;i.tileRanges.forEach((w,z)=>{for(let M=w.start.x;M<=w.end.x&&x<d;M++)for(let k=w.start.y;k<=w.end.y&&x<d;k++){let G=b.tileXYToRectangle(M,k,z);g.add(e(G,c.withAlpha(u)),`${s}_tile`),x++}})}return g}t.visualize=r})(f||={});function P(n,e){let r=!1,t=Object.getOwnPropertyDescriptor(n,e);if(!t){let i=Object.getPrototypeOf(n);for(;i&&!t;)t=Object.getOwnPropertyDescriptor(i,e),i=Object.getPrototypeOf(i)}return t&&t.get&&!t.set&&(r=!0),r}var L=require("cesium");function y(n,e){if((0,L.defined)(n)&&(0,L.defined)(e)){let{camera:r}=n;e.camera.position=r.positionWC.clone(),e.camera.direction=r.directionWC.clone(),e.camera.up=r.upWC.clone()}}var S=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:r}){this.tag=r||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,r){let t=this._eventListeners.get(e);if(t){let i={type:e,...r};t.forEach(a=>a(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[n.symbol],t=this._tagMap.get(r);t&&(t.delete(e),t.size===0&&this._tagMap.delete(r))}_invalidateCache(){this._valuesCache=null}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,n.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})),e}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)){let i=this.collection.remove(e);return i&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),i}if(Array.isArray(e)){if(e.length===0)return!1;let i=!1;for(let a of e)this.remove(a)&&(i=!0);return i}let r=this.get(e);if(r.length===0)return!1;let t=!1;for(let i of r)this.remove(i)&&(t=!0);return t}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof _.EntityCollection)return this.collection.values;{let e=[];for(let r=0;r<this.collection.length;r++)e.push(this.collection.get(r));return e}}get length(){return this.values?.length||0}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}get tags(){return Array.from(this._tagMap.keys())}update(e,r){let t=this.get(e);for(let i of t)this._removeFromTagMap(i),Object.defineProperty(i,n.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,_.defined)(t.show)&&(t.show=!0);return this}hide(e){let r=this.get(e);for(let t of r)(0,_.defined)(t.show)&&(t.show=!1);return this}toggle(e){let r=this.get(e);for(let t of r)(0,_.defined)(t.show)&&(t.show=!t.show);return this}setProperty(e,r,t=this.tag){let i=this.get(t);for(let a of i)if(e in a&&typeof a[e]!="function"){if(P(a,e))throw Error(`setProperty(${a}, ${e}) failed; The property is readonly.`);a[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,a)=>e(i,a))}map(e,r){return(r?this.get(r):this.values).map(e)}find(e,r){return(r?this.get(r):this.values).find(e)}},A=S;var p=require("cesium");var I=require("cesium");var V=require("cesium");function R(n,e){if(e.size===0)return new V.Rectangle;let r=Number.POSITIVE_INFINITY,t=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY,o=Array.from(e.keys()),s=Math.min(...o),c=e.get(s);if(c){let{start:d,end:T}=c,m=n.tileXYToRectangle(d.x,d.y,s),u=n.tileXYToRectangle(T.x,T.y,s);r=Math.min(m.west,r),t=Math.min(u.south,t),i=Math.max(u.east,i),a=Math.max(m.north,a)}return new V.Rectangle(r,t,i,a)}var h=class{_provider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(e){this._provider=e.provider,this._tileRanges=e.tileRanges,this._credit=e.credit||"custom",this._isCustom=e.isCustom!==void 0?e.isCustom:!0,this._rectangle=R(e.provider.tilingScheme,e.tileRanges),e.tileRanges.forEach((r,t)=>{this._provider.availability?.addAvailableTileRange(t,r.start.x,r.start.y,r.end.x,r.end.y)}),this._ready=!0}contains(e,r,t){if(this._tileRanges.size>0){if(!this._tileRanges.has(t))return!1;let a=this._tileRanges.get(t);return e>=a.start.x&&e<=a.end.x&&r>=a.start.y&&r<=a.end.y}let i=this._provider.tilingScheme.tileXYToRectangle(e,r,t);return I.Rectangle.intersection(i,this._rectangle)!==void 0}requestTileGeometry(e,r,t,i){if(!(!this._ready||!this.contains(e,r,t)||!this._provider.getTileDataAvailable(e,r,t)))return this._provider.requestTileGeometry(e,r,t,i)}getTileDataAvailable(e,r,t){if(this._tileRanges.size>0){if(!this._tileRanges.has(t))return!1;let i=this._tileRanges.get(t);return e>=i.start.x&&e<=i.end.x&&r>=i.start.y&&r<=i.end.y}return this._ready?this._provider.getTileDataAvailable(e,r,t)??!1:!1}get isCustom(){return this._isCustom}get credit(){return this._credit}get provider(){return this._provider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(e=>{async function n(r,t,i){let a=i?.credit||"custom",o=await I.CesiumTerrainProvider.fromUrl(r,{...i,credit:a});return new e({provider:o,tileRanges:t,credit:a})}e.fromUrl=n})(h||={});var v=class extends Array{add(e){if(Array.isArray(e)){for(let t of e)this.add(t);return this.length}let r;return e instanceof h?r=e:r=new h(e),this.push(r)}remove(e){if(Array.isArray(e))return e.forEach(t=>this.remove(t)),this;let r=this.indexOf(e);return r>=0&&this.splice(r,1),this}removeAll(){this.length=0}};var C=class n{_terrainAreas=new v;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e,r,t){this._terrainProvider=e,this._fallbackProvider=r,this._tilingScheme=e.tilingScheme,this._terrainAreas=new v(...t),this._availability=e.availability,this._ready=!0}static async create(e){try{let r;typeof e.terrainProvider=="string"?r=await p.CesiumTerrainProvider.fromUrl(e.terrainProvider,{requestVertexNormals:!0}):r=e.terrainProvider;let t;e.fallbackProvider?typeof e.fallbackProvider=="string"?t=await p.CesiumTerrainProvider.fromUrl(e.fallbackProvider,{requestVertexNormals:!0}):t=e.fallbackProvider:t=new p.EllipsoidTerrainProvider;let i=[];for(let a of e.terrainAreas){let o=typeof a.provider=="string"?await p.CesiumTerrainProvider.fromUrl(a.provider,{requestVertexNormals:!0}):a.provider;i.push(new h({provider:o,tileRanges:a.tileRanges,credit:a.credit,isCustom:a.isCustom}))}return new n(r,t,i)}catch(r){throw console.error("Failed to initialize HybridTerrainProvider:",r),r}}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get terrainAreas(){return[...this._terrainAreas]}get defaultProvider(){return this._terrainProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._terrainProvider?.credit}get errorEvent(){return this._terrainProvider.errorEvent}get hasWaterMask(){return this._terrainProvider.hasWaterMask}get hasVertexNormals(){return this._terrainProvider.hasVertexNormals}loadTileDataAvailability(e,r,t){return this._terrainProvider.loadTileDataAvailability(e,r,t)}getLevelMaximumGeometricError(e){return this._terrainProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,r,t,i){if(this._ready){for(let a of this._terrainAreas)if(a.contains(e,r,t))return a.requestTileGeometry(e,r,t,i);return this._terrainProvider.getTileDataAvailable(e,r,t)?this._terrainProvider.requestTileGeometry(e,r,t,i):this._fallbackProvider.requestTileGeometry(e,r,t,i)}}getTileDataAvailable(e,r,t){for(let i of this._terrainAreas)if(i.contains(e,r,t))return i.getTileDataAvailable(e,r,t);return this._terrainProvider.getTileDataAvailable(e,r,t)}};(e=>{async function n(r,t,i){let a=await p.CesiumTerrainProvider.fromUrl(r,{credit:"custom"});return e.create({terrainAreas:[{provider:a,tileRanges:i,credit:"custom"}],terrainProvider:t,fallbackProvider:new p.EllipsoidTerrainProvider})}e.createOverlay=n})(C||={});var N=require("cesium");function D(n,e,r){let t={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},i=new N.Viewer(e,{...t,...r});y(n,i);let a=n.imageryLayers;i.imageryLayers.removeAll();for(let c=0;c<a.length;c++){let d=a.get(c);i.imageryLayers.addImageryProvider(d.imageryProvider,c)}i.clock.startTime=n.clock.startTime.clone(),i.clock.stopTime=n.clock.stopTime.clone(),i.clock.currentTime=n.clock.currentTime.clone(),i.clock.multiplier=n.clock.multiplier,i.clock.clockStep=n.clock.clockStep,i.clock.clockRange=n.clock.clockRange,i.clock.shouldAnimate=n.clock.shouldAnimate,i.scene.globe.enableLighting=n.scene.globe.enableLighting,i.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,i.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let o=n.scene.screenSpaceCameraController.tiltEventTypes;o&&(i.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(o)?[...o]:o);let s=n.scene.screenSpaceCameraController.zoomEventTypes;return s&&(i.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(s)?[...s]:s),i}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { CesiumCollection, CesiumCollectionItem, Collection, CollectionEventType, EventHandler, NonFunction, Tag, WithTag } from './collection/index.cjs';
|
|
2
|
-
export { H as HybridTerrainProvider, T as TerrainArea, a as
|
|
3
|
-
export { TerrainAreas } from './terrain/index.cjs';
|
|
4
|
-
export {
|
|
2
|
+
export { H as HybridTerrainProvider, T as TerrainArea, a as TileRange } from './hybrid-terrain-provider-Cp_rA9j4.cjs';
|
|
3
|
+
export { TerrainAreas, computeRectangle } from './terrain/index.cjs';
|
|
4
|
+
export { TerrainVisualizer, isGetterOnly, syncCamera } from './utils/index.cjs';
|
|
5
5
|
export { cloneViewer } from './viewer/index.cjs';
|
|
6
6
|
import 'cesium';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { CesiumCollection, CesiumCollectionItem, Collection, CollectionEventType, EventHandler, NonFunction, Tag, WithTag } from './collection/index.js';
|
|
2
|
-
export { H as HybridTerrainProvider, T as TerrainArea, a as
|
|
3
|
-
export { TerrainAreas } from './terrain/index.js';
|
|
4
|
-
export {
|
|
2
|
+
export { H as HybridTerrainProvider, T as TerrainArea, a as TileRange } from './hybrid-terrain-provider-Cp_rA9j4.js';
|
|
3
|
+
export { TerrainAreas, computeRectangle } from './terrain/index.js';
|
|
4
|
+
export { TerrainVisualizer, isGetterOnly, syncCamera } from './utils/index.js';
|
|
5
5
|
export { cloneViewer } from './viewer/index.js';
|
|
6
6
|
import 'cesium';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as t,b as m,c as p,d as a}from"./chunk-3LRWGBW3.js";import{a as r,b as o,c as i}from"./chunk-DOPMSVYJ.js";import{a as n}from"./chunk-STARYORM.js";import{a as e}from"./chunk-YZ7AUGIO.js";export{i as Collection,a as HybridTerrainProvider,m as TerrainArea,p as TerrainAreas,r as TerrainVisualizer,n as cloneViewer,t as computeRectangle,o as isGetterOnly,e as syncCamera};
|
package/dist/terrain/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var h=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var R=(n,r)=>{for(var e in r)h(n,e,{get:r[e],enumerable:!0})},C=(n,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of P(r))!y.call(n,t)&&t!==e&&h(n,t,{get:()=>r[t],enumerable:!(i=A(r,t))||i.enumerable});return n};var w=n=>C(h({},"__esModule",{value:!0}),n);var x={};R(x,{HybridTerrainProvider:()=>d,TerrainArea:()=>o,TerrainAreas:()=>s,computeRectangle:()=>c});module.exports=w(x);var l=require("cesium");var v=require("cesium");var T=require("cesium");function c(n,r){if(r.size===0)return new T.Rectangle;let e=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY,u=Array.from(r.keys()),m=Math.min(...u),g=r.get(m);if(g){let{start:f,end:b}=g,p=n.tileXYToRectangle(f.x,f.y,m),_=n.tileXYToRectangle(b.x,b.y,m);e=Math.min(p.west,e),i=Math.min(_.south,i),t=Math.max(_.east,t),a=Math.max(p.north,a)}return new T.Rectangle(e,i,t,a)}var o=class{_provider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(r){this._provider=r.provider,this._tileRanges=r.tileRanges,this._credit=r.credit||"custom",this._isCustom=r.isCustom!==void 0?r.isCustom:!0,this._rectangle=c(r.provider.tilingScheme,r.tileRanges),r.tileRanges.forEach((e,i)=>{this._provider.availability?.addAvailableTileRange(i,e.start.x,e.start.y,e.end.x,e.end.y)}),this._ready=!0}contains(r,e,i){if(this._tileRanges.size>0){if(!this._tileRanges.has(i))return!1;let a=this._tileRanges.get(i);return r>=a.start.x&&r<=a.end.x&&e>=a.start.y&&e<=a.end.y}let t=this._provider.tilingScheme.tileXYToRectangle(r,e,i);return v.Rectangle.intersection(t,this._rectangle)!==void 0}requestTileGeometry(r,e,i,t){if(!(!this._ready||!this.contains(r,e,i)||!this._provider.getTileDataAvailable(r,e,i)))return this._provider.requestTileGeometry(r,e,i,t)}getTileDataAvailable(r,e,i){if(this._tileRanges.size>0){if(!this._tileRanges.has(i))return!1;let t=this._tileRanges.get(i);return r>=t.start.x&&r<=t.end.x&&e>=t.start.y&&e<=t.end.y}return this._ready?this._provider.getTileDataAvailable(r,e,i)??!1:!1}get isCustom(){return this._isCustom}get credit(){return this._credit}get provider(){return this._provider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(r=>{async function n(e,i,t){let a=t?.credit||"custom",u=await v.CesiumTerrainProvider.fromUrl(e,{...t,credit:a});return new r({provider:u,tileRanges:i,credit:a})}r.fromUrl=n})(o||={});var s=class extends Array{add(r){if(Array.isArray(r)){for(let i of r)this.add(i);return this.length}let e;return r instanceof o?e=r:e=new o(r),this.push(e)}remove(r){if(Array.isArray(r))return r.forEach(i=>this.remove(i)),this;let e=this.indexOf(r);return e>=0&&this.splice(e,1),this}removeAll(){this.length=0}};var d=class n{_terrainAreas=new s;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(r,e,i){this._terrainProvider=r,this._fallbackProvider=e,this._tilingScheme=r.tilingScheme,this._terrainAreas=new s(...i),this._availability=r.availability,this._ready=!0}static async create(r){try{let e;typeof r.terrainProvider=="string"?e=await l.CesiumTerrainProvider.fromUrl(r.terrainProvider,{requestVertexNormals:!0}):e=r.terrainProvider;let i;r.fallbackProvider?typeof r.fallbackProvider=="string"?i=await l.CesiumTerrainProvider.fromUrl(r.fallbackProvider,{requestVertexNormals:!0}):i=r.fallbackProvider:i=new l.EllipsoidTerrainProvider;let t=[];for(let a of r.terrainAreas){let u=typeof a.provider=="string"?await l.CesiumTerrainProvider.fromUrl(a.provider,{requestVertexNormals:!0}):a.provider;t.push(new o({provider:u,tileRanges:a.tileRanges,credit:a.credit,isCustom:a.isCustom}))}return new n(e,i,t)}catch(e){throw console.error("Failed to initialize HybridTerrainProvider:",e),e}}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get terrainAreas(){return[...this._terrainAreas]}get defaultProvider(){return this._terrainProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._terrainProvider?.credit}get errorEvent(){return this._terrainProvider.errorEvent}get hasWaterMask(){return this._terrainProvider.hasWaterMask}get hasVertexNormals(){return this._terrainProvider.hasVertexNormals}loadTileDataAvailability(r,e,i){return this._terrainProvider.loadTileDataAvailability(r,e,i)}getLevelMaximumGeometricError(r){return this._terrainProvider.getLevelMaximumGeometricError(r)}requestTileGeometry(r,e,i,t){if(this._ready){for(let a of this._terrainAreas)if(a.contains(r,e,i))return a.requestTileGeometry(r,e,i,t);return this._terrainProvider.getTileDataAvailable(r,e,i)?this._terrainProvider.requestTileGeometry(r,e,i,t):this._fallbackProvider.requestTileGeometry(r,e,i,t)}}getTileDataAvailable(r,e,i){for(let t of this._terrainAreas)if(t.contains(r,e,i))return t.getTileDataAvailable(r,e,i);return this._terrainProvider.getTileDataAvailable(r,e,i)}};(r=>{async function n(e,i,t){let a=await l.CesiumTerrainProvider.fromUrl(e,{credit:"custom"});return r.create({terrainAreas:[{provider:a,tileRanges:t,credit:"custom"}],terrainProvider:i,fallbackProvider:new l.EllipsoidTerrainProvider})}r.createOverlay=n})(d||={});
|
package/dist/terrain/index.d.cts
CHANGED
|
@@ -1,22 +1,39 @@
|
|
|
1
|
-
import { T as TerrainArea } from '../hybrid-terrain-provider-
|
|
2
|
-
export { H as HybridTerrainProvider
|
|
3
|
-
import 'cesium';
|
|
1
|
+
import { a as TileRange, T as TerrainArea } from '../hybrid-terrain-provider-Cp_rA9j4.cjs';
|
|
2
|
+
export { H as HybridTerrainProvider } from '../hybrid-terrain-provider-Cp_rA9j4.cjs';
|
|
3
|
+
import { TilingScheme, Rectangle } from 'cesium';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Calculates a bounding rectangle that encompasses all the specified tile ranges.
|
|
7
|
+
* @param tilingScheme The tiling scheme to use for calculation.
|
|
8
|
+
* @param from Tile ranges to calculate from.
|
|
9
|
+
*/
|
|
10
|
+
declare function computeRectangle(tilingScheme: TilingScheme, from: Map<number, TileRange>): Rectangle;
|
|
4
11
|
|
|
5
12
|
declare class TerrainAreas extends Array<TerrainArea> {
|
|
6
13
|
/**
|
|
7
14
|
* Adds a new terrain area to the collection.
|
|
8
15
|
* @param area A TerrainArea instance or constructor options
|
|
9
|
-
* @returns
|
|
16
|
+
* @returns The index of the added item
|
|
17
|
+
*/
|
|
18
|
+
add(area: TerrainArea | TerrainArea.ConstructorOptions): number;
|
|
19
|
+
/**
|
|
20
|
+
* Adds terrain areas to the collection.
|
|
21
|
+
* @param areas An array of TerrainArea instance or constructor options
|
|
22
|
+
* @returns The index of the added item
|
|
10
23
|
*/
|
|
11
|
-
add(
|
|
24
|
+
add(areas: (TerrainArea | TerrainArea.ConstructorOptions)[]): number;
|
|
12
25
|
/**
|
|
13
26
|
* Removes a terrain area from the collection.
|
|
14
27
|
*/
|
|
15
|
-
remove(area: TerrainArea):
|
|
28
|
+
remove(area: TerrainArea): this;
|
|
29
|
+
/**
|
|
30
|
+
* Removes multiple terrain areas from the collection.
|
|
31
|
+
*/
|
|
32
|
+
remove(areas: TerrainArea[]): this;
|
|
16
33
|
/**
|
|
17
34
|
* Clears all terrain areas.
|
|
18
35
|
*/
|
|
19
|
-
|
|
36
|
+
removeAll(): void;
|
|
20
37
|
}
|
|
21
38
|
|
|
22
|
-
export { TerrainArea, TerrainAreas };
|
|
39
|
+
export { TerrainArea, TerrainAreas, TileRange, computeRectangle };
|
package/dist/terrain/index.d.ts
CHANGED
|
@@ -1,22 +1,39 @@
|
|
|
1
|
-
import { T as TerrainArea } from '../hybrid-terrain-provider-
|
|
2
|
-
export { H as HybridTerrainProvider
|
|
3
|
-
import 'cesium';
|
|
1
|
+
import { a as TileRange, T as TerrainArea } from '../hybrid-terrain-provider-Cp_rA9j4.js';
|
|
2
|
+
export { H as HybridTerrainProvider } from '../hybrid-terrain-provider-Cp_rA9j4.js';
|
|
3
|
+
import { TilingScheme, Rectangle } from 'cesium';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Calculates a bounding rectangle that encompasses all the specified tile ranges.
|
|
7
|
+
* @param tilingScheme The tiling scheme to use for calculation.
|
|
8
|
+
* @param from Tile ranges to calculate from.
|
|
9
|
+
*/
|
|
10
|
+
declare function computeRectangle(tilingScheme: TilingScheme, from: Map<number, TileRange>): Rectangle;
|
|
4
11
|
|
|
5
12
|
declare class TerrainAreas extends Array<TerrainArea> {
|
|
6
13
|
/**
|
|
7
14
|
* Adds a new terrain area to the collection.
|
|
8
15
|
* @param area A TerrainArea instance or constructor options
|
|
9
|
-
* @returns
|
|
16
|
+
* @returns The index of the added item
|
|
17
|
+
*/
|
|
18
|
+
add(area: TerrainArea | TerrainArea.ConstructorOptions): number;
|
|
19
|
+
/**
|
|
20
|
+
* Adds terrain areas to the collection.
|
|
21
|
+
* @param areas An array of TerrainArea instance or constructor options
|
|
22
|
+
* @returns The index of the added item
|
|
10
23
|
*/
|
|
11
|
-
add(
|
|
24
|
+
add(areas: (TerrainArea | TerrainArea.ConstructorOptions)[]): number;
|
|
12
25
|
/**
|
|
13
26
|
* Removes a terrain area from the collection.
|
|
14
27
|
*/
|
|
15
|
-
remove(area: TerrainArea):
|
|
28
|
+
remove(area: TerrainArea): this;
|
|
29
|
+
/**
|
|
30
|
+
* Removes multiple terrain areas from the collection.
|
|
31
|
+
*/
|
|
32
|
+
remove(areas: TerrainArea[]): this;
|
|
16
33
|
/**
|
|
17
34
|
* Clears all terrain areas.
|
|
18
35
|
*/
|
|
19
|
-
|
|
36
|
+
removeAll(): void;
|
|
20
37
|
}
|
|
21
38
|
|
|
22
|
-
export { TerrainArea, TerrainAreas };
|
|
39
|
+
export { TerrainArea, TerrainAreas, TileRange, computeRectangle };
|
package/dist/terrain/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r,b as
|
|
1
|
+
import{a as r,b as e,c as o,d as t}from"../chunk-3LRWGBW3.js";export{t as HybridTerrainProvider,e as TerrainArea,o as TerrainAreas,r as computeRectangle};
|
package/dist/utils/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var I=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var S=(n,e)=>{for(var t in e)I(n,t,{get:e[t],enumerable:!0})},j=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of P(e))!V.call(n,r)&&r!==t&&I(n,r,{get:()=>e[r],enumerable:!(i=O(e,r))||i.enumerable});return n};var z=n=>j(I({},"__esModule",{value:!0}),n);var F={};S(F,{TerrainVisualizer:()=>v,isGetterOnly:()=>y,syncCamera:()=>L});module.exports=z(F);var s=require("cesium");var f=require("cesium");var E=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(a=>a(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache(){this._valuesCache=null}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),e}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)){let r=this.collection.remove(e);return r&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),r}if(Array.isArray(e)){if(e.length===0)return!1;let r=!1;for(let a of e)this.remove(a)&&(r=!0);return r}let t=this.get(e);if(t.length===0)return!1;let i=!1;for(let r of t)this.remove(r)&&(i=!0);return i}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof f.EntityCollection)return this.collection.values;{let e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t));return e}}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,f.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,f.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,f.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let a of r)if(e in a&&typeof a[e]!="function"){if(y(a,e))throw Error(`setProperty(${a}, ${e}) failed; The property is readonly.`);a[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,a)=>e(r,a))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},x=E;var v=class n{_viewer;_collection;_hybridTerrain;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",s.Color.RED],["default",s.Color.BLUE],["fallback",s.Color.GRAY],["grid",s.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new x({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._hybridTerrain=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._hybridTerrain)return;this._collection.remove(n.tag.grid),this._level=e;let t=this._hybridTerrain.tilingScheme;this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new s.TileCoordinatesImageryProvider({tilingScheme:t,color:s.Color.YELLOW})));let i=(o,l,d)=>{if(this._hybridTerrain){for(let m of this._hybridTerrain.terrainAreas)if(m.contains(o,l,d))return m.isCustom?this._colors.get("custom")||s.Color.RED:this._colors.get("default")||s.Color.BLUE;if(this._hybridTerrain.getTileDataAvailable(o,l,d))return this._colors.get("default")||s.Color.BLUE}return this._colors.get("fallback")||s.Color.TRANSPARENT},r=this._getVisibleRectangle();if(!r)return;function a(o){return o&&Number.isFinite(o.west)&&Number.isFinite(o.south)&&Number.isFinite(o.east)&&Number.isFinite(o.north)&&o.west<=o.east&&o.south<=o.north}if(!a(r)){console.warn("Invalid visible rectangle detected, skipping grid display");return}try{let o=t.positionToTileXY(s.Rectangle.northwest(r),e),l=t.positionToTileXY(s.Rectangle.southeast(r),e);if(!o||!l)return;let d=100,m=Math.min(l.x-o.x+1,d),b=Math.min(l.y-o.y+1,d);for(let c=o.x;c<=o.x+m-1;c++)for(let h=o.y;h<=o.y+b-1;h++)try{let u=t.tileXYToRectangle(c,h,e);if(!a(u)){console.warn(`Invalid rectangle for tile (${c}, ${h}, ${e}), skipping`);continue}let T=i(c,h,e),g=n.createRectangle(u,T.withAlpha(.3));g.properties?.addProperty("tileX",c),g.properties?.addProperty("tileY",h),g.properties?.addProperty("tileLevel",e),this._collection.add(g,n.tag.grid)}catch(u){console.warn(`Error creating tile (${c}, ${h}, ${e}): ${u.message}`);continue}console.log("\u{1F680} ~ TerrainVisualizer ~ showGrid ~ collection:",this._collection),this._visible=!0}catch(o){console.error("Error displaying tile grid:",o)}}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,a){return new s.Entity({rectangle:{coordinates:r,material:a,heightReference:s.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,a,o){let l=o?.tag||"terrain_area_visualization",d=o?.color||s.Color.RED,m=o?.maxTilesToShow||100,b=o?.show??!0,c=o?.alpha||.7,h=o?.tileAlpha||.2,u=new x({collection:a.entities,tag:l}),{rectangle:T}=r;if(u.add(i.createRectangle(T,d.withAlpha(c)),l),b&&r.tileRanges.size>0){let{tilingScheme:g}=r.provider,_=0;r.tileRanges.forEach((p,A)=>{for(let C=p.start.x;C<=p.end.x&&_<m;C++)for(let w=p.start.y;w<=p.end.y&&_<m;w++){let M=g.tileXYToRectangle(C,w,A);u.add(e(M,d.withAlpha(h)),`${l}_tile`),_++}})}return u}i.visualize=t})(v||={});function y(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var R=require("cesium");function L(n,e){if((0,R.defined)(n)&&(0,R.defined)(e)){let{camera:t}=n;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,7 +1,127 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import '../
|
|
4
|
-
|
|
1
|
+
import { Viewer, Color, EntityCollection, Entity, Rectangle } from 'cesium';
|
|
2
|
+
import { H as HybridTerrainProvider, T as TerrainArea } from '../hybrid-terrain-provider-Cp_rA9j4.cjs';
|
|
3
|
+
import { Collection } from '../collection/index.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @class
|
|
7
|
+
* Utility class for visualizing terrain provider boundaries and debugging terrain loading.
|
|
8
|
+
*/
|
|
9
|
+
declare class TerrainVisualizer {
|
|
10
|
+
private _viewer;
|
|
11
|
+
private _collection;
|
|
12
|
+
private _hybridTerrain?;
|
|
13
|
+
private _visible;
|
|
14
|
+
private _level;
|
|
15
|
+
private _tileCoordinatesLayer;
|
|
16
|
+
private _colors;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new `TerrainVisualizer`.
|
|
19
|
+
* @param viewer The Cesium viewer instance
|
|
20
|
+
* @param options {@link TerrainVisualizer.ConstructorOptions}
|
|
21
|
+
*/
|
|
22
|
+
constructor(viewer: Viewer, options?: TerrainVisualizer.ConstructorOptions);
|
|
23
|
+
/**
|
|
24
|
+
* Sets the terrain provider to visualize.
|
|
25
|
+
* @param terrainProvider The terrain provider to visualize.
|
|
26
|
+
*/
|
|
27
|
+
setTerrainProvider(terrainProvider: HybridTerrainProvider): void;
|
|
28
|
+
/**
|
|
29
|
+
* Updates all active visualizations.
|
|
30
|
+
*/
|
|
31
|
+
update(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Clears all visualizations.
|
|
34
|
+
*/
|
|
35
|
+
clear(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Shows a grid of tiles at the specified level.
|
|
38
|
+
* @param level The zoom level to visualize
|
|
39
|
+
*/
|
|
40
|
+
show(level?: number): void;
|
|
41
|
+
/**
|
|
42
|
+
* Hides the tile grid.
|
|
43
|
+
*/
|
|
44
|
+
hide(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Sets the colors used for visualization.
|
|
47
|
+
* @param colors Map of role names to colors
|
|
48
|
+
*/
|
|
49
|
+
setColors(colors: Record<string, Color>): void;
|
|
50
|
+
/**
|
|
51
|
+
* Flies the camera to focus on a terrain area.
|
|
52
|
+
* @param area The terrain area to focus on.
|
|
53
|
+
* @param options {@link Viewer.flyTo}
|
|
54
|
+
*/
|
|
55
|
+
flyTo(area: TerrainArea, options?: {
|
|
56
|
+
duration?: number;
|
|
57
|
+
}): void;
|
|
58
|
+
/**
|
|
59
|
+
* Gets the rectangle representing the current view.
|
|
60
|
+
* @returns The current view rectangle or undefined.
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
private _getVisibleRectangle;
|
|
64
|
+
/** The current zoom level set on the visualizer. */
|
|
65
|
+
get level(): number;
|
|
66
|
+
/** Set zoom level on the visualizer. */
|
|
67
|
+
set level(level: number);
|
|
68
|
+
/** Whether the grid is currently visible. */
|
|
69
|
+
get visible(): boolean;
|
|
70
|
+
/** The collection used in the visualizer. */
|
|
71
|
+
get collection(): Collection<EntityCollection, Entity>;
|
|
72
|
+
/** The viewer used in the visualizer */
|
|
73
|
+
get viewer(): Viewer;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @namespace
|
|
77
|
+
* Contains types, utility functions, and constants for terrain visualization.
|
|
78
|
+
*/
|
|
79
|
+
declare namespace TerrainVisualizer {
|
|
80
|
+
/** Initialization options for `TerrainVisualizer` constructor. */
|
|
81
|
+
interface ConstructorOptions {
|
|
82
|
+
/** Colors to use for different visualization elements */
|
|
83
|
+
colors?: Record<string, Color>;
|
|
84
|
+
/** Whether to show boundaries initially. */
|
|
85
|
+
boundaries?: boolean;
|
|
86
|
+
/** Whether to show tile grid initially. */
|
|
87
|
+
tile?: boolean;
|
|
88
|
+
/** Initial zoom level to use for visualizations. */
|
|
89
|
+
activeLevel?: number;
|
|
90
|
+
/** Terrain provider to visualize. */
|
|
91
|
+
terrainProvider?: HybridTerrainProvider;
|
|
92
|
+
}
|
|
93
|
+
/** Tag constants for entity collection management. */
|
|
94
|
+
const tag: {
|
|
95
|
+
default: string;
|
|
96
|
+
boundary: string;
|
|
97
|
+
grid: string;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Creates a ground-clamped rectangle entity for visualization.
|
|
101
|
+
* @param rectangle The rectangle to visualize
|
|
102
|
+
* @param color The color to use
|
|
103
|
+
* @returns A new entity
|
|
104
|
+
*/
|
|
105
|
+
function createRectangle(rectangle: Rectangle, color: Color): Entity;
|
|
106
|
+
/** Options for {@link TerrainVisualizer.visualize} */
|
|
107
|
+
interface Options {
|
|
108
|
+
color?: Color;
|
|
109
|
+
show?: boolean;
|
|
110
|
+
maxTilesToShow?: number;
|
|
111
|
+
levels?: number[];
|
|
112
|
+
tag?: string;
|
|
113
|
+
alpha?: number;
|
|
114
|
+
tileAlpha?: number;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Visualizes a specific terrain area in a viewer.
|
|
118
|
+
* @param terrain The terrain area to visualize.
|
|
119
|
+
* @param viewer The Cesium viewer.
|
|
120
|
+
* @param options Visualization options.
|
|
121
|
+
* @returns Collection of created entities.
|
|
122
|
+
*/
|
|
123
|
+
function visualize(area: TerrainArea, viewer: Viewer, options?: Options): Collection<EntityCollection, Entity>;
|
|
124
|
+
}
|
|
5
125
|
|
|
6
126
|
/**
|
|
7
127
|
* Examine the property descriptors at runtime
|
|
@@ -12,4 +132,11 @@ import '../collection/index.cjs';
|
|
|
12
132
|
*/
|
|
13
133
|
declare function isGetterOnly(o: object, k: string | number | symbol): boolean;
|
|
14
134
|
|
|
15
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Copies camera state from source viewer to destination viewer.
|
|
137
|
+
* @param source The source viewer to copy camera states from.
|
|
138
|
+
* @param dest The destination viewer to apply camera properties from the source.
|
|
139
|
+
*/
|
|
140
|
+
declare function syncCamera(source: Viewer, dest: Viewer): void;
|
|
141
|
+
|
|
142
|
+
export { TerrainVisualizer, isGetterOnly, syncCamera };
|