@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/utils/index.d.ts
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.js';
|
|
3
|
+
import { Collection } from '../collection/index.js';
|
|
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.js';
|
|
|
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 };
|
package/dist/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"../chunk-
|
|
1
|
+
import{a,b}from"../chunk-DOPMSVYJ.js";import{a as c}from"../chunk-YZ7AUGIO.js";export{a as TerrainVisualizer,b as isGetterOnly,c as syncCamera};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juun-roh/cesium-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Utilities to handle Cesium classes easier.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Cesium",
|
|
@@ -67,18 +67,18 @@
|
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@changesets/cli": "^2.29.
|
|
70
|
+
"@changesets/cli": "^2.29.2",
|
|
71
71
|
"@commitlint/cli": "^19.8.0",
|
|
72
72
|
"@commitlint/config-conventional": "^19.8.0",
|
|
73
73
|
"@commitlint/cz-commitlint": "^19.8.0",
|
|
74
74
|
"@commitlint/format": "^19.8.0",
|
|
75
75
|
"@commitlint/types": "^19.8.0",
|
|
76
|
-
"@eslint/js": "^9.
|
|
76
|
+
"@eslint/js": "^9.25.0",
|
|
77
77
|
"@typescript-eslint/eslint-plugin": "^8.30.1",
|
|
78
78
|
"@typescript-eslint/parser": "^8.30.1",
|
|
79
79
|
"@vitest/coverage-v8": "3.1.1",
|
|
80
80
|
"cesium": "^1.128.0",
|
|
81
|
-
"eslint": "^9.
|
|
81
|
+
"eslint": "^9.25.0",
|
|
82
82
|
"eslint-plugin-jsdoc": "^50.6.9",
|
|
83
83
|
"eslint-plugin-prettier": "^5.2.6",
|
|
84
84
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
@@ -86,10 +86,9 @@
|
|
|
86
86
|
"husky": "^9.1.7",
|
|
87
87
|
"rimraf": "^6.0.1",
|
|
88
88
|
"tsup": "^8.4.0",
|
|
89
|
-
"typedoc": "^0.28.
|
|
90
|
-
"typedoc-material-theme": "^1.4.0",
|
|
89
|
+
"typedoc": "^0.28.3",
|
|
91
90
|
"typescript": "^5.8.3",
|
|
92
|
-
"vite": "^6.2
|
|
91
|
+
"vite": "^6.3.2",
|
|
93
92
|
"vitest": "^3.1.1"
|
|
94
93
|
},
|
|
95
94
|
"scripts": {
|
package/dist/chunk-C52KJ2WP.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{GeographicTilingScheme as h,Rectangle as c}from"cesium";var o=class{_rectangle;_tilingScheme;_tileRanges;_levels;constructor(e,r){if(this._tilingScheme=r||new h,this._rectangle=new c,this._tileRanges=new Map,this._levels=new Set,e.type==="rectangle"&&e.rectangle)this._rectangle=c.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 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._tilingScheme.tileXYToRectangle(e,r,t);return c.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,a=Array.from(this._tileRanges.keys());if(a.length===0){this._rectangle=c.MAX_VALUE;return}let n=Math.min(...a),u=this._tileRanges.get(n);if(u){let{start:m,end:v}=u,b=this._tilingScheme.tileXYToRectangle(m.x,m.y,n),T=this._tilingScheme.tileXYToRectangle(v.x,v.y,n);e=Math.min(b.west,e),r=Math.min(T.south,r),t=Math.max(T.east,t),i=Math.max(b.north,i)}this._rectangle=new c(e,r,t,i)}};(r=>{function l(t,i,a,n=new h){let u=new Map;return u.set(a,{start:{x:t,y:i},end:{x:t,y:i}}),new r({type:"tileRange",tileRanges:u},n)}r.fromTile=l;function e(t,i=new h){return new r({type:"rectangle",rectangle:c.clone(t)},i)}r.fromRectangle=e})(o||={});import{CesiumTerrainProvider as p}from"cesium";var s=class l{_provider;_bounds;_levels;_ready=!1;_credit;_isCustom;constructor(e,r){this._bounds=e.bounds instanceof o?e.bounds:new o(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 p.fromUrl(e.provider,{requestVertexNormals:!0,credit:e.credit||"custom"}):r=e.provider,new l(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 l(r,t,i,a="custom"){let n=new o({type:"tileRange",tileRanges:t});return await e.create({provider:r,bounds:n,levels:i||Object.keys(t).map(m=>parseInt(m)),credit:a})}e.fromUrl=l})(s||={});var d=class extends Array{async add(e){let r;return e instanceof s?r=e:r=await s.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}};import{CesiumTerrainProvider as _,EllipsoidTerrainProvider as f,GeographicTilingScheme as P}from"cesium";var g=class l{_terrainAreas=new d;_terrainProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e,r,t){this._terrainProvider=e,this._fallbackProvider=r,this._tilingScheme=e.tilingScheme||new P,this._terrainAreas=new d(...t),this._availability=e.availability,this._ready=!0}static async create(e){try{let r;typeof e.terrainProvider=="string"?r=await _.fromUrl(e.terrainProvider,{requestVertexNormals:!0}):r=e.terrainProvider;let t;e.fallbackProvider?typeof e.fallbackProvider=="string"?t=await _.fromUrl(e.fallbackProvider,{requestVertexNormals:!0}):t=e.fallbackProvider:t=new f;let i=[];for(let a of e.terrainAreas){let n=await s.create(a);i.push(n)}return new l(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){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 l(r,t,i,a){return e.create({terrainAreas:[{provider:r,bounds:{type:"tileRange",tileRanges:i},levels:a||Object.keys(i).map(n=>parseInt(n)),credit:"custom"}],terrainProvider:t,fallbackProvider:new f})}e.createOverlay=l})(g||={});export{o as a,s as b,d as c,g as d};
|
package/dist/chunk-HC6YX7RQ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Color as c,Entity as B,HeightReference as V,Rectangle as L,TileCoordinatesImageryProvider as S}from"cesium";import{defined as C,EntityCollection as P}from"cesium";var w=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}_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){return this.collection.contains(e)}remove(e){let t=this.collection.remove(e);return t&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),t}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}get values(){if(this.collection instanceof P)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}getByTag(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}getFirstByTag(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}getTags(){return Array.from(this._tagMap.keys())}hasTag(e){let t=this._tagMap.get(e);return!!t&&t.size>0}updateTag(e,t){let i=this.getByTag(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}removeByTag(e){let t=0;return Array.isArray(e)?e.forEach(i=>{t+=this.removeByTag(i)}):this.getByTag(e).forEach(i=>{this.remove(i)&&t++}),t}show(e){let t=this.getByTag(e),i=0;for(let r of t)C(r.show)&&(r.show=!0,i++);return i}hide(e){let t=this.getByTag(e),i=0;for(let r of t)C(r.show)&&(r.show=!1,i++);return i}toggle(e){let t=this.getByTag(e),i=0;for(let r of t)C(r.show)&&(r.show=!r.show,i++);return i}setProperty(e,t,i=this.tag){let r=this.getByTag(i),a=0;for(let o of r)if(e in o&&typeof o[e]!="function"){if(E(o,e))throw Error(`setProperty(${o}, ${e}) failed; The property is readonly.`);o[e]=t,a++}return a}filter(e,t){return(t?this.getByTag(t):this.values).filter(e)}forEach(e,t){(t?this.getByTag(t):this.values).forEach((r,a)=>e(r,a))}},I=w;var f=class n{_viewer;_collection;_hybridTerrain;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",c.RED],["default",c.BLUE],["fallback",c.GRAY],["grid",c.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new I({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.removeByTag(this._collection.getTags())}show(e=15){if(!this._hybridTerrain)return;this._collection.removeByTag(n.tag.grid),this._level=e;let t=this._hybridTerrain.tilingScheme;this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new S({tilingScheme:t,color:c.YELLOW})));let i=(o,s,d)=>{if(this._hybridTerrain){for(let u of this._hybridTerrain.terrainAreas)if(u.contains(o,s,d))return u.isCustom?this._colors.get("custom")||c.RED:this._colors.get("default")||c.BLUE;if(this._hybridTerrain.getTileDataAvailable(o,s,d))return this._colors.get("default")||c.BLUE}return this._colors.get("fallback")||c.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(L.northwest(r),e),s=t.positionToTileXY(L.southeast(r),e);if(!o||!s)return;let d=100,u=Math.min(s.x-o.x+1,d),T=Math.min(s.y-o.y+1,d);for(let h=o.x;h<=o.x+u-1;h++)for(let g=o.y;g<=o.y+T-1;g++)try{let l=t.tileXYToRectangle(h,g,e);if(!a(l)){console.warn(`Invalid rectangle for tile (${h}, ${g}, ${e}), skipping`);continue}let v=i(h,g,e),m=n.createRectangle(l,v.withAlpha(.3));m.properties?.addProperty("tileX",h),m.properties?.addProperty("tileY",g),m.properties?.addProperty("tileLevel",e),this._collection.add(m,n.tag.grid)}catch(l){console.warn(`Error creating tile (${h}, ${g}, ${e}): ${l.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.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(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e.bounds;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 B({rectangle:{coordinates:r,material:a,heightReference:V.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,a,o){let s=o?.tag||"terrain_area_visualization",d=o?.color||c.RED,u=o?.maxTilesToShow||100,T=o?.show??!0,h=o?.alpha||.7,g=o?.tileAlpha||.2,l="provider"in r?r.bounds:r,v=new I({collection:a.entities,tag:s}),{rectangle:m}=l;if(v.add(i.createRectangle(m,d.withAlpha(h)),s),T&&l.levels.size>0){let{tilingScheme:A}=l;l.levels.forEach(x=>{let p=0,{tileRanges:R}=l;for(let[M,y]of R.entries())if(M===x)for(let b=y.start.x;b<=y.end.x&&p<u;b++)for(let _=y.start.y;_<=y.end.y&&p<u;_++){let O=A.tileXYToRectangle(b,_,x);v.add(e(O,d.withAlpha(g)),`${s}_tile`),p++}})}return v}i.visualize=t})(f||={});function E(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}export{f as a,E as b,I as c};
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { Viewer, Color, EntityCollection, Entity, Rectangle } from 'cesium';
|
|
2
|
-
import { H as HybridTerrainProvider, T as TerrainArea, a as TerrainBounds } from './hybrid-terrain-provider-C6aXdtyo.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(terrain: TerrainArea | TerrainBounds, viewer: Viewer, options?: Options): Collection<EntityCollection, Entity>;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Copies camera state from source viewer to destination viewer.
|
|
128
|
-
* @param source The source viewer to copy camera states from.
|
|
129
|
-
* @param dest The destination viewer to apply camera properties from the source.
|
|
130
|
-
*/
|
|
131
|
-
declare function syncCamera(source: Viewer, dest: Viewer): void;
|
|
132
|
-
|
|
133
|
-
export { TerrainVisualizer as T, syncCamera as s };
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { Viewer, Color, EntityCollection, Entity, Rectangle } from 'cesium';
|
|
2
|
-
import { H as HybridTerrainProvider, T as TerrainArea, a as TerrainBounds } from './hybrid-terrain-provider-C6aXdtyo.js';
|
|
3
|
-
import { Collection } from './collection/index.js';
|
|
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(terrain: TerrainArea | TerrainBounds, viewer: Viewer, options?: Options): Collection<EntityCollection, Entity>;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Copies camera state from source viewer to destination viewer.
|
|
128
|
-
* @param source The source viewer to copy camera states from.
|
|
129
|
-
* @param dest The destination viewer to apply camera properties from the source.
|
|
130
|
-
*/
|
|
131
|
-
declare function syncCamera(source: Viewer, dest: Viewer): void;
|
|
132
|
-
|
|
133
|
-
export { TerrainVisualizer as T, syncCamera as s };
|