@soonspacejs/plugin-tiles 2.14.33 → 2.14.35
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 +3 -0
- package/dist/index.esm.js +831 -270
- package/dist/plot/GroundDecalManager.d.ts +115 -0
- package/dist/plot/plugins/arrow.d.ts +25 -0
- package/dist/plot/plugins/base.d.ts +32 -0
- package/dist/plot/plugins/circle.d.ts +13 -0
- package/dist/plot/plugins/index.d.ts +10 -0
- package/dist/plot/plugins/line.d.ts +12 -0
- package/dist/plot/plugins/point.d.ts +14 -0
- package/dist/plot/plugins/polygon.d.ts +12 -0
- package/dist/plot/plugins/rectangle.d.ts +13 -0
- package/dist/plot/plugins/sector.d.ts +13 -0
- package/dist/plot/plugins/text.d.ts +14 -0
- package/dist/plot/plugins/types.d.ts +108 -0
- package/dist/plot/plugins/utils/ArrowUtils.d.ts +129 -0
- package/dist/plot/plugins/utils/colorUtils.d.ts +51 -0
- package/dist/plot/plugins/utils/coordUtils.d.ts +48 -0
- package/dist/terrain-tiles-renderer/TerrainTilesRenderer.d.ts +3 -0
- package/dist/terrain-tiles-renderer/types.d.ts +2 -1
- package/package.json +7 -4
package/dist/index.esm.js
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { TilesRenderer as
|
|
3
|
-
import { GLTFLoader as
|
|
4
|
-
import { MathUtils as
|
|
5
|
-
import { TilesFadePlugin as
|
|
6
|
-
|
|
1
|
+
import ee from "soonspacejs";
|
|
2
|
+
import { TilesRenderer as R } from "um-3d-tiles-renderer";
|
|
3
|
+
import { GLTFLoader as pe } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
4
|
+
import { MathUtils as C, MeshBasicMaterial as Me, Color as z, Vector3 as _e, Box3 as Oe, Sphere as Te, MeshStandardMaterial as we, ShaderMaterial as ue } from "three";
|
|
5
|
+
import { TilesFadePlugin as te, UpdateOnChangePlugin as se, QuantizedMeshPlugin as q, ImageOverlayPlugin as me, XYZTilesOverlay as ye, ReorientationPlugin as re, GeoJSONOverlay as Pe, CesiumIonOverlay as Se, TMSTilesOverlay as Ce, UrlTemplateTilesOverlay as Le, WMSTilesOverlay as Ee, WMTSCapabilitiesLoader as be, WMTSTilesOverlay as Ie, CesiumIonAuthPlugin as fe } from "um-3d-tiles-renderer/plugins";
|
|
6
|
+
import { PlotOverlay as Re } from "um-3d-tiles-renderer/three/plugins";
|
|
7
|
+
class xe {
|
|
7
8
|
constructor(e) {
|
|
8
9
|
this.parser = e, this.name = "KHR_texture_basisu_patch";
|
|
9
10
|
}
|
|
10
11
|
loadTexture(e) {
|
|
11
|
-
const t = this.parser,
|
|
12
|
-
if (!
|
|
12
|
+
const t = this.parser, s = t.json, a = s.textures[e].source, n = s.images[a];
|
|
13
|
+
if (!n || n.mimeType !== "image/ktx2")
|
|
13
14
|
return null;
|
|
14
15
|
const o = t.options.ktx2Loader;
|
|
15
16
|
if (!o)
|
|
16
|
-
throw new Error(`${
|
|
17
|
-
return t.loadTextureImage(e,
|
|
17
|
+
throw new Error(`${ee.utils.consoleSspTitle}请使用 setModelKtx2DecoderPath 设置 ktx2 解压库路径`);
|
|
18
|
+
return t.loadTextureImage(e, a, o);
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
class
|
|
21
|
+
class gt {
|
|
21
22
|
constructor(e) {
|
|
22
23
|
this.ssp = e;
|
|
23
|
-
const { controls: t, viewport:
|
|
24
|
-
this._tilesCamera =
|
|
25
|
-
this.cameraTransitionStart = !0,
|
|
24
|
+
const { controls: t, viewport: s } = e;
|
|
25
|
+
this._tilesCamera = s.camera, t.addEventListener("transitionstart", () => {
|
|
26
|
+
this.cameraTransitionStart = !0, s.state.useFreq = 1;
|
|
26
27
|
}), t.addEventListener("rest", () => {
|
|
27
|
-
this.cameraTransitionStart = !1, this.needsUpdate = !0,
|
|
28
|
+
this.cameraTransitionStart = !1, this.needsUpdate = !0, s.state.useFreq = 60;
|
|
28
29
|
}), e.signals.beforeRender.add(() => {
|
|
29
|
-
this.needsUpdate && (this.needsUpdate = !1, e.viewport.camera.updateMatrixWorld(), this.tilesMap.forEach((
|
|
30
|
-
|
|
30
|
+
this.needsUpdate && (this.needsUpdate = !1, e.viewport.camera.updateMatrixWorld(), this.tilesMap.forEach((r) => {
|
|
31
|
+
r.group.updateMatrixWorld(), r.update();
|
|
31
32
|
}));
|
|
32
33
|
}), e.signals.cameraObjectChange.add(() => {
|
|
33
|
-
this.tilesMap.forEach((
|
|
34
|
-
|
|
34
|
+
this.tilesMap.forEach((r) => {
|
|
35
|
+
r.deleteCamera(this._tilesCamera), r.setCamera(e.viewport.camera), r.setResolutionFromRenderer(e.viewport.camera, e.viewport.renderer);
|
|
35
36
|
}), this._tilesCamera = e.viewport.camera;
|
|
36
37
|
});
|
|
37
38
|
}
|
|
@@ -44,21 +45,21 @@ class se {
|
|
|
44
45
|
downloadQueue = null;
|
|
45
46
|
async loadTiles(e) {
|
|
46
47
|
if (this.tilesMap.has(e)) {
|
|
47
|
-
|
|
48
|
+
ee.utils.warn(`${e} already loaded`);
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
50
|
-
const { ssp: t, ssp: { viewport:
|
|
51
|
-
this.lruCache === null ? this.lruCache =
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const { dracoLoader:
|
|
55
|
-
|
|
56
|
-
const
|
|
51
|
+
const { ssp: t, ssp: { viewport: s } } = this, r = new R(e);
|
|
52
|
+
this.lruCache === null ? this.lruCache = r.lruCache : r.lruCache = this.lruCache, this.parseQueue === null ? this.parseQueue = r.parseQueue : r.parseQueue = this.parseQueue, this.downloadQueue === null ? this.downloadQueue = r.downloadQueue : r.downloadQueue = this.downloadQueue;
|
|
53
|
+
const a = new pe(r.manager);
|
|
54
|
+
a.register((d) => new xe(d));
|
|
55
|
+
const { dracoLoader: n, ktx2Loader: o, meshoptDecoder: h } = t.manager.store.modelManager.gltfLoader;
|
|
56
|
+
n && a.setDRACOLoader(n), o && a.setKTX2Loader(o), h && a.setMeshoptDecoder(h), r.manager.addHandler(/\.gltf$/, a), this.tilesMap.set(e, r), r.setCamera(this._tilesCamera), r.setResolutionFromRenderer(this._tilesCamera, s.renderer), r.lruCache.maxSize = 600, r.lruCache.minSize = 300, r.lruCache.unloadPercent = 0.8, t.addObject(r.group);
|
|
57
|
+
const u = () => {
|
|
57
58
|
this.cameraTransitionStart || (this.needsUpdate = !0, t.render());
|
|
58
59
|
};
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
return r.addEventListener("load-model", u), new Promise((d) => {
|
|
61
|
+
r.addEventListener("load-tile-set", () => {
|
|
62
|
+
u(), d(r);
|
|
62
63
|
});
|
|
63
64
|
});
|
|
64
65
|
}
|
|
@@ -67,31 +68,31 @@ class se {
|
|
|
67
68
|
return t ? (t.dispose(), this.tilesMap.delete(e), this.ssp.removeObject(t.group), !0) : !1;
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
|
-
let
|
|
71
|
+
let ke = class {
|
|
71
72
|
priority = -999;
|
|
72
73
|
processTileModel(e) {
|
|
73
74
|
e.traverse((t) => {
|
|
74
|
-
t.material && (t.material = new
|
|
75
|
+
t.material && (t.material = new Me());
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
78
|
};
|
|
78
|
-
const
|
|
79
|
-
class
|
|
79
|
+
const De = "https://sooncps.xwbuilders.com/api/ugis-dataprocess/v1/terrain/NhBLlMx3/";
|
|
80
|
+
class mt {
|
|
80
81
|
constructor(e) {
|
|
81
|
-
this.ssp = e, this.tiles = new
|
|
82
|
+
this.ssp = e, this.tiles = new R(De), this.tiles.fetchData = async (t, s) => {
|
|
82
83
|
if (/layer\.json$/.test(t)) {
|
|
83
|
-
const
|
|
84
|
-
return
|
|
84
|
+
const r = await fetch(t, s).then((a) => a.json());
|
|
85
|
+
return r.metadataAvailability = -1, new Response(JSON.stringify(r));
|
|
85
86
|
}
|
|
86
|
-
return fetch(t,
|
|
87
|
-
}, this.tilesFadePlugin = new
|
|
87
|
+
return fetch(t, s);
|
|
88
|
+
}, this.tilesFadePlugin = new te({ maximumFadeOutTiles: 200 }), this.updateOnChangePlugin = new se(), this.quantizedPlugin = new q({}), this.customMaterialPlugin = new ke(), this.imageOverlayPlugin = new me({
|
|
88
89
|
renderer: e.viewport.renderer,
|
|
89
90
|
overlays: [
|
|
90
|
-
new
|
|
91
|
+
new ye({
|
|
91
92
|
url: "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
|
|
92
93
|
})
|
|
93
94
|
]
|
|
94
|
-
}), this.reorientationPlugin = new
|
|
95
|
+
}), this.reorientationPlugin = new re({
|
|
95
96
|
lon: 120,
|
|
96
97
|
lat: 30,
|
|
97
98
|
height: 0.1
|
|
@@ -120,18 +121,18 @@ class ne {
|
|
|
120
121
|
disable() {
|
|
121
122
|
this.ssp.removeObject(this.tiles.group), this.ssp.signals.beforeRender.remove(this.beforeRenderHandler);
|
|
122
123
|
}
|
|
123
|
-
invalidate(e, t,
|
|
124
|
-
const
|
|
125
|
-
const
|
|
124
|
+
invalidate(e, t, s) {
|
|
125
|
+
const r = () => {
|
|
126
|
+
const n = C.degToRad(t), o = C.degToRad(e);
|
|
126
127
|
this.reorientationPlugin.transformLatLonHeightToOrigin(
|
|
127
|
-
|
|
128
|
+
n,
|
|
128
129
|
o,
|
|
129
|
-
|
|
130
|
-
), this.ssp.render(),
|
|
131
|
-
},
|
|
132
|
-
this.tiles.removeEventListener("load-root-tileset",
|
|
130
|
+
s
|
|
131
|
+
), this.ssp.render(), a();
|
|
132
|
+
}, a = () => {
|
|
133
|
+
this.tiles.removeEventListener("load-root-tileset", r), this.loedTilesSets.delete(r);
|
|
133
134
|
};
|
|
134
|
-
return this.tiles.addEventListener("load-root-tileset",
|
|
135
|
+
return this.tiles.addEventListener("load-root-tileset", r), this.loedTilesSets.add(r), this.tiles.root && r(), a;
|
|
135
136
|
}
|
|
136
137
|
dispose() {
|
|
137
138
|
this.disable(), this.loedTilesSets.forEach(
|
|
@@ -139,7 +140,7 @@ class ne {
|
|
|
139
140
|
), this.loedTilesSets.clear(), this.tiles.removeEventListener("needs-render", this.render), this.tiles.removeEventListener("needs-update", this.render), this.tiles.dispose();
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
|
-
class
|
|
143
|
+
class Ne {
|
|
143
144
|
// 使用较低的 priority 确保在 ImageOverlayPlugin 之后执行
|
|
144
145
|
// ImageOverlayPlugin 默认 priority 是 -1
|
|
145
146
|
priority = -10;
|
|
@@ -159,8 +160,8 @@ class H {
|
|
|
159
160
|
*/
|
|
160
161
|
updateAllLoadedModels(e) {
|
|
161
162
|
e.forEachLoadedModel((t) => {
|
|
162
|
-
t.traverse((
|
|
163
|
-
|
|
163
|
+
t.traverse((s) => {
|
|
164
|
+
s.material && this._applyToMaterial(s.material);
|
|
164
165
|
});
|
|
165
166
|
});
|
|
166
167
|
}
|
|
@@ -182,8 +183,8 @@ class H {
|
|
|
182
183
|
e.needsUpdate = !0;
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
|
-
var
|
|
186
|
-
class
|
|
186
|
+
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 || {}), U = /* @__PURE__ */ ((i) => (i.QUANTIZED_MESH = "quantizedMesh", i.CESIUM_ION = "cesiumIon", i))(U || {});
|
|
187
|
+
class Ae {
|
|
187
188
|
constructor(e, t) {
|
|
188
189
|
this.imageOverlayPlugin = e, this.resourceManager = t;
|
|
189
190
|
}
|
|
@@ -202,54 +203,54 @@ class B {
|
|
|
202
203
|
strokeStyle: e.strokeStyle,
|
|
203
204
|
strokeWidth: e.strokeWidth
|
|
204
205
|
};
|
|
205
|
-
e.color && (t.color = new
|
|
206
|
-
const
|
|
207
|
-
return this.imageOverlayPlugin.addOverlay(
|
|
206
|
+
e.color && (t.color = new z(e.color));
|
|
207
|
+
const s = new Pe(t);
|
|
208
|
+
return this.imageOverlayPlugin.addOverlay(s, e.order), this._instances.set(e.id, {
|
|
208
209
|
id: e.id,
|
|
209
|
-
type:
|
|
210
|
-
instance:
|
|
210
|
+
type: l.GEOJSON,
|
|
211
|
+
instance: s
|
|
211
212
|
}), this.resourceManager?.addOverlay({
|
|
212
213
|
id: e.id,
|
|
213
|
-
type:
|
|
214
|
+
type: l.GEOJSON,
|
|
214
215
|
options: e
|
|
215
|
-
}),
|
|
216
|
+
}), s;
|
|
216
217
|
}
|
|
217
218
|
updateGeoJSONColor(e, t) {
|
|
218
|
-
const
|
|
219
|
-
if (!
|
|
220
|
-
const
|
|
221
|
-
return
|
|
219
|
+
const s = this._instances.get(e);
|
|
220
|
+
if (!s || s.type !== l.GEOJSON) return !1;
|
|
221
|
+
const r = s.instance;
|
|
222
|
+
return r.color.set(t), r.redraw(), this.resourceManager?.updateOverlay(e, { color: t }), !0;
|
|
222
223
|
}
|
|
223
224
|
updateGeoJSONStrokeStyle(e, t) {
|
|
224
|
-
const
|
|
225
|
-
if (!
|
|
226
|
-
const
|
|
227
|
-
return
|
|
225
|
+
const s = this._instances.get(e);
|
|
226
|
+
if (!s || s.type !== l.GEOJSON) return !1;
|
|
227
|
+
const r = s.instance;
|
|
228
|
+
return r.strokeStyle = t, r.redraw(), this.resourceManager?.updateOverlay(e, { strokeStyle: t }), !0;
|
|
228
229
|
}
|
|
229
230
|
updateGeoJSONStrokeWidth(e, t) {
|
|
230
|
-
const
|
|
231
|
-
if (!
|
|
232
|
-
const
|
|
233
|
-
return
|
|
231
|
+
const s = this._instances.get(e);
|
|
232
|
+
if (!s || s.type !== l.GEOJSON) return !1;
|
|
233
|
+
const r = s.instance;
|
|
234
|
+
return r.strokeWidth = t, r.redraw(), this.resourceManager?.updateOverlay(e, { strokeWidth: t }), !0;
|
|
234
235
|
}
|
|
235
236
|
updateGeoJSONFillStyle(e, t) {
|
|
236
|
-
const
|
|
237
|
-
if (!
|
|
238
|
-
const
|
|
239
|
-
return
|
|
237
|
+
const s = this._instances.get(e);
|
|
238
|
+
if (!s || s.type !== l.GEOJSON) return !1;
|
|
239
|
+
const r = s.instance;
|
|
240
|
+
return r.fillStyle = t, r.redraw(), this.resourceManager?.updateOverlay(e, { fillStyle: t }), !0;
|
|
240
241
|
}
|
|
241
242
|
updateGeoJSONMode(e, t) {
|
|
242
|
-
const
|
|
243
|
-
if (!
|
|
244
|
-
const
|
|
245
|
-
return
|
|
243
|
+
const s = this._instances.get(e);
|
|
244
|
+
if (!s || s.type !== l.GEOJSON) return !1;
|
|
245
|
+
const r = s.instance;
|
|
246
|
+
return r.alphaInvert = !1, r.alphaMask = !1, r.fillStyle = "rgba( 255, 255, 255, 0.5 )", t === "mask" ? (r.alphaMask = !0, r.fillStyle = "white") : t === "invertMask" && (r.alphaInvert = !0, r.alphaMask = !0, r.fillStyle = "white"), r.redraw(), !0;
|
|
246
247
|
}
|
|
247
248
|
// =============== Cesium Ion ===============
|
|
248
249
|
addCesiumIon(e) {
|
|
249
250
|
if (!this.imageOverlayPlugin) return null;
|
|
250
251
|
if (this._instances.has(e.id))
|
|
251
252
|
return console.warn(`OverlayManager: Overlay "${e.id}" already exists`), null;
|
|
252
|
-
const t = new
|
|
253
|
+
const t = new Se({
|
|
253
254
|
assetId: e.assetId,
|
|
254
255
|
apiToken: e.apiToken,
|
|
255
256
|
autoRefreshToken: e.autoRefreshToken ?? !0,
|
|
@@ -258,11 +259,11 @@ class B {
|
|
|
258
259
|
});
|
|
259
260
|
return this.imageOverlayPlugin.addOverlay(t, e.order), this._instances.set(e.id, {
|
|
260
261
|
id: e.id,
|
|
261
|
-
type:
|
|
262
|
+
type: l.CESIUM_ION,
|
|
262
263
|
instance: t
|
|
263
264
|
}), this.resourceManager?.addOverlay({
|
|
264
265
|
id: e.id,
|
|
265
|
-
type:
|
|
266
|
+
type: l.CESIUM_ION,
|
|
266
267
|
options: e
|
|
267
268
|
}), t;
|
|
268
269
|
}
|
|
@@ -271,18 +272,18 @@ class B {
|
|
|
271
272
|
if (!this.imageOverlayPlugin) return null;
|
|
272
273
|
if (this._instances.has(e.id))
|
|
273
274
|
return console.warn(`OverlayManager: Overlay "${e.id}" already exists`), null;
|
|
274
|
-
const t = new
|
|
275
|
+
const t = new Ce({
|
|
275
276
|
url: e.url,
|
|
276
277
|
color: typeof e.color == "number" ? e.color : 16777215,
|
|
277
278
|
opacity: e.opacity ?? 1
|
|
278
279
|
});
|
|
279
280
|
return this.imageOverlayPlugin.addOverlay(t, e.order), this._instances.set(e.id, {
|
|
280
281
|
id: e.id,
|
|
281
|
-
type:
|
|
282
|
+
type: l.TMS,
|
|
282
283
|
instance: t
|
|
283
284
|
}), this.resourceManager?.addOverlay({
|
|
284
285
|
id: e.id,
|
|
285
|
-
type:
|
|
286
|
+
type: l.TMS,
|
|
286
287
|
options: e
|
|
287
288
|
}), t;
|
|
288
289
|
}
|
|
@@ -291,18 +292,18 @@ class B {
|
|
|
291
292
|
if (!this.imageOverlayPlugin) return null;
|
|
292
293
|
if (this._instances.has(e.id))
|
|
293
294
|
return console.warn(`OverlayManager: Overlay "${e.id}" already exists`), null;
|
|
294
|
-
const t = new
|
|
295
|
+
const t = new ye({
|
|
295
296
|
url: e.url,
|
|
296
297
|
color: typeof e.color == "number" ? e.color : 16777215,
|
|
297
298
|
opacity: e.opacity ?? 1
|
|
298
299
|
});
|
|
299
300
|
return this.imageOverlayPlugin.addOverlay(t, e.order), this._instances.set(e.id, {
|
|
300
301
|
id: e.id,
|
|
301
|
-
type:
|
|
302
|
+
type: l.XYZ,
|
|
302
303
|
instance: t
|
|
303
304
|
}), this.resourceManager?.addOverlay({
|
|
304
305
|
id: e.id,
|
|
305
|
-
type:
|
|
306
|
+
type: l.XYZ,
|
|
306
307
|
options: e
|
|
307
308
|
}), t;
|
|
308
309
|
}
|
|
@@ -342,7 +343,7 @@ class B {
|
|
|
342
343
|
if (!this.imageOverlayPlugin) return null;
|
|
343
344
|
if (this._instances.has(e.id))
|
|
344
345
|
return console.warn(`OverlayManager: Overlay "${e.id}" already exists`), null;
|
|
345
|
-
const t = new
|
|
346
|
+
const t = new Le({
|
|
346
347
|
url: e.url,
|
|
347
348
|
subdomains: e.subdomains,
|
|
348
349
|
levels: e.levels,
|
|
@@ -355,11 +356,11 @@ class B {
|
|
|
355
356
|
});
|
|
356
357
|
return this.imageOverlayPlugin.addOverlay(t, e.order), this._instances.set(e.id, {
|
|
357
358
|
id: e.id,
|
|
358
|
-
type:
|
|
359
|
+
type: l.URL_TEMPLATE,
|
|
359
360
|
instance: t
|
|
360
361
|
}), this.resourceManager?.addOverlay({
|
|
361
362
|
id: e.id,
|
|
362
|
-
type:
|
|
363
|
+
type: l.URL_TEMPLATE,
|
|
363
364
|
options: e
|
|
364
365
|
}), t;
|
|
365
366
|
}
|
|
@@ -374,55 +375,55 @@ class B {
|
|
|
374
375
|
crs: e.crs || "EPSG:4326",
|
|
375
376
|
format: e.format || "image/png",
|
|
376
377
|
tileDimension: e.tileDimension || 256
|
|
377
|
-
},
|
|
378
|
+
}, s = new Ee({
|
|
378
379
|
url: e.url,
|
|
379
380
|
layer: t.layer,
|
|
380
381
|
crs: t.crs,
|
|
381
382
|
format: t.format,
|
|
382
383
|
tileDimension: t.tileDimension,
|
|
383
384
|
styles: t.styles,
|
|
384
|
-
color: new
|
|
385
|
+
color: new z(typeof e.color == "number" ? e.color : 16777215),
|
|
385
386
|
opacity: e.opacity ?? 1
|
|
386
387
|
});
|
|
387
|
-
return this.imageOverlayPlugin.addOverlay(
|
|
388
|
+
return this.imageOverlayPlugin.addOverlay(s, e.order), this._instances.set(e.id, {
|
|
388
389
|
id: e.id,
|
|
389
|
-
type:
|
|
390
|
-
instance:
|
|
390
|
+
type: l.WMS,
|
|
391
|
+
instance: s
|
|
391
392
|
}), this.resourceManager?.addOverlay({
|
|
392
393
|
id: e.id,
|
|
393
|
-
type:
|
|
394
|
+
type: l.WMS,
|
|
394
395
|
options: e
|
|
395
|
-
}),
|
|
396
|
+
}), s;
|
|
396
397
|
}
|
|
397
398
|
// =============== WMTS ===============
|
|
398
399
|
async addWMTS(e) {
|
|
399
400
|
if (!this.imageOverlayPlugin) return null;
|
|
400
401
|
if (this._instances.has(e.id))
|
|
401
402
|
return console.warn(`OverlayManager: Overlay "${e.id}" already exists`), null;
|
|
402
|
-
const t = await new
|
|
403
|
-
let
|
|
404
|
-
t.layers.find((
|
|
405
|
-
(
|
|
403
|
+
const t = await new be().loadAsync(e.url), s = ["EPSG:4326", "EPSG:3857"];
|
|
404
|
+
let r = e.layer || "";
|
|
405
|
+
t.layers.find((n) => n.identifier === r) || (r = t.layers.find(
|
|
406
|
+
(n) => n?.tileMatrixSets?.some((o) => s.includes(o.supportedCRS))
|
|
406
407
|
)?.identifier || t.layers[0].identifier);
|
|
407
|
-
const
|
|
408
|
+
const a = new Ie({
|
|
408
409
|
capabilities: t,
|
|
409
|
-
layer:
|
|
410
|
+
layer: r,
|
|
410
411
|
dimensions: e.dimensions || null,
|
|
411
412
|
style: e.style || void 0,
|
|
412
413
|
tileMatrixSet: e.tileMatrixSet || null,
|
|
413
414
|
planar: !1,
|
|
414
|
-
color: new
|
|
415
|
+
color: new z(typeof e.color == "number" ? e.color : 16777215),
|
|
415
416
|
opacity: e.opacity ?? 1
|
|
416
417
|
});
|
|
417
|
-
return this.imageOverlayPlugin.addOverlay(
|
|
418
|
+
return this.imageOverlayPlugin.addOverlay(a, e.order), this._instances.set(e.id, {
|
|
418
419
|
id: e.id,
|
|
419
|
-
type:
|
|
420
|
-
instance:
|
|
420
|
+
type: l.WMTS,
|
|
421
|
+
instance: a
|
|
421
422
|
}), this.resourceManager?.addOverlay({
|
|
422
423
|
id: e.id,
|
|
423
|
-
type:
|
|
424
|
+
type: l.WMTS,
|
|
424
425
|
options: e
|
|
425
|
-
}),
|
|
426
|
+
}), a;
|
|
426
427
|
}
|
|
427
428
|
// =============== 通用方法 ===============
|
|
428
429
|
/**
|
|
@@ -431,12 +432,12 @@ class B {
|
|
|
431
432
|
remove(e) {
|
|
432
433
|
const t = this._instances.get(e);
|
|
433
434
|
return t ? [
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
435
|
+
l.XYZ,
|
|
436
|
+
l.TMS,
|
|
437
|
+
l.WMS,
|
|
438
|
+
l.WMTS,
|
|
439
|
+
l.CESIUM_ION,
|
|
440
|
+
l.URL_TEMPLATE
|
|
440
441
|
].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);
|
|
441
442
|
}
|
|
442
443
|
/**
|
|
@@ -455,23 +456,23 @@ class B {
|
|
|
455
456
|
* 设置 overlay 可见性
|
|
456
457
|
*/
|
|
457
458
|
setVisible(e, t) {
|
|
458
|
-
const
|
|
459
|
-
return
|
|
459
|
+
const s = this._instances.get(e);
|
|
460
|
+
return s && "opacity" in s.instance ? (s.instance.opacity = t ? 1 : 0, this.resourceManager?.updateOverlay(e, { opacity: t ? 1 : 0 }), !0) : !1;
|
|
460
461
|
}
|
|
461
462
|
/**
|
|
462
463
|
* 设置 overlay 透明度
|
|
463
464
|
*/
|
|
464
465
|
setOpacity(e, t) {
|
|
465
|
-
const
|
|
466
|
-
return
|
|
466
|
+
const s = this._instances.get(e);
|
|
467
|
+
return s && "opacity" in s.instance ? (s.instance.opacity = t, this.resourceManager?.updateOverlay(e, { opacity: t }), s.instance.redraw?.(), !0) : !1;
|
|
467
468
|
}
|
|
468
469
|
/**
|
|
469
470
|
* 设置 overlay 层级
|
|
470
471
|
*/
|
|
471
472
|
setOrder(e, t) {
|
|
472
473
|
if (!this.imageOverlayPlugin) return !1;
|
|
473
|
-
const
|
|
474
|
-
return
|
|
474
|
+
const s = this._instances.get(e);
|
|
475
|
+
return s ? (this.imageOverlayPlugin.setOverlayOrder(s.instance, t), this.resourceManager?.updateOverlay(e, { order: t }), !0) : !1;
|
|
475
476
|
}
|
|
476
477
|
/**
|
|
477
478
|
* 获取 overlay 层级
|
|
@@ -488,11 +489,11 @@ class B {
|
|
|
488
489
|
if (!this.imageOverlayPlugin) return !1;
|
|
489
490
|
const t = this._instances.get(e);
|
|
490
491
|
if (!t) return !1;
|
|
491
|
-
const
|
|
492
|
-
let
|
|
493
|
-
return
|
|
494
|
-
|
|
495
|
-
}), this.imageOverlayPlugin.setOverlayOrder(t.instance,
|
|
492
|
+
const s = this.imageOverlayPlugin.overlayInfo;
|
|
493
|
+
let r = 0;
|
|
494
|
+
return s.forEach((a) => {
|
|
495
|
+
a.order > r && (r = a.order);
|
|
496
|
+
}), this.imageOverlayPlugin.setOverlayOrder(t.instance, r + 1), this.resourceManager?.updateOverlay(e, { order: r + 1 }), !0;
|
|
496
497
|
}
|
|
497
498
|
/**
|
|
498
499
|
* 将 overlay 移到最底层
|
|
@@ -501,11 +502,11 @@ class B {
|
|
|
501
502
|
if (!this.imageOverlayPlugin) return !1;
|
|
502
503
|
const t = this._instances.get(e);
|
|
503
504
|
if (!t) return !1;
|
|
504
|
-
const
|
|
505
|
-
let
|
|
506
|
-
return
|
|
507
|
-
|
|
508
|
-
}), this.imageOverlayPlugin.setOverlayOrder(t.instance,
|
|
505
|
+
const s = this.imageOverlayPlugin.overlayInfo;
|
|
506
|
+
let r = 1 / 0;
|
|
507
|
+
return s.forEach((a) => {
|
|
508
|
+
a.order < r && (r = a.order);
|
|
509
|
+
}), this.imageOverlayPlugin.setOverlayOrder(t.instance, r - 1), this.resourceManager?.updateOverlay(e, { order: r - 1 }), !0;
|
|
509
510
|
}
|
|
510
511
|
// =============== 资源恢复 ===============
|
|
511
512
|
/**
|
|
@@ -523,25 +524,25 @@ class B {
|
|
|
523
524
|
_createOverlayFromResource(e) {
|
|
524
525
|
const t = this.resourceManager;
|
|
525
526
|
switch (this.resourceManager = void 0, e.type) {
|
|
526
|
-
case
|
|
527
|
+
case l.GEOJSON:
|
|
527
528
|
this.addGeoJSON(e.options);
|
|
528
529
|
break;
|
|
529
|
-
case
|
|
530
|
+
case l.CESIUM_ION:
|
|
530
531
|
this.addCesiumIon(e.options);
|
|
531
532
|
break;
|
|
532
|
-
case
|
|
533
|
+
case l.TMS:
|
|
533
534
|
this.addTMS(e.options);
|
|
534
535
|
break;
|
|
535
|
-
case
|
|
536
|
+
case l.XYZ:
|
|
536
537
|
this.addXYZ(e.options);
|
|
537
538
|
break;
|
|
538
|
-
case
|
|
539
|
+
case l.WMS:
|
|
539
540
|
this.addWMS(e.options);
|
|
540
541
|
break;
|
|
541
|
-
case
|
|
542
|
+
case l.WMTS:
|
|
542
543
|
this.addWMTS(e.options);
|
|
543
544
|
break;
|
|
544
|
-
case
|
|
545
|
+
case l.URL_TEMPLATE:
|
|
545
546
|
this.addUrlTemplate(e.options);
|
|
546
547
|
break;
|
|
547
548
|
}
|
|
@@ -566,13 +567,15 @@ class B {
|
|
|
566
567
|
_getLocalImageryCount() {
|
|
567
568
|
let e = 0;
|
|
568
569
|
return this._instances.forEach((t) => {
|
|
569
|
-
[
|
|
570
|
+
[l.XYZ, l.TMS, l.WMS, l.WMTS, l.CESIUM_ION, l.URL_TEMPLATE].includes(t.type) && e++;
|
|
570
571
|
}), e;
|
|
571
572
|
}
|
|
572
573
|
/**
|
|
573
574
|
* 只清理实例(保留 ResourceManager 中的配置)
|
|
574
575
|
*/
|
|
575
576
|
disposeInstances() {
|
|
577
|
+
console.log("disposeInstances"), console.log(this._instances);
|
|
578
|
+
debugger;
|
|
576
579
|
this._instances.forEach((e) => {
|
|
577
580
|
this.imageOverlayPlugin?.deleteOverlay(e.instance);
|
|
578
581
|
}), this._instances.clear();
|
|
@@ -584,7 +587,7 @@ class B {
|
|
|
584
587
|
this.disposeInstances(), this.resourceManager?.clear();
|
|
585
588
|
}
|
|
586
589
|
}
|
|
587
|
-
class
|
|
590
|
+
class Fe {
|
|
588
591
|
/** Overlay 资源配置 */
|
|
589
592
|
_overlays = /* @__PURE__ */ new Map();
|
|
590
593
|
// =============== Overlay 资源管理 ===============
|
|
@@ -642,15 +645,15 @@ class z {
|
|
|
642
645
|
getImageryOverlayCount() {
|
|
643
646
|
let e = 0;
|
|
644
647
|
return this._overlays.forEach((t) => {
|
|
645
|
-
(t.type ===
|
|
648
|
+
(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++;
|
|
646
649
|
}), e;
|
|
647
650
|
}
|
|
648
651
|
/**
|
|
649
652
|
* 更新 Overlay 配置
|
|
650
653
|
*/
|
|
651
654
|
updateOverlay(e, t) {
|
|
652
|
-
const
|
|
653
|
-
return
|
|
655
|
+
const s = this._overlays.get(e);
|
|
656
|
+
return s ? (s.options = { ...s.options, ...t }, !0) : !1;
|
|
654
657
|
}
|
|
655
658
|
// =============== 工具方法 ===============
|
|
656
659
|
/**
|
|
@@ -674,7 +677,7 @@ class z {
|
|
|
674
677
|
e.overlays && (this._overlays.clear(), e.overlays.forEach((t) => this._overlays.set(t.id, { ...t })));
|
|
675
678
|
}
|
|
676
679
|
}
|
|
677
|
-
class
|
|
680
|
+
class Ge {
|
|
678
681
|
/** 地形配置映射表 */
|
|
679
682
|
_terrains = /* @__PURE__ */ new Map();
|
|
680
683
|
/** 当前激活的地形 ID */
|
|
@@ -763,24 +766,570 @@ class $ {
|
|
|
763
766
|
this.clear();
|
|
764
767
|
}
|
|
765
768
|
}
|
|
766
|
-
|
|
767
|
-
class
|
|
769
|
+
let Ue = 1;
|
|
770
|
+
class S {
|
|
771
|
+
id;
|
|
772
|
+
category = "";
|
|
773
|
+
options;
|
|
774
|
+
constructor(e) {
|
|
775
|
+
this.id = String(Ue++), this.category = "", this.options = { ...e }, this.options.points && (this.options.points = this.options.points.map((t) => [t[0], t[1]]));
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* 合并更新 `options`(不可变风格:整表替换为新对象)。
|
|
779
|
+
* 子类应覆盖为 `Partial<具体Options>`,以便类型提示包含各类型专有字段。
|
|
780
|
+
*/
|
|
781
|
+
update(e) {
|
|
782
|
+
this.options = { ...this.options, ...e };
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* 浅拷贝快照:`options` 为一层展开新对象,`points` 与内部仍为同一数组引用。
|
|
786
|
+
* {@link GroundDecalManager.getItem} 默认使用此方法。
|
|
787
|
+
*/
|
|
788
|
+
getSnapshot() {
|
|
789
|
+
return { type: this.category, options: { ...this.options } };
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* 深拷贝快照:`points` 中每个顶点为新数组,修改返回值不会影响标绘内部状态。
|
|
793
|
+
* 需独立副本时请用 {@link GroundDecalManager.getItemDeep} 或本方法。
|
|
794
|
+
*/
|
|
795
|
+
getSnapshotDeep() {
|
|
796
|
+
const e = { ...this.options };
|
|
797
|
+
return e.points && (e.points = e.points.map((t) => [...t])), { type: this.category, options: e };
|
|
798
|
+
}
|
|
799
|
+
/** 用于计算 ENU 参考中心的坐标点 */
|
|
800
|
+
getCenterPoints() {
|
|
801
|
+
return this.options.points || [];
|
|
802
|
+
}
|
|
803
|
+
/** 用于计算最大空间范围的坐标点(子类可覆盖以扩展半径等) */
|
|
804
|
+
getExtentPoints() {
|
|
805
|
+
return this.options.points || [];
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
class We extends S {
|
|
809
|
+
category = "point";
|
|
810
|
+
constructor(e) {
|
|
811
|
+
super(e);
|
|
812
|
+
}
|
|
813
|
+
update(e) {
|
|
814
|
+
this.options = { ...this.options, ...e };
|
|
815
|
+
}
|
|
816
|
+
getCenterPoints() {
|
|
817
|
+
const e = this.options.points;
|
|
818
|
+
return e && e.length > 0 ? [e[0]] : [];
|
|
819
|
+
}
|
|
820
|
+
getExtentPoints() {
|
|
821
|
+
return this.getCenterPoints();
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
class Qe extends S {
|
|
825
|
+
category = "line";
|
|
826
|
+
constructor(e) {
|
|
827
|
+
super(e);
|
|
828
|
+
}
|
|
829
|
+
update(e) {
|
|
830
|
+
this.options = { ...this.options, ...e };
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
class je extends S {
|
|
834
|
+
category = "polygon";
|
|
835
|
+
constructor(e) {
|
|
836
|
+
super(e);
|
|
837
|
+
}
|
|
838
|
+
update(e) {
|
|
839
|
+
this.options = { ...this.options, ...e };
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
const ie = C.DEG2RAD;
|
|
843
|
+
new _e();
|
|
844
|
+
class He extends S {
|
|
845
|
+
category = "rectangle";
|
|
846
|
+
constructor(e) {
|
|
847
|
+
super(e);
|
|
848
|
+
}
|
|
849
|
+
update(e) {
|
|
850
|
+
this.options = { ...this.options, ...e };
|
|
851
|
+
}
|
|
852
|
+
getExtentPoints() {
|
|
853
|
+
const e = this.options.points;
|
|
854
|
+
if (!e || e.length === 0) return [];
|
|
855
|
+
const t = e[0][0], s = e[0][1], r = (this.options.width || 0) / 2, a = (this.options.height || 0) / 2, n = r / (111320 * Math.cos(s * ie)), o = a / 111320;
|
|
856
|
+
return [
|
|
857
|
+
[t, s],
|
|
858
|
+
[t - n, s - o],
|
|
859
|
+
[t + n, s + o]
|
|
860
|
+
];
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
class Be extends S {
|
|
864
|
+
category = "sector";
|
|
865
|
+
constructor(e) {
|
|
866
|
+
super(e);
|
|
867
|
+
}
|
|
868
|
+
update(e) {
|
|
869
|
+
this.options = { ...this.options, ...e };
|
|
870
|
+
}
|
|
871
|
+
getExtentPoints() {
|
|
872
|
+
const e = this.options.points;
|
|
873
|
+
if (!e || e.length === 0) return [];
|
|
874
|
+
const t = e[0][0], s = e[0][1], r = this.options.radius || 0, a = r / (111320 * Math.cos(s * ie)), n = r / 111320;
|
|
875
|
+
return [
|
|
876
|
+
[t - a, s - n],
|
|
877
|
+
[t + a, s + n]
|
|
878
|
+
];
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
const ce = 100, ae = 1e-4;
|
|
882
|
+
function T(i, e) {
|
|
883
|
+
return Math.sqrt((i[0] - e[0]) ** 2 + (i[1] - e[1]) ** 2);
|
|
884
|
+
}
|
|
885
|
+
function ne(i) {
|
|
886
|
+
let e = 0;
|
|
887
|
+
for (let t = 0; t < i.length - 1; t++)
|
|
888
|
+
e += T(i[t], i[t + 1]);
|
|
889
|
+
return e;
|
|
890
|
+
}
|
|
891
|
+
function Q(i) {
|
|
892
|
+
return ne(i) ** 0.99;
|
|
893
|
+
}
|
|
894
|
+
function oe(i, e) {
|
|
895
|
+
return [(i[0] + e[0]) / 2, (i[1] + e[1]) / 2];
|
|
896
|
+
}
|
|
897
|
+
function Z(i, e) {
|
|
898
|
+
const t = Math.asin(
|
|
899
|
+
Math.abs(e[1] - i[1]) / T(i, e)
|
|
900
|
+
);
|
|
901
|
+
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;
|
|
902
|
+
}
|
|
903
|
+
function Je(i, e, t) {
|
|
904
|
+
const s = Z(e, i) - Z(e, t);
|
|
905
|
+
return s < 0 ? s + Math.PI * 2 : s;
|
|
906
|
+
}
|
|
907
|
+
function ve(i, e, t) {
|
|
908
|
+
return (t[1] - i[1]) * (e[0] - i[0]) > (e[1] - i[1]) * (t[0] - i[0]);
|
|
909
|
+
}
|
|
910
|
+
function y(i, e, t, s, r) {
|
|
911
|
+
const a = Z(i, e), n = r ? a + t : a - t;
|
|
912
|
+
return [e[0] + s * Math.cos(n), e[1] + s * Math.sin(n)];
|
|
913
|
+
}
|
|
914
|
+
function le(i, e, t) {
|
|
915
|
+
let s = i[0] - e[0], r = i[1] - e[1];
|
|
916
|
+
const a = Math.sqrt(s * s + r * r);
|
|
917
|
+
s /= a, r /= a;
|
|
918
|
+
let n = t[0] - e[0], o = t[1] - e[1];
|
|
919
|
+
const h = Math.sqrt(n * n + o * o);
|
|
920
|
+
return n /= h, o /= h, [s + n, r + o];
|
|
921
|
+
}
|
|
922
|
+
function he(i, e, t, s) {
|
|
923
|
+
const r = le(e, t, s), a = Math.sqrt(r[0] ** 2 + r[1] ** 2), n = T(e, t), o = T(t, s);
|
|
924
|
+
let h, u;
|
|
925
|
+
if (a > ae) {
|
|
926
|
+
const d = r[0] / a, c = r[1] / a;
|
|
927
|
+
ve(e, t, s) ? (h = [t[0] - i * n * c, t[1] + i * n * d], u = [t[0] + i * o * c, t[1] - i * o * d]) : (h = [t[0] + i * n * c, t[1] - i * n * d], u = [t[0] - i * o * c, t[1] + i * o * d]);
|
|
928
|
+
} else
|
|
929
|
+
h = [t[0] + i * (e[0] - t[0]), t[1] + i * (e[1] - t[1])], u = [t[0] + i * (s[0] - t[0]), t[1] + i * (s[1] - t[1])];
|
|
930
|
+
return [h, u];
|
|
931
|
+
}
|
|
932
|
+
function ze(i, e) {
|
|
933
|
+
const [t, s, r] = [i[0], i[1], i[2]], n = he(0, t, s, r)[0], o = le(t, s, r);
|
|
934
|
+
if (Math.sqrt(o[0] ** 2 + o[1] ** 2) > ae) {
|
|
935
|
+
const u = oe(t, s), d = t[0] - u[0], c = t[1] - u[1], g = 2 / T(t, s), m = -g * c, p = g * d, f = m * m - p * p, M = 2 * m * p, _ = p * p - m * m, w = n[0] - u[0], P = n[1] - u[1];
|
|
936
|
+
return [u[0] + f * w + M * P, u[1] + M * w + _ * P];
|
|
937
|
+
}
|
|
938
|
+
return [t[0] + e * (s[0] - t[0]), t[1] + e * (s[1] - t[1])];
|
|
939
|
+
}
|
|
940
|
+
function Xe(i, e) {
|
|
941
|
+
const t = i.length, [s, r, a] = [i[t - 3], i[t - 2], i[t - 1]], o = he(0, s, r, a)[1], h = le(s, r, a);
|
|
942
|
+
if (Math.sqrt(h[0] ** 2 + h[1] ** 2) > ae) {
|
|
943
|
+
const d = oe(r, a), c = a[0] - d[0], g = a[1] - d[1], m = 2 / T(r, a), p = -m * g, f = m * c, M = p * p - f * f, _ = 2 * p * f, w = f * f - p * p, P = o[0] - d[0], L = o[1] - d[1];
|
|
944
|
+
return [d[0] + M * P + _ * L, d[1] + _ * P + w * L];
|
|
945
|
+
}
|
|
946
|
+
return [a[0] + e * (r[0] - a[0]), a[1] + e * (r[1] - a[1])];
|
|
947
|
+
}
|
|
948
|
+
function Ye(i, e) {
|
|
949
|
+
let s = [ze(e, i)];
|
|
950
|
+
for (let n = 0; n < e.length - 2; n++) {
|
|
951
|
+
const o = he(i, e[n], e[n + 1], e[n + 2]);
|
|
952
|
+
s = s.concat(o);
|
|
953
|
+
}
|
|
954
|
+
const r = Xe(e, i);
|
|
955
|
+
r && s.push(r);
|
|
956
|
+
const a = [];
|
|
957
|
+
for (let n = 0; n < e.length - 1; n++) {
|
|
958
|
+
const o = e[n], h = e[n + 1];
|
|
959
|
+
a.push(o);
|
|
960
|
+
for (let u = 0; u < ce; u++) {
|
|
961
|
+
const d = u / ce, c = 1 - d, g = d * d, m = g * d, p = c * c, f = p * c, M = s[n * 2], _ = s[n * 2 + 1];
|
|
962
|
+
a.push([
|
|
963
|
+
f * o[0] + 3 * p * d * M[0] + 3 * c * g * _[0] + m * h[0],
|
|
964
|
+
f * o[1] + 3 * p * d * M[1] + 3 * c * g * _[1] + m * h[1]
|
|
965
|
+
]);
|
|
966
|
+
}
|
|
967
|
+
a.push(h);
|
|
968
|
+
}
|
|
969
|
+
return a;
|
|
970
|
+
}
|
|
971
|
+
function $e(i, e) {
|
|
972
|
+
return i === 0 ? (e - 1) ** 2 / 2 : i === 1 ? (-2 * e ** 2 + 2 * e + 1) / 2 : i === 2 ? e ** 2 / 2 : 0;
|
|
973
|
+
}
|
|
974
|
+
function ge(i) {
|
|
975
|
+
if (i.length <= 2) return i;
|
|
976
|
+
const e = [i[0]], t = i.length - 3;
|
|
977
|
+
for (let s = 0; s <= t; s++)
|
|
978
|
+
for (let r = 0; r <= 1; r += 0.05) {
|
|
979
|
+
let a = 0, n = 0;
|
|
980
|
+
for (let o = 0; o <= 2; o++) {
|
|
981
|
+
const h = $e(o, r);
|
|
982
|
+
a += h * i[s + o][0], n += h * i[s + o][1];
|
|
983
|
+
}
|
|
984
|
+
e.push([a, n]);
|
|
985
|
+
}
|
|
986
|
+
return e.push(i[i.length - 1]), e;
|
|
987
|
+
}
|
|
988
|
+
function V(i, e) {
|
|
989
|
+
const t = Q([i, e]), s = t * 0.1, r = t * 0.2, a = t * 0.25, n = Math.PI / 8.5, o = Math.PI / 13, h = y(e, i, Math.PI / 2, s, !0), u = y(e, i, Math.PI / 2, s, !1), d = y(i, e, n, a, !1), c = y(i, e, n, a, !0), g = y(i, e, o, r, !1), m = y(i, e, o, r, !0);
|
|
990
|
+
return [h, g, d, e, c, m, u, i];
|
|
991
|
+
}
|
|
992
|
+
function K(i, e) {
|
|
993
|
+
if (i.length <= e) return i;
|
|
994
|
+
const t = [i[0]], s = (i.length - 1) / (e - 1);
|
|
995
|
+
for (let r = 1; r < e - 1; r++)
|
|
996
|
+
t.push(i[Math.round(r * s)]);
|
|
997
|
+
return t.push(i[i.length - 1]), t;
|
|
998
|
+
}
|
|
999
|
+
function qe(i) {
|
|
1000
|
+
if (i.length === 2)
|
|
1001
|
+
return V(i[0], i[1]);
|
|
1002
|
+
const e = Ye(0.3, i), t = K(e, 25), s = ne(t), r = 0.08, a = 0.12, n = 0.2, o = Math.PI / 8.5, h = Math.PI / 13, u = 0.15, d = s * r, c = s * u, g = [], m = [];
|
|
1003
|
+
let p = 0;
|
|
1004
|
+
const f = s - c;
|
|
1005
|
+
for (let v = 0; v < t.length && (v > 0 && (p += T(t[v - 1], t[v])), !(p > f)); v++) {
|
|
1006
|
+
const H = f > 0 ? p / f : 0, D = d * (1 - H * 0.5), N = v > 0 ? t[v - 1] : t[0], W = v < t.length - 1 ? t[v + 1] : t[v], A = W[0] - N[0], E = W[1] - N[1], F = Math.sqrt(A * A + E * E) || 1, G = -E / F, b = A / F;
|
|
1007
|
+
g.push([t[v][0] + G * D, t[v][1] + b * D]), m.push([t[v][0] - G * D, t[v][1] - b * D]);
|
|
1008
|
+
}
|
|
1009
|
+
const M = t[t.length - 1], _ = t[t.length - 2], w = s * a, P = s * n, L = y(_, M, h, w, !1), x = y(_, M, h, w, !0), k = y(_, M, o, P, !1), j = y(_, M, o, P, !0);
|
|
1010
|
+
return [...g, L, k, M, j, x, ...m.reverse()];
|
|
1011
|
+
}
|
|
1012
|
+
function Ze(i) {
|
|
1013
|
+
let e = i[0], t = i[1];
|
|
1014
|
+
ve(i[0], i[1], i[2]) && (e = i[1], t = i[0]);
|
|
1015
|
+
const r = [oe(e, t), ...i.slice(2)], a = 0.18, n = 0.3, o = 0.85, h = 0.15, u = 0.8;
|
|
1016
|
+
let d = Q(r), c = d * a;
|
|
1017
|
+
const g = r[r.length - 1];
|
|
1018
|
+
d = T(g, r[r.length - 2]);
|
|
1019
|
+
const m = T(e, t);
|
|
1020
|
+
c > m * u && (c = m * u);
|
|
1021
|
+
const p = c * n, f = c * h;
|
|
1022
|
+
c = Math.min(c, d);
|
|
1023
|
+
const M = c * o, _ = y(r[r.length - 2], g, 0, c, !0), w = y(r[r.length - 2], g, 0, M, !0), P = y(g, _, Math.PI / 2, p, !1), L = y(g, _, Math.PI / 2, p, !0), x = y(g, w, Math.PI / 2, f, !1), k = y(g, w, Math.PI / 2, f, !0), j = [x, P, g, L, k], v = m / Q(r), H = ne(r), N = Q(r) * v, W = T(x, k), A = (N - W) / 2;
|
|
1024
|
+
let E = 0;
|
|
1025
|
+
const F = [], G = [];
|
|
1026
|
+
for (let O = 1; O < r.length - 1; O++) {
|
|
1027
|
+
const J = Je(r[O - 1], r[O], r[O + 1]) / 2;
|
|
1028
|
+
E += T(r[O - 1], r[O]);
|
|
1029
|
+
const de = (N / 2 - E / H * A) / Math.sin(J);
|
|
1030
|
+
F.push(y(r[O - 1], r[O], Math.PI - J, de, !0)), G.push(y(r[O - 1], r[O], J, de, !1));
|
|
1031
|
+
}
|
|
1032
|
+
let b = [e, ...F, x], B = [t, ...G, k];
|
|
1033
|
+
return b = K(ge(b), 25), B = K(ge(B), 25), [...b, ...j, ...B.reverse()];
|
|
1034
|
+
}
|
|
1035
|
+
class Ve extends S {
|
|
1036
|
+
category = "arrow";
|
|
1037
|
+
/** `generateCoords()` 填充的闭合多边形顶点 */
|
|
1038
|
+
generatedCoords = [];
|
|
1039
|
+
constructor(e) {
|
|
1040
|
+
super(e);
|
|
1041
|
+
}
|
|
1042
|
+
update(e) {
|
|
1043
|
+
this.options = { ...this.options, ...e };
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* 按 `arrowType` 与控制点生成闭合多边形顶点(供 GroundDecalManager / PlotOverlay 重建几何)。
|
|
1047
|
+
*/
|
|
1048
|
+
generateCoords() {
|
|
1049
|
+
const e = this.options.points;
|
|
1050
|
+
if (!e || e.length < 2)
|
|
1051
|
+
return this.generatedCoords = [], [];
|
|
1052
|
+
const t = this.options.arrowType || "straight";
|
|
1053
|
+
return t === "fine" ? this.generatedCoords = V(e[0], e[1]) : t === "curved" ? this.generatedCoords = qe(e) : t === "attack" && e.length >= 3 ? this.generatedCoords = Ze(e) : this.generatedCoords = V(e[0], e[e.length - 1]), this.generatedCoords;
|
|
1054
|
+
}
|
|
1055
|
+
/** 浅拷贝:`options`、`generatedCoords` 与内部共享引用(顶点数组仍与 `options.points` 规则一致)。 */
|
|
1056
|
+
getSnapshot() {
|
|
1057
|
+
return {
|
|
1058
|
+
type: this.category,
|
|
1059
|
+
options: { ...this.options },
|
|
1060
|
+
generatedCoords: this.generatedCoords
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
/** 深拷贝:`options.points` 与 `generatedCoords` 均为新数组。 */
|
|
1064
|
+
getSnapshotDeep() {
|
|
1065
|
+
const e = super.getSnapshotDeep();
|
|
1066
|
+
return {
|
|
1067
|
+
type: e.type,
|
|
1068
|
+
options: e.options,
|
|
1069
|
+
generatedCoords: this.generatedCoords.map((t) => [...t])
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
class Ke extends S {
|
|
1074
|
+
category = "text";
|
|
1075
|
+
constructor(e) {
|
|
1076
|
+
super(e);
|
|
1077
|
+
}
|
|
1078
|
+
update(e) {
|
|
1079
|
+
this.options = { ...this.options, ...e };
|
|
1080
|
+
}
|
|
1081
|
+
getCenterPoints() {
|
|
1082
|
+
const e = this.options.points;
|
|
1083
|
+
return e && e.length > 0 ? [e[0]] : [];
|
|
1084
|
+
}
|
|
1085
|
+
getExtentPoints() {
|
|
1086
|
+
return this.getCenterPoints();
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
class et extends S {
|
|
1090
|
+
category = "circle";
|
|
1091
|
+
constructor(e) {
|
|
1092
|
+
super(e);
|
|
1093
|
+
}
|
|
1094
|
+
update(e) {
|
|
1095
|
+
this.options = { ...this.options, ...e };
|
|
1096
|
+
}
|
|
1097
|
+
getExtentPoints() {
|
|
1098
|
+
const e = this.options.points;
|
|
1099
|
+
if (!e || e.length === 0) return [];
|
|
1100
|
+
const t = e[0][0], s = e[0][1], r = this.options.radius || 0, a = r / (111320 * Math.cos(s * ie)), n = r / 111320;
|
|
1101
|
+
return [
|
|
1102
|
+
[t - a, s - n],
|
|
1103
|
+
[t + a, s + n]
|
|
1104
|
+
];
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
class tt {
|
|
1108
|
+
/** 标绘 id → 实例;与 `PlotOverlay.imageSource.shapes` 共用同一引用 */
|
|
1109
|
+
_items = /* @__PURE__ */ new Map();
|
|
1110
|
+
/** 标绘 id */
|
|
1111
|
+
id = "GROUND_DECAL_PLOT";
|
|
1112
|
+
/** 标绘 overlay */
|
|
1113
|
+
_overlay;
|
|
1114
|
+
/** SoonSpace 实例 */
|
|
1115
|
+
ssp;
|
|
1116
|
+
/** 传入的 ImageOverlayPlugin,用于在有图形时自动注册 overlay */
|
|
1117
|
+
_imageOverlayPlugin;
|
|
1118
|
+
/** overlay 是否已注册到 ImageOverlayPlugin */
|
|
1119
|
+
_overlayAttached = !1;
|
|
1120
|
+
/** 合并同一帧内多次 `_markDirty`,值为 `requestAnimationFrame` 句柄 */
|
|
1121
|
+
_redrawTimer = null;
|
|
1122
|
+
constructor(e) {
|
|
1123
|
+
this.ssp = e.ssp, this._imageOverlayPlugin = e.imageOverlayPlugin, this._overlay = new Re(), this._overlay.imageSource.shapes = this._items, this._overlay.imageSource.setRenderer(e.ssp.viewport.renderer);
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1126
|
+
* 内部使用的 `PlotOverlay` 实例。
|
|
1127
|
+
* 注册到 `ImageOverlayPlugin` 的 `overlays` 数组中,顺序靠后者通常绘制在上层。
|
|
1128
|
+
*/
|
|
1129
|
+
get overlay() {
|
|
1130
|
+
return this._overlay;
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* 绑定 / 更换 ImageOverlayPlugin(切换地形重建插件后调用)。
|
|
1134
|
+
* 如果当前已有图形,会在下一帧自动重新注册 overlay。
|
|
1135
|
+
*/
|
|
1136
|
+
setImageOverlayPlugin(e) {
|
|
1137
|
+
this._imageOverlayPlugin = e, this._overlayAttached = !1, this._items.size > 0 && this._markDirty();
|
|
1138
|
+
}
|
|
1139
|
+
// ── 图形创建:返回字符串 id,可用于后续查询 / 更新 / 删除 ──
|
|
1140
|
+
/**
|
|
1141
|
+
* 添加标绘:由 `options.type` 决定实例化哪一类 `GisPlot*`(与各类 `*Options` 对应)。
|
|
1142
|
+
*/
|
|
1143
|
+
addPlot(e) {
|
|
1144
|
+
let t;
|
|
1145
|
+
switch (e.type) {
|
|
1146
|
+
case "point": {
|
|
1147
|
+
const { type: s, ...r } = e;
|
|
1148
|
+
t = new We(r);
|
|
1149
|
+
break;
|
|
1150
|
+
}
|
|
1151
|
+
case "line": {
|
|
1152
|
+
const { type: s, ...r } = e;
|
|
1153
|
+
t = new Qe(r);
|
|
1154
|
+
break;
|
|
1155
|
+
}
|
|
1156
|
+
case "polygon": {
|
|
1157
|
+
const { type: s, ...r } = e;
|
|
1158
|
+
t = new je(r);
|
|
1159
|
+
break;
|
|
1160
|
+
}
|
|
1161
|
+
case "rectangle": {
|
|
1162
|
+
const { type: s, ...r } = e;
|
|
1163
|
+
t = new He(r);
|
|
1164
|
+
break;
|
|
1165
|
+
}
|
|
1166
|
+
case "circle": {
|
|
1167
|
+
const { type: s, ...r } = e;
|
|
1168
|
+
t = new et(r);
|
|
1169
|
+
break;
|
|
1170
|
+
}
|
|
1171
|
+
case "sector": {
|
|
1172
|
+
const { type: s, ...r } = e;
|
|
1173
|
+
t = new Be(r);
|
|
1174
|
+
break;
|
|
1175
|
+
}
|
|
1176
|
+
case "text": {
|
|
1177
|
+
const { type: s, ...r } = e;
|
|
1178
|
+
t = new Ke(r);
|
|
1179
|
+
break;
|
|
1180
|
+
}
|
|
1181
|
+
case "arrow": {
|
|
1182
|
+
const { type: s, ...r } = e;
|
|
1183
|
+
t = new Ve(r);
|
|
1184
|
+
break;
|
|
1185
|
+
}
|
|
1186
|
+
default:
|
|
1187
|
+
throw new Error("GroundDecalManager.addPlot: unknown type");
|
|
1188
|
+
}
|
|
1189
|
+
return this._items.set(t.id, t), this._markDirty(), t.id;
|
|
1190
|
+
}
|
|
1191
|
+
/** 按 id 移除标绘;存在并删除成功时触发重绘 */
|
|
1192
|
+
remove(e) {
|
|
1193
|
+
this._items.delete(e) && this._markDirty();
|
|
1194
|
+
}
|
|
1195
|
+
/** 清空全部标绘 */
|
|
1196
|
+
clear() {
|
|
1197
|
+
this._items.clear(), this._markDirty();
|
|
1198
|
+
}
|
|
1199
|
+
// ── 查询与修改 ──
|
|
1200
|
+
/**
|
|
1201
|
+
* 读取标绘快照(**浅拷贝**:`options` 为新对象,但 `points` 与内部仍为同一数组引用)。
|
|
1202
|
+
* 若需完全独立副本,请用 {@link getItemDeep}。
|
|
1203
|
+
*/
|
|
1204
|
+
getItem(e) {
|
|
1205
|
+
const t = this._items.get(e);
|
|
1206
|
+
return t ? t.getSnapshot() : null;
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* 深拷贝快照:`points` 等嵌套数组被复制,修改返回值不会影响内部状态。
|
|
1210
|
+
* 箭头类型额外深拷贝 `generatedCoords`。
|
|
1211
|
+
*/
|
|
1212
|
+
getItemDeep(e) {
|
|
1213
|
+
const t = this._items.get(e);
|
|
1214
|
+
return t ? t.getSnapshotDeep() : null;
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* 合并更新样式与几何字段(调用对应 `GisPlot*.update`)。
|
|
1218
|
+
* `patch` 形状需与该 id 下图元类型兼容。
|
|
1219
|
+
*/
|
|
1220
|
+
setStyle(e, t) {
|
|
1221
|
+
const s = this._items.get(e);
|
|
1222
|
+
s && (s.update(t), this._markDirty());
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* 将 **第一个顶点** 设为新的经纬度中心(适用于点、矩形中心、扇心、文字锚点等单中心语义)。
|
|
1226
|
+
*/
|
|
1227
|
+
setCenter(e, t) {
|
|
1228
|
+
const s = this._items.get(e);
|
|
1229
|
+
!s || !s.options.points || s.options.points.length === 0 || (t.lon !== void 0 && (s.options.points[0][0] = t.lon), t.lat !== void 0 && (s.options.points[0][1] = t.lat), this._markDirty());
|
|
1230
|
+
}
|
|
1231
|
+
/** 整体替换顶点列表(每项为 `[lon, lat]`) */
|
|
1232
|
+
setCoords(e, t) {
|
|
1233
|
+
const s = this._items.get(e);
|
|
1234
|
+
s && (s.options.points = t.map((r) => [...r]), this._markDirty());
|
|
1235
|
+
}
|
|
1236
|
+
/** 修改指定下标顶点;`coord` 分量可为 `undefined` 表示不改该分量 */
|
|
1237
|
+
setCoord(e, t, s) {
|
|
1238
|
+
const r = this._items.get(e);
|
|
1239
|
+
!r || !r.options.points || t < 0 || t >= r.options.points.length || (s[0] !== void 0 && (r.options.points[t][0] = s[0]), s[1] !== void 0 && (r.options.points[t][1] = s[1]), this._markDirty());
|
|
1240
|
+
}
|
|
1241
|
+
/** 在 `index` 处插入一个顶点(可插在末尾,`index` 越界时钳位) */
|
|
1242
|
+
insertCoord(e, t, s) {
|
|
1243
|
+
const r = this._items.get(e);
|
|
1244
|
+
if (!r || !r.options.points) return;
|
|
1245
|
+
const a = Math.max(0, Math.min(t, r.options.points.length));
|
|
1246
|
+
r.options.points.splice(a, 0, [...s]), this._markDirty();
|
|
1247
|
+
}
|
|
1248
|
+
/**
|
|
1249
|
+
* 删除指定下标顶点。
|
|
1250
|
+
* 多边形至少保留 3 点,其余类型至少 2 点(与 `shape.category` 联动)。
|
|
1251
|
+
*/
|
|
1252
|
+
removeCoord(e, t) {
|
|
1253
|
+
const s = this._items.get(e);
|
|
1254
|
+
if (!s || !s.options.points || t < 0 || t >= s.options.points.length) return;
|
|
1255
|
+
const r = s.category === "polygon" ? 3 : 2;
|
|
1256
|
+
s.options.points.length <= r || (s.options.points.splice(t, 1), this._markDirty());
|
|
1257
|
+
}
|
|
1258
|
+
/** 对所有顶点做经纬度平移(度) */
|
|
1259
|
+
translateCoords(e, t, s) {
|
|
1260
|
+
const r = this._items.get(e);
|
|
1261
|
+
if (!(!r || !r.options.points)) {
|
|
1262
|
+
for (const a of r.options.points)
|
|
1263
|
+
a[0] += t, a[1] += s;
|
|
1264
|
+
this._markDirty();
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
/** 仅对 `category === 'text'` 的项更新 `options.content` */
|
|
1268
|
+
setText(e, t) {
|
|
1269
|
+
const s = this._items.get(e);
|
|
1270
|
+
!s || s.category !== "text" || (s.options.content = t, this._markDirty());
|
|
1271
|
+
}
|
|
1272
|
+
/** 设置整个 overlay 不透明度(0–1,具体语义以 `PlotOverlay` 为准) */
|
|
1273
|
+
setGlobalOpacity(e) {
|
|
1274
|
+
this._overlay.opacity = e, this._markDirty();
|
|
1275
|
+
}
|
|
1276
|
+
getCoordCount(e) {
|
|
1277
|
+
const t = this._items.get(e);
|
|
1278
|
+
return !t || !t.options.points ? 0 : t.options.points.length;
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* 在经纬度平面上找离 `(lon, lat)` 最近的顶点下标(平方距离最小);
|
|
1282
|
+
* 无顶点时返回 `-1`。
|
|
1283
|
+
*/
|
|
1284
|
+
findNearestCoord(e, t, s) {
|
|
1285
|
+
const r = this._items.get(e);
|
|
1286
|
+
if (!r || !r.options.points || r.options.points.length === 0) return -1;
|
|
1287
|
+
let a = 0, n = 1 / 0;
|
|
1288
|
+
for (let o = 0; o < r.options.points.length; o++) {
|
|
1289
|
+
const h = r.options.points[o][0] - t, u = r.options.points[o][1] - s, d = h * h + u * u;
|
|
1290
|
+
d < n && (n = d, a = o);
|
|
1291
|
+
}
|
|
1292
|
+
return a;
|
|
1293
|
+
}
|
|
1294
|
+
render = () => {
|
|
1295
|
+
this.ssp.render();
|
|
1296
|
+
};
|
|
1297
|
+
/**
|
|
1298
|
+
* 释放 overlay 内部 RTT / 纹理等资源。
|
|
1299
|
+
* `PlotImageSource` 的运行时实现含 `dispose`,类型声明可能未列出,故做断言。
|
|
1300
|
+
*/
|
|
1301
|
+
dispose() {
|
|
1302
|
+
this._overlay.imageSource.dispose();
|
|
1303
|
+
}
|
|
1304
|
+
/**
|
|
1305
|
+
* 标记需要在下一帧重绘瓦片标绘层;同一帧内多次调用只会调度一次。
|
|
1306
|
+
* 首次有图形且尚未挂载时,先将 PlotOverlay 注册到 ImageOverlayPlugin(此时 shapes 已有数据,
|
|
1307
|
+
* `init()` → `hasContent` 能正确返回 true)。
|
|
1308
|
+
*/
|
|
1309
|
+
_markDirty() {
|
|
1310
|
+
this._redrawTimer || (this._redrawTimer = requestAnimationFrame(() => {
|
|
1311
|
+
this._redrawTimer = null, !this._overlayAttached && this._items.size > 0 && this._imageOverlayPlugin ? (this._imageOverlayPlugin.addOverlay(this._overlay), this._overlayAttached = !0) : this._overlay.redraw(), this.render();
|
|
1312
|
+
}));
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
const st = "https://sooncps.xwbuilders.com/api/ugis-dataprocess/v1/terrain/NhBLlMx3/", rt = "https://c.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png";
|
|
1316
|
+
class yt {
|
|
768
1317
|
constructor(e, t = {}) {
|
|
769
1318
|
this.ssp = e, this.options = t;
|
|
770
|
-
const
|
|
771
|
-
if (this.resourceManager = new
|
|
772
|
-
const
|
|
1319
|
+
const s = t.baseUrl || st;
|
|
1320
|
+
if (this.resourceManager = new Fe(), this.terrainManager = new Ge(), t.imageryUrl !== !1) {
|
|
1321
|
+
const r = t.imageryUrl || rt;
|
|
773
1322
|
this.resourceManager.addOverlay({
|
|
774
1323
|
id: this.defaultImageryId,
|
|
775
|
-
type:
|
|
776
|
-
options: { id: this.defaultImageryId, url:
|
|
1324
|
+
type: l.XYZ,
|
|
1325
|
+
options: { id: this.defaultImageryId, url: r }
|
|
777
1326
|
});
|
|
778
1327
|
}
|
|
779
|
-
this._alphaClipMode = t.alphaClipMode ?? "alphaTest", this._currentTerrainConfig = {
|
|
1328
|
+
this.groundDecalManager = new tt({ ssp: this.ssp }), this._alphaClipMode = t.alphaClipMode ?? "alphaTest", this._currentTerrainConfig = {
|
|
780
1329
|
id: this.defaultTerrainId,
|
|
781
|
-
type:
|
|
782
|
-
url:
|
|
783
|
-
}, this.terrainManager.add(this._currentTerrainConfig), this.terrainManager.setCurrentId(this._currentTerrainConfig.id), this.tiles = this._initTilesRenderer(this._currentTerrainConfig), this._initPlugins(this.tiles, this._currentTerrainConfig);
|
|
1330
|
+
type: U.QUANTIZED_MESH,
|
|
1331
|
+
url: s
|
|
1332
|
+
}, this.terrainManager.add(this._currentTerrainConfig), this.terrainManager.setCurrentId(this._currentTerrainConfig.id), this.tiles = this._initTilesRenderer(this._currentTerrainConfig), this._initPlugins(this.tiles, this._currentTerrainConfig), this.imageOverlayPlugin && this.groundDecalManager.setImageOverlayPlugin(this.imageOverlayPlugin);
|
|
784
1333
|
}
|
|
785
1334
|
defaultTerrainId = "__default_terrain__";
|
|
786
1335
|
defaultImageryId = "__default_imagery__";
|
|
@@ -796,6 +1345,8 @@ class le {
|
|
|
796
1345
|
terrainManager;
|
|
797
1346
|
/** Overlay 管理器(管理实例) */
|
|
798
1347
|
overlayManager;
|
|
1348
|
+
/** 标绘管理器(管理标绘实例) */
|
|
1349
|
+
groundDecalManager;
|
|
799
1350
|
/** 当前地形配置 */
|
|
800
1351
|
_currentTerrainConfig;
|
|
801
1352
|
/** Alpha 裁剪模式 */
|
|
@@ -808,7 +1359,7 @@ class le {
|
|
|
808
1359
|
* 是否使用 Cesium Ion 地形
|
|
809
1360
|
*/
|
|
810
1361
|
get isCesiumIon() {
|
|
811
|
-
return this._currentTerrainConfig.type ===
|
|
1362
|
+
return this._currentTerrainConfig.type === U.CESIUM_ION;
|
|
812
1363
|
}
|
|
813
1364
|
/**
|
|
814
1365
|
* 获取当前地形配置
|
|
@@ -854,9 +1405,9 @@ class le {
|
|
|
854
1405
|
this._alphaClipMode = e, this.customMaterialPlugin && (this.customMaterialPlugin.alphaClipMode = e), this._updateAlphaClipMode(), this.render();
|
|
855
1406
|
}
|
|
856
1407
|
_initTilesRenderer(e) {
|
|
857
|
-
return e.type ===
|
|
1408
|
+
return e.type === U.CESIUM_ION ? new R() : (
|
|
858
1409
|
// Cesium Ion 由插件设置 URL
|
|
859
|
-
new
|
|
1410
|
+
new R(e.url)
|
|
860
1411
|
);
|
|
861
1412
|
}
|
|
862
1413
|
/**
|
|
@@ -864,30 +1415,30 @@ class le {
|
|
|
864
1415
|
* @param config 地形配置
|
|
865
1416
|
*/
|
|
866
1417
|
_initPlugins(e, t) {
|
|
867
|
-
if (this.tilesFadePlugin = new
|
|
1418
|
+
if (this.tilesFadePlugin = new te({ maximumFadeOutTiles: 200 }), this.updateOnChangePlugin = new se(), e.registerPlugin(this.tilesFadePlugin), e.registerPlugin(this.updateOnChangePlugin), t.type === U.CESIUM_ION ? e.registerPlugin(new fe({
|
|
868
1419
|
apiToken: t.apiToken,
|
|
869
1420
|
assetId: t.assetId || "1",
|
|
870
1421
|
autoRefreshToken: t.autoRefreshToken ?? !0,
|
|
871
|
-
assetTypeHandler: (
|
|
872
|
-
|
|
1422
|
+
assetTypeHandler: (s, r) => {
|
|
1423
|
+
s === "TERRAIN" && r.getPluginByName("QUANTIZED_MESH_PLUGIN") === null && r.registerPlugin(new q({ useRecommendedSettings: !0 }));
|
|
873
1424
|
}
|
|
874
|
-
})) : (e.registerPlugin(new
|
|
875
|
-
const
|
|
876
|
-
if (/layer\.json$/.test(
|
|
877
|
-
const
|
|
878
|
-
return
|
|
1425
|
+
})) : (e.registerPlugin(new q({ useRecommendedSettings: !0 })), e.fetchData = async (s) => {
|
|
1426
|
+
const r = { method: "GET", mode: "cors" };
|
|
1427
|
+
if (/layer\.json$/.test(s)) {
|
|
1428
|
+
const a = await fetch(s, r).then((n) => n.json());
|
|
1429
|
+
return a.metadataAvailability = -1, new Response(JSON.stringify(a));
|
|
879
1430
|
}
|
|
880
|
-
return fetch(
|
|
881
|
-
}), this.options.useCustomMaterial !== !1 && (this.customMaterialPlugin = new
|
|
1431
|
+
return fetch(s, r);
|
|
1432
|
+
}), this.options.useCustomMaterial !== !1 && (this.customMaterialPlugin = new Ne(), this.customMaterialPlugin.alphaClipMode = this._alphaClipMode, e.registerPlugin(this.customMaterialPlugin)), this.imageOverlayPlugin = new me({
|
|
882
1433
|
renderer: this.ssp.viewport.renderer,
|
|
883
1434
|
overlays: []
|
|
884
|
-
}), e.registerPlugin(this.imageOverlayPlugin), this.overlayManager = new
|
|
885
|
-
const
|
|
886
|
-
this.reorientationPlugin = new
|
|
887
|
-
lon:
|
|
888
|
-
lat:
|
|
889
|
-
height:
|
|
890
|
-
}), e.registerPlugin(this.reorientationPlugin), this.invalidate(
|
|
1435
|
+
}), e.registerPlugin(this.imageOverlayPlugin), this.overlayManager = new Ae(this.imageOverlayPlugin, this.resourceManager), this.overlayManager.restoreFromResourceManager(), this.options.reorientation !== !1) {
|
|
1436
|
+
const s = this.options.reorientation || { lon: 120, lat: 30 };
|
|
1437
|
+
this.reorientationPlugin = new re({
|
|
1438
|
+
lon: s.lon,
|
|
1439
|
+
lat: s.lat,
|
|
1440
|
+
height: s.height ?? 0.1
|
|
1441
|
+
}), e.registerPlugin(this.reorientationPlugin), this.invalidate(s.lon, s.lat, s.height ?? 0.1);
|
|
891
1442
|
}
|
|
892
1443
|
e.maxDepth = this.options.maxDepth ?? 20, e.errorTarget = this.options.errorTarget ?? 1, e.addEventListener("needs-render", this.render), e.addEventListener("needs-update", this.render);
|
|
893
1444
|
}
|
|
@@ -924,7 +1475,7 @@ class le {
|
|
|
924
1475
|
* })
|
|
925
1476
|
*/
|
|
926
1477
|
setTerrain(e, t = void 0) {
|
|
927
|
-
e.id !== this._currentTerrainConfig.id && (t && (this.options = { ...this.options, ...t }), this.terrainManager.has(e.id) || this.terrainManager.add(e), this.terrainManager.setCurrentId(e.id), this._disposeTilesRenderer(), this._currentTerrainConfig = e, this.tiles = this._initTilesRenderer(e), this._initPlugins(this.tiles, e), this._enabled && this.ssp.addObject(this.tiles.group), this.render());
|
|
1478
|
+
e.id !== this._currentTerrainConfig.id && (t && (this.options = { ...this.options, ...t }), this.terrainManager.has(e.id) || this.terrainManager.add(e), this.terrainManager.setCurrentId(e.id), this._disposeTilesRenderer(), this._currentTerrainConfig = e, this.tiles = this._initTilesRenderer(e), this._initPlugins(this.tiles, e), this.imageOverlayPlugin && this.groundDecalManager && this.groundDecalManager.setImageOverlayPlugin(this.imageOverlayPlugin), this._enabled && this.ssp.addObject(this.tiles.group), this.render());
|
|
928
1479
|
}
|
|
929
1480
|
// =============== Overlay 快捷方法 ===============
|
|
930
1481
|
/**
|
|
@@ -1005,8 +1556,8 @@ class le {
|
|
|
1005
1556
|
* 更新 GeoJSON 颜色
|
|
1006
1557
|
*/
|
|
1007
1558
|
updateGeoJSONColor(e, t) {
|
|
1008
|
-
const
|
|
1009
|
-
return
|
|
1559
|
+
const s = this.overlayManager.updateGeoJSONColor(e, t);
|
|
1560
|
+
return s && this.render(), s;
|
|
1010
1561
|
}
|
|
1011
1562
|
/**
|
|
1012
1563
|
* 更新 GeoJSON 模式
|
|
@@ -1015,29 +1566,29 @@ class le {
|
|
|
1015
1566
|
* - invertMask: 只显示 GeoJSON 区域外的地形
|
|
1016
1567
|
*/
|
|
1017
1568
|
updateGeoJSONMode(e, t) {
|
|
1018
|
-
const
|
|
1019
|
-
return
|
|
1569
|
+
const s = this.overlayManager.updateGeoJSONMode(e, t);
|
|
1570
|
+
return s && this.render(), s;
|
|
1020
1571
|
}
|
|
1021
1572
|
/**
|
|
1022
1573
|
* 更新 GeoJSON 描边样式
|
|
1023
1574
|
*/
|
|
1024
1575
|
updateGeoJSONStrokeStyle(e, t) {
|
|
1025
|
-
const
|
|
1026
|
-
return
|
|
1576
|
+
const s = this.overlayManager.updateGeoJSONStrokeStyle(e, t);
|
|
1577
|
+
return s && this.render(), s;
|
|
1027
1578
|
}
|
|
1028
1579
|
/**
|
|
1029
1580
|
* 更新 GeoJSON 描边宽度
|
|
1030
1581
|
*/
|
|
1031
1582
|
updateGeoJSONStrokeWidth(e, t) {
|
|
1032
|
-
const
|
|
1033
|
-
return
|
|
1583
|
+
const s = this.overlayManager.updateGeoJSONStrokeWidth(e, t);
|
|
1584
|
+
return s && this.render(), s;
|
|
1034
1585
|
}
|
|
1035
1586
|
/**
|
|
1036
1587
|
* 更新 GeoJSON 填充样式
|
|
1037
1588
|
*/
|
|
1038
1589
|
updateGeoJSONFillStyle(e, t) {
|
|
1039
|
-
const
|
|
1040
|
-
return
|
|
1590
|
+
const s = this.overlayManager.updateGeoJSONFillStyle(e, t);
|
|
1591
|
+
return s && this.render(), s;
|
|
1041
1592
|
}
|
|
1042
1593
|
// =============== Overlay 层级控制 ===============
|
|
1043
1594
|
/**
|
|
@@ -1073,15 +1624,15 @@ class le {
|
|
|
1073
1624
|
* 设置 overlay 可见性
|
|
1074
1625
|
*/
|
|
1075
1626
|
setOverlayVisible(e, t) {
|
|
1076
|
-
const
|
|
1077
|
-
return
|
|
1627
|
+
const s = this.overlayManager.setVisible(e, t);
|
|
1628
|
+
return s && this.render(), s;
|
|
1078
1629
|
}
|
|
1079
1630
|
/**
|
|
1080
1631
|
* 设置 overlay 透明度
|
|
1081
1632
|
*/
|
|
1082
1633
|
setOverlayOpacity(e, t) {
|
|
1083
|
-
const
|
|
1084
|
-
return
|
|
1634
|
+
const s = this.overlayManager.setOpacity(e, t);
|
|
1635
|
+
return s && this.render(), s;
|
|
1085
1636
|
}
|
|
1086
1637
|
// =============== 生命周期 ===============
|
|
1087
1638
|
render = () => {
|
|
@@ -1099,27 +1650,27 @@ class le {
|
|
|
1099
1650
|
disable() {
|
|
1100
1651
|
this._enabled = !1, this.ssp.removeObject(this.tiles.group), this.ssp.signals.beforeRender.remove(this.beforeRenderHandler);
|
|
1101
1652
|
}
|
|
1102
|
-
invalidate(e, t,
|
|
1653
|
+
invalidate(e, t, s) {
|
|
1103
1654
|
if (!this.reorientationPlugin)
|
|
1104
1655
|
return console.warn("TilesRenderer: reorientationPlugin is not enabled, invalidate() will not work."), () => {
|
|
1105
1656
|
};
|
|
1106
|
-
const
|
|
1657
|
+
const r = this.reorientationPlugin;
|
|
1107
1658
|
this.options.reorientation = {
|
|
1108
1659
|
lon: e,
|
|
1109
1660
|
lat: t,
|
|
1110
|
-
height:
|
|
1661
|
+
height: s
|
|
1111
1662
|
};
|
|
1112
|
-
const
|
|
1113
|
-
const o =
|
|
1114
|
-
|
|
1663
|
+
const a = () => {
|
|
1664
|
+
const o = C.degToRad(t), h = C.degToRad(e);
|
|
1665
|
+
r.transformLatLonHeightToOrigin(
|
|
1115
1666
|
o,
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
), this.render(),
|
|
1119
|
-
},
|
|
1120
|
-
this.tiles.removeEventListener("load-root-tileset",
|
|
1667
|
+
h,
|
|
1668
|
+
s
|
|
1669
|
+
), this.render(), n();
|
|
1670
|
+
}, n = () => {
|
|
1671
|
+
this.tiles.removeEventListener("load-root-tileset", a), this.loedTilesSets.delete(a);
|
|
1121
1672
|
};
|
|
1122
|
-
return this.tiles.addEventListener("load-root-tileset",
|
|
1673
|
+
return this.tiles.addEventListener("load-root-tileset", a), this.loedTilesSets.add(a), this.tiles.root && a(), n;
|
|
1123
1674
|
}
|
|
1124
1675
|
dispose() {
|
|
1125
1676
|
this.disable(), this.terrainManager.dispose(), this.overlayManager.dispose(), this.loedTilesSets.forEach(
|
|
@@ -1127,12 +1678,12 @@ class le {
|
|
|
1127
1678
|
), this.loedTilesSets.clear(), this.tiles.removeEventListener("needs-render", this.render), this.tiles.removeEventListener("needs-update", this.render), this.tiles.dispose();
|
|
1128
1679
|
}
|
|
1129
1680
|
}
|
|
1130
|
-
const
|
|
1681
|
+
const I = {
|
|
1131
1682
|
DEFAULT: 0,
|
|
1132
1683
|
GRADIENT: 1,
|
|
1133
1684
|
TOPOGRAPHIC_LINES: 2,
|
|
1134
1685
|
LIGHTING: 3
|
|
1135
|
-
},
|
|
1686
|
+
}, it = {
|
|
1136
1687
|
vertexShader: (
|
|
1137
1688
|
/* glsl */
|
|
1138
1689
|
`
|
|
@@ -1158,7 +1709,7 @@ const h = {
|
|
|
1158
1709
|
}
|
|
1159
1710
|
`
|
|
1160
1711
|
)
|
|
1161
|
-
},
|
|
1712
|
+
}, at = {
|
|
1162
1713
|
vertexShader: (
|
|
1163
1714
|
/* glsl */
|
|
1164
1715
|
`
|
|
@@ -1204,10 +1755,10 @@ const h = {
|
|
|
1204
1755
|
`
|
|
1205
1756
|
)
|
|
1206
1757
|
};
|
|
1207
|
-
let
|
|
1208
|
-
class
|
|
1758
|
+
let X = null, Y = null, $ = null;
|
|
1759
|
+
class nt {
|
|
1209
1760
|
constructor(e, t) {
|
|
1210
|
-
this.ssp = e, this.options = t, "url" in this.options ? this.tiles = new
|
|
1761
|
+
this.ssp = e, this.options = t, "url" in this.options ? this.tiles = new R(this.options.url) : (this.tiles = new R(), this._initCesiumIon(this.options)), this._initBasePlugins(this.options);
|
|
1211
1762
|
}
|
|
1212
1763
|
tiles;
|
|
1213
1764
|
tilesFadePlugin;
|
|
@@ -1215,10 +1766,10 @@ class q {
|
|
|
1215
1766
|
reorientationPlugin;
|
|
1216
1767
|
options;
|
|
1217
1768
|
// 用于模型居中
|
|
1218
|
-
_box = new
|
|
1219
|
-
_sphere = new
|
|
1769
|
+
_box = new Oe();
|
|
1770
|
+
_sphere = new Te();
|
|
1220
1771
|
// 当前材质类型
|
|
1221
|
-
_materialType =
|
|
1772
|
+
_materialType = I.DEFAULT;
|
|
1222
1773
|
// 按需渲染标志
|
|
1223
1774
|
_needsUpdate = !0;
|
|
1224
1775
|
_cameraTransitionStart = !1;
|
|
@@ -1228,7 +1779,7 @@ class q {
|
|
|
1228
1779
|
*/
|
|
1229
1780
|
_initCesiumIon(e) {
|
|
1230
1781
|
this.tiles.registerPlugin(
|
|
1231
|
-
new
|
|
1782
|
+
new fe({
|
|
1232
1783
|
apiToken: e.apiToken,
|
|
1233
1784
|
assetId: e.assetId,
|
|
1234
1785
|
autoRefreshToken: e.autoRefreshToken ?? !0
|
|
@@ -1239,9 +1790,9 @@ class q {
|
|
|
1239
1790
|
* 初始化基础插件
|
|
1240
1791
|
*/
|
|
1241
1792
|
_initBasePlugins(e) {
|
|
1242
|
-
if (e._managedByPlugin || (
|
|
1793
|
+
if (e._managedByPlugin || (X === null ? X = this.tiles.lruCache : this.tiles.lruCache = X, Y === null ? Y = this.tiles.parseQueue : this.tiles.parseQueue = Y, $ === 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 te({ maximumFadeOutTiles: 200 }), this.updateOnChangePlugin = new se(), 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) {
|
|
1243
1794
|
const t = this.options.reorientation || { lon: 120, lat: 30 };
|
|
1244
|
-
this.reorientationPlugin = new
|
|
1795
|
+
this.reorientationPlugin = new re({
|
|
1245
1796
|
lon: t.lon,
|
|
1246
1797
|
lat: t.lat,
|
|
1247
1798
|
height: t.height ?? 0.1
|
|
@@ -1257,10 +1808,10 @@ class q {
|
|
|
1257
1808
|
* 设置 GLTF Loader
|
|
1258
1809
|
*/
|
|
1259
1810
|
_setupGLTFLoader() {
|
|
1260
|
-
const e = new
|
|
1811
|
+
const e = new pe(this.tiles.manager), t = this.ssp.manager?.store?.modelManager;
|
|
1261
1812
|
if (t?.gltfLoader) {
|
|
1262
|
-
const { dracoLoader:
|
|
1263
|
-
|
|
1813
|
+
const { dracoLoader: s, ktx2Loader: r, meshoptDecoder: a } = t.gltfLoader;
|
|
1814
|
+
s && e.setDRACOLoader(s), r && e.setKTX2Loader(r), a && e.setMeshoptDecoder(a);
|
|
1264
1815
|
}
|
|
1265
1816
|
this.tiles.manager.addHandler(/\.gltf$/, e);
|
|
1266
1817
|
}
|
|
@@ -1301,29 +1852,29 @@ class q {
|
|
|
1301
1852
|
onLoadModel = ({ scene: e }) => {
|
|
1302
1853
|
e.traverse((t) => {
|
|
1303
1854
|
t.isMesh && (t.originalMaterial = t.material);
|
|
1304
|
-
}), this._materialType !==
|
|
1855
|
+
}), this._materialType !== I.DEFAULT && this.updateMaterial(e);
|
|
1305
1856
|
};
|
|
1306
1857
|
/**
|
|
1307
1858
|
* 更新场景中所有网格的材质(参考 customMaterial.js)
|
|
1308
1859
|
*/
|
|
1309
1860
|
updateMaterial = (e) => {
|
|
1310
1861
|
const t = this._materialType;
|
|
1311
|
-
e.traverse((
|
|
1312
|
-
if (
|
|
1313
|
-
switch (
|
|
1314
|
-
case
|
|
1315
|
-
|
|
1862
|
+
e.traverse((s) => {
|
|
1863
|
+
if (s.isMesh)
|
|
1864
|
+
switch (s.material && s.material !== s.originalMaterial && s.material.dispose(), t) {
|
|
1865
|
+
case I.DEFAULT:
|
|
1866
|
+
s.material = s.originalMaterial, s.material && (s.material.side = 2), s.receiveShadow = !1, s.castShadow = !1;
|
|
1316
1867
|
break;
|
|
1317
|
-
case
|
|
1318
|
-
|
|
1868
|
+
case I.GRADIENT:
|
|
1869
|
+
s.material = new ue(it), s.material.side = 2, s.receiveShadow = !1, s.castShadow = !1;
|
|
1319
1870
|
break;
|
|
1320
|
-
case
|
|
1321
|
-
const
|
|
1322
|
-
|
|
1871
|
+
case I.TOPOGRAPHIC_LINES: {
|
|
1872
|
+
const r = new ue(at);
|
|
1873
|
+
r.extensions = { derivatives: !0 }, r.side = 2, s.material = r, s.receiveShadow = !1, s.castShadow = !1;
|
|
1323
1874
|
break;
|
|
1324
1875
|
}
|
|
1325
|
-
case
|
|
1326
|
-
|
|
1876
|
+
case I.LIGHTING:
|
|
1877
|
+
s.material = new we(), s.material.side = 2, s.receiveShadow = !0, s.castShadow = !0;
|
|
1327
1878
|
break;
|
|
1328
1879
|
}
|
|
1329
1880
|
});
|
|
@@ -1357,25 +1908,25 @@ class q {
|
|
|
1357
1908
|
disable() {
|
|
1358
1909
|
this.ssp.removeObject(this.tiles.group), this.ssp.signals.beforeRender.remove(this.beforeRenderHandler);
|
|
1359
1910
|
}
|
|
1360
|
-
invalidate(e, t,
|
|
1911
|
+
invalidate(e, t, s) {
|
|
1361
1912
|
if (!this.reorientationPlugin)
|
|
1362
1913
|
return console.warn(
|
|
1363
1914
|
"TilesRenderer: reorientationPlugin is not enabled, invalidate() will not work."
|
|
1364
1915
|
), () => {
|
|
1365
1916
|
};
|
|
1366
|
-
const
|
|
1917
|
+
const r = this.reorientationPlugin;
|
|
1367
1918
|
this.options.reorientation = {
|
|
1368
1919
|
lon: e,
|
|
1369
1920
|
lat: t,
|
|
1370
|
-
height:
|
|
1921
|
+
height: s
|
|
1371
1922
|
};
|
|
1372
|
-
const
|
|
1373
|
-
const o =
|
|
1374
|
-
|
|
1375
|
-
},
|
|
1376
|
-
this.tiles.removeEventListener("load-root-tileset",
|
|
1923
|
+
const a = () => {
|
|
1924
|
+
const o = C.degToRad(t), h = C.degToRad(e);
|
|
1925
|
+
r.transformLatLonHeightToOrigin(o, h, s), this.render(), n();
|
|
1926
|
+
}, n = () => {
|
|
1927
|
+
this.tiles.removeEventListener("load-root-tileset", a), this.loedTilesSets.delete(a);
|
|
1377
1928
|
};
|
|
1378
|
-
return this.tiles.addEventListener("load-root-tileset",
|
|
1929
|
+
return this.tiles.addEventListener("load-root-tileset", a), this.loedTilesSets.add(a), this.tiles.root && a(), n;
|
|
1379
1930
|
}
|
|
1380
1931
|
dispose() {
|
|
1381
1932
|
this.disable(), this.loedTilesSets.forEach(
|
|
@@ -1383,14 +1934,14 @@ class q {
|
|
|
1383
1934
|
), this.loedTilesSets.clear(), this.tiles.removeEventListener("load-model", this.onLoadModel), this.tiles.removeEventListener("dispose-model", this.onDisposeModel), this.options._managedByPlugin || (this.tiles.removeEventListener("load-model", this._onNeedsRender), this.tiles.removeEventListener("needs-render", this._onNeedsRender), this.tiles.removeEventListener("needs-update", this._onNeedsRender)), this.tiles.dispose();
|
|
1384
1935
|
}
|
|
1385
1936
|
}
|
|
1386
|
-
class
|
|
1937
|
+
class ft {
|
|
1387
1938
|
constructor(e) {
|
|
1388
1939
|
this.ssp = e;
|
|
1389
|
-
const { controls: t, viewport:
|
|
1390
|
-
this._tilesCamera =
|
|
1391
|
-
this.cameraTransitionStart = !0,
|
|
1940
|
+
const { controls: t, viewport: s } = e;
|
|
1941
|
+
this._tilesCamera = s.camera, t.addEventListener("transitionstart", () => {
|
|
1942
|
+
this.cameraTransitionStart = !0, s.state.useFreq = 1;
|
|
1392
1943
|
}), t.addEventListener("rest", () => {
|
|
1393
|
-
this.cameraTransitionStart = !1, this.needsUpdate = !0,
|
|
1944
|
+
this.cameraTransitionStart = !1, this.needsUpdate = !0, s.state.useFreq = 60;
|
|
1394
1945
|
}), e.signals.beforeRender.add(this._beforeRenderHandler), e.signals.cameraObjectChange.add(this._onCameraObjectChange);
|
|
1395
1946
|
}
|
|
1396
1947
|
/** 存储多个 tiles 实例,key 为 url */
|
|
@@ -1421,18 +1972,18 @@ class oe {
|
|
|
1421
1972
|
async loadTiles(e) {
|
|
1422
1973
|
const t = "url" in e ? e.url : e.assetId;
|
|
1423
1974
|
if (this.tilesMap.has(t))
|
|
1424
|
-
return
|
|
1425
|
-
const { ssp:
|
|
1975
|
+
return ee.utils.warn(`${t} already loaded`), this.tilesMap.get(t);
|
|
1976
|
+
const { ssp: s } = this, r = new nt(s, {
|
|
1426
1977
|
...e,
|
|
1427
1978
|
_managedByPlugin: !0
|
|
1428
|
-
}), { tiles:
|
|
1429
|
-
this._lruCache === null ? this._lruCache =
|
|
1430
|
-
const
|
|
1431
|
-
this.cameraTransitionStart || (this.needsUpdate = !0,
|
|
1979
|
+
}), { tiles: a } = r;
|
|
1980
|
+
this._lruCache === null ? this._lruCache = a.lruCache : a.lruCache = this._lruCache, this._parseQueue === null ? this._parseQueue = a.parseQueue : a.parseQueue = this._parseQueue, this._downloadQueue === null ? this._downloadQueue = a.downloadQueue : a.downloadQueue = this._downloadQueue, a.lruCache.maxSize = 600, a.lruCache.minSize = 300, a.lruCache.unloadPercent = 0.8, this.tilesMap.set(t, r), a.setCamera(this._tilesCamera), a.setResolutionFromRenderer(this._tilesCamera, s.viewport.renderer), s.addObject(a.group);
|
|
1981
|
+
const n = () => {
|
|
1982
|
+
this.cameraTransitionStart || (this.needsUpdate = !0, s.render());
|
|
1432
1983
|
};
|
|
1433
|
-
return
|
|
1434
|
-
|
|
1435
|
-
|
|
1984
|
+
return a.addEventListener("load-model", n), new Promise((o) => {
|
|
1985
|
+
a.addEventListener("load-tile-set", () => {
|
|
1986
|
+
n(), o(r);
|
|
1436
1987
|
});
|
|
1437
1988
|
});
|
|
1438
1989
|
}
|
|
@@ -1465,9 +2016,9 @@ class oe {
|
|
|
1465
2016
|
e.tiles.dispose(), this.ssp.removeObject(e.tiles.group);
|
|
1466
2017
|
}), this.tilesMap.clear();
|
|
1467
2018
|
}
|
|
1468
|
-
invalidate(e, t,
|
|
1469
|
-
this.tilesMap.forEach((
|
|
1470
|
-
|
|
2019
|
+
invalidate(e, t, s) {
|
|
2020
|
+
this.tilesMap.forEach((r) => {
|
|
2021
|
+
r.invalidate(e, t, s);
|
|
1471
2022
|
});
|
|
1472
2023
|
}
|
|
1473
2024
|
/**
|
|
@@ -1478,14 +2029,24 @@ class oe {
|
|
|
1478
2029
|
}
|
|
1479
2030
|
}
|
|
1480
2031
|
export {
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
2032
|
+
mt as ArcgisTilesRenderer,
|
|
2033
|
+
Ve as GisPlotArrow,
|
|
2034
|
+
S as GisPlotBase,
|
|
2035
|
+
et as GisPlotCircle,
|
|
2036
|
+
Qe as GisPlotLine,
|
|
2037
|
+
We as GisPlotPoint,
|
|
2038
|
+
je as GisPlotPolygon,
|
|
2039
|
+
He as GisPlotRectangle,
|
|
2040
|
+
Be as GisPlotSector,
|
|
2041
|
+
Ke as GisPlotText,
|
|
2042
|
+
tt as GroundDecalManager,
|
|
2043
|
+
I as MaterialType,
|
|
2044
|
+
Ae as OverlayManager,
|
|
2045
|
+
l as OverlayType,
|
|
2046
|
+
yt as TerrainTilesRenderer,
|
|
2047
|
+
U as TerrainType,
|
|
2048
|
+
Ne as TileCustomMaterialPlugin,
|
|
2049
|
+
nt as TilesRenderer,
|
|
2050
|
+
ft as TilesRendererManager,
|
|
2051
|
+
gt as default
|
|
1491
2052
|
};
|