@soonspacejs/plugin-tiles 2.15.2 → 2.15.5
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/index.d.ts +1 -1
- package/dist/index.esm.js +413 -290
- package/dist/terrain-tiles-renderer/OverlayManager.d.ts +19 -4
- package/dist/terrain-tiles-renderer/ResourceManager.d.ts +2 -2
- package/dist/terrain-tiles-renderer/TerrainTilesRenderer.d.ts +25 -4
- package/dist/terrain-tiles-renderer/types.d.ts +49 -0
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import z from "soonspacejs";
|
|
2
|
-
import { TilesRenderer as
|
|
3
|
-
import { GLTFLoader as
|
|
4
|
-
import { MathUtils as
|
|
5
|
-
import { TilesFadePlugin as ie, UpdateOnChangePlugin as ae, QuantizedMeshPlugin as ee, ImageOverlayPlugin as
|
|
6
|
-
class
|
|
2
|
+
import { TilesRenderer as L } from "um-3d-tiles-renderer";
|
|
3
|
+
import { GLTFLoader as me } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
4
|
+
import { MathUtils as S, MeshBasicMaterial as ve, Color as q, Vector3 as Pe, Box3 as Ce, Sphere as _e, MeshStandardMaterial as Ie, ShaderMaterial as ge, Matrix4 as U } from "three";
|
|
5
|
+
import { TilesFadePlugin as ie, UpdateOnChangePlugin as ae, QuantizedMeshPlugin as ee, ImageOverlayPlugin as Oe, XYZTilesOverlay as Me, ReorientationPlugin as ne, StyledGeoJSONOverlay as pe, CesiumIonOverlay as be, TMSTilesOverlay as Re, UrlTemplateTilesOverlay as Ee, WMSTilesOverlay as ke, WMTSCapabilitiesLoader as Le, WMTSTilesOverlay as xe, CesiumIonAuthPlugin as Se, PlotSdfPlugin as Ne } from "um-3d-tiles-renderer/plugins";
|
|
6
|
+
class Fe {
|
|
7
7
|
constructor(e) {
|
|
8
8
|
this.parser = e, this.name = "KHR_texture_basisu_patch";
|
|
9
9
|
}
|
|
@@ -17,7 +17,7 @@ class Ae {
|
|
|
17
17
|
return t.loadTextureImage(e, a, o);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
class
|
|
20
|
+
class pt {
|
|
21
21
|
constructor(e) {
|
|
22
22
|
this.ssp = e;
|
|
23
23
|
const { controls: t, viewport: r } = e;
|
|
@@ -47,18 +47,18 @@ class _t {
|
|
|
47
47
|
z.utils.warn(`${e} already loaded`);
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
const { ssp: t, ssp: { viewport: r } } = this, s = new
|
|
50
|
+
const { ssp: t, ssp: { viewport: r } } = this, s = new L(e);
|
|
51
51
|
this.lruCache === null ? this.lruCache = s.lruCache : s.lruCache = this.lruCache, this.parseQueue === null ? this.parseQueue = s.parseQueue : s.parseQueue = this.parseQueue, this.downloadQueue === null ? this.downloadQueue = s.downloadQueue : s.downloadQueue = this.downloadQueue;
|
|
52
|
-
const a = new
|
|
53
|
-
a.register((
|
|
54
|
-
const { dracoLoader: n, ktx2Loader: o, meshoptDecoder:
|
|
55
|
-
n && a.setDRACOLoader(n), o && a.setKTX2Loader(o),
|
|
52
|
+
const a = new me(s.manager);
|
|
53
|
+
a.register((h) => new Fe(h));
|
|
54
|
+
const { dracoLoader: n, ktx2Loader: o, meshoptDecoder: d } = t.manager.store.modelManager.gltfLoader;
|
|
55
|
+
n && a.setDRACOLoader(n), o && a.setKTX2Loader(o), d && a.setMeshoptDecoder(d), s.manager.addHandler(/\.gltf$/, a), this.tilesMap.set(e, s), s.setCamera(this._tilesCamera), s.setResolutionFromRenderer(this._tilesCamera, r.renderer), s.lruCache.maxSize = 600, s.lruCache.minSize = 300, s.lruCache.unloadPercent = 0.8, t.addObject(s.group);
|
|
56
56
|
const u = () => {
|
|
57
57
|
this.cameraTransitionStart || (this.needsUpdate = !0, t.render());
|
|
58
58
|
};
|
|
59
|
-
return s.addEventListener("load-model", u), new Promise((
|
|
59
|
+
return s.addEventListener("load-model", u), new Promise((h) => {
|
|
60
60
|
s.addEventListener("load-tile-set", () => {
|
|
61
|
-
u(),
|
|
61
|
+
u(), h(s);
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
64
|
}
|
|
@@ -67,24 +67,24 @@ class _t {
|
|
|
67
67
|
return t ? (t.dispose(), this.tilesMap.delete(e), this.ssp.removeObject(t.group), !0) : !1;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
let
|
|
70
|
+
let Ge = class {
|
|
71
71
|
priority = -999;
|
|
72
72
|
processTileModel(e) {
|
|
73
73
|
e.traverse((t) => {
|
|
74
|
-
t.material && (t.material = new
|
|
74
|
+
t.material && (t.material = new ve());
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
|
-
const
|
|
79
|
-
class
|
|
78
|
+
const De = "https://sooncps.xwbuilders.com/api/ugis-dataprocess/v1/terrain/NhBLlMx3/";
|
|
79
|
+
class ft {
|
|
80
80
|
constructor(e) {
|
|
81
|
-
this.ssp = e, this.tiles = new
|
|
81
|
+
this.ssp = e, this.tiles = new L(De), this.tiles.fetchData = async (t, r) => {
|
|
82
82
|
if (/layer\.json$/.test(t)) {
|
|
83
83
|
const s = await fetch(t, r).then((a) => a.json());
|
|
84
84
|
return s.metadataAvailability = -1, new Response(JSON.stringify(s));
|
|
85
85
|
}
|
|
86
86
|
return fetch(t, r);
|
|
87
|
-
}, this.tilesFadePlugin = new ie({ maximumFadeOutTiles: 200 }), this.updateOnChangePlugin = new ae(), this.quantizedPlugin = new ee({}), this.customMaterialPlugin = new
|
|
87
|
+
}, this.tilesFadePlugin = new ie({ maximumFadeOutTiles: 200 }), this.updateOnChangePlugin = new ae(), this.quantizedPlugin = new ee({}), this.customMaterialPlugin = new Ge(), this.imageOverlayPlugin = new Oe({
|
|
88
88
|
renderer: e.viewport.renderer,
|
|
89
89
|
overlays: [
|
|
90
90
|
new Me({
|
|
@@ -122,7 +122,7 @@ class Ot {
|
|
|
122
122
|
}
|
|
123
123
|
invalidate(e, t, r) {
|
|
124
124
|
const s = () => {
|
|
125
|
-
const n =
|
|
125
|
+
const n = S.degToRad(t), o = S.degToRad(e);
|
|
126
126
|
this.reorientationPlugin.transformLatLonHeightToOrigin(
|
|
127
127
|
n,
|
|
128
128
|
o,
|
|
@@ -139,43 +139,7 @@ class Ot {
|
|
|
139
139
|
), this.loedTilesSets.clear(), this.tiles.removeEventListener("needs-render", this.render), this.tiles.removeEventListener("needs-update", this.render), this.tiles.dispose();
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
|
|
143
|
-
return i.type === "FeatureCollection" && Array.isArray(i.features);
|
|
144
|
-
}
|
|
145
|
-
function Ue(i) {
|
|
146
|
-
return i.type === "Feature" && "geometry" in i;
|
|
147
|
-
}
|
|
148
|
-
function We(i) {
|
|
149
|
-
return {
|
|
150
|
-
type: "Feature",
|
|
151
|
-
geometry: i,
|
|
152
|
-
properties: {}
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
function Qe(i) {
|
|
156
|
-
return Ge(i) ? {
|
|
157
|
-
type: "FeatureCollection",
|
|
158
|
-
features: [...i.features]
|
|
159
|
-
} : Ue(i) ? {
|
|
160
|
-
type: "FeatureCollection",
|
|
161
|
-
features: [i]
|
|
162
|
-
} : {
|
|
163
|
-
type: "FeatureCollection",
|
|
164
|
-
features: [We(i)]
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
function je(i) {
|
|
168
|
-
const e = {
|
|
169
|
-
type: "FeatureCollection",
|
|
170
|
-
features: []
|
|
171
|
-
};
|
|
172
|
-
for (const t of i) {
|
|
173
|
-
const r = Qe(t);
|
|
174
|
-
e.features.push(...r.features);
|
|
175
|
-
}
|
|
176
|
-
return e;
|
|
177
|
-
}
|
|
178
|
-
class ze {
|
|
142
|
+
class Ae {
|
|
179
143
|
// 使用较低的 priority 确保在 ImageOverlayPlugin 之后执行
|
|
180
144
|
// ImageOverlayPlugin 默认 priority 是 -1
|
|
181
145
|
priority = -999;
|
|
@@ -186,7 +150,7 @@ class ze {
|
|
|
186
150
|
*/
|
|
187
151
|
processTileModel(e) {
|
|
188
152
|
e.traverse((t) => {
|
|
189
|
-
t.material && (t.material = new
|
|
153
|
+
t.material && (t.material = new ve());
|
|
190
154
|
});
|
|
191
155
|
}
|
|
192
156
|
/**
|
|
@@ -218,67 +182,145 @@ class ze {
|
|
|
218
182
|
e.needsUpdate = !0;
|
|
219
183
|
}
|
|
220
184
|
}
|
|
221
|
-
var
|
|
222
|
-
class
|
|
185
|
+
var l = /* @__PURE__ */ ((i) => (i.GEOJSON = "geojson", i.CESIUM_ION = "cesiumIon", i.TMS = "tms", i.XYZ = "xyz", i.WMS = "wms", i.WMTS = "wmts", i.URL_TEMPLATE = "urlTemplate", i.PLOT = "plot", i))(l || {}), I = /* @__PURE__ */ ((i) => (i.QUANTIZED_MESH = "quantizedMesh", i.CESIUM_ION = "cesiumIon", i))(I || {});
|
|
186
|
+
class Q {
|
|
223
187
|
constructor(e, t) {
|
|
224
188
|
this.imageOverlayPlugin = e, this.resourceManager = t;
|
|
225
189
|
}
|
|
226
190
|
/** 存储所有 overlay 实例 */
|
|
227
191
|
static MAX_OVERLAY_INSTANCES = 10;
|
|
228
192
|
_instances = /* @__PURE__ */ new Map();
|
|
193
|
+
_geoJSONUtilityOverlay = null;
|
|
229
194
|
// =============== GeoJSON ===============
|
|
230
195
|
addGeoJSONOverlay(e) {
|
|
231
196
|
const t = this._getImageOverlayPluginForAdd(e.id);
|
|
232
197
|
if (!t) return null;
|
|
233
|
-
const r = {
|
|
198
|
+
const r = e.mode ?? "overlay", s = {
|
|
234
199
|
url: e.url,
|
|
235
200
|
geojson: e.geojson,
|
|
236
201
|
opacity: e.opacity ?? 1,
|
|
202
|
+
resolution: e.resolution ?? e.tileDimension,
|
|
203
|
+
pointRadius: e.pointRadius,
|
|
237
204
|
fillStyle: e.fillStyle,
|
|
238
205
|
strokeStyle: e.strokeStyle,
|
|
239
|
-
strokeWidth: e.strokeWidth
|
|
206
|
+
strokeWidth: e.strokeWidth,
|
|
207
|
+
defaultStyle: this._buildGeoJSONDefaultStyle(e, r),
|
|
208
|
+
...this._getGeoJSONModeFlags(r)
|
|
240
209
|
};
|
|
241
|
-
e.color && (
|
|
242
|
-
const
|
|
243
|
-
return t.addOverlay(
|
|
210
|
+
e.color !== void 0 && (s.color = new q(e.color));
|
|
211
|
+
const a = new pe(s);
|
|
212
|
+
return t.addOverlay(a, e.order), this._instances.set(e.id, {
|
|
244
213
|
id: e.id,
|
|
245
214
|
type: e.type,
|
|
246
|
-
instance:
|
|
215
|
+
instance: a,
|
|
216
|
+
options: { ...e, mode: r }
|
|
247
217
|
}), this.resourceManager?.addOverlay({
|
|
248
218
|
id: e.id,
|
|
249
219
|
type: e.type,
|
|
250
220
|
options: e
|
|
251
|
-
}),
|
|
221
|
+
}), a;
|
|
252
222
|
}
|
|
253
223
|
updateGeoJSONColor(e, t) {
|
|
254
224
|
const r = this._instances.get(e);
|
|
255
|
-
if (!r || r.type !==
|
|
225
|
+
if (!r || r.type !== l.GEOJSON) return !1;
|
|
256
226
|
const s = r.instance;
|
|
257
|
-
return s.color.set(t), s.
|
|
227
|
+
return s.color.set(t), s.requestUpdate?.(), this._updateOverlayOptions(e, { color: t }), !0;
|
|
228
|
+
}
|
|
229
|
+
updateGeoJSONDefaultStyle(e, t) {
|
|
230
|
+
const r = this._instances.get(e);
|
|
231
|
+
if (!r || r.type !== l.GEOJSON) return !1;
|
|
232
|
+
const s = r.instance, a = r.options, n = {
|
|
233
|
+
...a.defaultStyle || {},
|
|
234
|
+
...t
|
|
235
|
+
}, o = {
|
|
236
|
+
...a,
|
|
237
|
+
defaultStyle: n
|
|
238
|
+
};
|
|
239
|
+
return s.defaultStyle = this._buildGeoJSONDefaultStyle(o, o.mode ?? "overlay"), this._updateOverlayOptions(e, { defaultStyle: n }), !0;
|
|
258
240
|
}
|
|
259
241
|
updateGeoJSONStrokeStyle(e, t) {
|
|
260
242
|
const r = this._instances.get(e);
|
|
261
|
-
if (!r || r.type !==
|
|
262
|
-
const s = r.instance
|
|
263
|
-
|
|
243
|
+
if (!r || r.type !== l.GEOJSON) return !1;
|
|
244
|
+
const s = r.instance, a = r.options, n = {
|
|
245
|
+
...a.defaultStyle || {},
|
|
246
|
+
strokeStyle: t
|
|
247
|
+
}, o = {
|
|
248
|
+
...a,
|
|
249
|
+
strokeStyle: t,
|
|
250
|
+
defaultStyle: n
|
|
251
|
+
};
|
|
252
|
+
return s.defaultStyle = this._buildGeoJSONDefaultStyle(o, o.mode ?? "overlay"), this._updateOverlayOptions(e, { strokeStyle: t, defaultStyle: n }), !0;
|
|
264
253
|
}
|
|
265
254
|
updateGeoJSONStrokeWidth(e, t) {
|
|
266
255
|
const r = this._instances.get(e);
|
|
267
|
-
if (!r || r.type !==
|
|
268
|
-
const s = r.instance
|
|
269
|
-
|
|
256
|
+
if (!r || r.type !== l.GEOJSON) return !1;
|
|
257
|
+
const s = r.instance, a = r.options, n = {
|
|
258
|
+
...a.defaultStyle || {},
|
|
259
|
+
strokeWidth: t
|
|
260
|
+
}, o = {
|
|
261
|
+
...a,
|
|
262
|
+
strokeWidth: t,
|
|
263
|
+
defaultStyle: n
|
|
264
|
+
};
|
|
265
|
+
return s.defaultStyle = this._buildGeoJSONDefaultStyle(o, o.mode ?? "overlay"), this._updateOverlayOptions(e, { strokeWidth: t, defaultStyle: n }), !0;
|
|
270
266
|
}
|
|
271
267
|
updateGeoJSONFillStyle(e, t) {
|
|
272
268
|
const r = this._instances.get(e);
|
|
273
|
-
if (!r || r.type !==
|
|
274
|
-
const s = r.instance
|
|
275
|
-
|
|
269
|
+
if (!r || r.type !== l.GEOJSON) return !1;
|
|
270
|
+
const s = r.instance, a = r.options, n = {
|
|
271
|
+
...a.defaultStyle || {},
|
|
272
|
+
fillStyle: t
|
|
273
|
+
}, o = {
|
|
274
|
+
...a,
|
|
275
|
+
fillStyle: t,
|
|
276
|
+
defaultStyle: n
|
|
277
|
+
};
|
|
278
|
+
return s.defaultStyle = this._buildGeoJSONDefaultStyle(o, o.mode ?? "overlay"), this._updateOverlayOptions(e, { fillStyle: t, defaultStyle: n }), !0;
|
|
276
279
|
}
|
|
277
280
|
updateGeoJSONMode(e, t) {
|
|
278
281
|
const r = this._instances.get(e);
|
|
279
|
-
if (!r || r.type !==
|
|
280
|
-
const s = r.instance
|
|
281
|
-
|
|
282
|
+
if (!r || r.type !== l.GEOJSON) return !1;
|
|
283
|
+
const s = r.instance, a = {
|
|
284
|
+
...r.options,
|
|
285
|
+
mode: t
|
|
286
|
+
}, n = this._getGeoJSONModeFlags(t);
|
|
287
|
+
return s.alphaInvert = n.alphaInvert, s.alphaMask = n.alphaMask, s.defaultStyle = this._buildGeoJSONDefaultStyle(a, t), s.requestUpdate?.(), this._updateOverlayOptions(e, { mode: t }), !0;
|
|
288
|
+
}
|
|
289
|
+
setGeoJSON(e, t) {
|
|
290
|
+
const r = this._instances.get(e);
|
|
291
|
+
return !r || r.type !== l.GEOJSON ? !1 : (r.instance.setGeoJSON(t), this._updateOverlayOptions(e, { geojson: t }), !0);
|
|
292
|
+
}
|
|
293
|
+
normalizeGeoJSON(e) {
|
|
294
|
+
return this._getGeoJSONUtilityOverlay().normalizeGeoJSON(e);
|
|
295
|
+
}
|
|
296
|
+
mergeGeoJSON(e) {
|
|
297
|
+
return this._getGeoJSONUtilityOverlay().mergeGeoJSON(e);
|
|
298
|
+
}
|
|
299
|
+
setMergedGeoJSON(e, t, r) {
|
|
300
|
+
const s = this._instances.get(e);
|
|
301
|
+
if (!s || s.type !== l.GEOJSON) return null;
|
|
302
|
+
const n = s.instance.setMergedGeoJSON(t, r);
|
|
303
|
+
return this._updateOverlayOptions(e, { geojson: n }), n;
|
|
304
|
+
}
|
|
305
|
+
getGeoJSONFeatureById(e, t) {
|
|
306
|
+
const r = this._instances.get(e);
|
|
307
|
+
return !r || r.type !== l.GEOJSON ? null : r.instance.getFeatureById(t);
|
|
308
|
+
}
|
|
309
|
+
updateGeoJSONFeatureStyleById(e, t, r) {
|
|
310
|
+
const s = this._instances.get(e);
|
|
311
|
+
return !s || s.type !== l.GEOJSON ? !1 : (s.instance.updateFeatureStyleById(
|
|
312
|
+
t,
|
|
313
|
+
r,
|
|
314
|
+
{ requestUpdate: !0 }
|
|
315
|
+
), !0);
|
|
316
|
+
}
|
|
317
|
+
updateGeoJSONFeatureStylesByIds(e, t, r) {
|
|
318
|
+
const s = this._instances.get(e);
|
|
319
|
+
return !s || s.type !== l.GEOJSON ? !1 : (s.instance.updateFeatureStylesByIds(
|
|
320
|
+
t,
|
|
321
|
+
r,
|
|
322
|
+
{ requestUpdate: !0 }
|
|
323
|
+
), !0);
|
|
282
324
|
}
|
|
283
325
|
// =============== Cesium Ion ===============
|
|
284
326
|
addCesiumIonOverlay(e) {
|
|
@@ -294,7 +336,8 @@ class B {
|
|
|
294
336
|
return t.addOverlay(r, e.order), this._instances.set(e.id, {
|
|
295
337
|
id: e.id,
|
|
296
338
|
type: e.type,
|
|
297
|
-
instance: r
|
|
339
|
+
instance: r,
|
|
340
|
+
options: { ...e }
|
|
298
341
|
}), this.resourceManager?.addOverlay({
|
|
299
342
|
id: e.id,
|
|
300
343
|
type: e.type,
|
|
@@ -305,7 +348,7 @@ class B {
|
|
|
305
348
|
addTMSOverlay(e) {
|
|
306
349
|
const t = this._getImageOverlayPluginForAdd(e.id);
|
|
307
350
|
if (!t) return null;
|
|
308
|
-
const r = new
|
|
351
|
+
const r = new Re({
|
|
309
352
|
url: e.url,
|
|
310
353
|
color: typeof e.color == "number" ? e.color : 16777215,
|
|
311
354
|
opacity: e.opacity ?? 1
|
|
@@ -313,7 +356,8 @@ class B {
|
|
|
313
356
|
return t.addOverlay(r, e.order), this._instances.set(e.id, {
|
|
314
357
|
id: e.id,
|
|
315
358
|
type: e.type,
|
|
316
|
-
instance: r
|
|
359
|
+
instance: r,
|
|
360
|
+
options: { ...e }
|
|
317
361
|
}), this.resourceManager?.addOverlay({
|
|
318
362
|
id: e.id,
|
|
319
363
|
type: e.type,
|
|
@@ -332,7 +376,8 @@ class B {
|
|
|
332
376
|
return t.addOverlay(r, e.order), this._instances.set(e.id, {
|
|
333
377
|
id: e.id,
|
|
334
378
|
type: e.type,
|
|
335
|
-
instance: r
|
|
379
|
+
instance: r,
|
|
380
|
+
options: { ...e }
|
|
336
381
|
}), this.resourceManager?.addOverlay({
|
|
337
382
|
id: e.id,
|
|
338
383
|
type: e.type,
|
|
@@ -388,7 +433,8 @@ class B {
|
|
|
388
433
|
return t.addOverlay(r, e.order), this._instances.set(e.id, {
|
|
389
434
|
id: e.id,
|
|
390
435
|
type: e.type,
|
|
391
|
-
instance: r
|
|
436
|
+
instance: r,
|
|
437
|
+
options: { ...e }
|
|
392
438
|
}), this.resourceManager?.addOverlay({
|
|
393
439
|
id: e.id,
|
|
394
440
|
type: e.type,
|
|
@@ -405,20 +451,21 @@ class B {
|
|
|
405
451
|
crs: e.crs || "EPSG:4326",
|
|
406
452
|
format: e.format || "image/png",
|
|
407
453
|
tileDimension: e.tileDimension || 256
|
|
408
|
-
}, s = new
|
|
454
|
+
}, s = new ke({
|
|
409
455
|
url: e.url,
|
|
410
456
|
layer: r.layer,
|
|
411
457
|
crs: r.crs,
|
|
412
458
|
format: r.format,
|
|
413
459
|
tileDimension: r.tileDimension,
|
|
414
460
|
styles: r.styles,
|
|
415
|
-
color: new
|
|
461
|
+
color: new q(typeof e.color == "number" ? e.color : 16777215),
|
|
416
462
|
opacity: e.opacity ?? 1
|
|
417
463
|
});
|
|
418
464
|
return t.addOverlay(s, e.order), this._instances.set(e.id, {
|
|
419
465
|
id: e.id,
|
|
420
466
|
type: e.type,
|
|
421
|
-
instance: s
|
|
467
|
+
instance: s,
|
|
468
|
+
options: { ...e }
|
|
422
469
|
}), this.resourceManager?.addOverlay({
|
|
423
470
|
id: e.id,
|
|
424
471
|
type: e.type,
|
|
@@ -429,25 +476,26 @@ class B {
|
|
|
429
476
|
async addWMTSOverlay(e) {
|
|
430
477
|
const t = this._getImageOverlayPluginForAdd(e.id);
|
|
431
478
|
if (!t) return null;
|
|
432
|
-
const r = await new
|
|
479
|
+
const r = await new Le().loadAsync(e.url), s = ["EPSG:4326", "EPSG:3857"];
|
|
433
480
|
let a = e.layer || "";
|
|
434
481
|
r.layers.find((o) => o.identifier === a) || (a = r.layers.find(
|
|
435
|
-
(o) => o?.tileMatrixSets?.some((
|
|
482
|
+
(o) => o?.tileMatrixSets?.some((d) => s.includes(d.supportedCRS))
|
|
436
483
|
)?.identifier || r.layers[0].identifier);
|
|
437
|
-
const n = new
|
|
484
|
+
const n = new xe({
|
|
438
485
|
capabilities: r,
|
|
439
486
|
layer: a,
|
|
440
487
|
dimensions: e.dimensions || null,
|
|
441
488
|
style: e.style || void 0,
|
|
442
489
|
tileMatrixSet: e.tileMatrixSet || null,
|
|
443
490
|
planar: !1,
|
|
444
|
-
color: new
|
|
491
|
+
color: new q(typeof e.color == "number" ? e.color : 16777215),
|
|
445
492
|
opacity: e.opacity ?? 1
|
|
446
493
|
});
|
|
447
494
|
return t.addOverlay(n, e.order), this._instances.set(e.id, {
|
|
448
495
|
id: e.id,
|
|
449
496
|
type: e.type,
|
|
450
|
-
instance: n
|
|
497
|
+
instance: n,
|
|
498
|
+
options: { ...e }
|
|
451
499
|
}), this.resourceManager?.addOverlay({
|
|
452
500
|
id: e.id,
|
|
453
501
|
type: e.type,
|
|
@@ -461,12 +509,12 @@ class B {
|
|
|
461
509
|
remove(e) {
|
|
462
510
|
const t = this._instances.get(e);
|
|
463
511
|
return t ? [
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
512
|
+
l.XYZ,
|
|
513
|
+
l.TMS,
|
|
514
|
+
l.WMS,
|
|
515
|
+
l.WMTS,
|
|
516
|
+
l.CESIUM_ION,
|
|
517
|
+
l.URL_TEMPLATE
|
|
470
518
|
].includes(t.type) && (this.resourceManager?.getImageryOverlayCount() ?? this._getLocalImageryCount()) <= 1 ? (console.warn("OverlayManager: Cannot remove overlay - at least one imagery overlay must remain"), !1) : (this.imageOverlayPlugin?.deleteOverlay(t.instance), this._instances.delete(e), this.resourceManager?.removeOverlay(e), !0) : (console.warn(`OverlayManager: Overlay "${e}" not found`), !1);
|
|
471
519
|
}
|
|
472
520
|
/**
|
|
@@ -486,14 +534,14 @@ class B {
|
|
|
486
534
|
*/
|
|
487
535
|
setVisible(e, t) {
|
|
488
536
|
const r = this._instances.get(e);
|
|
489
|
-
return r && "opacity" in r.instance ? (r.instance.opacity = t ? 1 : 0, this.
|
|
537
|
+
return r && "opacity" in r.instance ? (r.instance.opacity = t ? 1 : 0, this._updateOverlayOptions(e, { opacity: t ? 1 : 0 }), !0) : !1;
|
|
490
538
|
}
|
|
491
539
|
/**
|
|
492
540
|
* 设置 overlay 透明度
|
|
493
541
|
*/
|
|
494
542
|
setOpacity(e, t) {
|
|
495
543
|
const r = this._instances.get(e);
|
|
496
|
-
return r && "opacity" in r.instance ? (r.instance.opacity = t, this.
|
|
544
|
+
return r && "opacity" in r.instance ? (r.instance.opacity = t, this._updateOverlayOptions(e, { opacity: t }), r.instance.redraw?.(), !0) : !1;
|
|
497
545
|
}
|
|
498
546
|
/**
|
|
499
547
|
* 设置 overlay 层级
|
|
@@ -501,7 +549,7 @@ class B {
|
|
|
501
549
|
setOrder(e, t) {
|
|
502
550
|
if (!this.imageOverlayPlugin) return !1;
|
|
503
551
|
const r = this._instances.get(e);
|
|
504
|
-
return r ? (this.imageOverlayPlugin.setOverlayOrder(r.instance, t), this.
|
|
552
|
+
return r ? (this.imageOverlayPlugin.setOverlayOrder(r.instance, t), this._updateOverlayOptions(e, { order: t }), !0) : !1;
|
|
505
553
|
}
|
|
506
554
|
/**
|
|
507
555
|
* 获取 overlay 层级
|
|
@@ -522,7 +570,7 @@ class B {
|
|
|
522
570
|
let s = 0;
|
|
523
571
|
return r.forEach((a) => {
|
|
524
572
|
a.order > s && (s = a.order);
|
|
525
|
-
}), this.imageOverlayPlugin.setOverlayOrder(t.instance, s + 1), this.
|
|
573
|
+
}), this.imageOverlayPlugin.setOverlayOrder(t.instance, s + 1), this._updateOverlayOptions(e, { order: s + 1 }), !0;
|
|
526
574
|
}
|
|
527
575
|
/**
|
|
528
576
|
* 将 overlay 移到最底层
|
|
@@ -535,7 +583,7 @@ class B {
|
|
|
535
583
|
let s = 1 / 0;
|
|
536
584
|
return r.forEach((a) => {
|
|
537
585
|
a.order < s && (s = a.order);
|
|
538
|
-
}), this.imageOverlayPlugin.setOverlayOrder(t.instance, s - 1), this.
|
|
586
|
+
}), this.imageOverlayPlugin.setOverlayOrder(t.instance, s - 1), this._updateOverlayOptions(e, { order: s - 1 }), !0;
|
|
539
587
|
}
|
|
540
588
|
// =============== 资源恢复 ===============
|
|
541
589
|
/**
|
|
@@ -553,25 +601,25 @@ class B {
|
|
|
553
601
|
_createOverlayFromResource(e) {
|
|
554
602
|
const t = this.resourceManager;
|
|
555
603
|
switch (this.resourceManager = void 0, e.type) {
|
|
556
|
-
case
|
|
604
|
+
case l.GEOJSON:
|
|
557
605
|
this.addGeoJSONOverlay(e.options);
|
|
558
606
|
break;
|
|
559
|
-
case
|
|
607
|
+
case l.CESIUM_ION:
|
|
560
608
|
this.addCesiumIonOverlay(e.options);
|
|
561
609
|
break;
|
|
562
|
-
case
|
|
610
|
+
case l.TMS:
|
|
563
611
|
this.addTMSOverlay(e.options);
|
|
564
612
|
break;
|
|
565
|
-
case
|
|
613
|
+
case l.XYZ:
|
|
566
614
|
this.addXYZOverlay(e.options);
|
|
567
615
|
break;
|
|
568
|
-
case
|
|
616
|
+
case l.WMS:
|
|
569
617
|
this.addWMSOverlay(e.options);
|
|
570
618
|
break;
|
|
571
|
-
case
|
|
619
|
+
case l.WMTS:
|
|
572
620
|
this.addWMTSOverlay(e.options);
|
|
573
621
|
break;
|
|
574
|
-
case
|
|
622
|
+
case l.URL_TEMPLATE:
|
|
575
623
|
this.addUrlTemplateOverlay(e.options);
|
|
576
624
|
break;
|
|
577
625
|
}
|
|
@@ -590,8 +638,45 @@ class B {
|
|
|
590
638
|
get count() {
|
|
591
639
|
return this._instances.size;
|
|
592
640
|
}
|
|
641
|
+
_buildGeoJSONDefaultStyle(e, t = "overlay") {
|
|
642
|
+
const r = {
|
|
643
|
+
visible: !0,
|
|
644
|
+
zIndex: 0,
|
|
645
|
+
opacity: 1,
|
|
646
|
+
fillStyle: "rgba( 255, 255, 255, 0.5 )",
|
|
647
|
+
fillOpacity: 1,
|
|
648
|
+
strokeStyle: "white",
|
|
649
|
+
strokeWidth: 2,
|
|
650
|
+
strokeOpacity: 1,
|
|
651
|
+
lineDash: [],
|
|
652
|
+
lineCap: "butt",
|
|
653
|
+
lineJoin: "miter",
|
|
654
|
+
pointRadius: 6,
|
|
655
|
+
pointOpacity: 1,
|
|
656
|
+
pointFillStyle: null,
|
|
657
|
+
pointStrokeStyle: null,
|
|
658
|
+
pointStrokeWidth: null
|
|
659
|
+
};
|
|
660
|
+
return e.visible !== void 0 && (r.visible = e.visible), e.zIndex !== void 0 && (r.zIndex = e.zIndex), e.fillStyle !== void 0 && (r.fillStyle = e.fillStyle), e.fillOpacity !== void 0 && (r.fillOpacity = e.fillOpacity), e.strokeStyle !== void 0 && (r.strokeStyle = e.strokeStyle), e.strokeWidth !== void 0 && (r.strokeWidth = e.strokeWidth), e.strokeOpacity !== void 0 && (r.strokeOpacity = e.strokeOpacity), e.lineDash !== void 0 && (r.lineDash = e.lineDash), e.lineCap !== void 0 && (r.lineCap = e.lineCap), e.lineJoin !== void 0 && (r.lineJoin = e.lineJoin), e.pointRadius !== void 0 && (r.pointRadius = e.pointRadius), e.pointFillStyle !== void 0 && (r.pointFillStyle = e.pointFillStyle), e.pointStrokeStyle !== void 0 && (r.pointStrokeStyle = e.pointStrokeStyle), e.pointStrokeWidth !== void 0 && (r.pointStrokeWidth = e.pointStrokeWidth), Object.assign(r, e.defaultStyle || {}), (t === "mask" || t === "invertMask") && (r.fillStyle = "white", r.fillOpacity = 1), r;
|
|
661
|
+
}
|
|
662
|
+
_getGeoJSONModeFlags(e) {
|
|
663
|
+
return {
|
|
664
|
+
alphaMask: e === "mask" || e === "invertMask",
|
|
665
|
+
alphaInvert: e === "invertMask"
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
_getGeoJSONUtilityOverlay() {
|
|
669
|
+
return this._geoJSONUtilityOverlay || (this._geoJSONUtilityOverlay = new pe({})), this._geoJSONUtilityOverlay;
|
|
670
|
+
}
|
|
671
|
+
_updateOverlayOptions(e, t) {
|
|
672
|
+
const r = this._instances.get(e);
|
|
673
|
+
r && (r.options = {
|
|
674
|
+
...r.options || {},
|
|
675
|
+
...t
|
|
676
|
+
}), this.resourceManager?.updateOverlay(e, t);
|
|
677
|
+
}
|
|
593
678
|
_getImageOverlayPluginForAdd(e) {
|
|
594
|
-
return this.imageOverlayPlugin ? this._instances.has(e) ? (console.warn(`OverlayManager: Overlay "${e}" already exists`), null) : this._instances.size >=
|
|
679
|
+
return this.imageOverlayPlugin ? this._instances.has(e) ? (console.warn(`OverlayManager: Overlay "${e}" already exists`), null) : this._instances.size >= Q.MAX_OVERLAY_INSTANCES ? (console.error(`OverlayManager: Cannot add overlay "${e}" because the maximum number of overlays is ${Q.MAX_OVERLAY_INSTANCES}`), null) : this.imageOverlayPlugin : null;
|
|
595
680
|
}
|
|
596
681
|
/**
|
|
597
682
|
* 获取本地影像数量(不依赖 ResourceManager)
|
|
@@ -599,7 +684,7 @@ class B {
|
|
|
599
684
|
_getLocalImageryCount() {
|
|
600
685
|
let e = 0;
|
|
601
686
|
return this._instances.forEach((t) => {
|
|
602
|
-
[
|
|
687
|
+
[l.XYZ, l.TMS, l.WMS, l.WMTS, l.CESIUM_ION, l.URL_TEMPLATE].includes(t.type) && e++;
|
|
603
688
|
}), e;
|
|
604
689
|
}
|
|
605
690
|
/**
|
|
@@ -617,7 +702,7 @@ class B {
|
|
|
617
702
|
this.disposeInstances(), this.resourceManager?.clear();
|
|
618
703
|
}
|
|
619
704
|
}
|
|
620
|
-
class
|
|
705
|
+
class Je {
|
|
621
706
|
/** Overlay 资源配置 */
|
|
622
707
|
_overlays = /* @__PURE__ */ new Map();
|
|
623
708
|
// =============== Overlay 资源管理 ===============
|
|
@@ -675,7 +760,7 @@ class Be {
|
|
|
675
760
|
getImageryOverlayCount() {
|
|
676
761
|
let e = 0;
|
|
677
762
|
return this._overlays.forEach((t) => {
|
|
678
|
-
(t.type ===
|
|
763
|
+
(t.type === l.XYZ || t.type === l.TMS || t.type === l.WMS || t.type === l.WMTS || t.type === l.CESIUM_ION || t.type === l.URL_TEMPLATE) && e++;
|
|
679
764
|
}), e;
|
|
680
765
|
}
|
|
681
766
|
/**
|
|
@@ -707,7 +792,7 @@ class Be {
|
|
|
707
792
|
e.overlays && (this._overlays.clear(), e.overlays.forEach((t) => this._overlays.set(t.id, { ...t })));
|
|
708
793
|
}
|
|
709
794
|
}
|
|
710
|
-
class
|
|
795
|
+
class Ue {
|
|
711
796
|
/** 地形配置映射表 */
|
|
712
797
|
_terrains = /* @__PURE__ */ new Map();
|
|
713
798
|
/** 当前激活的地形 ID */
|
|
@@ -796,13 +881,13 @@ class He {
|
|
|
796
881
|
this.clear();
|
|
797
882
|
}
|
|
798
883
|
}
|
|
799
|
-
let
|
|
884
|
+
let We = 1;
|
|
800
885
|
class C {
|
|
801
886
|
id;
|
|
802
887
|
category = "";
|
|
803
888
|
options;
|
|
804
889
|
constructor(e) {
|
|
805
|
-
this.id = String(
|
|
890
|
+
this.id = String(We++), this.category = "", this.options = { ...e }, this.options.points && (this.options.points = this.options.points.map((t) => [t[0], t[1]]));
|
|
806
891
|
}
|
|
807
892
|
/**
|
|
808
893
|
* 合并更新 `options`(不可变风格:整表替换为新对象)。
|
|
@@ -835,7 +920,7 @@ class C {
|
|
|
835
920
|
return this.options.points || [];
|
|
836
921
|
}
|
|
837
922
|
}
|
|
838
|
-
class
|
|
923
|
+
class Be extends C {
|
|
839
924
|
category = "point";
|
|
840
925
|
constructor(e) {
|
|
841
926
|
super(e);
|
|
@@ -851,7 +936,7 @@ class Xe extends C {
|
|
|
851
936
|
return this.getCenterPoints();
|
|
852
937
|
}
|
|
853
938
|
}
|
|
854
|
-
class
|
|
939
|
+
class ze extends C {
|
|
855
940
|
category = "line";
|
|
856
941
|
constructor(e) {
|
|
857
942
|
super(e);
|
|
@@ -860,7 +945,7 @@ class Ye extends C {
|
|
|
860
945
|
this.options = { ...this.options, ...e };
|
|
861
946
|
}
|
|
862
947
|
}
|
|
863
|
-
class
|
|
948
|
+
class Qe extends C {
|
|
864
949
|
category = "polygon";
|
|
865
950
|
constructor(e) {
|
|
866
951
|
super(e);
|
|
@@ -869,7 +954,7 @@ class Ze extends C {
|
|
|
869
954
|
this.options = { ...this.options, ...e };
|
|
870
955
|
}
|
|
871
956
|
}
|
|
872
|
-
class
|
|
957
|
+
class je extends C {
|
|
873
958
|
category = "rectangle";
|
|
874
959
|
constructor(e) {
|
|
875
960
|
super(e);
|
|
@@ -878,9 +963,9 @@ class qe extends C {
|
|
|
878
963
|
this.options = { ...this.options, ...e };
|
|
879
964
|
}
|
|
880
965
|
}
|
|
881
|
-
const Te =
|
|
966
|
+
const Te = S.DEG2RAD;
|
|
882
967
|
new Pe();
|
|
883
|
-
class
|
|
968
|
+
class He extends C {
|
|
884
969
|
category = "sector";
|
|
885
970
|
constructor(e) {
|
|
886
971
|
super(e);
|
|
@@ -898,29 +983,29 @@ class Ve extends C {
|
|
|
898
983
|
];
|
|
899
984
|
}
|
|
900
985
|
}
|
|
901
|
-
const
|
|
902
|
-
function
|
|
986
|
+
const ye = 100, oe = 1e-4;
|
|
987
|
+
function T(i, e) {
|
|
903
988
|
return Math.sqrt((i[0] - e[0]) ** 2 + (i[1] - e[1]) ** 2);
|
|
904
989
|
}
|
|
905
990
|
function le(i) {
|
|
906
991
|
let e = 0;
|
|
907
992
|
for (let t = 0; t < i.length - 1; t++)
|
|
908
|
-
e +=
|
|
993
|
+
e += T(i[t], i[t + 1]);
|
|
909
994
|
return e;
|
|
910
995
|
}
|
|
911
|
-
function
|
|
996
|
+
function B(i) {
|
|
912
997
|
return le(i) ** 0.99;
|
|
913
998
|
}
|
|
914
|
-
function
|
|
999
|
+
function de(i, e) {
|
|
915
1000
|
return [(i[0] + e[0]) / 2, (i[1] + e[1]) / 2];
|
|
916
1001
|
}
|
|
917
1002
|
function te(i, e) {
|
|
918
1003
|
const t = Math.asin(
|
|
919
|
-
Math.abs(e[1] - i[1]) /
|
|
1004
|
+
Math.abs(e[1] - i[1]) / T(i, e)
|
|
920
1005
|
);
|
|
921
1006
|
return e[1] >= i[1] && e[0] >= i[0] ? t + Math.PI : e[1] >= i[1] && e[0] < i[0] ? Math.PI * 2 - t : e[1] < i[1] && e[0] < i[0] ? t : Math.PI - t;
|
|
922
1007
|
}
|
|
923
|
-
function
|
|
1008
|
+
function Xe(i, e, t) {
|
|
924
1009
|
const r = te(e, i) - te(e, t);
|
|
925
1010
|
return r < 0 ? r + Math.PI * 2 : r;
|
|
926
1011
|
}
|
|
@@ -931,83 +1016,83 @@ function f(i, e, t, r, s) {
|
|
|
931
1016
|
const a = te(i, e), n = s ? a + t : a - t;
|
|
932
1017
|
return [e[0] + r * Math.cos(n), e[1] + r * Math.sin(n)];
|
|
933
1018
|
}
|
|
934
|
-
function
|
|
1019
|
+
function he(i, e, t) {
|
|
935
1020
|
let r = i[0] - e[0], s = i[1] - e[1];
|
|
936
1021
|
const a = Math.sqrt(r * r + s * s);
|
|
937
1022
|
r /= a, s /= a;
|
|
938
1023
|
let n = t[0] - e[0], o = t[1] - e[1];
|
|
939
|
-
const
|
|
940
|
-
return n /=
|
|
1024
|
+
const d = Math.sqrt(n * n + o * o);
|
|
1025
|
+
return n /= d, o /= d, [r + n, s + o];
|
|
941
1026
|
}
|
|
942
1027
|
function ue(i, e, t, r) {
|
|
943
|
-
const s =
|
|
944
|
-
let
|
|
1028
|
+
const s = he(e, t, r), a = Math.sqrt(s[0] ** 2 + s[1] ** 2), n = T(e, t), o = T(t, r);
|
|
1029
|
+
let d, u;
|
|
945
1030
|
if (a > oe) {
|
|
946
|
-
const
|
|
947
|
-
we(e, t, r) ? (
|
|
1031
|
+
const h = s[0] / a, c = s[1] / a;
|
|
1032
|
+
we(e, t, r) ? (d = [t[0] - i * n * c, t[1] + i * n * h], u = [t[0] + i * o * c, t[1] - i * o * h]) : (d = [t[0] + i * n * c, t[1] - i * n * h], u = [t[0] - i * o * c, t[1] + i * o * h]);
|
|
948
1033
|
} else
|
|
949
|
-
|
|
950
|
-
return [
|
|
1034
|
+
d = [t[0] + i * (e[0] - t[0]), t[1] + i * (e[1] - t[1])], u = [t[0] + i * (r[0] - t[0]), t[1] + i * (r[1] - t[1])];
|
|
1035
|
+
return [d, u];
|
|
951
1036
|
}
|
|
952
|
-
function
|
|
953
|
-
const [t, r, s] = [i[0], i[1], i[2]], n = ue(0, t, r, s)[0], o =
|
|
1037
|
+
function Ye(i, e) {
|
|
1038
|
+
const [t, r, s] = [i[0], i[1], i[2]], n = ue(0, t, r, s)[0], o = he(t, r, s);
|
|
954
1039
|
if (Math.sqrt(o[0] ** 2 + o[1] ** 2) > oe) {
|
|
955
|
-
const u =
|
|
956
|
-
return [u[0] +
|
|
1040
|
+
const u = de(t, r), h = t[0] - u[0], c = t[1] - u[1], g = 2 / T(t, r), y = -g * c, p = g * h, m = y * y - p * p, _ = 2 * y * p, O = p * p - y * y, w = n[0] - u[0], P = n[1] - u[1];
|
|
1041
|
+
return [u[0] + m * w + _ * P, u[1] + _ * w + O * P];
|
|
957
1042
|
}
|
|
958
1043
|
return [t[0] + e * (r[0] - t[0]), t[1] + e * (r[1] - t[1])];
|
|
959
1044
|
}
|
|
960
|
-
function
|
|
961
|
-
const t = i.length, [r, s, a] = [i[t - 3], i[t - 2], i[t - 1]], o = ue(0, r, s, a)[1],
|
|
962
|
-
if (Math.sqrt(
|
|
963
|
-
const
|
|
964
|
-
return [
|
|
1045
|
+
function qe(i, e) {
|
|
1046
|
+
const t = i.length, [r, s, a] = [i[t - 3], i[t - 2], i[t - 1]], o = ue(0, r, s, a)[1], d = he(r, s, a);
|
|
1047
|
+
if (Math.sqrt(d[0] ** 2 + d[1] ** 2) > oe) {
|
|
1048
|
+
const h = de(s, a), c = a[0] - h[0], g = a[1] - h[1], y = 2 / T(s, a), p = -y * g, m = y * c, _ = p * p - m * m, O = 2 * p * m, w = m * m - p * p, P = o[0] - h[0], b = o[1] - h[1];
|
|
1049
|
+
return [h[0] + _ * P + O * b, h[1] + O * P + w * b];
|
|
965
1050
|
}
|
|
966
1051
|
return [a[0] + e * (s[0] - a[0]), a[1] + e * (s[1] - a[1])];
|
|
967
1052
|
}
|
|
968
|
-
function
|
|
969
|
-
let r = [
|
|
1053
|
+
function Ze(i, e) {
|
|
1054
|
+
let r = [Ye(e, i)];
|
|
970
1055
|
for (let n = 0; n < e.length - 2; n++) {
|
|
971
1056
|
const o = ue(i, e[n], e[n + 1], e[n + 2]);
|
|
972
1057
|
r = r.concat(o);
|
|
973
1058
|
}
|
|
974
|
-
const s =
|
|
1059
|
+
const s = qe(e, i);
|
|
975
1060
|
s && r.push(s);
|
|
976
1061
|
const a = [];
|
|
977
1062
|
for (let n = 0; n < e.length - 1; n++) {
|
|
978
|
-
const o = e[n],
|
|
1063
|
+
const o = e[n], d = e[n + 1];
|
|
979
1064
|
a.push(o);
|
|
980
|
-
for (let u = 0; u <
|
|
981
|
-
const
|
|
1065
|
+
for (let u = 0; u < ye; u++) {
|
|
1066
|
+
const h = u / ye, c = 1 - h, g = h * h, y = g * h, p = c * c, m = p * c, _ = r[n * 2], O = r[n * 2 + 1];
|
|
982
1067
|
a.push([
|
|
983
|
-
|
|
984
|
-
|
|
1068
|
+
m * o[0] + 3 * p * h * _[0] + 3 * c * g * O[0] + y * d[0],
|
|
1069
|
+
m * o[1] + 3 * p * h * _[1] + 3 * c * g * O[1] + y * d[1]
|
|
985
1070
|
]);
|
|
986
1071
|
}
|
|
987
|
-
a.push(
|
|
1072
|
+
a.push(d);
|
|
988
1073
|
}
|
|
989
1074
|
return a;
|
|
990
1075
|
}
|
|
991
|
-
function
|
|
1076
|
+
function Ve(i, e) {
|
|
992
1077
|
return i === 0 ? (e - 1) ** 2 / 2 : i === 1 ? (-2 * e ** 2 + 2 * e + 1) / 2 : i === 2 ? e ** 2 / 2 : 0;
|
|
993
1078
|
}
|
|
994
|
-
function
|
|
1079
|
+
function fe(i) {
|
|
995
1080
|
if (i.length <= 2) return i;
|
|
996
1081
|
const e = [i[0]], t = i.length - 3;
|
|
997
1082
|
for (let r = 0; r <= t; r++)
|
|
998
1083
|
for (let s = 0; s <= 1; s += 0.05) {
|
|
999
1084
|
let a = 0, n = 0;
|
|
1000
1085
|
for (let o = 0; o <= 2; o++) {
|
|
1001
|
-
const
|
|
1002
|
-
a +=
|
|
1086
|
+
const d = Ve(o, s);
|
|
1087
|
+
a += d * i[r + o][0], n += d * i[r + o][1];
|
|
1003
1088
|
}
|
|
1004
1089
|
e.push([a, n]);
|
|
1005
1090
|
}
|
|
1006
1091
|
return e.push(i[i.length - 1]), e;
|
|
1007
1092
|
}
|
|
1008
1093
|
function re(i, e) {
|
|
1009
|
-
const t =
|
|
1010
|
-
return [
|
|
1094
|
+
const t = B([i, e]), r = t * 0.1, s = t * 0.2, a = t * 0.25, n = Math.PI / 8.5, o = Math.PI / 13, d = f(e, i, Math.PI / 2, r, !0), u = f(e, i, Math.PI / 2, r, !1), h = f(i, e, n, a, !1), c = f(i, e, n, a, !0), g = f(i, e, o, s, !1), y = f(i, e, o, s, !0);
|
|
1095
|
+
return [d, g, h, e, c, y, u, i];
|
|
1011
1096
|
}
|
|
1012
1097
|
function se(i, e) {
|
|
1013
1098
|
if (i.length <= e) return i;
|
|
@@ -1016,43 +1101,43 @@ function se(i, e) {
|
|
|
1016
1101
|
t.push(i[Math.round(s * r)]);
|
|
1017
1102
|
return t.push(i[i.length - 1]), t;
|
|
1018
1103
|
}
|
|
1019
|
-
function
|
|
1104
|
+
function $e(i) {
|
|
1020
1105
|
if (i.length === 2)
|
|
1021
1106
|
return re(i[0], i[1]);
|
|
1022
|
-
const e =
|
|
1107
|
+
const e = Ze(0.3, i), t = se(e, 25), r = le(t), s = 0.08, a = 0.12, n = 0.2, o = Math.PI / 8.5, d = Math.PI / 13, u = 0.15, h = r * s, c = r * u, g = [], y = [];
|
|
1023
1108
|
let p = 0;
|
|
1024
|
-
const
|
|
1025
|
-
for (let v = 0; v < t.length && (v > 0 && (p +=
|
|
1026
|
-
const
|
|
1027
|
-
g.push([t[v][0] +
|
|
1109
|
+
const m = r - c;
|
|
1110
|
+
for (let v = 0; v < t.length && (v > 0 && (p += T(t[v - 1], t[v])), !(p > m)); v++) {
|
|
1111
|
+
const H = m > 0 ? p / m : 0, F = h * (1 - H * 0.5), G = v > 0 ? t[v - 1] : t[0], W = v < t.length - 1 ? t[v + 1] : t[v], D = W[0] - G[0], R = W[1] - G[1], A = Math.sqrt(D * D + R * R) || 1, J = -R / A, E = D / A;
|
|
1112
|
+
g.push([t[v][0] + J * F, t[v][1] + E * F]), y.push([t[v][0] - J * F, t[v][1] - E * F]);
|
|
1028
1113
|
}
|
|
1029
|
-
const _ = t[t.length - 1],
|
|
1030
|
-
return [...g, b,
|
|
1114
|
+
const _ = t[t.length - 1], O = t[t.length - 2], w = r * a, P = r * n, b = f(O, _, d, w, !1), x = f(O, _, d, w, !0), N = f(O, _, o, P, !1), j = f(O, _, o, P, !0);
|
|
1115
|
+
return [...g, b, N, _, j, x, ...y.reverse()];
|
|
1031
1116
|
}
|
|
1032
|
-
function
|
|
1117
|
+
function Ke(i) {
|
|
1033
1118
|
let e = i[0], t = i[1];
|
|
1034
1119
|
we(i[0], i[1], i[2]) && (e = i[1], t = i[0]);
|
|
1035
|
-
const s = [
|
|
1036
|
-
let
|
|
1120
|
+
const s = [de(e, t), ...i.slice(2)], a = 0.18, n = 0.3, o = 0.85, d = 0.15, u = 0.8;
|
|
1121
|
+
let h = B(s), c = h * a;
|
|
1037
1122
|
const g = s[s.length - 1];
|
|
1038
|
-
|
|
1039
|
-
const
|
|
1040
|
-
c >
|
|
1041
|
-
const p = c * n,
|
|
1042
|
-
c = Math.min(c,
|
|
1043
|
-
const _ = c * o,
|
|
1044
|
-
let
|
|
1045
|
-
const
|
|
1046
|
-
for (let
|
|
1047
|
-
const Y =
|
|
1048
|
-
|
|
1049
|
-
const ce = (
|
|
1050
|
-
|
|
1051
|
-
}
|
|
1052
|
-
let E = [e, ...
|
|
1053
|
-
return E = se(
|
|
1123
|
+
h = T(g, s[s.length - 2]);
|
|
1124
|
+
const y = T(e, t);
|
|
1125
|
+
c > y * u && (c = y * u);
|
|
1126
|
+
const p = c * n, m = c * d;
|
|
1127
|
+
c = Math.min(c, h);
|
|
1128
|
+
const _ = c * o, O = f(s[s.length - 2], g, 0, c, !0), w = f(s[s.length - 2], g, 0, _, !0), P = f(g, O, Math.PI / 2, p, !1), b = f(g, O, Math.PI / 2, p, !0), x = f(g, w, Math.PI / 2, m, !1), N = f(g, w, Math.PI / 2, m, !0), j = [x, P, g, b, N], v = y / B(s), H = le(s), G = B(s) * v, W = T(x, N), D = (G - W) / 2;
|
|
1129
|
+
let R = 0;
|
|
1130
|
+
const A = [], J = [];
|
|
1131
|
+
for (let M = 1; M < s.length - 1; M++) {
|
|
1132
|
+
const Y = Xe(s[M - 1], s[M], s[M + 1]) / 2;
|
|
1133
|
+
R += T(s[M - 1], s[M]);
|
|
1134
|
+
const ce = (G / 2 - R / H * D) / Math.sin(Y);
|
|
1135
|
+
A.push(f(s[M - 1], s[M], Math.PI - Y, ce, !0)), J.push(f(s[M - 1], s[M], Y, ce, !1));
|
|
1136
|
+
}
|
|
1137
|
+
let E = [e, ...A, x], X = [t, ...J, N];
|
|
1138
|
+
return E = se(fe(E), 25), X = se(fe(X), 25), [...E, ...j, ...X.reverse()];
|
|
1054
1139
|
}
|
|
1055
|
-
class
|
|
1140
|
+
class et extends C {
|
|
1056
1141
|
category = "arrow";
|
|
1057
1142
|
/** `generateCoords()` 填充的闭合多边形顶点 */
|
|
1058
1143
|
generatedCoords = [];
|
|
@@ -1070,7 +1155,7 @@ class at extends C {
|
|
|
1070
1155
|
if (!e || e.length < 2)
|
|
1071
1156
|
return this.generatedCoords = [], [];
|
|
1072
1157
|
const t = this.options.arrowType || "straight";
|
|
1073
|
-
return t === "fine" ? this.generatedCoords = re(e[0], e[1]) : t === "curved" ? this.generatedCoords =
|
|
1158
|
+
return t === "fine" ? this.generatedCoords = re(e[0], e[1]) : t === "curved" ? this.generatedCoords = $e(e) : t === "attack" && e.length >= 3 ? this.generatedCoords = Ke(e) : this.generatedCoords = re(e[0], e[e.length - 1]), this.generatedCoords;
|
|
1074
1159
|
}
|
|
1075
1160
|
/** 浅拷贝:`options`、`generatedCoords` 与内部共享引用(顶点数组仍与 `options.points` 规则一致)。 */
|
|
1076
1161
|
getSnapshot() {
|
|
@@ -1090,7 +1175,7 @@ class at extends C {
|
|
|
1090
1175
|
};
|
|
1091
1176
|
}
|
|
1092
1177
|
}
|
|
1093
|
-
class
|
|
1178
|
+
class tt extends C {
|
|
1094
1179
|
category = "text";
|
|
1095
1180
|
constructor(e) {
|
|
1096
1181
|
super(e);
|
|
@@ -1106,7 +1191,7 @@ class nt extends C {
|
|
|
1106
1191
|
return this.getCenterPoints();
|
|
1107
1192
|
}
|
|
1108
1193
|
}
|
|
1109
|
-
class
|
|
1194
|
+
class rt extends C {
|
|
1110
1195
|
category = "circle";
|
|
1111
1196
|
constructor(e) {
|
|
1112
1197
|
super(e);
|
|
@@ -1124,7 +1209,7 @@ class ot extends C {
|
|
|
1124
1209
|
];
|
|
1125
1210
|
}
|
|
1126
1211
|
}
|
|
1127
|
-
class
|
|
1212
|
+
class st {
|
|
1128
1213
|
/** 标绘 id → 实例;与 `PlotOverlay.imageSource.shapes` 共用同一引用 */
|
|
1129
1214
|
_items = /* @__PURE__ */ new Map();
|
|
1130
1215
|
/** 标绘 id */
|
|
@@ -1163,42 +1248,42 @@ class lt {
|
|
|
1163
1248
|
switch (e.type) {
|
|
1164
1249
|
case "point": {
|
|
1165
1250
|
const { type: r, ...s } = e;
|
|
1166
|
-
t = new
|
|
1251
|
+
t = new Be(s);
|
|
1167
1252
|
break;
|
|
1168
1253
|
}
|
|
1169
1254
|
case "line": {
|
|
1170
1255
|
const { type: r, ...s } = e;
|
|
1171
|
-
t = new
|
|
1256
|
+
t = new ze(s);
|
|
1172
1257
|
break;
|
|
1173
1258
|
}
|
|
1174
1259
|
case "polygon": {
|
|
1175
1260
|
const { type: r, ...s } = e;
|
|
1176
|
-
t = new
|
|
1261
|
+
t = new Qe(s);
|
|
1177
1262
|
break;
|
|
1178
1263
|
}
|
|
1179
1264
|
case "rectangle": {
|
|
1180
1265
|
const { type: r, ...s } = e;
|
|
1181
|
-
t = new
|
|
1266
|
+
t = new je(s);
|
|
1182
1267
|
break;
|
|
1183
1268
|
}
|
|
1184
1269
|
case "circle": {
|
|
1185
1270
|
const { type: r, ...s } = e;
|
|
1186
|
-
t = new
|
|
1271
|
+
t = new rt(s);
|
|
1187
1272
|
break;
|
|
1188
1273
|
}
|
|
1189
1274
|
case "sector": {
|
|
1190
1275
|
const { type: r, ...s } = e;
|
|
1191
|
-
t = new
|
|
1276
|
+
t = new He(s);
|
|
1192
1277
|
break;
|
|
1193
1278
|
}
|
|
1194
1279
|
case "text": {
|
|
1195
1280
|
const { type: r, ...s } = e;
|
|
1196
|
-
t = new
|
|
1281
|
+
t = new tt(s);
|
|
1197
1282
|
break;
|
|
1198
1283
|
}
|
|
1199
1284
|
case "arrow": {
|
|
1200
1285
|
const { type: r, ...s } = e;
|
|
1201
|
-
t = new
|
|
1286
|
+
t = new et(s);
|
|
1202
1287
|
break;
|
|
1203
1288
|
}
|
|
1204
1289
|
default:
|
|
@@ -1304,8 +1389,8 @@ class lt {
|
|
|
1304
1389
|
if (!s || !s.options.points || s.options.points.length === 0) return -1;
|
|
1305
1390
|
let a = 0, n = 1 / 0;
|
|
1306
1391
|
for (let o = 0; o < s.options.points.length; o++) {
|
|
1307
|
-
const
|
|
1308
|
-
|
|
1392
|
+
const d = s.options.points[o][0] - t, u = s.options.points[o][1] - r, h = d * d + u * u;
|
|
1393
|
+
h < n && (n = h, a = o);
|
|
1309
1394
|
}
|
|
1310
1395
|
return a;
|
|
1311
1396
|
}
|
|
@@ -1330,22 +1415,22 @@ class lt {
|
|
|
1330
1415
|
}));
|
|
1331
1416
|
}
|
|
1332
1417
|
}
|
|
1333
|
-
const
|
|
1334
|
-
class
|
|
1418
|
+
const it = "https://sooncps.xwbuilders.com/api/ugis-dataprocess/v1/terrain/NhBLlMx3/", at = "https://c.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png";
|
|
1419
|
+
class mt {
|
|
1335
1420
|
constructor(e, t = {}) {
|
|
1336
1421
|
this.ssp = e, this.options = t;
|
|
1337
|
-
const r = t.baseUrl ||
|
|
1338
|
-
if (this.resourceManager = new
|
|
1339
|
-
const s = t.imageryUrl ||
|
|
1422
|
+
const r = t.baseUrl || it;
|
|
1423
|
+
if (this.resourceManager = new Je(), this.terrainManager = new Ue(), t.imageryUrl !== !1) {
|
|
1424
|
+
const s = t.imageryUrl || at;
|
|
1340
1425
|
this.resourceManager.addOverlay({
|
|
1341
1426
|
id: this.defaultImageryId,
|
|
1342
|
-
type:
|
|
1343
|
-
options: { id: this.defaultImageryId, url: s, type:
|
|
1427
|
+
type: l.XYZ,
|
|
1428
|
+
options: { id: this.defaultImageryId, url: s, type: l.XYZ }
|
|
1344
1429
|
});
|
|
1345
1430
|
}
|
|
1346
|
-
this.groundDecalManager = new
|
|
1431
|
+
this.groundDecalManager = new st({ ssp: this.ssp }), this._alphaClipMode = t.alphaClipMode ?? "alphaTest", this._currentTerrainConfig = {
|
|
1347
1432
|
id: this.defaultTerrainId,
|
|
1348
|
-
type:
|
|
1433
|
+
type: I.QUANTIZED_MESH,
|
|
1349
1434
|
url: r
|
|
1350
1435
|
}, this.terrainManager.add(this._currentTerrainConfig), this.terrainManager.setCurrentId(this._currentTerrainConfig.id), this.tiles = this._initTilesRenderer(this._currentTerrainConfig), this._initPlugins(this.tiles, this._currentTerrainConfig);
|
|
1351
1436
|
}
|
|
@@ -1379,7 +1464,7 @@ class Tt {
|
|
|
1379
1464
|
* 是否使用 Cesium Ion 地形
|
|
1380
1465
|
*/
|
|
1381
1466
|
get isCesiumIon() {
|
|
1382
|
-
return this._currentTerrainConfig.type ===
|
|
1467
|
+
return this._currentTerrainConfig.type === I.CESIUM_ION;
|
|
1383
1468
|
}
|
|
1384
1469
|
/**
|
|
1385
1470
|
* 获取当前地形配置
|
|
@@ -1425,9 +1510,9 @@ class Tt {
|
|
|
1425
1510
|
this._alphaClipMode = e, this.customMaterialPlugin && (this.customMaterialPlugin.alphaClipMode = e), this._updateAlphaClipMode(), this.render();
|
|
1426
1511
|
}
|
|
1427
1512
|
_initTilesRenderer(e) {
|
|
1428
|
-
return e.type ===
|
|
1513
|
+
return e.type === I.CESIUM_ION ? new L() : (
|
|
1429
1514
|
// Cesium Ion 由插件设置 URL
|
|
1430
|
-
new
|
|
1515
|
+
new L(e.url)
|
|
1431
1516
|
);
|
|
1432
1517
|
}
|
|
1433
1518
|
/**
|
|
@@ -1435,8 +1520,8 @@ class Tt {
|
|
|
1435
1520
|
* @param config 地形配置
|
|
1436
1521
|
*/
|
|
1437
1522
|
_initPlugins(e, t) {
|
|
1438
|
-
if (this.tilesFadePlugin = new ie({ maximumFadeOutTiles: 200 }), this.updateOnChangePlugin = new ae(), e.registerPlugin(this.tilesFadePlugin), e.registerPlugin(this.updateOnChangePlugin), t.type ===
|
|
1439
|
-
new
|
|
1523
|
+
if (this.tilesFadePlugin = new ie({ maximumFadeOutTiles: 200 }), this.updateOnChangePlugin = new ae(), e.registerPlugin(this.tilesFadePlugin), e.registerPlugin(this.updateOnChangePlugin), t.type === I.CESIUM_ION ? e.registerPlugin(
|
|
1524
|
+
new Se({
|
|
1440
1525
|
apiToken: t.apiToken,
|
|
1441
1526
|
assetId: t.assetId || "1",
|
|
1442
1527
|
autoRefreshToken: t.autoRefreshToken ?? !0,
|
|
@@ -1455,10 +1540,10 @@ class Tt {
|
|
|
1455
1540
|
return a.metadataAvailability = -1, new Response(JSON.stringify(a));
|
|
1456
1541
|
}
|
|
1457
1542
|
return fetch(r, s);
|
|
1458
|
-
}), this.options.useCustomMaterial !== !1 && (this.customMaterialPlugin = new
|
|
1543
|
+
}), this.options.useCustomMaterial !== !1 && (this.customMaterialPlugin = new Ae(), this.customMaterialPlugin.alphaClipMode = this._alphaClipMode, e.registerPlugin(this.customMaterialPlugin)), this.imageOverlayPlugin = new Oe({
|
|
1459
1544
|
renderer: this.ssp.viewport.renderer,
|
|
1460
1545
|
overlays: []
|
|
1461
|
-
}), e.registerPlugin(this.imageOverlayPlugin), this.plotSDFPlugin = new
|
|
1546
|
+
}), e.registerPlugin(this.imageOverlayPlugin), this.plotSDFPlugin = new Ne(), this.groundDecalManager?.setPlotSDFPlugin(this.plotSDFPlugin), this.tiles.registerPlugin(this.plotSDFPlugin), this.overlayManager = new Q(
|
|
1462
1547
|
this.imageOverlayPlugin,
|
|
1463
1548
|
this.resourceManager
|
|
1464
1549
|
), this.overlayManager.restoreFromResourceManager(), this.options.reorientation !== !1) {
|
|
@@ -1519,7 +1604,7 @@ class Tt {
|
|
|
1519
1604
|
setTerrain(e, t = void 0) {
|
|
1520
1605
|
if (t && (this.options = { ...this.options, ...t }), this.terrainManager.has(e.id) || this.terrainManager.add(e), this.terrainManager.setCurrentId(e.id), this.terrainManager.currentId === e.id) {
|
|
1521
1606
|
const r = this.terrainManager.getCurrent();
|
|
1522
|
-
e.type ===
|
|
1607
|
+
e.type === I.QUANTIZED_MESH && r?.type === I.QUANTIZED_MESH && (r.url = e.url);
|
|
1523
1608
|
}
|
|
1524
1609
|
this._disposeTilesRenderer(), this._currentTerrainConfig = e, this.tiles = this._initTilesRenderer(e), this._initPlugins(this.tiles, e), this.plotSDFPlugin && this.groundDecalManager && this.groundDecalManager.setPlotSDFPlugin(this.plotSDFPlugin), this._enabled && this.ssp.addObject(this.tiles.group), this.render();
|
|
1525
1610
|
}
|
|
@@ -1532,17 +1617,17 @@ class Tt {
|
|
|
1532
1617
|
*/
|
|
1533
1618
|
async addOverlay(e) {
|
|
1534
1619
|
switch (e.type) {
|
|
1535
|
-
case
|
|
1620
|
+
case l.GEOJSON:
|
|
1536
1621
|
return this.overlayManager.addGeoJSONOverlay(e);
|
|
1537
|
-
case
|
|
1622
|
+
case l.CESIUM_ION:
|
|
1538
1623
|
return this.overlayManager.addCesiumIonOverlay(e);
|
|
1539
|
-
case
|
|
1624
|
+
case l.TMS:
|
|
1540
1625
|
return this.overlayManager.addTMSOverlay(e);
|
|
1541
|
-
case
|
|
1626
|
+
case l.XYZ:
|
|
1542
1627
|
return this.overlayManager.addXYZOverlay(e);
|
|
1543
|
-
case
|
|
1628
|
+
case l.WMS:
|
|
1544
1629
|
return await this.overlayManager.addWMSOverlay(e);
|
|
1545
|
-
case
|
|
1630
|
+
case l.WMTS:
|
|
1546
1631
|
return await this.overlayManager.addWMTSOverlay(e);
|
|
1547
1632
|
default:
|
|
1548
1633
|
return this.overlayManager.addUrlTemplateOverlay(e);
|
|
@@ -1592,14 +1677,52 @@ class Tt {
|
|
|
1592
1677
|
const r = this.overlayManager.updateGeoJSONFillStyle(e, t);
|
|
1593
1678
|
return r && this.render(), r;
|
|
1594
1679
|
}
|
|
1680
|
+
/**
|
|
1681
|
+
* 更新 StyledGeoJSONOverlay 的默认 feature 样式
|
|
1682
|
+
*/
|
|
1683
|
+
updateGeoJSONDefaultStyle(e, t) {
|
|
1684
|
+
const r = this.overlayManager.updateGeoJSONDefaultStyle(e, t);
|
|
1685
|
+
return r && this.render(), r;
|
|
1686
|
+
}
|
|
1687
|
+
/**
|
|
1688
|
+
* 替换 GeoJSON 数据
|
|
1689
|
+
*/
|
|
1690
|
+
setGeoJSON(e, t) {
|
|
1691
|
+
const r = this.overlayManager.setGeoJSON(e, t);
|
|
1692
|
+
return r && this.render(), r;
|
|
1693
|
+
}
|
|
1694
|
+
/**
|
|
1695
|
+
* 合并多个 GeoJSON 后替换指定 StyledGeoJSONOverlay 的数据
|
|
1696
|
+
*/
|
|
1697
|
+
setMergedGeoJSON(e, t, r) {
|
|
1698
|
+
const s = this.overlayManager.setMergedGeoJSON(e, t, r);
|
|
1699
|
+
return s && this.render(), s;
|
|
1700
|
+
}
|
|
1701
|
+
getGeoJSONFeatureById(e, t) {
|
|
1702
|
+
return this.overlayManager.getGeoJSONFeatureById(e, t);
|
|
1703
|
+
}
|
|
1704
|
+
updateGeoJSONFeatureStyleById(e, t, r) {
|
|
1705
|
+
const s = this.overlayManager.updateGeoJSONFeatureStyleById(e, t, r);
|
|
1706
|
+
return s && this.render(), s;
|
|
1707
|
+
}
|
|
1708
|
+
updateGeoJSONFeatureStylesByIds(e, t, r) {
|
|
1709
|
+
const s = this.overlayManager.updateGeoJSONFeatureStylesByIds(e, t, r);
|
|
1710
|
+
return s && this.render(), s;
|
|
1711
|
+
}
|
|
1595
1712
|
// =============== GeoJSON 管理 ===============
|
|
1713
|
+
/**
|
|
1714
|
+
* 将任意 GeoJSON 根对象规范化为 FeatureCollection
|
|
1715
|
+
*/
|
|
1716
|
+
normalizeGeoJSON(e) {
|
|
1717
|
+
return this.overlayManager.normalizeGeoJSON(e);
|
|
1718
|
+
}
|
|
1596
1719
|
/**
|
|
1597
1720
|
* 合并多个 GeoJSON
|
|
1598
1721
|
* @param geojsons 待合并的 GeoJSON 数组
|
|
1599
1722
|
* @returns 合并后的 GeoJSON
|
|
1600
1723
|
*/
|
|
1601
1724
|
mergeGeoJSON(e) {
|
|
1602
|
-
return
|
|
1725
|
+
return this.overlayManager.mergeGeoJSON(e);
|
|
1603
1726
|
}
|
|
1604
1727
|
// =============== Overlay 层级控制 ===============
|
|
1605
1728
|
/**
|
|
@@ -1674,8 +1797,8 @@ class Tt {
|
|
|
1674
1797
|
height: r
|
|
1675
1798
|
};
|
|
1676
1799
|
const a = () => {
|
|
1677
|
-
const o =
|
|
1678
|
-
s.transformLatLonHeightToOrigin(o,
|
|
1800
|
+
const o = S.degToRad(t), d = S.degToRad(e);
|
|
1801
|
+
s.transformLatLonHeightToOrigin(o, d, r), this.render(), n();
|
|
1679
1802
|
}, n = () => {
|
|
1680
1803
|
this.tiles.removeEventListener("load-root-tileset", a), this.loedTilesSets.delete(a);
|
|
1681
1804
|
};
|
|
@@ -1687,12 +1810,12 @@ class Tt {
|
|
|
1687
1810
|
), this.loedTilesSets.clear(), this.tiles.removeEventListener("needs-render", this.render), this.tiles.removeEventListener("needs-update", this.render), this.tiles.dispose();
|
|
1688
1811
|
}
|
|
1689
1812
|
}
|
|
1690
|
-
const
|
|
1813
|
+
const k = {
|
|
1691
1814
|
DEFAULT: 0,
|
|
1692
1815
|
GRADIENT: 1,
|
|
1693
1816
|
TOPOGRAPHIC_LINES: 2,
|
|
1694
1817
|
LIGHTING: 3
|
|
1695
|
-
},
|
|
1818
|
+
}, nt = {
|
|
1696
1819
|
vertexShader: (
|
|
1697
1820
|
/* glsl */
|
|
1698
1821
|
`
|
|
@@ -1718,7 +1841,7 @@ const L = {
|
|
|
1718
1841
|
}
|
|
1719
1842
|
`
|
|
1720
1843
|
)
|
|
1721
|
-
},
|
|
1844
|
+
}, ot = {
|
|
1722
1845
|
vertexShader: (
|
|
1723
1846
|
/* glsl */
|
|
1724
1847
|
`
|
|
@@ -1764,10 +1887,10 @@ const L = {
|
|
|
1764
1887
|
`
|
|
1765
1888
|
)
|
|
1766
1889
|
};
|
|
1767
|
-
let
|
|
1768
|
-
class
|
|
1890
|
+
let Z = null, V = null, $ = null;
|
|
1891
|
+
class lt {
|
|
1769
1892
|
constructor(e, t) {
|
|
1770
|
-
this.ssp = e, this.options = t, "url" in this.options ? this.tiles = new
|
|
1893
|
+
this.ssp = e, this.options = t, "url" in this.options ? this.tiles = new L(this.options.url) : (this.tiles = new L(), this._initCesiumIon(this.options)), this._initBasePlugins(this.options);
|
|
1771
1894
|
}
|
|
1772
1895
|
tiles;
|
|
1773
1896
|
tilesFadePlugin;
|
|
@@ -1775,10 +1898,10 @@ class gt {
|
|
|
1775
1898
|
reorientationPlugin;
|
|
1776
1899
|
options;
|
|
1777
1900
|
// 用于模型居中
|
|
1778
|
-
_box = new
|
|
1779
|
-
_sphere = new
|
|
1901
|
+
_box = new Ce();
|
|
1902
|
+
_sphere = new _e();
|
|
1780
1903
|
// 当前材质类型
|
|
1781
|
-
_materialType =
|
|
1904
|
+
_materialType = k.DEFAULT;
|
|
1782
1905
|
// 按需渲染标志
|
|
1783
1906
|
_needsUpdate = !0;
|
|
1784
1907
|
_cameraTransitionStart = !1;
|
|
@@ -1788,7 +1911,7 @@ class gt {
|
|
|
1788
1911
|
*/
|
|
1789
1912
|
_initCesiumIon(e) {
|
|
1790
1913
|
this.tiles.registerPlugin(
|
|
1791
|
-
new
|
|
1914
|
+
new Se({
|
|
1792
1915
|
apiToken: e.apiToken,
|
|
1793
1916
|
assetId: e.assetId,
|
|
1794
1917
|
autoRefreshToken: e.autoRefreshToken ?? !0
|
|
@@ -1799,7 +1922,7 @@ class gt {
|
|
|
1799
1922
|
* 初始化基础插件
|
|
1800
1923
|
*/
|
|
1801
1924
|
_initBasePlugins(e) {
|
|
1802
|
-
if (e._managedByPlugin || (
|
|
1925
|
+
if (e._managedByPlugin || (Z === null ? Z = this.tiles.lruCache : this.tiles.lruCache = Z, V === null ? V = this.tiles.parseQueue : this.tiles.parseQueue = V, $ === null ? $ = this.tiles.downloadQueue : this.tiles.downloadQueue = $, this.tiles.lruCache.maxSize = 600, this.tiles.lruCache.minSize = 300, this.tiles.lruCache.unloadPercent = 0.8), this._setupGLTFLoader(), this.tilesFadePlugin = new ie({ maximumFadeOutTiles: 200 }), this.updateOnChangePlugin = new ae(), this.tiles.registerPlugin(this.tilesFadePlugin), this.tiles.registerPlugin(this.updateOnChangePlugin), this.tiles.maxDepth = e.maxDepth ?? 20, this.tiles.errorTarget = e.errorTarget ?? 2, this.options.reorientation) {
|
|
1803
1926
|
const t = this.options.reorientation || { lon: 120, lat: 30 };
|
|
1804
1927
|
this.reorientationPlugin = new ne({
|
|
1805
1928
|
lon: t.lon,
|
|
@@ -1817,7 +1940,7 @@ class gt {
|
|
|
1817
1940
|
* 设置 GLTF Loader
|
|
1818
1941
|
*/
|
|
1819
1942
|
_setupGLTFLoader() {
|
|
1820
|
-
const e = new
|
|
1943
|
+
const e = new me(this.tiles.manager), t = this.ssp.manager?.store?.modelManager;
|
|
1821
1944
|
if (t?.gltfLoader) {
|
|
1822
1945
|
const { dracoLoader: r, ktx2Loader: s, meshoptDecoder: a } = t.gltfLoader;
|
|
1823
1946
|
r && e.setDRACOLoader(r), s && e.setKTX2Loader(s), a && e.setMeshoptDecoder(a);
|
|
@@ -1861,7 +1984,7 @@ class gt {
|
|
|
1861
1984
|
onLoadModel = ({ scene: e }) => {
|
|
1862
1985
|
e.traverse((t) => {
|
|
1863
1986
|
t.isMesh && (t.originalMaterial = t.material);
|
|
1864
|
-
}), this._materialType !==
|
|
1987
|
+
}), this._materialType !== k.DEFAULT && this.updateMaterial(e);
|
|
1865
1988
|
};
|
|
1866
1989
|
/**
|
|
1867
1990
|
* 更新场景中所有网格的材质(参考 customMaterial.js)
|
|
@@ -1871,19 +1994,19 @@ class gt {
|
|
|
1871
1994
|
e.traverse((r) => {
|
|
1872
1995
|
if (r.isMesh)
|
|
1873
1996
|
switch (r.material && r.material !== r.originalMaterial && r.material.dispose(), t) {
|
|
1874
|
-
case
|
|
1997
|
+
case k.DEFAULT:
|
|
1875
1998
|
r.material = r.originalMaterial, r.material && (r.material.side = 2), r.receiveShadow = !1, r.castShadow = !1;
|
|
1876
1999
|
break;
|
|
1877
|
-
case
|
|
1878
|
-
r.material = new ge(
|
|
2000
|
+
case k.GRADIENT:
|
|
2001
|
+
r.material = new ge(nt), r.material.side = 2, r.receiveShadow = !1, r.castShadow = !1;
|
|
1879
2002
|
break;
|
|
1880
|
-
case
|
|
1881
|
-
const s = new ge(
|
|
2003
|
+
case k.TOPOGRAPHIC_LINES: {
|
|
2004
|
+
const s = new ge(ot);
|
|
1882
2005
|
s.extensions = { derivatives: !0 }, s.side = 2, r.material = s, r.receiveShadow = !1, r.castShadow = !1;
|
|
1883
2006
|
break;
|
|
1884
2007
|
}
|
|
1885
|
-
case
|
|
1886
|
-
r.material = new
|
|
2008
|
+
case k.LIGHTING:
|
|
2009
|
+
r.material = new Ie(), r.material.side = 2, r.receiveShadow = !0, r.castShadow = !0;
|
|
1887
2010
|
break;
|
|
1888
2011
|
}
|
|
1889
2012
|
});
|
|
@@ -1930,8 +2053,8 @@ class gt {
|
|
|
1930
2053
|
height: r
|
|
1931
2054
|
};
|
|
1932
2055
|
const a = () => {
|
|
1933
|
-
const o =
|
|
1934
|
-
s.transformLatLonHeightToOrigin(o,
|
|
2056
|
+
const o = S.degToRad(t), d = S.degToRad(e);
|
|
2057
|
+
s.transformLatLonHeightToOrigin(o, d, r), this.render(), n();
|
|
1935
2058
|
}, n = () => {
|
|
1936
2059
|
this.tiles.removeEventListener("load-root-tileset", a), this.loedTilesSets.delete(a);
|
|
1937
2060
|
};
|
|
@@ -1944,7 +2067,7 @@ class gt {
|
|
|
1944
2067
|
}
|
|
1945
2068
|
}
|
|
1946
2069
|
const K = 2;
|
|
1947
|
-
class
|
|
2070
|
+
class vt {
|
|
1948
2071
|
constructor(e) {
|
|
1949
2072
|
this.ssp = e;
|
|
1950
2073
|
const { controls: t, viewport: r } = e;
|
|
@@ -1965,12 +2088,12 @@ class wt {
|
|
|
1965
2088
|
_downloadQueue = null;
|
|
1966
2089
|
_referenceOrigin = null;
|
|
1967
2090
|
_referencePlacements = /* @__PURE__ */ new WeakMap();
|
|
1968
|
-
_referenceFrame = new
|
|
1969
|
-
_targetFrame = new
|
|
1970
|
-
_sourceFrame = new
|
|
1971
|
-
_placementMatrix = new
|
|
1972
|
-
_upCorrectionMatrix = new
|
|
1973
|
-
_boundingSphere = new
|
|
2091
|
+
_referenceFrame = new U();
|
|
2092
|
+
_targetFrame = new U();
|
|
2093
|
+
_sourceFrame = new U();
|
|
2094
|
+
_placementMatrix = new U();
|
|
2095
|
+
_upCorrectionMatrix = new U();
|
|
2096
|
+
_boundingSphere = new _e();
|
|
1974
2097
|
_beforeRenderHandler = () => {
|
|
1975
2098
|
this.needsUpdate && (this.needsUpdate = !1, this.ssp.viewport.camera.updateMatrixWorld(), this.tilesMap.forEach((e) => {
|
|
1976
2099
|
e.tiles.setCamera(this.ssp.viewport.camera), e.tiles.setResolutionFromRenderer(this.ssp.viewport.camera, this.ssp.viewport.renderer), e.applyAutoCenter(), e.tiles.group.updateMatrixWorld(), e.tiles.update();
|
|
@@ -2011,20 +2134,20 @@ class wt {
|
|
|
2011
2134
|
const t = "url" in e ? e.url : e.assetId;
|
|
2012
2135
|
if (this.tilesMap.has(t))
|
|
2013
2136
|
return z.utils.warn(`${t} already loaded`), this.tilesMap.get(t);
|
|
2014
|
-
const { ssp: r } = this, s = this._getReferencePlacement(e), a = this._getTilesRendererOptions(e, s), n = new
|
|
2137
|
+
const { ssp: r } = this, s = this._getReferencePlacement(e), a = this._getTilesRendererOptions(e, s), n = new lt(r, {
|
|
2015
2138
|
...a,
|
|
2016
2139
|
_managedByPlugin: !0
|
|
2017
2140
|
});
|
|
2018
2141
|
s && (this._referencePlacements.set(n, s), n.options.reorientation = s);
|
|
2019
2142
|
const { tiles: o } = n;
|
|
2020
2143
|
this._lruCache === null ? this._lruCache = o.lruCache : o.lruCache = this._lruCache, this._parseQueue === null ? this._parseQueue = o.parseQueue : o.parseQueue = this._parseQueue, this._downloadQueue === null ? this._downloadQueue = o.downloadQueue : o.downloadQueue = this._downloadQueue, o.lruCache.maxSize = 600, o.lruCache.minSize = 300, o.lruCache.unloadPercent = 0.8, this.tilesMap.set(t, n), o.setCamera(this._tilesCamera), o.setResolutionFromRenderer(this._tilesCamera, r.viewport.renderer), r.addObject(o.group), this._referenceOrigin && this.applyReferencePlacement(n, s);
|
|
2021
|
-
const
|
|
2144
|
+
const d = () => {
|
|
2022
2145
|
this.cameraTransitionStart || (this.needsUpdate = !0, r.render());
|
|
2023
2146
|
};
|
|
2024
|
-
return o.addEventListener("load-model",
|
|
2147
|
+
return o.addEventListener("load-model", d), new Promise((u) => {
|
|
2025
2148
|
o.addEventListener("load-tile-set", () => {
|
|
2026
|
-
const
|
|
2027
|
-
this._referenceOrigin && this.applyReferencePlacement(n,
|
|
2149
|
+
const h = this._referencePlacements.get(n);
|
|
2150
|
+
this._referenceOrigin && this.applyReferencePlacement(n, h ?? null), d(), u(n);
|
|
2028
2151
|
});
|
|
2029
2152
|
});
|
|
2030
2153
|
}
|
|
@@ -2073,8 +2196,8 @@ class wt {
|
|
|
2073
2196
|
return z.utils.warn("TilesRendererManager: reference origin is not set."), !1;
|
|
2074
2197
|
const { ellipsoid: r, group: s } = e.tiles, a = this._referenceOrigin, n = this._isGeoreferenced(e);
|
|
2075
2198
|
if (r.getObjectFrame(
|
|
2076
|
-
|
|
2077
|
-
|
|
2199
|
+
S.degToRad(a.lat),
|
|
2200
|
+
S.degToRad(a.lon),
|
|
2078
2201
|
a.height ?? 0.1,
|
|
2079
2202
|
0,
|
|
2080
2203
|
0,
|
|
@@ -2083,8 +2206,8 @@ class wt {
|
|
|
2083
2206
|
K
|
|
2084
2207
|
), this._placementMatrix.copy(this._referenceFrame).invert(), t)
|
|
2085
2208
|
r.getObjectFrame(
|
|
2086
|
-
|
|
2087
|
-
|
|
2209
|
+
S.degToRad(t.lat),
|
|
2210
|
+
S.degToRad(t.lon),
|
|
2088
2211
|
t.height ?? 0,
|
|
2089
2212
|
0,
|
|
2090
2213
|
0,
|
|
@@ -2163,24 +2286,24 @@ class wt {
|
|
|
2163
2286
|
}
|
|
2164
2287
|
}
|
|
2165
2288
|
export {
|
|
2166
|
-
|
|
2167
|
-
|
|
2289
|
+
ft as ArcgisTilesRenderer,
|
|
2290
|
+
et as GisPlotArrow,
|
|
2168
2291
|
C as GisPlotBase,
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2292
|
+
rt as GisPlotCircle,
|
|
2293
|
+
ze as GisPlotLine,
|
|
2294
|
+
Be as GisPlotPoint,
|
|
2295
|
+
Qe as GisPlotPolygon,
|
|
2296
|
+
je as GisPlotRectangle,
|
|
2297
|
+
He as GisPlotSector,
|
|
2298
|
+
tt as GisPlotText,
|
|
2299
|
+
st as GroundDecalManager,
|
|
2300
|
+
k as MaterialType,
|
|
2301
|
+
Q as OverlayManager,
|
|
2302
|
+
l as OverlayType,
|
|
2303
|
+
mt as TerrainTilesRenderer,
|
|
2304
|
+
I as TerrainType,
|
|
2305
|
+
Ae as TileCustomMaterialPlugin,
|
|
2306
|
+
lt as TilesRenderer,
|
|
2307
|
+
vt as TilesRendererManager,
|
|
2308
|
+
pt as default
|
|
2186
2309
|
};
|