@juun-roh/cesium-utils 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/index.cjs +1 -1
- package/dist/dev/index.d.cts +1 -125
- package/dist/dev/index.d.ts +1 -125
- package/dist/dev/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/terrain/dev/index.cjs +1 -0
- package/dist/terrain/dev/index.d.cts +125 -0
- package/dist/terrain/dev/index.d.ts +125 -0
- package/dist/terrain/dev/index.js +1 -0
- package/package.json +28 -23
package/dist/dev/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var b=(e,n)=>{for(var t in n)f(e,t,{get:n[t],enumerable:!0})},m=(e,n,t,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of w(n))!T.call(e,o)&&o!==t&&f(e,o,{get:()=>n[o],enumerable:!(c=g(n,o))||c.enumerable});return e};var E=e=>m(f({},"__esModule",{value:!0}),e);var v={};b(v,{Deprecate:()=>l,deprecate:()=>S});module.exports=E(v);var x;(D=>{let e=new Set,n=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(r,s={}){if(!n)return;let{once:i=!0,prefix:a="[DEPRECATED]",includeStack:p=!0,removeInVersion:d}=s;if(i&&e.has(r))return;let u=`${a} ${r}`;d&&(u+=` This feature will be removed in ${d}.`),typeof console<"u"&&console.warn&&(p?(console.warn(u),console.trace("Deprecation stack trace:")):console.warn(u)),i&&e.add(r)}D.warn=t;function c(r,s,i={}){let a=((...p)=>(t(s,i),r(...p)));return Object.defineProperty(a,"name",{value:r.name,configurable:!0}),a}D.deprecate=c;function o(){e.clear()}D.clear=o;function I(){return e.size}D.getWarningCount=I;function h(r){return e.has(r)}D.hasShown=h})(x||={});var l=x;var S=l.deprecate;
|
package/dist/dev/index.d.cts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { Viewer, Color, Rectangle } from 'cesium';
|
|
2
|
-
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-Th8n2hZ1.cjs';
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* Utility for managing deprecation warnings in the cesium-utils library.
|
|
6
3
|
* Provides runtime warnings to help developers identify deprecated API usage.
|
|
@@ -96,127 +93,6 @@ declare namespace Deprecate {
|
|
|
96
93
|
function hasShown(message: string): boolean;
|
|
97
94
|
}
|
|
98
95
|
|
|
99
|
-
/**
|
|
100
|
-
* @class
|
|
101
|
-
* Utility class for visualizing terrain provider boundaries and debugging terrain loading.
|
|
102
|
-
*/
|
|
103
|
-
declare class TerrainVisualizer {
|
|
104
|
-
private _viewer;
|
|
105
|
-
private _terrainProvider;
|
|
106
|
-
private _visible;
|
|
107
|
-
private _tileCoordinatesLayer;
|
|
108
|
-
private _hybridImageryLayer;
|
|
109
|
-
private _colors;
|
|
110
|
-
/**
|
|
111
|
-
* Creates a new `TerrainVisualizer`.
|
|
112
|
-
* @param viewer The Cesium viewer instance
|
|
113
|
-
* @param options {@link TerrainVisualizer.ConstructorOptions}
|
|
114
|
-
*/
|
|
115
|
-
constructor(viewer: Viewer, options: TerrainVisualizer.ConstructorOptions);
|
|
116
|
-
/**
|
|
117
|
-
* Sets the terrain provider to visualize.
|
|
118
|
-
* @param terrainProvider The terrain provider to visualize.
|
|
119
|
-
*/
|
|
120
|
-
setTerrainProvider(terrainProvider: HybridTerrainProvider): void;
|
|
121
|
-
/**
|
|
122
|
-
* Updates all active visualizations.
|
|
123
|
-
*/
|
|
124
|
-
update(): void;
|
|
125
|
-
/**
|
|
126
|
-
* Clears all visualizations.
|
|
127
|
-
*/
|
|
128
|
-
clear(): void;
|
|
129
|
-
/**
|
|
130
|
-
* Shows terrain visualization using HybridImageryProvider.
|
|
131
|
-
* Optionally adds tile coordinate grid overlay.
|
|
132
|
-
* @param options Visualization options
|
|
133
|
-
*/
|
|
134
|
-
show(options?: {
|
|
135
|
-
/** Show tile coordinate labels. Default: true */
|
|
136
|
-
showTileCoordinates?: boolean;
|
|
137
|
-
/** Transparency level (0-1). Default: 0.5 */
|
|
138
|
-
alpha?: number;
|
|
139
|
-
}): void;
|
|
140
|
-
private _ensureTileCoordinatesLayer;
|
|
141
|
-
/**
|
|
142
|
-
* Hides the terrain visualization.
|
|
143
|
-
*/
|
|
144
|
-
hide(): void;
|
|
145
|
-
/**
|
|
146
|
-
* Sets the colors used for visualization.
|
|
147
|
-
* @param colors Map of role names to colors
|
|
148
|
-
*/
|
|
149
|
-
setColors(colors: Record<string, Color>): void;
|
|
150
|
-
/**
|
|
151
|
-
* Shows terrain regions using HybridImageryProvider (performant, global coverage).
|
|
152
|
-
* This replaces the entity-based approach with an imagery layer.
|
|
153
|
-
* @param alpha Transparency level (0-1), default 0.5
|
|
154
|
-
*/
|
|
155
|
-
showImageryOverlay(alpha?: number): void;
|
|
156
|
-
/**
|
|
157
|
-
* Hides the imagery overlay.
|
|
158
|
-
*/
|
|
159
|
-
hideImageryOverlay(): void;
|
|
160
|
-
/**
|
|
161
|
-
* Shows tile coordinate grid overlay.
|
|
162
|
-
*/
|
|
163
|
-
showTileCoordinates(): void;
|
|
164
|
-
/**
|
|
165
|
-
* Hides tile coordinate grid overlay.
|
|
166
|
-
*/
|
|
167
|
-
hideTileCoordinates(): void;
|
|
168
|
-
/**
|
|
169
|
-
* Sets the transparency of the imagery overlay.
|
|
170
|
-
* @param alpha Transparency level (0-1), where 0 is fully transparent and 1 is fully opaque
|
|
171
|
-
*/
|
|
172
|
-
setAlpha(alpha: number): void;
|
|
173
|
-
/**
|
|
174
|
-
* Flies the camera to focus on a rectangle.
|
|
175
|
-
* @param rectangle The rectangle to focus on.
|
|
176
|
-
* @param options {@link Viewer.flyTo}
|
|
177
|
-
*/
|
|
178
|
-
flyTo(rectangle: Rectangle, options?: {
|
|
179
|
-
duration?: number;
|
|
180
|
-
}): void;
|
|
181
|
-
/** Whether tile coordinates are currently visible. */
|
|
182
|
-
get tileCoordinatesVisible(): boolean;
|
|
183
|
-
/** Whether the grid is currently visible. */
|
|
184
|
-
get visible(): boolean;
|
|
185
|
-
/** The viewer used in the visualizer */
|
|
186
|
-
get viewer(): Viewer;
|
|
187
|
-
/** The colors used in the visualizer */
|
|
188
|
-
get colors(): Map<string, Color>;
|
|
189
|
-
/** The hybrid terrain instance used in the visualizer */
|
|
190
|
-
get terrainProvider(): HybridTerrainProvider;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* @namespace
|
|
194
|
-
* Contains types, utility functions, and constants for terrain visualization.
|
|
195
|
-
*/
|
|
196
|
-
declare namespace TerrainVisualizer {
|
|
197
|
-
/** Initialization options for `TerrainVisualizer` constructor. */
|
|
198
|
-
interface ConstructorOptions {
|
|
199
|
-
/** Colors to use for different visualization elements */
|
|
200
|
-
colors?: Record<string, Color>;
|
|
201
|
-
/** Whether to show tile grid initially. */
|
|
202
|
-
tile?: boolean;
|
|
203
|
-
/** Initial zoom level to use for visualizations. */
|
|
204
|
-
activeLevel?: number;
|
|
205
|
-
/** Terrain provider to visualize. */
|
|
206
|
-
terrainProvider: HybridTerrainProvider;
|
|
207
|
-
}
|
|
208
|
-
/** Options for {@link TerrainVisualizer.visualize} */
|
|
209
|
-
interface Options {
|
|
210
|
-
color?: Color;
|
|
211
|
-
show?: boolean;
|
|
212
|
-
maxTilesToShow?: number;
|
|
213
|
-
levels?: number[];
|
|
214
|
-
tag?: string;
|
|
215
|
-
alpha?: number;
|
|
216
|
-
tileAlpha?: number;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
96
|
declare const deprecate: typeof Deprecate.deprecate;
|
|
221
97
|
|
|
222
|
-
export { Deprecate,
|
|
98
|
+
export { Deprecate, deprecate };
|
package/dist/dev/index.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { Viewer, Color, Rectangle } from 'cesium';
|
|
2
|
-
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-Th8n2hZ1.js';
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* Utility for managing deprecation warnings in the cesium-utils library.
|
|
6
3
|
* Provides runtime warnings to help developers identify deprecated API usage.
|
|
@@ -96,127 +93,6 @@ declare namespace Deprecate {
|
|
|
96
93
|
function hasShown(message: string): boolean;
|
|
97
94
|
}
|
|
98
95
|
|
|
99
|
-
/**
|
|
100
|
-
* @class
|
|
101
|
-
* Utility class for visualizing terrain provider boundaries and debugging terrain loading.
|
|
102
|
-
*/
|
|
103
|
-
declare class TerrainVisualizer {
|
|
104
|
-
private _viewer;
|
|
105
|
-
private _terrainProvider;
|
|
106
|
-
private _visible;
|
|
107
|
-
private _tileCoordinatesLayer;
|
|
108
|
-
private _hybridImageryLayer;
|
|
109
|
-
private _colors;
|
|
110
|
-
/**
|
|
111
|
-
* Creates a new `TerrainVisualizer`.
|
|
112
|
-
* @param viewer The Cesium viewer instance
|
|
113
|
-
* @param options {@link TerrainVisualizer.ConstructorOptions}
|
|
114
|
-
*/
|
|
115
|
-
constructor(viewer: Viewer, options: TerrainVisualizer.ConstructorOptions);
|
|
116
|
-
/**
|
|
117
|
-
* Sets the terrain provider to visualize.
|
|
118
|
-
* @param terrainProvider The terrain provider to visualize.
|
|
119
|
-
*/
|
|
120
|
-
setTerrainProvider(terrainProvider: HybridTerrainProvider): void;
|
|
121
|
-
/**
|
|
122
|
-
* Updates all active visualizations.
|
|
123
|
-
*/
|
|
124
|
-
update(): void;
|
|
125
|
-
/**
|
|
126
|
-
* Clears all visualizations.
|
|
127
|
-
*/
|
|
128
|
-
clear(): void;
|
|
129
|
-
/**
|
|
130
|
-
* Shows terrain visualization using HybridImageryProvider.
|
|
131
|
-
* Optionally adds tile coordinate grid overlay.
|
|
132
|
-
* @param options Visualization options
|
|
133
|
-
*/
|
|
134
|
-
show(options?: {
|
|
135
|
-
/** Show tile coordinate labels. Default: true */
|
|
136
|
-
showTileCoordinates?: boolean;
|
|
137
|
-
/** Transparency level (0-1). Default: 0.5 */
|
|
138
|
-
alpha?: number;
|
|
139
|
-
}): void;
|
|
140
|
-
private _ensureTileCoordinatesLayer;
|
|
141
|
-
/**
|
|
142
|
-
* Hides the terrain visualization.
|
|
143
|
-
*/
|
|
144
|
-
hide(): void;
|
|
145
|
-
/**
|
|
146
|
-
* Sets the colors used for visualization.
|
|
147
|
-
* @param colors Map of role names to colors
|
|
148
|
-
*/
|
|
149
|
-
setColors(colors: Record<string, Color>): void;
|
|
150
|
-
/**
|
|
151
|
-
* Shows terrain regions using HybridImageryProvider (performant, global coverage).
|
|
152
|
-
* This replaces the entity-based approach with an imagery layer.
|
|
153
|
-
* @param alpha Transparency level (0-1), default 0.5
|
|
154
|
-
*/
|
|
155
|
-
showImageryOverlay(alpha?: number): void;
|
|
156
|
-
/**
|
|
157
|
-
* Hides the imagery overlay.
|
|
158
|
-
*/
|
|
159
|
-
hideImageryOverlay(): void;
|
|
160
|
-
/**
|
|
161
|
-
* Shows tile coordinate grid overlay.
|
|
162
|
-
*/
|
|
163
|
-
showTileCoordinates(): void;
|
|
164
|
-
/**
|
|
165
|
-
* Hides tile coordinate grid overlay.
|
|
166
|
-
*/
|
|
167
|
-
hideTileCoordinates(): void;
|
|
168
|
-
/**
|
|
169
|
-
* Sets the transparency of the imagery overlay.
|
|
170
|
-
* @param alpha Transparency level (0-1), where 0 is fully transparent and 1 is fully opaque
|
|
171
|
-
*/
|
|
172
|
-
setAlpha(alpha: number): void;
|
|
173
|
-
/**
|
|
174
|
-
* Flies the camera to focus on a rectangle.
|
|
175
|
-
* @param rectangle The rectangle to focus on.
|
|
176
|
-
* @param options {@link Viewer.flyTo}
|
|
177
|
-
*/
|
|
178
|
-
flyTo(rectangle: Rectangle, options?: {
|
|
179
|
-
duration?: number;
|
|
180
|
-
}): void;
|
|
181
|
-
/** Whether tile coordinates are currently visible. */
|
|
182
|
-
get tileCoordinatesVisible(): boolean;
|
|
183
|
-
/** Whether the grid is currently visible. */
|
|
184
|
-
get visible(): boolean;
|
|
185
|
-
/** The viewer used in the visualizer */
|
|
186
|
-
get viewer(): Viewer;
|
|
187
|
-
/** The colors used in the visualizer */
|
|
188
|
-
get colors(): Map<string, Color>;
|
|
189
|
-
/** The hybrid terrain instance used in the visualizer */
|
|
190
|
-
get terrainProvider(): HybridTerrainProvider;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* @namespace
|
|
194
|
-
* Contains types, utility functions, and constants for terrain visualization.
|
|
195
|
-
*/
|
|
196
|
-
declare namespace TerrainVisualizer {
|
|
197
|
-
/** Initialization options for `TerrainVisualizer` constructor. */
|
|
198
|
-
interface ConstructorOptions {
|
|
199
|
-
/** Colors to use for different visualization elements */
|
|
200
|
-
colors?: Record<string, Color>;
|
|
201
|
-
/** Whether to show tile grid initially. */
|
|
202
|
-
tile?: boolean;
|
|
203
|
-
/** Initial zoom level to use for visualizations. */
|
|
204
|
-
activeLevel?: number;
|
|
205
|
-
/** Terrain provider to visualize. */
|
|
206
|
-
terrainProvider: HybridTerrainProvider;
|
|
207
|
-
}
|
|
208
|
-
/** Options for {@link TerrainVisualizer.visualize} */
|
|
209
|
-
interface Options {
|
|
210
|
-
color?: Color;
|
|
211
|
-
show?: boolean;
|
|
212
|
-
maxTilesToShow?: number;
|
|
213
|
-
levels?: number[];
|
|
214
|
-
tag?: string;
|
|
215
|
-
alpha?: number;
|
|
216
|
-
tileAlpha?: number;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
96
|
declare const deprecate: typeof Deprecate.deprecate;
|
|
221
97
|
|
|
222
|
-
export { Deprecate,
|
|
98
|
+
export { Deprecate, deprecate };
|
package/dist/dev/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var s;(w=>{let n=new Set,u=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function f(e,o={}){if(!u)return;let{once:r=!0,prefix:t="[DEPRECATED]",includeStack:i=!0,removeInVersion:c}=o;if(r&&n.has(e))return;let a=`${t} ${e}`;c&&(a+=` This feature will be removed in ${c}.`),typeof console<"u"&&console.warn&&(i?(console.warn(a),console.trace("Deprecation stack trace:")):console.warn(a)),r&&n.add(e)}w.warn=f;function l(e,o,r={}){let t=((...i)=>(f(o,r),e(...i)));return Object.defineProperty(t,"name",{value:e.name,configurable:!0}),t}w.deprecate=l;function d(){n.clear()}w.clear=d;function x(){return n.size}w.getWarningCount=x;function g(e){return n.has(e)}w.hasShown=g})(s||={});var p=s;var m=p.deprecate;export{p as Deprecate,m as deprecate};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r}from"./chunk-WTOAUTEK.js";import{a as e,b as i,c as o}from"./chunk-PSCNWZUR.js";import"./chunk-6I6OKECI.js";import{a as
|
|
1
|
+
import{a as r}from"./chunk-WTOAUTEK.js";import{a as e,b as i,c as o}from"./chunk-PSCNWZUR.js";import"./chunk-6I6OKECI.js";import{a as p,b as m}from"./chunk-Z2COOTT4.js";import{a as t}from"./chunk-XHMLNB5Q.js";export{r as Collection,o as Highlight,t as HybridTerrainProvider,e as SilhouetteHighlight,i as SurfaceHighlight,m as cloneViewer,p as syncCamera};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var y=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var w=(a,e)=>{for(var r in e)y(a,r,{get:e[r],enumerable:!0})},I=(a,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of C(e))!L.call(a,t)&&t!==r&&y(a,t,{get:()=>e[t],enumerable:!(i=T(e,t))||i.enumerable});return a};var x=a=>I(y({},"__esModule",{value:!0}),a);var R={};w(R,{TerrainVisualizer:()=>m});module.exports=x(R);var l=require("cesium");var v=require("cesium");var b=require("cesium"),h=class a{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new b.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,r,i){return this._defaultProvider.loadTileDataAvailability(e,r,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,r,i,t){if(this._ready){for(let o of this._regions)if(a.TerrainRegion.contains(o,e,r,i))return o.provider.requestTileGeometry(e,r,i,t);return this._defaultProvider.getTileDataAvailable(e,r,i)?this._defaultProvider.requestTileGeometry(e,r,i,t):this._fallbackProvider.requestTileGeometry(e,r,i,t)}}getTileDataAvailable(e,r,i){for(let t of this._regions)if(a.TerrainRegion.contains(t,e,r,i))return!0;return this._defaultProvider.getTileDataAvailable(e,r,i)}};(r=>{function a(i,t,o){return new r({regions:i.map(s=>({...s})),defaultProvider:t,fallbackProvider:o})}r.fromTileRanges=a;let e;(t=>{function i(o,s,d,c){if(o.levels&&!o.levels.includes(c))return!1;if(o.tiles){let n=o.tiles.get(c);if(!n)return!1;let[f,_]=Array.isArray(n.x)?n.x:[n.x,n.x],[P,p]=Array.isArray(n.y)?n.y:[n.y,n.y];return s>=f&&s<=_&&d>=P&&d<=p}return!1}t.contains=i})(e=r.TerrainRegion||={})})(h||={});var g=h;var u=class extends v.GridImageryProvider{_terrainProvider;_colors;constructor(e){let{terrainProvider:r,colors:i,...t}=e;super(t),this._terrainProvider=r,this._colors=i}requestImage(e,r,i){for(let t of this._terrainProvider.regions)if(this._isInRegionOrUpsampled(t,e,r,i))return this._createCanvasElement(this._colors.get("custom")||v.Color.RED);return this._terrainProvider.defaultProvider.getTileDataAvailable(e,r,i)?this._createCanvasElement(this._colors.get("default")||v.Color.BLUE):this._createCanvasElement(this._colors.get("fallback")||v.Color.GRAY)}_isInRegionOrUpsampled(e,r,i,t){let o=r,s=i,d=t;for(;d>=0;){if(g.TerrainRegion.contains(e,o,s,d))return!0;if(d===0)break;d--,o=Math.floor(o/2),s=Math.floor(s/2)}return!1}_createCanvasElement(e){let r=document.createElement("canvas");r.width=256,r.height=256;let i=r.getContext("2d"),t=e.withAlpha(.3).toCssColorString();if(!i)throw new Error("canvas context undefined");return i.fillStyle=t,i.fillRect(0,0,256,256),Promise.resolve(r)}};var m=class{_viewer;_terrainProvider;_visible=!1;_tileCoordinatesLayer;_hybridImageryLayer;_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._terrainProvider=r.terrainProvider,r.colors&&Object.entries(r.colors).forEach(([i,t])=>{this._colors.set(i,t)}),r.tile!==void 0&&r.tile&&this.show()}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){let e=this._visible,r=!!this._tileCoordinatesLayer,i=this._hybridImageryLayer?.alpha??.5;this.clear(),e&&this.show({showTileCoordinates:r,alpha:i})}clear(){this.hide()}show(e){if(!this._terrainProvider)return;let r=e?.showTileCoordinates??!0,i=e?.alpha??.5;r&&this._ensureTileCoordinatesLayer(),this.showImageryOverlay(i),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new l.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:l.Color.YELLOW})))}hide(){this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this.hideImageryOverlay(),this._visible=!1}setColors(e){Object.entries(e).forEach(([r,i])=>{this._colors.set(r,i)}),this.update()}showImageryOverlay(e=.5){this._hybridImageryLayer&&this._viewer.imageryLayers.remove(this._hybridImageryLayer);let r=new u({terrainProvider:this._terrainProvider,colors:this._colors,tilingScheme:this._terrainProvider.tilingScheme});this._hybridImageryLayer=this._viewer.imageryLayers.addImageryProvider(r),this._hybridImageryLayer.alpha=e,console.log("HybridImageryProvider overlay enabled")}hideImageryOverlay(){this._hybridImageryLayer&&(this._viewer.imageryLayers.remove(this._hybridImageryLayer),this._hybridImageryLayer=void 0,console.log("HybridImageryProvider overlay disabled"))}showTileCoordinates(){this._ensureTileCoordinatesLayer()}hideTileCoordinates(){this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0)}setAlpha(e){this._hybridImageryLayer&&(this._hybridImageryLayer.alpha=e)}flyTo(e,r){this._viewer.camera.flyTo({destination:e,...r,complete:()=>{this._visible&&this.update()}})}get tileCoordinatesVisible(){return!!this._tileCoordinatesLayer}get visible(){return this._visible}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Viewer, Color, Rectangle } from 'cesium';
|
|
2
|
+
import { H as HybridTerrainProvider } from '../../hybrid-terrain-provider-Th8n2hZ1.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @class
|
|
6
|
+
* Utility class for visualizing terrain provider boundaries and debugging terrain loading.
|
|
7
|
+
*/
|
|
8
|
+
declare class TerrainVisualizer {
|
|
9
|
+
private _viewer;
|
|
10
|
+
private _terrainProvider;
|
|
11
|
+
private _visible;
|
|
12
|
+
private _tileCoordinatesLayer;
|
|
13
|
+
private _hybridImageryLayer;
|
|
14
|
+
private _colors;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new `TerrainVisualizer`.
|
|
17
|
+
* @param viewer The Cesium viewer instance
|
|
18
|
+
* @param options {@link TerrainVisualizer.ConstructorOptions}
|
|
19
|
+
*/
|
|
20
|
+
constructor(viewer: Viewer, options: TerrainVisualizer.ConstructorOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Sets the terrain provider to visualize.
|
|
23
|
+
* @param terrainProvider The terrain provider to visualize.
|
|
24
|
+
*/
|
|
25
|
+
setTerrainProvider(terrainProvider: HybridTerrainProvider): void;
|
|
26
|
+
/**
|
|
27
|
+
* Updates all active visualizations.
|
|
28
|
+
*/
|
|
29
|
+
update(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Clears all visualizations.
|
|
32
|
+
*/
|
|
33
|
+
clear(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Shows terrain visualization using HybridImageryProvider.
|
|
36
|
+
* Optionally adds tile coordinate grid overlay.
|
|
37
|
+
* @param options Visualization options
|
|
38
|
+
*/
|
|
39
|
+
show(options?: {
|
|
40
|
+
/** Show tile coordinate labels. Default: true */
|
|
41
|
+
showTileCoordinates?: boolean;
|
|
42
|
+
/** Transparency level (0-1). Default: 0.5 */
|
|
43
|
+
alpha?: number;
|
|
44
|
+
}): void;
|
|
45
|
+
private _ensureTileCoordinatesLayer;
|
|
46
|
+
/**
|
|
47
|
+
* Hides the terrain visualization.
|
|
48
|
+
*/
|
|
49
|
+
hide(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Sets the colors used for visualization.
|
|
52
|
+
* @param colors Map of role names to colors
|
|
53
|
+
*/
|
|
54
|
+
setColors(colors: Record<string, Color>): void;
|
|
55
|
+
/**
|
|
56
|
+
* Shows terrain regions using HybridImageryProvider (performant, global coverage).
|
|
57
|
+
* This replaces the entity-based approach with an imagery layer.
|
|
58
|
+
* @param alpha Transparency level (0-1), default 0.5
|
|
59
|
+
*/
|
|
60
|
+
showImageryOverlay(alpha?: number): void;
|
|
61
|
+
/**
|
|
62
|
+
* Hides the imagery overlay.
|
|
63
|
+
*/
|
|
64
|
+
hideImageryOverlay(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Shows tile coordinate grid overlay.
|
|
67
|
+
*/
|
|
68
|
+
showTileCoordinates(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Hides tile coordinate grid overlay.
|
|
71
|
+
*/
|
|
72
|
+
hideTileCoordinates(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Sets the transparency of the imagery overlay.
|
|
75
|
+
* @param alpha Transparency level (0-1), where 0 is fully transparent and 1 is fully opaque
|
|
76
|
+
*/
|
|
77
|
+
setAlpha(alpha: number): void;
|
|
78
|
+
/**
|
|
79
|
+
* Flies the camera to focus on a rectangle.
|
|
80
|
+
* @param rectangle The rectangle to focus on.
|
|
81
|
+
* @param options {@link Viewer.flyTo}
|
|
82
|
+
*/
|
|
83
|
+
flyTo(rectangle: Rectangle, options?: {
|
|
84
|
+
duration?: number;
|
|
85
|
+
}): void;
|
|
86
|
+
/** Whether tile coordinates are currently visible. */
|
|
87
|
+
get tileCoordinatesVisible(): boolean;
|
|
88
|
+
/** Whether the grid is currently visible. */
|
|
89
|
+
get visible(): boolean;
|
|
90
|
+
/** The viewer used in the visualizer */
|
|
91
|
+
get viewer(): Viewer;
|
|
92
|
+
/** The colors used in the visualizer */
|
|
93
|
+
get colors(): Map<string, Color>;
|
|
94
|
+
/** The hybrid terrain instance used in the visualizer */
|
|
95
|
+
get terrainProvider(): HybridTerrainProvider;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @namespace
|
|
99
|
+
* Contains types, utility functions, and constants for terrain visualization.
|
|
100
|
+
*/
|
|
101
|
+
declare namespace TerrainVisualizer {
|
|
102
|
+
/** Initialization options for `TerrainVisualizer` constructor. */
|
|
103
|
+
interface ConstructorOptions {
|
|
104
|
+
/** Colors to use for different visualization elements */
|
|
105
|
+
colors?: Record<string, Color>;
|
|
106
|
+
/** Whether to show tile grid initially. */
|
|
107
|
+
tile?: boolean;
|
|
108
|
+
/** Initial zoom level to use for visualizations. */
|
|
109
|
+
activeLevel?: number;
|
|
110
|
+
/** Terrain provider to visualize. */
|
|
111
|
+
terrainProvider: HybridTerrainProvider;
|
|
112
|
+
}
|
|
113
|
+
/** Options for {@link TerrainVisualizer.visualize} */
|
|
114
|
+
interface Options {
|
|
115
|
+
color?: Color;
|
|
116
|
+
show?: boolean;
|
|
117
|
+
maxTilesToShow?: number;
|
|
118
|
+
levels?: number[];
|
|
119
|
+
tag?: string;
|
|
120
|
+
alpha?: number;
|
|
121
|
+
tileAlpha?: number;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { TerrainVisualizer };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Viewer, Color, Rectangle } from 'cesium';
|
|
2
|
+
import { H as HybridTerrainProvider } from '../../hybrid-terrain-provider-Th8n2hZ1.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @class
|
|
6
|
+
* Utility class for visualizing terrain provider boundaries and debugging terrain loading.
|
|
7
|
+
*/
|
|
8
|
+
declare class TerrainVisualizer {
|
|
9
|
+
private _viewer;
|
|
10
|
+
private _terrainProvider;
|
|
11
|
+
private _visible;
|
|
12
|
+
private _tileCoordinatesLayer;
|
|
13
|
+
private _hybridImageryLayer;
|
|
14
|
+
private _colors;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new `TerrainVisualizer`.
|
|
17
|
+
* @param viewer The Cesium viewer instance
|
|
18
|
+
* @param options {@link TerrainVisualizer.ConstructorOptions}
|
|
19
|
+
*/
|
|
20
|
+
constructor(viewer: Viewer, options: TerrainVisualizer.ConstructorOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Sets the terrain provider to visualize.
|
|
23
|
+
* @param terrainProvider The terrain provider to visualize.
|
|
24
|
+
*/
|
|
25
|
+
setTerrainProvider(terrainProvider: HybridTerrainProvider): void;
|
|
26
|
+
/**
|
|
27
|
+
* Updates all active visualizations.
|
|
28
|
+
*/
|
|
29
|
+
update(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Clears all visualizations.
|
|
32
|
+
*/
|
|
33
|
+
clear(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Shows terrain visualization using HybridImageryProvider.
|
|
36
|
+
* Optionally adds tile coordinate grid overlay.
|
|
37
|
+
* @param options Visualization options
|
|
38
|
+
*/
|
|
39
|
+
show(options?: {
|
|
40
|
+
/** Show tile coordinate labels. Default: true */
|
|
41
|
+
showTileCoordinates?: boolean;
|
|
42
|
+
/** Transparency level (0-1). Default: 0.5 */
|
|
43
|
+
alpha?: number;
|
|
44
|
+
}): void;
|
|
45
|
+
private _ensureTileCoordinatesLayer;
|
|
46
|
+
/**
|
|
47
|
+
* Hides the terrain visualization.
|
|
48
|
+
*/
|
|
49
|
+
hide(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Sets the colors used for visualization.
|
|
52
|
+
* @param colors Map of role names to colors
|
|
53
|
+
*/
|
|
54
|
+
setColors(colors: Record<string, Color>): void;
|
|
55
|
+
/**
|
|
56
|
+
* Shows terrain regions using HybridImageryProvider (performant, global coverage).
|
|
57
|
+
* This replaces the entity-based approach with an imagery layer.
|
|
58
|
+
* @param alpha Transparency level (0-1), default 0.5
|
|
59
|
+
*/
|
|
60
|
+
showImageryOverlay(alpha?: number): void;
|
|
61
|
+
/**
|
|
62
|
+
* Hides the imagery overlay.
|
|
63
|
+
*/
|
|
64
|
+
hideImageryOverlay(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Shows tile coordinate grid overlay.
|
|
67
|
+
*/
|
|
68
|
+
showTileCoordinates(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Hides tile coordinate grid overlay.
|
|
71
|
+
*/
|
|
72
|
+
hideTileCoordinates(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Sets the transparency of the imagery overlay.
|
|
75
|
+
* @param alpha Transparency level (0-1), where 0 is fully transparent and 1 is fully opaque
|
|
76
|
+
*/
|
|
77
|
+
setAlpha(alpha: number): void;
|
|
78
|
+
/**
|
|
79
|
+
* Flies the camera to focus on a rectangle.
|
|
80
|
+
* @param rectangle The rectangle to focus on.
|
|
81
|
+
* @param options {@link Viewer.flyTo}
|
|
82
|
+
*/
|
|
83
|
+
flyTo(rectangle: Rectangle, options?: {
|
|
84
|
+
duration?: number;
|
|
85
|
+
}): void;
|
|
86
|
+
/** Whether tile coordinates are currently visible. */
|
|
87
|
+
get tileCoordinatesVisible(): boolean;
|
|
88
|
+
/** Whether the grid is currently visible. */
|
|
89
|
+
get visible(): boolean;
|
|
90
|
+
/** The viewer used in the visualizer */
|
|
91
|
+
get viewer(): Viewer;
|
|
92
|
+
/** The colors used in the visualizer */
|
|
93
|
+
get colors(): Map<string, Color>;
|
|
94
|
+
/** The hybrid terrain instance used in the visualizer */
|
|
95
|
+
get terrainProvider(): HybridTerrainProvider;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @namespace
|
|
99
|
+
* Contains types, utility functions, and constants for terrain visualization.
|
|
100
|
+
*/
|
|
101
|
+
declare namespace TerrainVisualizer {
|
|
102
|
+
/** Initialization options for `TerrainVisualizer` constructor. */
|
|
103
|
+
interface ConstructorOptions {
|
|
104
|
+
/** Colors to use for different visualization elements */
|
|
105
|
+
colors?: Record<string, Color>;
|
|
106
|
+
/** Whether to show tile grid initially. */
|
|
107
|
+
tile?: boolean;
|
|
108
|
+
/** Initial zoom level to use for visualizations. */
|
|
109
|
+
activeLevel?: number;
|
|
110
|
+
/** Terrain provider to visualize. */
|
|
111
|
+
terrainProvider: HybridTerrainProvider;
|
|
112
|
+
}
|
|
113
|
+
/** Options for {@link TerrainVisualizer.visualize} */
|
|
114
|
+
interface Options {
|
|
115
|
+
color?: Color;
|
|
116
|
+
show?: boolean;
|
|
117
|
+
maxTilesToShow?: number;
|
|
118
|
+
levels?: number[];
|
|
119
|
+
tag?: string;
|
|
120
|
+
alpha?: number;
|
|
121
|
+
tileAlpha?: number;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { TerrainVisualizer };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as v}from"../../chunk-XHMLNB5Q.js";import{Color as a,TileCoordinatesImageryProvider as c}from"cesium";import{Color as d,GridImageryProvider as m}from"cesium";var o=class extends m{_terrainProvider;_colors;constructor(r){let{terrainProvider:e,colors:i,...t}=r;super(t),this._terrainProvider=e,this._colors=i}requestImage(r,e,i){for(let t of this._terrainProvider.regions)if(this._isInRegionOrUpsampled(t,r,e,i))return this._createCanvasElement(this._colors.get("custom")||d.RED);return this._terrainProvider.defaultProvider.getTileDataAvailable(r,e,i)?this._createCanvasElement(this._colors.get("default")||d.BLUE):this._createCanvasElement(this._colors.get("fallback")||d.GRAY)}_isInRegionOrUpsampled(r,e,i,t){let n=e,l=i,s=t;for(;s>=0;){if(v.TerrainRegion.contains(r,n,l,s))return!0;if(s===0)break;s--,n=Math.floor(n/2),l=Math.floor(l/2)}return!1}_createCanvasElement(r){let e=document.createElement("canvas");e.width=256,e.height=256;let i=e.getContext("2d"),t=r.withAlpha(.3).toCssColorString();if(!i)throw new Error("canvas context undefined");return i.fillStyle=t,i.fillRect(0,0,256,256),Promise.resolve(e)}};var h=class{_viewer;_terrainProvider;_visible=!1;_tileCoordinatesLayer;_hybridImageryLayer;_colors=new Map([["custom",a.RED],["default",a.BLUE],["fallback",a.GRAY],["grid",a.YELLOW]]);constructor(r,e){this._viewer=r,this._terrainProvider=e.terrainProvider,e.colors&&Object.entries(e.colors).forEach(([i,t])=>{this._colors.set(i,t)}),e.tile!==void 0&&e.tile&&this.show()}setTerrainProvider(r){this._terrainProvider=r,this.update()}update(){let r=this._visible,e=!!this._tileCoordinatesLayer,i=this._hybridImageryLayer?.alpha??.5;this.clear(),r&&this.show({showTileCoordinates:e,alpha:i})}clear(){this.hide()}show(r){if(!this._terrainProvider)return;let e=r?.showTileCoordinates??!0,i=r?.alpha??.5;e&&this._ensureTileCoordinatesLayer(),this.showImageryOverlay(i),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new c({tilingScheme:this._terrainProvider.tilingScheme,color:a.YELLOW})))}hide(){this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this.hideImageryOverlay(),this._visible=!1}setColors(r){Object.entries(r).forEach(([e,i])=>{this._colors.set(e,i)}),this.update()}showImageryOverlay(r=.5){this._hybridImageryLayer&&this._viewer.imageryLayers.remove(this._hybridImageryLayer);let e=new o({terrainProvider:this._terrainProvider,colors:this._colors,tilingScheme:this._terrainProvider.tilingScheme});this._hybridImageryLayer=this._viewer.imageryLayers.addImageryProvider(e),this._hybridImageryLayer.alpha=r,console.log("HybridImageryProvider overlay enabled")}hideImageryOverlay(){this._hybridImageryLayer&&(this._viewer.imageryLayers.remove(this._hybridImageryLayer),this._hybridImageryLayer=void 0,console.log("HybridImageryProvider overlay disabled"))}showTileCoordinates(){this._ensureTileCoordinatesLayer()}hideTileCoordinates(){this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0)}setAlpha(r){this._hybridImageryLayer&&(this._hybridImageryLayer.alpha=r)}flyTo(r,e){this._viewer.camera.flyTo({destination:r,...e,complete:()=>{this._visible&&this.update()}})}get tileCoordinatesVisible(){return!!this._tileCoordinatesLayer}get visible(){return this._visible}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};export{h as TerrainVisualizer};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juun-roh/cesium-utils",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Solve common Cesium.js challenges: combine multiple terrain sources, tag and filter entity collections, and add visual highlights.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cesium",
|
|
@@ -66,6 +66,11 @@
|
|
|
66
66
|
"import": "./dist/terrain/index.js",
|
|
67
67
|
"require": "./dist/terrain/index.cjs"
|
|
68
68
|
},
|
|
69
|
+
"./terrain/dev": {
|
|
70
|
+
"types": "./dist/terrain/dev/index.d.ts",
|
|
71
|
+
"import": "./dist/terrain/dev/index.js",
|
|
72
|
+
"require": "./dist/terrain/dev/index.cjs"
|
|
73
|
+
},
|
|
69
74
|
"./dev": {
|
|
70
75
|
"types": "./dist/dev/index.d.ts",
|
|
71
76
|
"import": "./dist/dev/index.js",
|
|
@@ -86,7 +91,7 @@
|
|
|
86
91
|
"node": ">=20.0.0"
|
|
87
92
|
},
|
|
88
93
|
"peerDependencies": {
|
|
89
|
-
"cesium": "
|
|
94
|
+
"cesium": ">=1.133.0"
|
|
90
95
|
},
|
|
91
96
|
"publishConfig": {
|
|
92
97
|
"access": "public"
|
|
@@ -97,31 +102,31 @@
|
|
|
97
102
|
}
|
|
98
103
|
},
|
|
99
104
|
"devDependencies": {
|
|
100
|
-
"@changesets/cli": "^2.
|
|
101
|
-
"@commitlint/cli": "^20.
|
|
102
|
-
"@commitlint/config-conventional": "^20.
|
|
103
|
-
"@commitlint/cz-commitlint": "^20.
|
|
104
|
-
"@commitlint/format": "^20.
|
|
105
|
-
"@commitlint/types": "^20.
|
|
106
|
-
"@eslint/js": "^9.39.
|
|
107
|
-
"@types/node": "^25.
|
|
108
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
109
|
-
"@typescript-eslint/parser": "^8.
|
|
110
|
-
"@vitest/coverage-v8": "^4.0.
|
|
111
|
-
"cesium": "^1.
|
|
112
|
-
"eslint": "^
|
|
113
|
-
"eslint-plugin-jsdoc": "^
|
|
114
|
-
"eslint-plugin-prettier": "^5.5.
|
|
105
|
+
"@changesets/cli": "^2.30.0",
|
|
106
|
+
"@commitlint/cli": "^20.4.3",
|
|
107
|
+
"@commitlint/config-conventional": "^20.4.3",
|
|
108
|
+
"@commitlint/cz-commitlint": "^20.4.3",
|
|
109
|
+
"@commitlint/format": "^20.4.3",
|
|
110
|
+
"@commitlint/types": "^20.4.3",
|
|
111
|
+
"@eslint/js": "^9.39.4",
|
|
112
|
+
"@types/node": "^25.3.5",
|
|
113
|
+
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
114
|
+
"@typescript-eslint/parser": "^8.56.1",
|
|
115
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
116
|
+
"cesium": "^1.139.1",
|
|
117
|
+
"eslint": "^10.0.3",
|
|
118
|
+
"eslint-plugin-jsdoc": "^62.7.1",
|
|
119
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
115
120
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
116
|
-
"eslint-plugin-unused-imports": "^4.
|
|
121
|
+
"eslint-plugin-unused-imports": "^4.4.1",
|
|
117
122
|
"husky": "^9.1.7",
|
|
118
|
-
"jsdom": "^
|
|
119
|
-
"rimraf": "^6.1.
|
|
123
|
+
"jsdom": "^28.1.0",
|
|
124
|
+
"rimraf": "^6.1.3",
|
|
120
125
|
"tsup": "^8.5.1",
|
|
121
|
-
"typedoc": "^0.28.
|
|
126
|
+
"typedoc": "^0.28.17",
|
|
122
127
|
"typescript": "^5.9.3",
|
|
123
|
-
"vite": "^7.3.
|
|
124
|
-
"vitest": "^4.0.
|
|
128
|
+
"vite": "^7.3.1",
|
|
129
|
+
"vitest": "^4.0.18"
|
|
125
130
|
},
|
|
126
131
|
"scripts": {
|
|
127
132
|
"build": "tsup",
|