@juun-roh/cesium-utils 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -100
- package/dist/chunk-WTOAUTEK.js +1 -0
- package/dist/collection/index.cjs +1 -1
- package/dist/collection/index.d.cts +35 -1
- package/dist/collection/index.d.ts +35 -1
- package/dist/collection/index.js +1 -1
- package/dist/dev/index.cjs +1 -1
- package/dist/dev/index.d.cts +1 -126
- package/dist/dev/index.d.ts +1 -126
- package/dist/dev/index.js +1 -1
- package/dist/experimental/index.cjs +1 -1
- package/dist/experimental/index.d.cts +22 -12
- package/dist/experimental/index.d.ts +22 -12
- package/dist/experimental/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/terrain/dev/index.cjs +1 -0
- package/dist/terrain/dev/index.d.cts +125 -0
- package/dist/terrain/dev/index.d.ts +125 -0
- package/dist/terrain/dev/index.js +1 -0
- package/package.json +41 -31
- package/dist/chunk-L62HNMU7.js +0 -1
- package/dist/chunk-R5KTUXEL.js +0 -1
- package/dist/type-check-C17vkHMg.d.cts +0 -46
- package/dist/type-check-C17vkHMg.d.ts +0 -46
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Viewer, Cartesian3, JulianDate } from 'cesium';
|
|
1
|
+
import { Viewer, Cartesian3, JulianDate, Color, Entity } from 'cesium';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @since Cesium 1.132.0
|
|
@@ -15,12 +15,13 @@ import { Viewer, Cartesian3, JulianDate } from 'cesium';
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
declare class Sunlight {
|
|
18
|
-
private
|
|
19
|
-
private _sunDirectionWC;
|
|
18
|
+
private _uniformState;
|
|
20
19
|
private _viewer;
|
|
21
20
|
private _analyzing;
|
|
22
21
|
private _pointEntityId?;
|
|
23
|
-
private
|
|
22
|
+
private _objectsToExclude;
|
|
23
|
+
private _polylines;
|
|
24
|
+
private _points;
|
|
24
25
|
constructor(viewer: Viewer);
|
|
25
26
|
/** The sun position in 3D world coordinates at the current scene time. */
|
|
26
27
|
get sunPositionWC(): Cartesian3;
|
|
@@ -29,42 +30,51 @@ declare class Sunlight {
|
|
|
29
30
|
/** Whether sunlight analysis is currently in progress. */
|
|
30
31
|
get isAnalyzing(): boolean;
|
|
31
32
|
/**
|
|
32
|
-
* Gets
|
|
33
|
+
* Gets virtual position and direction of the sun to reduce calculation overhead.
|
|
33
34
|
*
|
|
34
35
|
* @param from target point to start from
|
|
35
|
-
* @param radius virtual distance between target point and the sun. Defaults to
|
|
36
|
+
* @param radius virtual distance between target point and the sun. Defaults to 10000 (10km)
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
|
+
virtualSun(from: Cartesian3, radius?: number): {
|
|
39
|
+
position: Cartesian3;
|
|
40
|
+
direction: Cartesian3;
|
|
41
|
+
};
|
|
38
42
|
/**
|
|
39
43
|
* Analyze the sunlight acceptance from a given point at a given time.
|
|
40
44
|
* @param from target point to analyze
|
|
41
45
|
* @param at time to analyze
|
|
42
46
|
* @param options {@link Sunlight.AnalyzeOptions}
|
|
43
47
|
*/
|
|
44
|
-
analyze(from: Cartesian3, at: JulianDate, options?: Sunlight.AnalyzeOptions): Sunlight.AnalysisResult
|
|
48
|
+
analyze(from: Cartesian3, at: JulianDate, options?: Sunlight.AnalyzeOptions): Promise<Sunlight.AnalysisResult>;
|
|
45
49
|
/**
|
|
46
50
|
* Analyze the sunlight acceptance from a given point at a given time range.
|
|
47
51
|
* @param from target point to analyze
|
|
48
52
|
* @param range time range to analyze
|
|
49
53
|
* @param options {@link Sunlight.AnalyzeOptions}
|
|
50
54
|
*/
|
|
51
|
-
analyze(from: Cartesian3, range: Sunlight.TimeRange, options?: Sunlight.AnalyzeOptions): Sunlight.AnalysisResult[]
|
|
55
|
+
analyze(from: Cartesian3, range: Sunlight.TimeRange, options?: Sunlight.AnalyzeOptions): Promise<Sunlight.AnalysisResult[]>;
|
|
52
56
|
/**
|
|
53
57
|
* Remove all instances created for debug purpose
|
|
54
58
|
*/
|
|
55
59
|
clear(): void;
|
|
56
60
|
/**
|
|
57
|
-
* Create
|
|
61
|
+
* Create an ellipsoid entity for ray collision detection to complement cesium's native click event accuracy
|
|
58
62
|
* @param at where to create the entity
|
|
59
63
|
* @param show whether to show point entity
|
|
60
64
|
* @param errorBoundary size of the point entity for error tolerance
|
|
61
65
|
*/
|
|
62
|
-
|
|
66
|
+
setTargetPoint(at: Cartesian3, show?: boolean, errorBoundary?: number, color?: Color): Entity;
|
|
63
67
|
private _analyzeSingleTime;
|
|
64
68
|
private _analyzeTimeRange;
|
|
69
|
+
/**
|
|
70
|
+
* @returns A promise tht resolves to an object containing the object and position of the first intersection.
|
|
71
|
+
* @see https://github.com/CesiumGS/cesium/blob/1.136/packages/engine/Source/Scene/Scene.js#L4868
|
|
72
|
+
*/
|
|
73
|
+
private _pick;
|
|
65
74
|
private _getExcludedObjects;
|
|
66
75
|
}
|
|
67
76
|
declare namespace Sunlight {
|
|
77
|
+
const DETECTION_ELLIPSOID_ID = "sunlight-detection-ellipsoid";
|
|
68
78
|
/** for time-range analysis */
|
|
69
79
|
interface TimeRange {
|
|
70
80
|
/** When to start analysis */
|
|
@@ -88,7 +98,7 @@ declare namespace Sunlight {
|
|
|
88
98
|
/** ISO time string */
|
|
89
99
|
timestamp: string;
|
|
90
100
|
/** Whether the sunlight has reached */
|
|
91
|
-
result: boolean;
|
|
101
|
+
result: boolean | any;
|
|
92
102
|
}
|
|
93
103
|
}
|
|
94
104
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Viewer, Cartesian3, JulianDate } from 'cesium';
|
|
1
|
+
import { Viewer, Cartesian3, JulianDate, Color, Entity } from 'cesium';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @since Cesium 1.132.0
|
|
@@ -15,12 +15,13 @@ import { Viewer, Cartesian3, JulianDate } from 'cesium';
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
declare class Sunlight {
|
|
18
|
-
private
|
|
19
|
-
private _sunDirectionWC;
|
|
18
|
+
private _uniformState;
|
|
20
19
|
private _viewer;
|
|
21
20
|
private _analyzing;
|
|
22
21
|
private _pointEntityId?;
|
|
23
|
-
private
|
|
22
|
+
private _objectsToExclude;
|
|
23
|
+
private _polylines;
|
|
24
|
+
private _points;
|
|
24
25
|
constructor(viewer: Viewer);
|
|
25
26
|
/** The sun position in 3D world coordinates at the current scene time. */
|
|
26
27
|
get sunPositionWC(): Cartesian3;
|
|
@@ -29,42 +30,51 @@ declare class Sunlight {
|
|
|
29
30
|
/** Whether sunlight analysis is currently in progress. */
|
|
30
31
|
get isAnalyzing(): boolean;
|
|
31
32
|
/**
|
|
32
|
-
* Gets
|
|
33
|
+
* Gets virtual position and direction of the sun to reduce calculation overhead.
|
|
33
34
|
*
|
|
34
35
|
* @param from target point to start from
|
|
35
|
-
* @param radius virtual distance between target point and the sun. Defaults to
|
|
36
|
+
* @param radius virtual distance between target point and the sun. Defaults to 10000 (10km)
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
|
+
virtualSun(from: Cartesian3, radius?: number): {
|
|
39
|
+
position: Cartesian3;
|
|
40
|
+
direction: Cartesian3;
|
|
41
|
+
};
|
|
38
42
|
/**
|
|
39
43
|
* Analyze the sunlight acceptance from a given point at a given time.
|
|
40
44
|
* @param from target point to analyze
|
|
41
45
|
* @param at time to analyze
|
|
42
46
|
* @param options {@link Sunlight.AnalyzeOptions}
|
|
43
47
|
*/
|
|
44
|
-
analyze(from: Cartesian3, at: JulianDate, options?: Sunlight.AnalyzeOptions): Sunlight.AnalysisResult
|
|
48
|
+
analyze(from: Cartesian3, at: JulianDate, options?: Sunlight.AnalyzeOptions): Promise<Sunlight.AnalysisResult>;
|
|
45
49
|
/**
|
|
46
50
|
* Analyze the sunlight acceptance from a given point at a given time range.
|
|
47
51
|
* @param from target point to analyze
|
|
48
52
|
* @param range time range to analyze
|
|
49
53
|
* @param options {@link Sunlight.AnalyzeOptions}
|
|
50
54
|
*/
|
|
51
|
-
analyze(from: Cartesian3, range: Sunlight.TimeRange, options?: Sunlight.AnalyzeOptions): Sunlight.AnalysisResult[]
|
|
55
|
+
analyze(from: Cartesian3, range: Sunlight.TimeRange, options?: Sunlight.AnalyzeOptions): Promise<Sunlight.AnalysisResult[]>;
|
|
52
56
|
/**
|
|
53
57
|
* Remove all instances created for debug purpose
|
|
54
58
|
*/
|
|
55
59
|
clear(): void;
|
|
56
60
|
/**
|
|
57
|
-
* Create
|
|
61
|
+
* Create an ellipsoid entity for ray collision detection to complement cesium's native click event accuracy
|
|
58
62
|
* @param at where to create the entity
|
|
59
63
|
* @param show whether to show point entity
|
|
60
64
|
* @param errorBoundary size of the point entity for error tolerance
|
|
61
65
|
*/
|
|
62
|
-
|
|
66
|
+
setTargetPoint(at: Cartesian3, show?: boolean, errorBoundary?: number, color?: Color): Entity;
|
|
63
67
|
private _analyzeSingleTime;
|
|
64
68
|
private _analyzeTimeRange;
|
|
69
|
+
/**
|
|
70
|
+
* @returns A promise tht resolves to an object containing the object and position of the first intersection.
|
|
71
|
+
* @see https://github.com/CesiumGS/cesium/blob/1.136/packages/engine/Source/Scene/Scene.js#L4868
|
|
72
|
+
*/
|
|
73
|
+
private _pick;
|
|
65
74
|
private _getExcludedObjects;
|
|
66
75
|
}
|
|
67
76
|
declare namespace Sunlight {
|
|
77
|
+
const DETECTION_ELLIPSOID_ID = "sunlight-detection-ellipsoid";
|
|
68
78
|
/** for time-range analysis */
|
|
69
79
|
interface TimeRange {
|
|
70
80
|
/** When to start analysis */
|
|
@@ -88,7 +98,7 @@ declare namespace Sunlight {
|
|
|
88
98
|
/** ISO time string */
|
|
89
99
|
timestamp: string;
|
|
90
100
|
/** Whether the sunlight has reached */
|
|
91
|
-
result: boolean;
|
|
101
|
+
result: boolean | any;
|
|
92
102
|
}
|
|
93
103
|
}
|
|
94
104
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Color as
|
|
1
|
+
import{Cartesian3 as n,Color as h,Entity as p,EntityCollection as d,JulianDate as u,Material as _,PolylineCollection as g,Ray as m}from"cesium";var o=class c{_uniformState;_viewer;_analyzing=!1;_pointEntityId;_objectsToExclude=[];_polylines;_points;constructor(e){this._uniformState=e.scene.context.uniformState,this._viewer=e,this._polylines=e.scene.primitives.add(new g),this._points=new d,e.entities.add(this._points)}get sunPositionWC(){return this._uniformState._sunPositionWC}get sunDirectionWC(){return this._uniformState._sunDirectionWC}get isAnalyzing(){return this._analyzing}virtualSun(e,t=1e4){let i=n.normalize(n.subtract(this.sunPositionWC,e,new n),new n);return n.multiplyByScalar(i,t,i),{position:n.add(e,i,new n),direction:n.normalize(n.subtract(e,this.sunPositionWC,new n),new n)}}async analyze(e,t,i){if(!this._pointEntityId)throw new Error("Analyze error boundary hasn't been set. Create Error boundary entity first using createDetectionEllipsoid first.");let s=this._viewer.clock.currentTime.clone();this._analyzing=!0;try{return t instanceof u?await this._analyzeSingleTime(e,t,i):await this._analyzeTimeRange(e,t,i)}finally{this._viewer.clock.currentTime=s,this._viewer.scene.render(),this._analyzing=!1}}clear(){this._objectsToExclude=[],this._points.values.length>0&&this._points.removeAll(),this._polylines.length>0&&this._polylines.removeAll()}setTargetPoint(e,t,i,s=h.LIMEGREEN.withAlpha(.8)){this._pointEntityId&&this._viewer.entities.removeById(this._pointEntityId);let a=i??3,r=this._viewer.entities.add(new p({ellipsoid:{show:t,radii:new n(a,a,a),material:t?s:void 0,fill:!0},position:e,id:c.DETECTION_ELLIPSOID_ID}));return this._pointEntityId=r.id,this._viewer.scene.render(),r}async _analyzeSingleTime(e,t,i){this._viewer.clock.currentTime=t,this._viewer.scene.render(t);let s=[e,this.virtualSun(e).position];if(i?.debugShowRays){let r=this._polylines.add({show:!0,positions:s,width:5,material:new _({fabric:{type:"Color",uniforms:{color:h.YELLOW.withAlpha(.5)}}})});this._objectsToExclude.push(r)}let a=await this._pick(e,i?.objectsToExclude);return{timestamp:t.toString(),result:a?a.object?.id?.id===this._pointEntityId:!1}}async _analyzeTimeRange(e,t,i){let s=[],{start:a,end:r,step:y}=t,l=a.clone();for(;u.compare(l,r)<=0;)s.push(await this._analyzeSingleTime(e,l,i)),u.addSeconds(l,y,l);return s}async _pick(e,t,i=.1){let{position:s,direction:a}=this.virtualSun(e),r=new m(s,a);return await this._viewer.scene.pickFromRayMostDetailed(r,this._getExcludedObjects(t),i)}_getExcludedObjects(e){return[...this._objectsToExclude,...e??[]]}};(e=>e.DETECTION_ELLIPSOID_ID="sunlight-detection-ellipsoid")(o||={});var w=o;export{w as Sunlight};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var w=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var B=(r,e)=>{for(var t in e)w(r,t,{get:e[t],enumerable:!0})},N=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of G(e))!F.call(r,n)&&n!==t&&w(r,n,{get:()=>e[n],enumerable:!(i=V(e,n))||i.enumerable});return r};var W=r=>N(w({},"__esModule",{value:!0}),r);var q={};B(q,{Collection:()=>x,Highlight:()=>I,HybridTerrainProvider:()=>T,SilhouetteHighlight:()=>g,SurfaceHighlight:()=>p,cloneViewer:()=>H,syncCamera:()=>C});module.exports=W(q);var v=require("cesium");var R;(d=>{let r=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(l,s={}){if(!e)return;let{once:f=!0,prefix:c="[DEPRECATED]",includeStack:y=!0,removeInVersion:b}=s;if(f&&r.has(l))return;let P=`${c} ${l}`;b&&(P+=` This feature will be removed in ${b}.`),typeof console<"u"&&console.warn&&(y?(console.warn(P),console.trace("Deprecation stack trace:")):console.warn(P)),f&&r.add(l)}d.warn=t;function i(l,s,f={}){let c=((...y)=>(t(s,f),l(...y)));return Object.defineProperty(c,"name",{value:l.name,configurable:!0}),c}d.deprecate=i;function n(){r.clear()}d.clear=n;function a(){return r.size}d.getWarningCount=a;function h(l){return r.has(l)}d.hasShown=h})(R||={});var A=R;var k=require("cesium");var D=require("cesium");var M=require("cesium"),_=class r{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new M.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,t,i){return this._defaultProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,i,n){if(this._ready){for(let a of this._regions)if(r.TerrainRegion.contains(a,e,t,i))return a.provider.requestTileGeometry(e,t,i,n);return this._defaultProvider.getTileDataAvailable(e,t,i)?this._defaultProvider.requestTileGeometry(e,t,i,n):this._fallbackProvider.requestTileGeometry(e,t,i,n)}}getTileDataAvailable(e,t,i){for(let n of this._regions)if(r.TerrainRegion.contains(n,e,t,i))return!0;return this._defaultProvider.getTileDataAvailable(e,t,i)}};(t=>{function r(i,n,a){return new t({regions:i.map(h=>({...h})),defaultProvider:n,fallbackProvider:a})}t.fromTileRanges=r;let e;(n=>{function i(a,h,d,l){if(a.levels&&!a.levels.includes(l))return!1;if(a.tiles){let s=a.tiles.get(l);if(!s)return!1;let[f,c]=Array.isArray(s.x)?s.x:[s.x,s.x],[y,b]=Array.isArray(s.y)?s.y:[s.y,s.y];return h>=f&&h<=c&&d>=y&&d<=b}return!1}n.contains=i})(e=t.TerrainRegion||={})})(_||={});var T=_;function O(r,e){let t=!1,i=Object.getOwnPropertyDescriptor(r,e);if(!i){let n=Object.getPrototypeOf(r);for(;n&&!i;)i=Object.getOwnPropertyDescriptor(n,e),n=Object.getPrototypeOf(n)}return i&&i.get&&!i.set&&(t=!0),t}var se=A.deprecate;var E=class r{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof v.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get tags(){return Array.from(this._tagMap.keys())}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(n=>{this.add(n,t)}):(Object.defineProperty(e,r.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}update(e,t){let i=this.get(e);for(let n of i)this._removeFromTagMap(n),Object.defineProperty(n,r.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(n,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,v.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,v.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,v.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let n=this.get(i),a=e.split("."),h=["__proto__","constructor","prototype"];for(let d of n){let l=!1;for(let c of a)if(h.includes(c)){l=!0;break}if(l)continue;let s=d,f=0;for(;f<a.length-1;f++){let c=a[f];if(!(c in s)||(s=s[c],!s||typeof s!="object"))break}if(f===a.length-1){let c=a[a.length-1];if(c in s&&typeof s[c]!="function"){if(O(s,c))throw Error(`Cannot set read-only property '${e}' on ${d.constructor.name}`);s[c]=t}}}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((n,a)=>e(n,a))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}_emit(e,t){let i=this._eventListeners.get(e);if(i){let n={type:e,...t};i.forEach(a=>a(n))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[r.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof v.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof v.PrimitiveCollection?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof v.DataSourceCollection?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof v.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}},x=E;var m=require("cesium");var u=require("cesium"),g=class{_color=u.Color.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=u.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=u.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}show(e,t){if((0,u.defined)(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{if(e instanceof u.Cesium3DTileFeature)this._silhouette.uniforms.color=t?.color||this._color,this._silhouette.selected.push(e);else{if(!e.model)return;this._entity=e,e.model.silhouetteSize=new u.ConstantProperty(t?.width||2),e.model.silhouetteColor=new u.ConstantProperty(t?.color||this._color)}this._currentObject=e,this._currentOptions=t?{...t}:void 0}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0}}}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&u.Color.equals(e.color||this._color,t.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new u.ConstantProperty(u.Color.TRANSPARENT),this._entity.model.silhouetteSize=new u.ConstantProperty(0),this._entity=void 0)}};var o=require("cesium"),p=class{_color=o.Color.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new o.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}show(e,t){if(!(!(0,o.defined)(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof o.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof o.GroundPrimitive)this._update(e,t);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=e,this._currentOptions=t?{...t}:void 0,this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0;return}}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&o.Color.equals(e.color||this._color,t.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof o.Entity){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let n;i.positions.length>0&&!o.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?n=[...i.positions,i.positions[0]]:n=i.positions,this._entity.polyline=new o.PolylineGraphics({positions:n,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new o.PolygonGraphics({hierarchy:i,material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||o.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let n=e.polyline.width?.getValue();this._entity.polyline=new o.PolylineGraphics({positions:i,material:t.color,width:n+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let n=[o.Cartesian3.fromRadians(i.west,i.north),o.Cartesian3.fromRadians(i.east,i.north),o.Cartesian3.fromRadians(i.east,i.south),o.Cartesian3.fromRadians(i.west,i.south),o.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new o.PolylineGraphics({positions:n,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new o.RectangleGraphics({coordinates:i,material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND}))}}else if(e instanceof o.GroundPrimitive){let i=e.geometryInstances,n=Array.isArray(i)?i[0]:i;if(!n.geometry.attributes.position)return;let a=n.geometry.attributes.position.values,h=[];for(let d=0;d<a.length;d+=3)h.push(new o.Cartesian3(a[d],a[d+1],a[d+2]));t.outline?this._entity.polyline=new o.PolylineGraphics({positions:h,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new o.PolygonGraphics({hierarchy:new o.PolygonHierarchy(h),material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND,classificationType:o.ClassificationType.BOTH})}}};var L=class r{static instances=new WeakMap;_surface;_silhouette;_color=m.Color.RED;constructor(e){this._surface=new p(e),this._silhouette=new g(e),this._surface.color=this._color,this._silhouette.color=this._color}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}static getInstance(e){let t=e.container;return r.instances.has(t)||r.instances.set(t,new r(e)),r.instances.get(t)}static releaseInstance(e){let t=e.container,i=r.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),r.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if((0,m.defined)(i))return i instanceof m.Cesium3DTileFeature?this._silhouette.show(i,t):i instanceof m.Entity&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if((0,m.defined)(e)){if(e instanceof m.Entity||e instanceof m.Cesium3DTileFeature||e instanceof m.GroundPrimitive)return e;if(e.id instanceof m.Entity)return e.id;if(e.primitive instanceof m.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}},I=L;var j=require("cesium");var S=require("cesium");function C(r,e){if((0,S.defined)(r)&&(0,S.defined)(e)){let{camera:t}=r;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}function H(r,e,t){let i={baseLayerPicker:r.baseLayerPicker!==void 0,geocoder:r.geocoder!==void 0,homeButton:r.homeButton!==void 0,sceneModePicker:r.sceneModePicker!==void 0,timeline:r.timeline!==void 0,navigationHelpButton:r.navigationHelpButton!==void 0,animation:r.animation!==void 0,fullscreenButton:r.fullscreenButton!==void 0,shouldAnimate:r.clock.shouldAnimate,terrainProvider:r.terrainProvider,requestRenderMode:r.scene.requestRenderMode,infoBox:r.infoBox!==void 0},n=new j.Viewer(e,{...i,...t});C(r,n);let a=r.imageryLayers;n.imageryLayers.removeAll();for(let l=0;l<a.length;l++){let s=a.get(l);n.imageryLayers.addImageryProvider(s.imageryProvider,l)}n.clock.startTime=r.clock.startTime.clone(),n.clock.stopTime=r.clock.stopTime.clone(),n.clock.currentTime=r.clock.currentTime.clone(),n.clock.multiplier=r.clock.multiplier,n.clock.clockStep=r.clock.clockStep,n.clock.clockRange=r.clock.clockRange,n.clock.shouldAnimate=r.clock.shouldAnimate,n.scene.globe.enableLighting=r.scene.globe.enableLighting,n.scene.globe.depthTestAgainstTerrain=r.scene.globe.depthTestAgainstTerrain,n.scene.screenSpaceCameraController.enableCollisionDetection=r.scene.screenSpaceCameraController.enableCollisionDetection;let h=r.scene.screenSpaceCameraController.tiltEventTypes;h&&(n.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(h)?[...h]:h);let d=r.scene.screenSpaceCameraController.zoomEventTypes;return d&&(n.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(d)?[...d]:d),n}
|
|
1
|
+
"use strict";var y=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var G=(n,e)=>{for(var t in e)y(n,t,{get:e[t],enumerable:!0})},V=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of D(e))!k.call(n,r)&&r!==t&&y(n,r,{get:()=>e[r],enumerable:!(i=j(e,r))||i.enumerable});return n};var F=n=>V(y({},"__esModule",{value:!0}),n);var B={};G(B,{Collection:()=>T,Highlight:()=>O,HybridTerrainProvider:()=>w,SilhouetteHighlight:()=>m,SurfaceHighlight:()=>p,cloneViewer:()=>x,syncCamera:()=>v});module.exports=F(B);var d=require("cesium");function _(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}function C(n,e,t){let i=e.split(".");for(let l of i)if(S(l))return{success:!1,reason:"dangerous-property",message:`Property path contains dangerous property name: "${l}"`};let r=n,s=0;for(;s<i.length-1;s++){let l=i[s];if(!r||typeof r!="object"||!Object.prototype.hasOwnProperty.call(r,l))return{success:!1,reason:"invalid-path",message:`Property path "${e}" does not exist or contains inherited properties`};if(r=r[l],!r||typeof r!="object"||r===Object.prototype)return{success:!1,reason:"invalid-path",message:`Cannot traverse path "${e}" - reached non-object or prototype`}}if(s!==i.length-1)return{success:!1,reason:"invalid-path",message:`Failed to traverse property path "${e}"`};let a=i[i.length-1];if(S(a))return{success:!1,reason:"dangerous-property",message:`Cannot set dangerous property "${a}"`};if(!r||typeof r!="object"||r===Object.prototype)return{success:!1,reason:"invalid-path",message:"Cannot set property on invalid target"};if(a in r){if(typeof r[a]=="function")return{success:!1,reason:"function-property",message:`Cannot set function property "${a}"`};if(_(r,a))return{success:!1,reason:"read-only",message:`Cannot set read-only property "${e}"`}}return r[a]=t,{success:!0}}var N=["__proto__","constructor","prototype"];function S(n){return N.includes(n)}var b=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof d.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get tags(){return Array.from(this._tagMap.keys())}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,d.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,d.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,d.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let s of r){let a=C(s,e,t);if(!a.success&&a.reason==="read-only")throw Error(`Cannot set read-only property '${e}' on ${s.constructor.name}`)}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,s)=>e(r,s))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(s=>s(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof d.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof d.PrimitiveCollection?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof d.DataSourceCollection?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof d.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}},T=b;var h=require("cesium");var c=require("cesium"),m=class{_color=c.Color.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=c.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=c.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}show(e,t){if((0,c.defined)(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{if(e instanceof c.Cesium3DTileFeature)this._silhouette.uniforms.color=t?.color||this._color,this._silhouette.selected.push(e);else{if(!e.model)return;this._entity=e,e.model.silhouetteSize=new c.ConstantProperty(t?.width||2),e.model.silhouetteColor=new c.ConstantProperty(t?.color||this._color)}this._currentObject=e,this._currentOptions=t?{...t}:void 0}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0}}}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&c.Color.equals(e.color||this._color,t.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new c.ConstantProperty(c.Color.TRANSPARENT),this._entity.model.silhouetteSize=new c.ConstantProperty(0),this._entity=void 0)}};var o=require("cesium"),p=class{_color=o.Color.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new o.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}show(e,t){if(!(!(0,o.defined)(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof o.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof o.GroundPrimitive)this._update(e,t);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=e,this._currentOptions=t?{...t}:void 0,this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0;return}}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&o.Color.equals(e.color||this._color,t.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof o.Entity){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let r;i.positions.length>0&&!o.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new o.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new o.PolygonGraphics({hierarchy:i,material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||o.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let r=e.polyline.width?.getValue();this._entity.polyline=new o.PolylineGraphics({positions:i,material:t.color,width:r+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let r=[o.Cartesian3.fromRadians(i.west,i.north),o.Cartesian3.fromRadians(i.east,i.north),o.Cartesian3.fromRadians(i.east,i.south),o.Cartesian3.fromRadians(i.west,i.south),o.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new o.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new o.RectangleGraphics({coordinates:i,material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND}))}}else if(e instanceof o.GroundPrimitive){let i=e.geometryInstances,r=Array.isArray(i)?i[0]:i;if(!r.geometry.attributes.position)return;let s=r.geometry.attributes.position.values,a=[];for(let l=0;l<s.length;l+=3)a.push(new o.Cartesian3(s[l],s[l+1],s[l+2]));t.outline?this._entity.polyline=new o.PolylineGraphics({positions:a,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new o.PolygonGraphics({hierarchy:new o.PolygonHierarchy(a),material:t.color,heightReference:o.HeightReference.CLAMP_TO_GROUND,classificationType:o.ClassificationType.BOTH})}}};var P=class n{static instances=new WeakMap;_surface;_silhouette;_color=h.Color.RED;constructor(e){this._surface=new p(e),this._silhouette=new m(e),this._surface.color=this._color,this._silhouette.color=this._color}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,i=n.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),n.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if((0,h.defined)(i))return i instanceof h.Cesium3DTileFeature?this._silhouette.show(i,t):i instanceof h.Entity&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if((0,h.defined)(e)){if(e instanceof h.Entity||e instanceof h.Cesium3DTileFeature||e instanceof h.GroundPrimitive)return e;if(e.id instanceof h.Entity)return e.id;if(e.primitive instanceof h.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}},O=P;var R=require("cesium"),g=class n{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new R.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,t,i){return this._defaultProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,i,r){if(this._ready){for(let s of this._regions)if(n.TerrainRegion.contains(s,e,t,i))return s.provider.requestTileGeometry(e,t,i,r);return this._defaultProvider.getTileDataAvailable(e,t,i)?this._defaultProvider.requestTileGeometry(e,t,i,r):this._fallbackProvider.requestTileGeometry(e,t,i,r)}}getTileDataAvailable(e,t,i){for(let r of this._regions)if(n.TerrainRegion.contains(r,e,t,i))return!0;return this._defaultProvider.getTileDataAvailable(e,t,i)}};(t=>{function n(i,r,s){return new t({regions:i.map(a=>({...a})),defaultProvider:r,fallbackProvider:s})}t.fromTileRanges=n;let e;(r=>{function i(s,a,l,f){if(s.levels&&!s.levels.includes(f))return!1;if(s.tiles){let u=s.tiles.get(f);if(!u)return!1;let[I,L]=Array.isArray(u.x)?u.x:[u.x,u.x],[A,M]=Array.isArray(u.y)?u.y:[u.y,u.y];return a>=I&&a<=L&&l>=A&&l<=M}return!1}r.contains=i})(e=t.TerrainRegion||={})})(g||={});var w=g;var H=require("cesium");var E=require("cesium");function v(n,e){if((0,E.defined)(n)&&(0,E.defined)(e)){let{camera:t}=n;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}function x(n,e,t){let i={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},r=new H.Viewer(e,{...i,...t});v(n,r);let s=n.imageryLayers;r.imageryLayers.removeAll();for(let f=0;f<s.length;f++){let u=s.get(f);r.imageryLayers.addImageryProvider(u.imageryProvider,f)}r.clock.startTime=n.clock.startTime.clone(),r.clock.stopTime=n.clock.stopTime.clone(),r.clock.currentTime=n.clock.currentTime.clone(),r.clock.multiplier=n.clock.multiplier,r.clock.clockStep=n.clock.clockStep,r.clock.clockRange=n.clock.clockRange,r.clock.shouldAnimate=n.clock.shouldAnimate,r.scene.globe.enableLighting=n.scene.globe.enableLighting,r.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,r.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let a=n.scene.screenSpaceCameraController.tiltEventTypes;a&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(a)?[...a]:a);let l=n.scene.screenSpaceCameraController.zoomEventTypes;return l&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(l)?[...l]:l),r}
|
package/dist/index.d.cts
CHANGED
|
@@ -4,4 +4,3 @@ export { TerrainOptions, TerrainRegion, TerrainTiles } from './terrain/index.cjs
|
|
|
4
4
|
export { cloneViewer, syncCamera } from './viewer/index.cjs';
|
|
5
5
|
export { H as HybridTerrainProvider } from './hybrid-terrain-provider-Th8n2hZ1.cjs';
|
|
6
6
|
import 'cesium';
|
|
7
|
-
import './type-check-C17vkHMg.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,3 @@ export { TerrainOptions, TerrainRegion, TerrainTiles } from './terrain/index.js'
|
|
|
4
4
|
export { cloneViewer, syncCamera } from './viewer/index.js';
|
|
5
5
|
export { H as HybridTerrainProvider } from './hybrid-terrain-provider-Th8n2hZ1.js';
|
|
6
6
|
import 'cesium';
|
|
7
|
-
import './type-check-C17vkHMg.js';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
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};
|