@soonspacejs/plugin-tiles 2.15.1 → 2.15.4
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 +681 -549
- package/dist/plot/GroundDecalManager.d.ts +1 -1
- package/dist/plot/plugins/types.d.ts +20 -3
- package/dist/terrain-tiles-renderer/OverlayManager.d.ts +9 -7
- package/dist/terrain-tiles-renderer/TerrainTilesRenderer.d.ts +20 -53
- package/dist/terrain-tiles-renderer/types.d.ts +2 -0
- package/dist/tiles-renderer/TilesRendererManager.d.ts +38 -2
- package/package.json +4 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import
|
|
1
|
+
import z from "soonspacejs";
|
|
2
2
|
import { TilesRenderer as x } from "um-3d-tiles-renderer";
|
|
3
|
-
import { GLTFLoader as
|
|
4
|
-
import { MathUtils as
|
|
5
|
-
import { TilesFadePlugin as
|
|
6
|
-
class
|
|
3
|
+
import { GLTFLoader as fe } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
4
|
+
import { MathUtils as T, MeshBasicMaterial as ye, Color as Z, Vector3 as Pe, Box3 as Se, Sphere as ve, MeshStandardMaterial as Ce, ShaderMaterial as ge, Matrix4 as W } from "three";
|
|
5
|
+
import { TilesFadePlugin as ie, UpdateOnChangePlugin as ae, QuantizedMeshPlugin as ee, ImageOverlayPlugin as _e, XYZTilesOverlay as Me, ReorientationPlugin as ne, GeoJSONOverlay as Re, CesiumIonOverlay as be, TMSTilesOverlay as Ie, UrlTemplateTilesOverlay as Ee, WMSTilesOverlay as Le, WMTSCapabilitiesLoader as xe, WMTSTilesOverlay as ke, CesiumIonAuthPlugin as Oe, PlotSdfPlugin as Fe } from "um-3d-tiles-renderer/plugins";
|
|
6
|
+
class Ae {
|
|
7
7
|
constructor(e) {
|
|
8
8
|
this.parser = e, this.name = "KHR_texture_basisu_patch";
|
|
9
9
|
}
|
|
10
10
|
loadTexture(e) {
|
|
11
|
-
const t = this.parser,
|
|
11
|
+
const t = this.parser, r = t.json, a = r.textures[e].source, n = r.images[a];
|
|
12
12
|
if (!n || n.mimeType !== "image/ktx2")
|
|
13
13
|
return null;
|
|
14
14
|
const o = t.options.ktx2Loader;
|
|
15
15
|
if (!o)
|
|
16
|
-
throw new Error(`${
|
|
16
|
+
throw new Error(`${z.utils.consoleSspTitle}请使用 setModelKtx2DecoderPath 设置 ktx2 解压库路径`);
|
|
17
17
|
return t.loadTextureImage(e, a, o);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
class
|
|
20
|
+
class _t {
|
|
21
21
|
constructor(e) {
|
|
22
22
|
this.ssp = e;
|
|
23
|
-
const { controls: t, viewport:
|
|
24
|
-
this._tilesCamera =
|
|
25
|
-
this.cameraTransitionStart = !0,
|
|
23
|
+
const { controls: t, viewport: r } = e;
|
|
24
|
+
this._tilesCamera = r.camera, t.addEventListener("transitionstart", () => {
|
|
25
|
+
this.cameraTransitionStart = !0, r.state.useFreq = 1;
|
|
26
26
|
}), t.addEventListener("rest", () => {
|
|
27
|
-
this.cameraTransitionStart = !1, this.needsUpdate = !0,
|
|
27
|
+
this.cameraTransitionStart = !1, this.needsUpdate = !0, r.state.useFreq = 60;
|
|
28
28
|
}), e.signals.beforeRender.add(() => {
|
|
29
|
-
this.needsUpdate && (this.needsUpdate = !1, e.viewport.camera.updateMatrixWorld(), this.tilesMap.forEach((
|
|
30
|
-
|
|
29
|
+
this.needsUpdate && (this.needsUpdate = !1, e.viewport.camera.updateMatrixWorld(), this.tilesMap.forEach((s) => {
|
|
30
|
+
s.group.updateMatrixWorld(), s.update();
|
|
31
31
|
}));
|
|
32
32
|
}), e.signals.cameraObjectChange.add(() => {
|
|
33
|
-
this.tilesMap.forEach((
|
|
34
|
-
|
|
33
|
+
this.tilesMap.forEach((s) => {
|
|
34
|
+
s.deleteCamera(this._tilesCamera), s.setCamera(e.viewport.camera), s.setResolutionFromRenderer(e.viewport.camera, e.viewport.renderer);
|
|
35
35
|
}), this._tilesCamera = e.viewport.camera;
|
|
36
36
|
});
|
|
37
37
|
}
|
|
@@ -44,21 +44,21 @@ class ct {
|
|
|
44
44
|
downloadQueue = null;
|
|
45
45
|
async loadTiles(e) {
|
|
46
46
|
if (this.tilesMap.has(e)) {
|
|
47
|
-
|
|
47
|
+
z.utils.warn(`${e} already loaded`);
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
const { ssp: t, ssp: { viewport:
|
|
51
|
-
this.lruCache === null ? this.lruCache =
|
|
52
|
-
const a = new
|
|
53
|
-
a.register((
|
|
54
|
-
const { dracoLoader: n, ktx2Loader: o, meshoptDecoder:
|
|
55
|
-
n && a.setDRACOLoader(n), o && a.setKTX2Loader(o),
|
|
50
|
+
const { ssp: t, ssp: { viewport: r } } = this, s = new x(e);
|
|
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 fe(s.manager);
|
|
53
|
+
a.register((d) => new Ae(d));
|
|
54
|
+
const { dracoLoader: n, ktx2Loader: o, meshoptDecoder: l } = t.manager.store.modelManager.gltfLoader;
|
|
55
|
+
n && a.setDRACOLoader(n), o && a.setKTX2Loader(o), l && a.setMeshoptDecoder(l), 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
|
|
60
|
-
|
|
61
|
-
u(),
|
|
59
|
+
return s.addEventListener("load-model", u), new Promise((d) => {
|
|
60
|
+
s.addEventListener("load-tile-set", () => {
|
|
61
|
+
u(), d(s);
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
64
|
}
|
|
@@ -67,31 +67,31 @@ class ct {
|
|
|
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 De = 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 ye());
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
|
-
const
|
|
79
|
-
class
|
|
78
|
+
const Ne = "https://sooncps.xwbuilders.com/api/ugis-dataprocess/v1/terrain/NhBLlMx3/";
|
|
79
|
+
class Ot {
|
|
80
80
|
constructor(e) {
|
|
81
|
-
this.ssp = e, this.tiles = new x(
|
|
81
|
+
this.ssp = e, this.tiles = new x(Ne), this.tiles.fetchData = async (t, r) => {
|
|
82
82
|
if (/layer\.json$/.test(t)) {
|
|
83
|
-
const
|
|
84
|
-
return
|
|
83
|
+
const s = await fetch(t, r).then((a) => a.json());
|
|
84
|
+
return s.metadataAvailability = -1, new Response(JSON.stringify(s));
|
|
85
85
|
}
|
|
86
|
-
return fetch(t,
|
|
87
|
-
}, this.tilesFadePlugin = new
|
|
86
|
+
return fetch(t, r);
|
|
87
|
+
}, this.tilesFadePlugin = new ie({ maximumFadeOutTiles: 200 }), this.updateOnChangePlugin = new ae(), this.quantizedPlugin = new ee({}), this.customMaterialPlugin = new De(), this.imageOverlayPlugin = new _e({
|
|
88
88
|
renderer: e.viewport.renderer,
|
|
89
89
|
overlays: [
|
|
90
|
-
new
|
|
90
|
+
new Me({
|
|
91
91
|
url: "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
|
|
92
92
|
})
|
|
93
93
|
]
|
|
94
|
-
}), this.reorientationPlugin = new
|
|
94
|
+
}), this.reorientationPlugin = new ne({
|
|
95
95
|
lon: 120,
|
|
96
96
|
lat: 30,
|
|
97
97
|
height: 0.1
|
|
@@ -120,18 +120,18 @@ class pt {
|
|
|
120
120
|
disable() {
|
|
121
121
|
this.ssp.removeObject(this.tiles.group), this.ssp.signals.beforeRender.remove(this.beforeRenderHandler);
|
|
122
122
|
}
|
|
123
|
-
invalidate(e, t,
|
|
124
|
-
const
|
|
125
|
-
const n =
|
|
123
|
+
invalidate(e, t, r) {
|
|
124
|
+
const s = () => {
|
|
125
|
+
const n = T.degToRad(t), o = T.degToRad(e);
|
|
126
126
|
this.reorientationPlugin.transformLatLonHeightToOrigin(
|
|
127
127
|
n,
|
|
128
128
|
o,
|
|
129
|
-
|
|
129
|
+
r
|
|
130
130
|
), this.ssp.render(), a();
|
|
131
131
|
}, a = () => {
|
|
132
|
-
this.tiles.removeEventListener("load-root-tileset",
|
|
132
|
+
this.tiles.removeEventListener("load-root-tileset", s), this.loedTilesSets.delete(s);
|
|
133
133
|
};
|
|
134
|
-
return this.tiles.addEventListener("load-root-tileset",
|
|
134
|
+
return this.tiles.addEventListener("load-root-tileset", s), this.loedTilesSets.add(s), this.tiles.root && s(), a;
|
|
135
135
|
}
|
|
136
136
|
dispose() {
|
|
137
137
|
this.disable(), this.loedTilesSets.forEach(
|
|
@@ -139,7 +139,43 @@ class pt {
|
|
|
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
|
-
|
|
142
|
+
function Ge(i) {
|
|
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 {
|
|
143
179
|
// 使用较低的 priority 确保在 ImageOverlayPlugin 之后执行
|
|
144
180
|
// ImageOverlayPlugin 默认 priority 是 -1
|
|
145
181
|
priority = -999;
|
|
@@ -150,7 +186,7 @@ class Fe {
|
|
|
150
186
|
*/
|
|
151
187
|
processTileModel(e) {
|
|
152
188
|
e.traverse((t) => {
|
|
153
|
-
t.material && (t.material = new
|
|
189
|
+
t.material && (t.material = new ye());
|
|
154
190
|
});
|
|
155
191
|
}
|
|
156
192
|
/**
|
|
@@ -159,8 +195,8 @@ class Fe {
|
|
|
159
195
|
*/
|
|
160
196
|
updateAllLoadedModels(e) {
|
|
161
197
|
e.forEachLoadedModel((t) => {
|
|
162
|
-
t.traverse((
|
|
163
|
-
|
|
198
|
+
t.traverse((r) => {
|
|
199
|
+
r.material;
|
|
164
200
|
});
|
|
165
201
|
});
|
|
166
202
|
}
|
|
@@ -182,19 +218,19 @@ class Fe {
|
|
|
182
218
|
e.needsUpdate = !0;
|
|
183
219
|
}
|
|
184
220
|
}
|
|
185
|
-
var
|
|
186
|
-
class
|
|
221
|
+
var h = /* @__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))(h || {}), R = /* @__PURE__ */ ((i) => (i.QUANTIZED_MESH = "quantizedMesh", i.CESIUM_ION = "cesiumIon", i))(R || {});
|
|
222
|
+
class B {
|
|
187
223
|
constructor(e, t) {
|
|
188
224
|
this.imageOverlayPlugin = e, this.resourceManager = t;
|
|
189
225
|
}
|
|
190
226
|
/** 存储所有 overlay 实例 */
|
|
227
|
+
static MAX_OVERLAY_INSTANCES = 10;
|
|
191
228
|
_instances = /* @__PURE__ */ new Map();
|
|
192
229
|
// =============== GeoJSON ===============
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
const t = {
|
|
230
|
+
addGeoJSONOverlay(e) {
|
|
231
|
+
const t = this._getImageOverlayPluginForAdd(e.id);
|
|
232
|
+
if (!t) return null;
|
|
233
|
+
const r = {
|
|
198
234
|
url: e.url,
|
|
199
235
|
geojson: e.geojson,
|
|
200
236
|
opacity: e.opacity ?? 1,
|
|
@@ -202,109 +238,106 @@ class Ne {
|
|
|
202
238
|
strokeStyle: e.strokeStyle,
|
|
203
239
|
strokeWidth: e.strokeWidth
|
|
204
240
|
};
|
|
205
|
-
e.color && (
|
|
206
|
-
const s = new
|
|
207
|
-
return
|
|
241
|
+
e.color && (r.color = new Z(e.color));
|
|
242
|
+
const s = new Re(r);
|
|
243
|
+
return t.addOverlay(s, e.order), this._instances.set(e.id, {
|
|
208
244
|
id: e.id,
|
|
209
|
-
type:
|
|
245
|
+
type: e.type,
|
|
210
246
|
instance: s
|
|
211
247
|
}), this.resourceManager?.addOverlay({
|
|
212
248
|
id: e.id,
|
|
213
|
-
type:
|
|
249
|
+
type: e.type,
|
|
214
250
|
options: e
|
|
215
251
|
}), s;
|
|
216
252
|
}
|
|
217
253
|
updateGeoJSONColor(e, t) {
|
|
218
|
-
const
|
|
219
|
-
if (!
|
|
220
|
-
const
|
|
221
|
-
return
|
|
254
|
+
const r = this._instances.get(e);
|
|
255
|
+
if (!r || r.type !== h.GEOJSON) return !1;
|
|
256
|
+
const s = r.instance;
|
|
257
|
+
return s.color.set(t), s.redraw(), this.resourceManager?.updateOverlay(e, { color: t }), !0;
|
|
222
258
|
}
|
|
223
259
|
updateGeoJSONStrokeStyle(e, t) {
|
|
224
|
-
const
|
|
225
|
-
if (!
|
|
226
|
-
const
|
|
227
|
-
return
|
|
260
|
+
const r = this._instances.get(e);
|
|
261
|
+
if (!r || r.type !== h.GEOJSON) return !1;
|
|
262
|
+
const s = r.instance;
|
|
263
|
+
return s.strokeStyle = t, s.redraw(), this.resourceManager?.updateOverlay(e, { strokeStyle: t }), !0;
|
|
228
264
|
}
|
|
229
265
|
updateGeoJSONStrokeWidth(e, t) {
|
|
230
|
-
const
|
|
231
|
-
if (!
|
|
232
|
-
const
|
|
233
|
-
return
|
|
266
|
+
const r = this._instances.get(e);
|
|
267
|
+
if (!r || r.type !== h.GEOJSON) return !1;
|
|
268
|
+
const s = r.instance;
|
|
269
|
+
return s.strokeWidth = t, s.redraw(), this.resourceManager?.updateOverlay(e, { strokeWidth: t }), !0;
|
|
234
270
|
}
|
|
235
271
|
updateGeoJSONFillStyle(e, t) {
|
|
236
|
-
const
|
|
237
|
-
if (!
|
|
238
|
-
const
|
|
239
|
-
return
|
|
272
|
+
const r = this._instances.get(e);
|
|
273
|
+
if (!r || r.type !== h.GEOJSON) return !1;
|
|
274
|
+
const s = r.instance;
|
|
275
|
+
return s.fillStyle = t, s.redraw(), this.resourceManager?.updateOverlay(e, { fillStyle: t }), !0;
|
|
240
276
|
}
|
|
241
277
|
updateGeoJSONMode(e, t) {
|
|
242
|
-
const
|
|
243
|
-
if (!
|
|
244
|
-
const
|
|
245
|
-
return
|
|
278
|
+
const r = this._instances.get(e);
|
|
279
|
+
if (!r || r.type !== h.GEOJSON) return !1;
|
|
280
|
+
const s = r.instance;
|
|
281
|
+
return s.alphaInvert = !1, s.alphaMask = !1, s.fillStyle = "rgba( 255, 255, 255, 0.5 )", t === "mask" ? (s.alphaMask = !0, s.fillStyle = "white") : t === "invertMask" && (s.alphaInvert = !0, s.alphaMask = !0, s.fillStyle = "white"), s.redraw(), !0;
|
|
246
282
|
}
|
|
247
283
|
// =============== Cesium Ion ===============
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if (
|
|
251
|
-
|
|
252
|
-
const t = new Pe({
|
|
284
|
+
addCesiumIonOverlay(e) {
|
|
285
|
+
const t = this._getImageOverlayPluginForAdd(e.id);
|
|
286
|
+
if (!t) return null;
|
|
287
|
+
const r = new be({
|
|
253
288
|
assetId: e.assetId,
|
|
254
289
|
apiToken: e.apiToken,
|
|
255
290
|
autoRefreshToken: e.autoRefreshToken ?? !0,
|
|
256
291
|
color: typeof e.color == "number" ? e.color : 16777215,
|
|
257
292
|
opacity: e.opacity ?? 1
|
|
258
293
|
});
|
|
259
|
-
return
|
|
294
|
+
return t.addOverlay(r, e.order), this._instances.set(e.id, {
|
|
260
295
|
id: e.id,
|
|
261
|
-
type:
|
|
262
|
-
instance:
|
|
296
|
+
type: e.type,
|
|
297
|
+
instance: r
|
|
263
298
|
}), this.resourceManager?.addOverlay({
|
|
264
299
|
id: e.id,
|
|
265
|
-
type:
|
|
300
|
+
type: e.type,
|
|
266
301
|
options: e
|
|
267
|
-
}),
|
|
302
|
+
}), r;
|
|
268
303
|
}
|
|
269
304
|
// =============== TMS ===============
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
if (
|
|
273
|
-
|
|
274
|
-
const t = new Ce({
|
|
305
|
+
addTMSOverlay(e) {
|
|
306
|
+
const t = this._getImageOverlayPluginForAdd(e.id);
|
|
307
|
+
if (!t) return null;
|
|
308
|
+
const r = new Ie({
|
|
275
309
|
url: e.url,
|
|
276
310
|
color: typeof e.color == "number" ? e.color : 16777215,
|
|
277
311
|
opacity: e.opacity ?? 1
|
|
278
312
|
});
|
|
279
|
-
return
|
|
313
|
+
return t.addOverlay(r, e.order), this._instances.set(e.id, {
|
|
280
314
|
id: e.id,
|
|
281
|
-
type:
|
|
282
|
-
instance:
|
|
315
|
+
type: e.type,
|
|
316
|
+
instance: r
|
|
283
317
|
}), this.resourceManager?.addOverlay({
|
|
284
318
|
id: e.id,
|
|
285
|
-
type:
|
|
319
|
+
type: e.type,
|
|
286
320
|
options: e
|
|
287
|
-
}),
|
|
321
|
+
}), r;
|
|
288
322
|
}
|
|
289
323
|
// =============== XYZ ===============
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (
|
|
293
|
-
|
|
294
|
-
const t = new fe({
|
|
324
|
+
addXYZOverlay(e) {
|
|
325
|
+
const t = this._getImageOverlayPluginForAdd(e.id);
|
|
326
|
+
if (!t) return null;
|
|
327
|
+
const r = new Me({
|
|
295
328
|
url: e.url,
|
|
296
329
|
color: typeof e.color == "number" ? e.color : 16777215,
|
|
297
330
|
opacity: e.opacity ?? 1
|
|
298
331
|
});
|
|
299
|
-
return
|
|
332
|
+
return t.addOverlay(r, e.order), this._instances.set(e.id, {
|
|
300
333
|
id: e.id,
|
|
301
|
-
type:
|
|
302
|
-
instance:
|
|
334
|
+
type: e.type,
|
|
335
|
+
instance: r
|
|
303
336
|
}), this.resourceManager?.addOverlay({
|
|
304
337
|
id: e.id,
|
|
305
|
-
type:
|
|
338
|
+
type: e.type,
|
|
306
339
|
options: e
|
|
307
|
-
}),
|
|
340
|
+
}), r;
|
|
308
341
|
}
|
|
309
342
|
// =============== URL Template ===============
|
|
310
343
|
/**
|
|
@@ -338,11 +371,10 @@ class Ne {
|
|
|
338
371
|
* url: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'
|
|
339
372
|
* })
|
|
340
373
|
*/
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
if (
|
|
344
|
-
|
|
345
|
-
const t = new Le({
|
|
374
|
+
addUrlTemplateOverlay(e) {
|
|
375
|
+
const t = this._getImageOverlayPluginForAdd(e.id);
|
|
376
|
+
if (!t) return null;
|
|
377
|
+
const r = new Ee({
|
|
346
378
|
url: e.url,
|
|
347
379
|
subdomains: e.subdomains,
|
|
348
380
|
levels: e.levels,
|
|
@@ -353,76 +385,74 @@ class Ne {
|
|
|
353
385
|
color: typeof e.color == "number" ? e.color : 16777215,
|
|
354
386
|
opacity: e.opacity ?? 1
|
|
355
387
|
});
|
|
356
|
-
return
|
|
388
|
+
return t.addOverlay(r, e.order), this._instances.set(e.id, {
|
|
357
389
|
id: e.id,
|
|
358
|
-
type:
|
|
359
|
-
instance:
|
|
390
|
+
type: e.type,
|
|
391
|
+
instance: r
|
|
360
392
|
}), this.resourceManager?.addOverlay({
|
|
361
393
|
id: e.id,
|
|
362
|
-
type:
|
|
394
|
+
type: e.type,
|
|
363
395
|
options: e
|
|
364
|
-
}),
|
|
396
|
+
}), r;
|
|
365
397
|
}
|
|
366
398
|
// =============== WMS ===============
|
|
367
|
-
async
|
|
368
|
-
|
|
369
|
-
if (
|
|
370
|
-
|
|
371
|
-
const t = {
|
|
399
|
+
async addWMSOverlay(e) {
|
|
400
|
+
const t = this._getImageOverlayPluginForAdd(e.id);
|
|
401
|
+
if (!t) return null;
|
|
402
|
+
const r = {
|
|
372
403
|
layer: e.layer || "",
|
|
373
404
|
styles: e.styles || "",
|
|
374
405
|
crs: e.crs || "EPSG:4326",
|
|
375
406
|
format: e.format || "image/png",
|
|
376
407
|
tileDimension: e.tileDimension || 256
|
|
377
|
-
}, s = new
|
|
408
|
+
}, s = new Le({
|
|
378
409
|
url: e.url,
|
|
379
|
-
layer:
|
|
380
|
-
crs:
|
|
381
|
-
format:
|
|
382
|
-
tileDimension:
|
|
383
|
-
styles:
|
|
384
|
-
color: new
|
|
410
|
+
layer: r.layer,
|
|
411
|
+
crs: r.crs,
|
|
412
|
+
format: r.format,
|
|
413
|
+
tileDimension: r.tileDimension,
|
|
414
|
+
styles: r.styles,
|
|
415
|
+
color: new Z(typeof e.color == "number" ? e.color : 16777215),
|
|
385
416
|
opacity: e.opacity ?? 1
|
|
386
417
|
});
|
|
387
|
-
return
|
|
418
|
+
return t.addOverlay(s, e.order), this._instances.set(e.id, {
|
|
388
419
|
id: e.id,
|
|
389
|
-
type:
|
|
420
|
+
type: e.type,
|
|
390
421
|
instance: s
|
|
391
422
|
}), this.resourceManager?.addOverlay({
|
|
392
423
|
id: e.id,
|
|
393
|
-
type:
|
|
424
|
+
type: e.type,
|
|
394
425
|
options: e
|
|
395
426
|
}), s;
|
|
396
427
|
}
|
|
397
428
|
// =============== WMTS ===============
|
|
398
|
-
async
|
|
399
|
-
|
|
400
|
-
if (
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
layer: r,
|
|
429
|
+
async addWMTSOverlay(e) {
|
|
430
|
+
const t = this._getImageOverlayPluginForAdd(e.id);
|
|
431
|
+
if (!t) return null;
|
|
432
|
+
const r = await new xe().loadAsync(e.url), s = ["EPSG:4326", "EPSG:3857"];
|
|
433
|
+
let a = e.layer || "";
|
|
434
|
+
r.layers.find((o) => o.identifier === a) || (a = r.layers.find(
|
|
435
|
+
(o) => o?.tileMatrixSets?.some((l) => s.includes(l.supportedCRS))
|
|
436
|
+
)?.identifier || r.layers[0].identifier);
|
|
437
|
+
const n = new ke({
|
|
438
|
+
capabilities: r,
|
|
439
|
+
layer: a,
|
|
410
440
|
dimensions: e.dimensions || null,
|
|
411
441
|
style: e.style || void 0,
|
|
412
442
|
tileMatrixSet: e.tileMatrixSet || null,
|
|
413
443
|
planar: !1,
|
|
414
|
-
color: new
|
|
444
|
+
color: new Z(typeof e.color == "number" ? e.color : 16777215),
|
|
415
445
|
opacity: e.opacity ?? 1
|
|
416
446
|
});
|
|
417
|
-
return
|
|
447
|
+
return t.addOverlay(n, e.order), this._instances.set(e.id, {
|
|
418
448
|
id: e.id,
|
|
419
|
-
type:
|
|
420
|
-
instance:
|
|
449
|
+
type: e.type,
|
|
450
|
+
instance: n
|
|
421
451
|
}), this.resourceManager?.addOverlay({
|
|
422
452
|
id: e.id,
|
|
423
|
-
type:
|
|
453
|
+
type: e.type,
|
|
424
454
|
options: e
|
|
425
|
-
}),
|
|
455
|
+
}), n;
|
|
426
456
|
}
|
|
427
457
|
// =============== 通用方法 ===============
|
|
428
458
|
/**
|
|
@@ -431,12 +461,12 @@ class Ne {
|
|
|
431
461
|
remove(e) {
|
|
432
462
|
const t = this._instances.get(e);
|
|
433
463
|
return t ? [
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
464
|
+
h.XYZ,
|
|
465
|
+
h.TMS,
|
|
466
|
+
h.WMS,
|
|
467
|
+
h.WMTS,
|
|
468
|
+
h.CESIUM_ION,
|
|
469
|
+
h.URL_TEMPLATE
|
|
440
470
|
].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
471
|
}
|
|
442
472
|
/**
|
|
@@ -455,23 +485,23 @@ class Ne {
|
|
|
455
485
|
* 设置 overlay 可见性
|
|
456
486
|
*/
|
|
457
487
|
setVisible(e, t) {
|
|
458
|
-
const
|
|
459
|
-
return
|
|
488
|
+
const r = this._instances.get(e);
|
|
489
|
+
return r && "opacity" in r.instance ? (r.instance.opacity = t ? 1 : 0, this.resourceManager?.updateOverlay(e, { opacity: t ? 1 : 0 }), !0) : !1;
|
|
460
490
|
}
|
|
461
491
|
/**
|
|
462
492
|
* 设置 overlay 透明度
|
|
463
493
|
*/
|
|
464
494
|
setOpacity(e, t) {
|
|
465
|
-
const
|
|
466
|
-
return
|
|
495
|
+
const r = this._instances.get(e);
|
|
496
|
+
return r && "opacity" in r.instance ? (r.instance.opacity = t, this.resourceManager?.updateOverlay(e, { opacity: t }), r.instance.redraw?.(), !0) : !1;
|
|
467
497
|
}
|
|
468
498
|
/**
|
|
469
499
|
* 设置 overlay 层级
|
|
470
500
|
*/
|
|
471
501
|
setOrder(e, t) {
|
|
472
502
|
if (!this.imageOverlayPlugin) return !1;
|
|
473
|
-
const
|
|
474
|
-
return
|
|
503
|
+
const r = this._instances.get(e);
|
|
504
|
+
return r ? (this.imageOverlayPlugin.setOverlayOrder(r.instance, t), this.resourceManager?.updateOverlay(e, { order: t }), !0) : !1;
|
|
475
505
|
}
|
|
476
506
|
/**
|
|
477
507
|
* 获取 overlay 层级
|
|
@@ -488,11 +518,11 @@ class Ne {
|
|
|
488
518
|
if (!this.imageOverlayPlugin) return !1;
|
|
489
519
|
const t = this._instances.get(e);
|
|
490
520
|
if (!t) return !1;
|
|
491
|
-
const
|
|
492
|
-
let
|
|
493
|
-
return
|
|
494
|
-
a.order >
|
|
495
|
-
}), this.imageOverlayPlugin.setOverlayOrder(t.instance,
|
|
521
|
+
const r = this.imageOverlayPlugin.overlayInfo;
|
|
522
|
+
let s = 0;
|
|
523
|
+
return r.forEach((a) => {
|
|
524
|
+
a.order > s && (s = a.order);
|
|
525
|
+
}), this.imageOverlayPlugin.setOverlayOrder(t.instance, s + 1), this.resourceManager?.updateOverlay(e, { order: s + 1 }), !0;
|
|
496
526
|
}
|
|
497
527
|
/**
|
|
498
528
|
* 将 overlay 移到最底层
|
|
@@ -501,11 +531,11 @@ class Ne {
|
|
|
501
531
|
if (!this.imageOverlayPlugin) return !1;
|
|
502
532
|
const t = this._instances.get(e);
|
|
503
533
|
if (!t) return !1;
|
|
504
|
-
const
|
|
505
|
-
let
|
|
506
|
-
return
|
|
507
|
-
a.order <
|
|
508
|
-
}), this.imageOverlayPlugin.setOverlayOrder(t.instance,
|
|
534
|
+
const r = this.imageOverlayPlugin.overlayInfo;
|
|
535
|
+
let s = 1 / 0;
|
|
536
|
+
return r.forEach((a) => {
|
|
537
|
+
a.order < s && (s = a.order);
|
|
538
|
+
}), this.imageOverlayPlugin.setOverlayOrder(t.instance, s - 1), this.resourceManager?.updateOverlay(e, { order: s - 1 }), !0;
|
|
509
539
|
}
|
|
510
540
|
// =============== 资源恢复 ===============
|
|
511
541
|
/**
|
|
@@ -523,26 +553,26 @@ class Ne {
|
|
|
523
553
|
_createOverlayFromResource(e) {
|
|
524
554
|
const t = this.resourceManager;
|
|
525
555
|
switch (this.resourceManager = void 0, e.type) {
|
|
526
|
-
case
|
|
527
|
-
this.
|
|
556
|
+
case h.GEOJSON:
|
|
557
|
+
this.addGeoJSONOverlay(e.options);
|
|
528
558
|
break;
|
|
529
|
-
case
|
|
530
|
-
this.
|
|
559
|
+
case h.CESIUM_ION:
|
|
560
|
+
this.addCesiumIonOverlay(e.options);
|
|
531
561
|
break;
|
|
532
|
-
case
|
|
533
|
-
this.
|
|
562
|
+
case h.TMS:
|
|
563
|
+
this.addTMSOverlay(e.options);
|
|
534
564
|
break;
|
|
535
|
-
case
|
|
536
|
-
this.
|
|
565
|
+
case h.XYZ:
|
|
566
|
+
this.addXYZOverlay(e.options);
|
|
537
567
|
break;
|
|
538
|
-
case
|
|
539
|
-
this.
|
|
568
|
+
case h.WMS:
|
|
569
|
+
this.addWMSOverlay(e.options);
|
|
540
570
|
break;
|
|
541
|
-
case
|
|
542
|
-
this.
|
|
571
|
+
case h.WMTS:
|
|
572
|
+
this.addWMTSOverlay(e.options);
|
|
543
573
|
break;
|
|
544
|
-
case
|
|
545
|
-
this.
|
|
574
|
+
case h.URL_TEMPLATE:
|
|
575
|
+
this.addUrlTemplateOverlay(e.options);
|
|
546
576
|
break;
|
|
547
577
|
}
|
|
548
578
|
this.resourceManager = t;
|
|
@@ -560,13 +590,16 @@ class Ne {
|
|
|
560
590
|
get count() {
|
|
561
591
|
return this._instances.size;
|
|
562
592
|
}
|
|
593
|
+
_getImageOverlayPluginForAdd(e) {
|
|
594
|
+
return this.imageOverlayPlugin ? this._instances.has(e) ? (console.warn(`OverlayManager: Overlay "${e}" already exists`), null) : this._instances.size >= B.MAX_OVERLAY_INSTANCES ? (console.error(`OverlayManager: Cannot add overlay "${e}" because the maximum number of overlays is ${B.MAX_OVERLAY_INSTANCES}`), null) : this.imageOverlayPlugin : null;
|
|
595
|
+
}
|
|
563
596
|
/**
|
|
564
597
|
* 获取本地影像数量(不依赖 ResourceManager)
|
|
565
598
|
*/
|
|
566
599
|
_getLocalImageryCount() {
|
|
567
600
|
let e = 0;
|
|
568
601
|
return this._instances.forEach((t) => {
|
|
569
|
-
[
|
|
602
|
+
[h.XYZ, h.TMS, h.WMS, h.WMTS, h.CESIUM_ION, h.URL_TEMPLATE].includes(t.type) && e++;
|
|
570
603
|
}), e;
|
|
571
604
|
}
|
|
572
605
|
/**
|
|
@@ -584,7 +617,7 @@ class Ne {
|
|
|
584
617
|
this.disposeInstances(), this.resourceManager?.clear();
|
|
585
618
|
}
|
|
586
619
|
}
|
|
587
|
-
class
|
|
620
|
+
class Be {
|
|
588
621
|
/** Overlay 资源配置 */
|
|
589
622
|
_overlays = /* @__PURE__ */ new Map();
|
|
590
623
|
// =============== Overlay 资源管理 ===============
|
|
@@ -642,15 +675,15 @@ class Ae {
|
|
|
642
675
|
getImageryOverlayCount() {
|
|
643
676
|
let e = 0;
|
|
644
677
|
return this._overlays.forEach((t) => {
|
|
645
|
-
(t.type ===
|
|
678
|
+
(t.type === h.XYZ || t.type === h.TMS || t.type === h.WMS || t.type === h.WMTS || t.type === h.CESIUM_ION || t.type === h.URL_TEMPLATE) && e++;
|
|
646
679
|
}), e;
|
|
647
680
|
}
|
|
648
681
|
/**
|
|
649
682
|
* 更新 Overlay 配置
|
|
650
683
|
*/
|
|
651
684
|
updateOverlay(e, t) {
|
|
652
|
-
const
|
|
653
|
-
return
|
|
685
|
+
const r = this._overlays.get(e);
|
|
686
|
+
return r ? (r.options = { ...r.options, ...t }, !0) : !1;
|
|
654
687
|
}
|
|
655
688
|
// =============== 工具方法 ===============
|
|
656
689
|
/**
|
|
@@ -674,7 +707,7 @@ class Ae {
|
|
|
674
707
|
e.overlays && (this._overlays.clear(), e.overlays.forEach((t) => this._overlays.set(t.id, { ...t })));
|
|
675
708
|
}
|
|
676
709
|
}
|
|
677
|
-
class
|
|
710
|
+
class He {
|
|
678
711
|
/** 地形配置映射表 */
|
|
679
712
|
_terrains = /* @__PURE__ */ new Map();
|
|
680
713
|
/** 当前激活的地形 ID */
|
|
@@ -763,13 +796,13 @@ class Ue {
|
|
|
763
796
|
this.clear();
|
|
764
797
|
}
|
|
765
798
|
}
|
|
766
|
-
let
|
|
767
|
-
class
|
|
799
|
+
let Je = 1;
|
|
800
|
+
class C {
|
|
768
801
|
id;
|
|
769
802
|
category = "";
|
|
770
803
|
options;
|
|
771
804
|
constructor(e) {
|
|
772
|
-
this.id = String(
|
|
805
|
+
this.id = String(Je++), this.category = "", this.options = { ...e }, this.options.points && (this.options.points = this.options.points.map((t) => [t[0], t[1]]));
|
|
773
806
|
}
|
|
774
807
|
/**
|
|
775
808
|
* 合并更新 `options`(不可变风格:整表替换为新对象)。
|
|
@@ -802,7 +835,7 @@ class P {
|
|
|
802
835
|
return this.options.points || [];
|
|
803
836
|
}
|
|
804
837
|
}
|
|
805
|
-
class
|
|
838
|
+
class Xe extends C {
|
|
806
839
|
category = "point";
|
|
807
840
|
constructor(e) {
|
|
808
841
|
super(e);
|
|
@@ -818,7 +851,7 @@ class We extends P {
|
|
|
818
851
|
return this.getCenterPoints();
|
|
819
852
|
}
|
|
820
853
|
}
|
|
821
|
-
class
|
|
854
|
+
class Ye extends C {
|
|
822
855
|
category = "line";
|
|
823
856
|
constructor(e) {
|
|
824
857
|
super(e);
|
|
@@ -827,7 +860,7 @@ class Qe extends P {
|
|
|
827
860
|
this.options = { ...this.options, ...e };
|
|
828
861
|
}
|
|
829
862
|
}
|
|
830
|
-
class
|
|
863
|
+
class Ze extends C {
|
|
831
864
|
category = "polygon";
|
|
832
865
|
constructor(e) {
|
|
833
866
|
super(e);
|
|
@@ -836,7 +869,7 @@ class He extends P {
|
|
|
836
869
|
this.options = { ...this.options, ...e };
|
|
837
870
|
}
|
|
838
871
|
}
|
|
839
|
-
class
|
|
872
|
+
class qe extends C {
|
|
840
873
|
category = "rectangle";
|
|
841
874
|
constructor(e) {
|
|
842
875
|
super(e);
|
|
@@ -845,9 +878,9 @@ class je extends P {
|
|
|
845
878
|
this.options = { ...this.options, ...e };
|
|
846
879
|
}
|
|
847
880
|
}
|
|
848
|
-
const
|
|
849
|
-
new
|
|
850
|
-
class
|
|
881
|
+
const Te = T.DEG2RAD;
|
|
882
|
+
new Pe();
|
|
883
|
+
class Ve extends C {
|
|
851
884
|
category = "sector";
|
|
852
885
|
constructor(e) {
|
|
853
886
|
super(e);
|
|
@@ -858,168 +891,168 @@ class Be extends P {
|
|
|
858
891
|
getExtentPoints() {
|
|
859
892
|
const e = this.options.points;
|
|
860
893
|
if (!e || e.length === 0) return [];
|
|
861
|
-
const t = e[0][0],
|
|
894
|
+
const t = e[0][0], r = e[0][1], s = this.options.radius || 0, a = s / (111320 * Math.cos(r * Te)), n = s / 111320;
|
|
862
895
|
return [
|
|
863
|
-
[t - a,
|
|
864
|
-
[t + a,
|
|
896
|
+
[t - a, r - n],
|
|
897
|
+
[t + a, r + n]
|
|
865
898
|
];
|
|
866
899
|
}
|
|
867
900
|
}
|
|
868
|
-
const
|
|
869
|
-
function
|
|
901
|
+
const pe = 100, oe = 1e-4;
|
|
902
|
+
function w(i, e) {
|
|
870
903
|
return Math.sqrt((i[0] - e[0]) ** 2 + (i[1] - e[1]) ** 2);
|
|
871
904
|
}
|
|
872
|
-
function
|
|
905
|
+
function le(i) {
|
|
873
906
|
let e = 0;
|
|
874
907
|
for (let t = 0; t < i.length - 1; t++)
|
|
875
|
-
e +=
|
|
908
|
+
e += w(i[t], i[t + 1]);
|
|
876
909
|
return e;
|
|
877
910
|
}
|
|
878
|
-
function
|
|
879
|
-
return
|
|
911
|
+
function j(i) {
|
|
912
|
+
return le(i) ** 0.99;
|
|
880
913
|
}
|
|
881
|
-
function
|
|
914
|
+
function he(i, e) {
|
|
882
915
|
return [(i[0] + e[0]) / 2, (i[1] + e[1]) / 2];
|
|
883
916
|
}
|
|
884
|
-
function
|
|
917
|
+
function te(i, e) {
|
|
885
918
|
const t = Math.asin(
|
|
886
|
-
Math.abs(e[1] - i[1]) /
|
|
919
|
+
Math.abs(e[1] - i[1]) / w(i, e)
|
|
887
920
|
);
|
|
888
921
|
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;
|
|
889
922
|
}
|
|
890
|
-
function
|
|
891
|
-
const
|
|
892
|
-
return
|
|
923
|
+
function $e(i, e, t) {
|
|
924
|
+
const r = te(e, i) - te(e, t);
|
|
925
|
+
return r < 0 ? r + Math.PI * 2 : r;
|
|
893
926
|
}
|
|
894
|
-
function
|
|
927
|
+
function we(i, e, t) {
|
|
895
928
|
return (t[1] - i[1]) * (e[0] - i[0]) > (e[1] - i[1]) * (t[0] - i[0]);
|
|
896
929
|
}
|
|
897
|
-
function f(i, e, t,
|
|
898
|
-
const a =
|
|
899
|
-
return [e[0] +
|
|
930
|
+
function f(i, e, t, r, s) {
|
|
931
|
+
const a = te(i, e), n = s ? a + t : a - t;
|
|
932
|
+
return [e[0] + r * Math.cos(n), e[1] + r * Math.sin(n)];
|
|
900
933
|
}
|
|
901
|
-
function
|
|
902
|
-
let
|
|
903
|
-
const a = Math.sqrt(
|
|
904
|
-
|
|
934
|
+
function de(i, e, t) {
|
|
935
|
+
let r = i[0] - e[0], s = i[1] - e[1];
|
|
936
|
+
const a = Math.sqrt(r * r + s * s);
|
|
937
|
+
r /= a, s /= a;
|
|
905
938
|
let n = t[0] - e[0], o = t[1] - e[1];
|
|
906
|
-
const
|
|
907
|
-
return n /=
|
|
939
|
+
const l = Math.sqrt(n * n + o * o);
|
|
940
|
+
return n /= l, o /= l, [r + n, s + o];
|
|
908
941
|
}
|
|
909
|
-
function
|
|
910
|
-
const
|
|
911
|
-
let
|
|
912
|
-
if (a >
|
|
913
|
-
const
|
|
914
|
-
|
|
942
|
+
function ue(i, e, t, r) {
|
|
943
|
+
const s = de(e, t, r), a = Math.sqrt(s[0] ** 2 + s[1] ** 2), n = w(e, t), o = w(t, r);
|
|
944
|
+
let l, u;
|
|
945
|
+
if (a > oe) {
|
|
946
|
+
const d = s[0] / a, c = s[1] / a;
|
|
947
|
+
we(e, t, r) ? (l = [t[0] - i * n * c, t[1] + i * n * d], u = [t[0] + i * o * c, t[1] - i * o * d]) : (l = [t[0] + i * n * c, t[1] - i * n * d], u = [t[0] - i * o * c, t[1] + i * o * d]);
|
|
915
948
|
} else
|
|
916
|
-
|
|
917
|
-
return [
|
|
949
|
+
l = [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])];
|
|
950
|
+
return [l, u];
|
|
918
951
|
}
|
|
919
|
-
function
|
|
920
|
-
const [t,
|
|
921
|
-
if (Math.sqrt(o[0] ** 2 + o[1] ** 2) >
|
|
922
|
-
const u =
|
|
923
|
-
return [u[0] + y *
|
|
952
|
+
function Ke(i, e) {
|
|
953
|
+
const [t, r, s] = [i[0], i[1], i[2]], n = ue(0, t, r, s)[0], o = de(t, r, s);
|
|
954
|
+
if (Math.sqrt(o[0] ** 2 + o[1] ** 2) > oe) {
|
|
955
|
+
const u = he(t, r), d = t[0] - u[0], c = t[1] - u[1], g = 2 / w(t, r), m = -g * c, p = g * d, y = m * m - p * p, _ = 2 * m * p, M = p * p - m * m, P = n[0] - u[0], S = n[1] - u[1];
|
|
956
|
+
return [u[0] + y * P + _ * S, u[1] + _ * P + M * S];
|
|
924
957
|
}
|
|
925
|
-
return [t[0] + e * (
|
|
958
|
+
return [t[0] + e * (r[0] - t[0]), t[1] + e * (r[1] - t[1])];
|
|
926
959
|
}
|
|
927
|
-
function
|
|
928
|
-
const t = i.length, [
|
|
929
|
-
if (Math.sqrt(
|
|
930
|
-
const
|
|
931
|
-
return [
|
|
960
|
+
function et(i, e) {
|
|
961
|
+
const t = i.length, [r, s, a] = [i[t - 3], i[t - 2], i[t - 1]], o = ue(0, r, s, a)[1], l = de(r, s, a);
|
|
962
|
+
if (Math.sqrt(l[0] ** 2 + l[1] ** 2) > oe) {
|
|
963
|
+
const d = he(s, a), c = a[0] - d[0], g = a[1] - d[1], m = 2 / w(s, a), p = -m * g, y = m * c, _ = p * p - y * y, M = 2 * p * y, P = y * y - p * p, S = o[0] - d[0], b = o[1] - d[1];
|
|
964
|
+
return [d[0] + _ * S + M * b, d[1] + M * S + P * b];
|
|
932
965
|
}
|
|
933
|
-
return [a[0] + e * (
|
|
966
|
+
return [a[0] + e * (s[0] - a[0]), a[1] + e * (s[1] - a[1])];
|
|
934
967
|
}
|
|
935
|
-
function
|
|
936
|
-
let
|
|
968
|
+
function tt(i, e) {
|
|
969
|
+
let r = [Ke(e, i)];
|
|
937
970
|
for (let n = 0; n < e.length - 2; n++) {
|
|
938
|
-
const o =
|
|
939
|
-
|
|
971
|
+
const o = ue(i, e[n], e[n + 1], e[n + 2]);
|
|
972
|
+
r = r.concat(o);
|
|
940
973
|
}
|
|
941
|
-
const
|
|
942
|
-
|
|
974
|
+
const s = et(e, i);
|
|
975
|
+
s && r.push(s);
|
|
943
976
|
const a = [];
|
|
944
977
|
for (let n = 0; n < e.length - 1; n++) {
|
|
945
|
-
const o = e[n],
|
|
978
|
+
const o = e[n], l = e[n + 1];
|
|
946
979
|
a.push(o);
|
|
947
|
-
for (let u = 0; u <
|
|
948
|
-
const
|
|
980
|
+
for (let u = 0; u < pe; u++) {
|
|
981
|
+
const d = u / pe, c = 1 - d, g = d * d, m = g * d, p = c * c, y = p * c, _ = r[n * 2], M = r[n * 2 + 1];
|
|
949
982
|
a.push([
|
|
950
|
-
y * o[0] + 3 * p *
|
|
951
|
-
y * o[1] + 3 * p *
|
|
983
|
+
y * o[0] + 3 * p * d * _[0] + 3 * c * g * M[0] + m * l[0],
|
|
984
|
+
y * o[1] + 3 * p * d * _[1] + 3 * c * g * M[1] + m * l[1]
|
|
952
985
|
]);
|
|
953
986
|
}
|
|
954
|
-
a.push(
|
|
987
|
+
a.push(l);
|
|
955
988
|
}
|
|
956
989
|
return a;
|
|
957
990
|
}
|
|
958
|
-
function
|
|
991
|
+
function rt(i, e) {
|
|
959
992
|
return i === 0 ? (e - 1) ** 2 / 2 : i === 1 ? (-2 * e ** 2 + 2 * e + 1) / 2 : i === 2 ? e ** 2 / 2 : 0;
|
|
960
993
|
}
|
|
961
|
-
function
|
|
994
|
+
function me(i) {
|
|
962
995
|
if (i.length <= 2) return i;
|
|
963
996
|
const e = [i[0]], t = i.length - 3;
|
|
964
|
-
for (let
|
|
965
|
-
for (let
|
|
997
|
+
for (let r = 0; r <= t; r++)
|
|
998
|
+
for (let s = 0; s <= 1; s += 0.05) {
|
|
966
999
|
let a = 0, n = 0;
|
|
967
1000
|
for (let o = 0; o <= 2; o++) {
|
|
968
|
-
const
|
|
969
|
-
a +=
|
|
1001
|
+
const l = rt(o, s);
|
|
1002
|
+
a += l * i[r + o][0], n += l * i[r + o][1];
|
|
970
1003
|
}
|
|
971
1004
|
e.push([a, n]);
|
|
972
1005
|
}
|
|
973
1006
|
return e.push(i[i.length - 1]), e;
|
|
974
1007
|
}
|
|
975
|
-
function
|
|
976
|
-
const t =
|
|
977
|
-
return [
|
|
1008
|
+
function re(i, e) {
|
|
1009
|
+
const t = j([i, e]), r = t * 0.1, s = t * 0.2, a = t * 0.25, n = Math.PI / 8.5, o = Math.PI / 13, l = f(e, i, Math.PI / 2, r, !0), u = f(e, i, Math.PI / 2, r, !1), d = f(i, e, n, a, !1), c = f(i, e, n, a, !0), g = f(i, e, o, s, !1), m = f(i, e, o, s, !0);
|
|
1010
|
+
return [l, g, d, e, c, m, u, i];
|
|
978
1011
|
}
|
|
979
|
-
function
|
|
1012
|
+
function se(i, e) {
|
|
980
1013
|
if (i.length <= e) return i;
|
|
981
|
-
const t = [i[0]],
|
|
982
|
-
for (let
|
|
983
|
-
t.push(i[Math.round(
|
|
1014
|
+
const t = [i[0]], r = (i.length - 1) / (e - 1);
|
|
1015
|
+
for (let s = 1; s < e - 1; s++)
|
|
1016
|
+
t.push(i[Math.round(s * r)]);
|
|
984
1017
|
return t.push(i[i.length - 1]), t;
|
|
985
1018
|
}
|
|
986
|
-
function
|
|
1019
|
+
function st(i) {
|
|
987
1020
|
if (i.length === 2)
|
|
988
|
-
return
|
|
989
|
-
const e =
|
|
1021
|
+
return re(i[0], i[1]);
|
|
1022
|
+
const e = tt(0.3, i), t = se(e, 25), r = le(t), s = 0.08, a = 0.12, n = 0.2, o = Math.PI / 8.5, l = Math.PI / 13, u = 0.15, d = r * s, c = r * u, g = [], m = [];
|
|
990
1023
|
let p = 0;
|
|
991
|
-
const y =
|
|
992
|
-
for (let v = 0; v < t.length && (v > 0 && (p +=
|
|
993
|
-
const
|
|
994
|
-
g.push([t[v][0] +
|
|
1024
|
+
const y = r - c;
|
|
1025
|
+
for (let v = 0; v < t.length && (v > 0 && (p += w(t[v - 1], t[v])), !(p > y)); v++) {
|
|
1026
|
+
const J = y > 0 ? p / y : 0, A = d * (1 - J * 0.5), D = v > 0 ? t[v - 1] : t[0], Q = v < t.length - 1 ? t[v + 1] : t[v], N = Q[0] - D[0], I = Q[1] - D[1], G = Math.sqrt(N * N + I * I) || 1, U = -I / G, E = N / G;
|
|
1027
|
+
g.push([t[v][0] + U * A, t[v][1] + E * A]), m.push([t[v][0] - U * A, t[v][1] - E * A]);
|
|
995
1028
|
}
|
|
996
|
-
const
|
|
997
|
-
return [...g,
|
|
1029
|
+
const _ = t[t.length - 1], M = t[t.length - 2], P = r * a, S = r * n, b = f(M, _, l, P, !1), k = f(M, _, l, P, !0), F = f(M, _, o, S, !1), H = f(M, _, o, S, !0);
|
|
1030
|
+
return [...g, b, F, _, H, k, ...m.reverse()];
|
|
998
1031
|
}
|
|
999
|
-
function
|
|
1032
|
+
function it(i) {
|
|
1000
1033
|
let e = i[0], t = i[1];
|
|
1001
|
-
|
|
1002
|
-
const
|
|
1003
|
-
let
|
|
1004
|
-
const g =
|
|
1005
|
-
|
|
1006
|
-
const m =
|
|
1034
|
+
we(i[0], i[1], i[2]) && (e = i[1], t = i[0]);
|
|
1035
|
+
const s = [he(e, t), ...i.slice(2)], a = 0.18, n = 0.3, o = 0.85, l = 0.15, u = 0.8;
|
|
1036
|
+
let d = j(s), c = d * a;
|
|
1037
|
+
const g = s[s.length - 1];
|
|
1038
|
+
d = w(g, s[s.length - 2]);
|
|
1039
|
+
const m = w(e, t);
|
|
1007
1040
|
c > m * u && (c = m * u);
|
|
1008
|
-
const p = c * n, y = c *
|
|
1009
|
-
c = Math.min(c,
|
|
1010
|
-
const
|
|
1041
|
+
const p = c * n, y = c * l;
|
|
1042
|
+
c = Math.min(c, d);
|
|
1043
|
+
const _ = c * o, M = f(s[s.length - 2], g, 0, c, !0), P = f(s[s.length - 2], g, 0, _, !0), S = f(g, M, Math.PI / 2, p, !1), b = f(g, M, Math.PI / 2, p, !0), k = f(g, P, Math.PI / 2, y, !1), F = f(g, P, Math.PI / 2, y, !0), H = [k, S, g, b, F], v = m / j(s), J = le(s), D = j(s) * v, Q = w(k, F), N = (D - Q) / 2;
|
|
1011
1044
|
let I = 0;
|
|
1012
|
-
const
|
|
1013
|
-
for (let
|
|
1014
|
-
const
|
|
1015
|
-
I +=
|
|
1016
|
-
const
|
|
1017
|
-
|
|
1018
|
-
}
|
|
1019
|
-
let
|
|
1020
|
-
return
|
|
1045
|
+
const G = [], U = [];
|
|
1046
|
+
for (let O = 1; O < s.length - 1; O++) {
|
|
1047
|
+
const Y = $e(s[O - 1], s[O], s[O + 1]) / 2;
|
|
1048
|
+
I += w(s[O - 1], s[O]);
|
|
1049
|
+
const ce = (D / 2 - I / J * N) / Math.sin(Y);
|
|
1050
|
+
G.push(f(s[O - 1], s[O], Math.PI - Y, ce, !0)), U.push(f(s[O - 1], s[O], Y, ce, !1));
|
|
1051
|
+
}
|
|
1052
|
+
let E = [e, ...G, k], X = [t, ...U, F];
|
|
1053
|
+
return E = se(me(E), 25), X = se(me(X), 25), [...E, ...H, ...X.reverse()];
|
|
1021
1054
|
}
|
|
1022
|
-
class
|
|
1055
|
+
class at extends C {
|
|
1023
1056
|
category = "arrow";
|
|
1024
1057
|
/** `generateCoords()` 填充的闭合多边形顶点 */
|
|
1025
1058
|
generatedCoords = [];
|
|
@@ -1037,7 +1070,7 @@ class Ve extends P {
|
|
|
1037
1070
|
if (!e || e.length < 2)
|
|
1038
1071
|
return this.generatedCoords = [], [];
|
|
1039
1072
|
const t = this.options.arrowType || "straight";
|
|
1040
|
-
return t === "fine" ? this.generatedCoords =
|
|
1073
|
+
return t === "fine" ? this.generatedCoords = re(e[0], e[1]) : t === "curved" ? this.generatedCoords = st(e) : t === "attack" && e.length >= 3 ? this.generatedCoords = it(e) : this.generatedCoords = re(e[0], e[e.length - 1]), this.generatedCoords;
|
|
1041
1074
|
}
|
|
1042
1075
|
/** 浅拷贝:`options`、`generatedCoords` 与内部共享引用(顶点数组仍与 `options.points` 规则一致)。 */
|
|
1043
1076
|
getSnapshot() {
|
|
@@ -1057,7 +1090,7 @@ class Ve extends P {
|
|
|
1057
1090
|
};
|
|
1058
1091
|
}
|
|
1059
1092
|
}
|
|
1060
|
-
class
|
|
1093
|
+
class nt extends C {
|
|
1061
1094
|
category = "text";
|
|
1062
1095
|
constructor(e) {
|
|
1063
1096
|
super(e);
|
|
@@ -1073,7 +1106,7 @@ class Ke extends P {
|
|
|
1073
1106
|
return this.getCenterPoints();
|
|
1074
1107
|
}
|
|
1075
1108
|
}
|
|
1076
|
-
class
|
|
1109
|
+
class ot extends C {
|
|
1077
1110
|
category = "circle";
|
|
1078
1111
|
constructor(e) {
|
|
1079
1112
|
super(e);
|
|
@@ -1084,14 +1117,14 @@ class et extends P {
|
|
|
1084
1117
|
getExtentPoints() {
|
|
1085
1118
|
const e = this.options.points;
|
|
1086
1119
|
if (!e || e.length === 0) return [];
|
|
1087
|
-
const t = e[0][0],
|
|
1120
|
+
const t = e[0][0], r = e[0][1], s = this.options.radius || 0, a = s / (111320 * Math.cos(r * Te)), n = s / 111320;
|
|
1088
1121
|
return [
|
|
1089
|
-
[t - a,
|
|
1090
|
-
[t + a,
|
|
1122
|
+
[t - a, r - n],
|
|
1123
|
+
[t + a, r + n]
|
|
1091
1124
|
];
|
|
1092
1125
|
}
|
|
1093
1126
|
}
|
|
1094
|
-
class
|
|
1127
|
+
class lt {
|
|
1095
1128
|
/** 标绘 id → 实例;与 `PlotOverlay.imageSource.shapes` 共用同一引用 */
|
|
1096
1129
|
_items = /* @__PURE__ */ new Map();
|
|
1097
1130
|
/** 标绘 id */
|
|
@@ -1129,43 +1162,43 @@ class tt {
|
|
|
1129
1162
|
let t;
|
|
1130
1163
|
switch (e.type) {
|
|
1131
1164
|
case "point": {
|
|
1132
|
-
const { type:
|
|
1133
|
-
t = new
|
|
1165
|
+
const { type: r, ...s } = e;
|
|
1166
|
+
t = new Xe(s);
|
|
1134
1167
|
break;
|
|
1135
1168
|
}
|
|
1136
1169
|
case "line": {
|
|
1137
|
-
const { type:
|
|
1138
|
-
t = new
|
|
1170
|
+
const { type: r, ...s } = e;
|
|
1171
|
+
t = new Ye(s);
|
|
1139
1172
|
break;
|
|
1140
1173
|
}
|
|
1141
1174
|
case "polygon": {
|
|
1142
|
-
const { type:
|
|
1143
|
-
t = new
|
|
1175
|
+
const { type: r, ...s } = e;
|
|
1176
|
+
t = new Ze(s);
|
|
1144
1177
|
break;
|
|
1145
1178
|
}
|
|
1146
1179
|
case "rectangle": {
|
|
1147
|
-
const { type:
|
|
1148
|
-
t = new
|
|
1180
|
+
const { type: r, ...s } = e;
|
|
1181
|
+
t = new qe(s);
|
|
1149
1182
|
break;
|
|
1150
1183
|
}
|
|
1151
1184
|
case "circle": {
|
|
1152
|
-
const { type:
|
|
1153
|
-
t = new
|
|
1185
|
+
const { type: r, ...s } = e;
|
|
1186
|
+
t = new ot(s);
|
|
1154
1187
|
break;
|
|
1155
1188
|
}
|
|
1156
1189
|
case "sector": {
|
|
1157
|
-
const { type:
|
|
1158
|
-
t = new
|
|
1190
|
+
const { type: r, ...s } = e;
|
|
1191
|
+
t = new Ve(s);
|
|
1159
1192
|
break;
|
|
1160
1193
|
}
|
|
1161
1194
|
case "text": {
|
|
1162
|
-
const { type:
|
|
1163
|
-
t = new
|
|
1195
|
+
const { type: r, ...s } = e;
|
|
1196
|
+
t = new nt(s);
|
|
1164
1197
|
break;
|
|
1165
1198
|
}
|
|
1166
1199
|
case "arrow": {
|
|
1167
|
-
const { type:
|
|
1168
|
-
t = new
|
|
1200
|
+
const { type: r, ...s } = e;
|
|
1201
|
+
t = new at(s);
|
|
1169
1202
|
break;
|
|
1170
1203
|
}
|
|
1171
1204
|
default:
|
|
@@ -1203,60 +1236,60 @@ class tt {
|
|
|
1203
1236
|
* `patch` 形状需与该 id 下图元类型兼容。
|
|
1204
1237
|
*/
|
|
1205
1238
|
setStyle(e, t) {
|
|
1206
|
-
const
|
|
1207
|
-
|
|
1239
|
+
const r = this._items.get(e);
|
|
1240
|
+
r && (r.update(t), this._markDirty());
|
|
1208
1241
|
}
|
|
1209
1242
|
/**
|
|
1210
1243
|
* 将 **第一个顶点** 设为新的经纬度中心(适用于点、矩形中心、扇心、文字锚点等单中心语义)。
|
|
1211
1244
|
*/
|
|
1212
1245
|
setCenter(e, t) {
|
|
1213
|
-
const
|
|
1214
|
-
!
|
|
1246
|
+
const r = this._items.get(e);
|
|
1247
|
+
!r || !r.options.points || r.options.points.length === 0 || (t.lon !== void 0 && (r.options.points[0][0] = t.lon), t.lat !== void 0 && (r.options.points[0][1] = t.lat), this._markDirty());
|
|
1215
1248
|
}
|
|
1216
1249
|
/** 整体替换顶点列表(每项为 `[lon, lat]`) */
|
|
1217
1250
|
setCoords(e, t) {
|
|
1218
|
-
const
|
|
1219
|
-
|
|
1251
|
+
const r = this._items.get(e);
|
|
1252
|
+
r && (r.options.points = t.map((s) => [...s]), this._markDirty());
|
|
1220
1253
|
}
|
|
1221
1254
|
/** 修改指定下标顶点;`coord` 分量可为 `undefined` 表示不改该分量 */
|
|
1222
|
-
setCoord(e, t,
|
|
1223
|
-
const
|
|
1224
|
-
!
|
|
1255
|
+
setCoord(e, t, r) {
|
|
1256
|
+
const s = this._items.get(e);
|
|
1257
|
+
!s || !s.options.points || t < 0 || t >= s.options.points.length || (r[0] !== void 0 && (s.options.points[t][0] = r[0]), r[1] !== void 0 && (s.options.points[t][1] = r[1]), this._markDirty());
|
|
1225
1258
|
}
|
|
1226
1259
|
/** 在 `index` 处插入一个顶点(可插在末尾,`index` 越界时钳位) */
|
|
1227
|
-
insertCoord(e, t,
|
|
1228
|
-
const
|
|
1229
|
-
if (!
|
|
1230
|
-
const a = Math.max(0, Math.min(t,
|
|
1231
|
-
|
|
1260
|
+
insertCoord(e, t, r) {
|
|
1261
|
+
const s = this._items.get(e);
|
|
1262
|
+
if (!s || !s.options.points) return;
|
|
1263
|
+
const a = Math.max(0, Math.min(t, s.options.points.length));
|
|
1264
|
+
s.options.points.splice(a, 0, [...r]), this._markDirty();
|
|
1232
1265
|
}
|
|
1233
1266
|
/**
|
|
1234
1267
|
* 删除指定下标顶点。
|
|
1235
1268
|
* 多边形至少保留 3 点,其余类型至少 2 点(与 `shape.category` 联动)。
|
|
1236
1269
|
*/
|
|
1237
1270
|
removeCoord(e, t) {
|
|
1238
|
-
const
|
|
1239
|
-
if (!
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1271
|
+
const r = this._items.get(e);
|
|
1272
|
+
if (!r || !r.options.points || t < 0 || t >= r.options.points.length) return;
|
|
1273
|
+
const s = r.category === "polygon" ? 3 : 2;
|
|
1274
|
+
r.options.points.length <= s || (r.options.points.splice(t, 1), this._markDirty());
|
|
1242
1275
|
}
|
|
1243
1276
|
/** 对所有顶点做经纬度平移(度) */
|
|
1244
|
-
translateCoords(e, t,
|
|
1245
|
-
const
|
|
1246
|
-
if (!(!
|
|
1247
|
-
for (const a of
|
|
1248
|
-
a[0] += t, a[1] +=
|
|
1277
|
+
translateCoords(e, t, r) {
|
|
1278
|
+
const s = this._items.get(e);
|
|
1279
|
+
if (!(!s || !s.options.points)) {
|
|
1280
|
+
for (const a of s.options.points)
|
|
1281
|
+
a[0] += t, a[1] += r;
|
|
1249
1282
|
this._markDirty();
|
|
1250
1283
|
}
|
|
1251
1284
|
}
|
|
1252
1285
|
/** 仅对 `category === 'text'` 的项更新 `options.content` */
|
|
1253
1286
|
setText(e, t) {
|
|
1254
|
-
const
|
|
1255
|
-
!
|
|
1287
|
+
const r = this._items.get(e);
|
|
1288
|
+
!r || r.category !== "text" || (r.options.content = t, this._markDirty());
|
|
1256
1289
|
}
|
|
1257
1290
|
/** 设置整个 overlay 不透明度(0–1,具体语义以 `PlotOverlay` 为准) */
|
|
1258
1291
|
setGlobalOpacity(e) {
|
|
1259
|
-
this._plotSdfPlugin.opacity = e, this._markDirty();
|
|
1292
|
+
this._plotSdfPlugin && (this._plotSdfPlugin.opacity = e, this._markDirty());
|
|
1260
1293
|
}
|
|
1261
1294
|
getCoordCount(e) {
|
|
1262
1295
|
const t = this._items.get(e);
|
|
@@ -1266,13 +1299,13 @@ class tt {
|
|
|
1266
1299
|
* 在经纬度平面上找离 `(lon, lat)` 最近的顶点下标(平方距离最小);
|
|
1267
1300
|
* 无顶点时返回 `-1`。
|
|
1268
1301
|
*/
|
|
1269
|
-
findNearestCoord(e, t,
|
|
1270
|
-
const
|
|
1271
|
-
if (!
|
|
1302
|
+
findNearestCoord(e, t, r) {
|
|
1303
|
+
const s = this._items.get(e);
|
|
1304
|
+
if (!s || !s.options.points || s.options.points.length === 0) return -1;
|
|
1272
1305
|
let a = 0, n = 1 / 0;
|
|
1273
|
-
for (let o = 0; o <
|
|
1274
|
-
const
|
|
1275
|
-
|
|
1306
|
+
for (let o = 0; o < s.options.points.length; o++) {
|
|
1307
|
+
const l = s.options.points[o][0] - t, u = s.options.points[o][1] - r, d = l * l + u * u;
|
|
1308
|
+
d < n && (n = d, a = o);
|
|
1276
1309
|
}
|
|
1277
1310
|
return a;
|
|
1278
1311
|
}
|
|
@@ -1284,7 +1317,7 @@ class tt {
|
|
|
1284
1317
|
* `PlotSDFPlugin` 的运行时实现含 `dispose`,类型声明可能未列出,故做断言。
|
|
1285
1318
|
*/
|
|
1286
1319
|
dispose() {
|
|
1287
|
-
this._plotSdfPlugin.dispose();
|
|
1320
|
+
this._plotSdfPlugin && this._plotSdfPlugin.dispose();
|
|
1288
1321
|
}
|
|
1289
1322
|
/**
|
|
1290
1323
|
* 标记需要在下一帧重绘瓦片标绘层;同一帧内多次调用只会调度一次。
|
|
@@ -1293,27 +1326,27 @@ class tt {
|
|
|
1293
1326
|
*/
|
|
1294
1327
|
_markDirty() {
|
|
1295
1328
|
this._redrawTimer || (this._redrawTimer = requestAnimationFrame(() => {
|
|
1296
|
-
this._redrawTimer = null, !this._overlayAttached && this._items.size > 0 &&
|
|
1329
|
+
this._plotSdfPlugin && (this._redrawTimer = null, !this._overlayAttached && this._items.size > 0 && (this._plotSdfPlugin.shapes = this._items, this._overlayAttached = !0), this._plotSdfPlugin.redraw(), this.render());
|
|
1297
1330
|
}));
|
|
1298
1331
|
}
|
|
1299
1332
|
}
|
|
1300
|
-
const
|
|
1301
|
-
class
|
|
1333
|
+
const ht = "https://sooncps.xwbuilders.com/api/ugis-dataprocess/v1/terrain/NhBLlMx3/", dt = "https://c.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png";
|
|
1334
|
+
class Tt {
|
|
1302
1335
|
constructor(e, t = {}) {
|
|
1303
1336
|
this.ssp = e, this.options = t;
|
|
1304
|
-
const
|
|
1305
|
-
if (this.resourceManager = new
|
|
1306
|
-
const
|
|
1337
|
+
const r = t.baseUrl || ht;
|
|
1338
|
+
if (this.resourceManager = new Be(), this.terrainManager = new He(), t.imageryUrl !== !1) {
|
|
1339
|
+
const s = t.imageryUrl || dt;
|
|
1307
1340
|
this.resourceManager.addOverlay({
|
|
1308
1341
|
id: this.defaultImageryId,
|
|
1309
|
-
type:
|
|
1310
|
-
options: { id: this.defaultImageryId, url:
|
|
1342
|
+
type: h.XYZ,
|
|
1343
|
+
options: { id: this.defaultImageryId, url: s, type: h.XYZ }
|
|
1311
1344
|
});
|
|
1312
1345
|
}
|
|
1313
|
-
this.groundDecalManager = new
|
|
1346
|
+
this.groundDecalManager = new lt({ ssp: this.ssp }), this._alphaClipMode = t.alphaClipMode ?? "alphaTest", this._currentTerrainConfig = {
|
|
1314
1347
|
id: this.defaultTerrainId,
|
|
1315
|
-
type:
|
|
1316
|
-
url:
|
|
1348
|
+
type: R.QUANTIZED_MESH,
|
|
1349
|
+
url: r
|
|
1317
1350
|
}, this.terrainManager.add(this._currentTerrainConfig), this.terrainManager.setCurrentId(this._currentTerrainConfig.id), this.tiles = this._initTilesRenderer(this._currentTerrainConfig), this._initPlugins(this.tiles, this._currentTerrainConfig);
|
|
1318
1351
|
}
|
|
1319
1352
|
defaultTerrainId = "__default_terrain__";
|
|
@@ -1346,7 +1379,7 @@ class mt {
|
|
|
1346
1379
|
* 是否使用 Cesium Ion 地形
|
|
1347
1380
|
*/
|
|
1348
1381
|
get isCesiumIon() {
|
|
1349
|
-
return this._currentTerrainConfig.type ===
|
|
1382
|
+
return this._currentTerrainConfig.type === R.CESIUM_ION;
|
|
1350
1383
|
}
|
|
1351
1384
|
/**
|
|
1352
1385
|
* 获取当前地形配置
|
|
@@ -1392,7 +1425,7 @@ class mt {
|
|
|
1392
1425
|
this._alphaClipMode = e, this.customMaterialPlugin && (this.customMaterialPlugin.alphaClipMode = e), this._updateAlphaClipMode(), this.render();
|
|
1393
1426
|
}
|
|
1394
1427
|
_initTilesRenderer(e) {
|
|
1395
|
-
return e.type ===
|
|
1428
|
+
return e.type === R.CESIUM_ION ? new x() : (
|
|
1396
1429
|
// Cesium Ion 由插件设置 URL
|
|
1397
1430
|
new x(e.url)
|
|
1398
1431
|
);
|
|
@@ -1402,42 +1435,42 @@ class mt {
|
|
|
1402
1435
|
* @param config 地形配置
|
|
1403
1436
|
*/
|
|
1404
1437
|
_initPlugins(e, t) {
|
|
1405
|
-
if (this.tilesFadePlugin = new
|
|
1406
|
-
new
|
|
1438
|
+
if (this.tilesFadePlugin = new ie({ maximumFadeOutTiles: 200 }), this.updateOnChangePlugin = new ae(), e.registerPlugin(this.tilesFadePlugin), e.registerPlugin(this.updateOnChangePlugin), t.type === R.CESIUM_ION ? e.registerPlugin(
|
|
1439
|
+
new Oe({
|
|
1407
1440
|
apiToken: t.apiToken,
|
|
1408
1441
|
assetId: t.assetId || "1",
|
|
1409
1442
|
autoRefreshToken: t.autoRefreshToken ?? !0,
|
|
1410
|
-
assetTypeHandler: (
|
|
1411
|
-
|
|
1412
|
-
new
|
|
1443
|
+
assetTypeHandler: (r, s) => {
|
|
1444
|
+
r === "TERRAIN" && s.getPluginByName("QUANTIZED_MESH_PLUGIN") === null && s.registerPlugin(
|
|
1445
|
+
new ee({ useRecommendedSettings: !0 })
|
|
1413
1446
|
);
|
|
1414
1447
|
}
|
|
1415
1448
|
})
|
|
1416
1449
|
) : (e.registerPlugin(
|
|
1417
|
-
new
|
|
1418
|
-
), e.fetchData = async (
|
|
1419
|
-
const
|
|
1420
|
-
if (/layer\.json$/.test(
|
|
1421
|
-
const a = await fetch(
|
|
1450
|
+
new ee({ useRecommendedSettings: !0 })
|
|
1451
|
+
), e.fetchData = async (r) => {
|
|
1452
|
+
const s = { method: "GET", mode: "cors" };
|
|
1453
|
+
if (/layer\.json$/.test(r)) {
|
|
1454
|
+
const a = await fetch(r, s).then((n) => n.json());
|
|
1422
1455
|
return a.metadataAvailability = -1, new Response(JSON.stringify(a));
|
|
1423
1456
|
}
|
|
1424
|
-
return fetch(
|
|
1425
|
-
}), this.options.useCustomMaterial !== !1 && (this.customMaterialPlugin = new
|
|
1457
|
+
return fetch(r, s);
|
|
1458
|
+
}), this.options.useCustomMaterial !== !1 && (this.customMaterialPlugin = new ze(), this.customMaterialPlugin.alphaClipMode = this._alphaClipMode, e.registerPlugin(this.customMaterialPlugin)), this.imageOverlayPlugin = new _e({
|
|
1426
1459
|
renderer: this.ssp.viewport.renderer,
|
|
1427
1460
|
overlays: []
|
|
1428
|
-
}), e.registerPlugin(this.imageOverlayPlugin), this.plotSDFPlugin = new
|
|
1461
|
+
}), e.registerPlugin(this.imageOverlayPlugin), this.plotSDFPlugin = new Fe(), this.groundDecalManager?.setPlotSDFPlugin(this.plotSDFPlugin), this.tiles.registerPlugin(this.plotSDFPlugin), this.overlayManager = new B(
|
|
1429
1462
|
this.imageOverlayPlugin,
|
|
1430
1463
|
this.resourceManager
|
|
1431
1464
|
), this.overlayManager.restoreFromResourceManager(), this.options.reorientation !== !1) {
|
|
1432
|
-
const
|
|
1433
|
-
this.reorientationPlugin = new
|
|
1434
|
-
lon:
|
|
1435
|
-
lat:
|
|
1436
|
-
height:
|
|
1465
|
+
const r = this.options.reorientation || { lon: 120, lat: 30 };
|
|
1466
|
+
this.reorientationPlugin = new ne({
|
|
1467
|
+
lon: r.lon,
|
|
1468
|
+
lat: r.lat,
|
|
1469
|
+
height: r.height ?? 0.1
|
|
1437
1470
|
}), e.registerPlugin(this.reorientationPlugin), this.invalidate(
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1471
|
+
r.lon,
|
|
1472
|
+
r.lat,
|
|
1473
|
+
r.height ?? 0.1
|
|
1441
1474
|
);
|
|
1442
1475
|
}
|
|
1443
1476
|
e.maxDepth = this.options.maxDepth ?? 20, e.errorTarget = this.options.errorTarget ?? 1, e.addEventListener("needs-render", this.render), e.addEventListener("needs-update", this.render);
|
|
@@ -1455,6 +1488,15 @@ class mt {
|
|
|
1455
1488
|
_updateAlphaClipMode() {
|
|
1456
1489
|
this.customMaterialPlugin && this.customMaterialPlugin.updateAllLoadedModels(this.tiles);
|
|
1457
1490
|
}
|
|
1491
|
+
// =============== 事件监听 ===============
|
|
1492
|
+
/**
|
|
1493
|
+
* 添加影像或倾斜加载事件监听
|
|
1494
|
+
*/
|
|
1495
|
+
addEventLoad(e) {
|
|
1496
|
+
this.tiles.addEventListener("load-error", ({ tile: t, error: r, url: s }) => {
|
|
1497
|
+
e({ tile: t, error: r, url: s });
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1458
1500
|
// =============== 地形管理 API ===============
|
|
1459
1501
|
/**
|
|
1460
1502
|
* 设置地形
|
|
@@ -1476,79 +1518,35 @@ class mt {
|
|
|
1476
1518
|
*/
|
|
1477
1519
|
setTerrain(e, t = void 0) {
|
|
1478
1520
|
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) {
|
|
1479
|
-
const
|
|
1480
|
-
e.type ===
|
|
1521
|
+
const r = this.terrainManager.getCurrent();
|
|
1522
|
+
e.type === R.QUANTIZED_MESH && r?.type === R.QUANTIZED_MESH && (r.url = e.url);
|
|
1481
1523
|
}
|
|
1482
1524
|
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();
|
|
1483
1525
|
}
|
|
1484
1526
|
// =============== Overlay 快捷方法 ===============
|
|
1485
1527
|
/**
|
|
1486
|
-
* 添加
|
|
1487
|
-
*
|
|
1488
|
-
*
|
|
1489
|
-
*
|
|
1490
|
-
* url: './data/china.geojson',
|
|
1491
|
-
* color: '#ff0000',
|
|
1492
|
-
* opacity: 0.8
|
|
1493
|
-
* })
|
|
1528
|
+
* 添加 Overlay
|
|
1529
|
+
* 根据 options.type 自动识别类型并调用对应方法
|
|
1530
|
+
* @param options Overlay 配置选项,必须包含 type 字段
|
|
1531
|
+
* @returns Overlay 实例或 null(如果添加失败)
|
|
1494
1532
|
*/
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
*/
|
|
1513
|
-
addXYZOverlay(e) {
|
|
1514
|
-
return this.overlayManager.addXYZ(e);
|
|
1515
|
-
}
|
|
1516
|
-
/**
|
|
1517
|
-
* 添加 URL Template Overlay
|
|
1518
|
-
*
|
|
1519
|
-
* 支持多种 URL 模板变量:
|
|
1520
|
-
* - `{z}`, `{x}`, `{y}` - 标准 XYZ 坐标
|
|
1521
|
-
* - `{s}` - 子域名轮换
|
|
1522
|
-
* - `{reverseY}` - TMS 风格的 Y 坐标
|
|
1523
|
-
* - `{westDegrees}`, `{southDegrees}`, `{eastDegrees}`, `{northDegrees}` - 地理边界框
|
|
1524
|
-
*
|
|
1525
|
-
* @example
|
|
1526
|
-
* tilesPlugin.addUrlTemplateOverlay({
|
|
1527
|
-
* id: 'osm',
|
|
1528
|
-
* url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
|
|
1529
|
-
* })
|
|
1530
|
-
*
|
|
1531
|
-
* @example
|
|
1532
|
-
* tilesPlugin.addUrlTemplateOverlay({
|
|
1533
|
-
* id: 'carto',
|
|
1534
|
-
* url: 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
|
|
1535
|
-
* subdomains: 'abcd'
|
|
1536
|
-
* })
|
|
1537
|
-
*/
|
|
1538
|
-
addUrlTemplateOverlay(e) {
|
|
1539
|
-
return this.overlayManager.addUrlTemplate(e);
|
|
1540
|
-
}
|
|
1541
|
-
/**
|
|
1542
|
-
* 添加 WMS Tiles Overlay
|
|
1543
|
-
*/
|
|
1544
|
-
addWMSOverlay(e) {
|
|
1545
|
-
return this.overlayManager.addWMS(e);
|
|
1546
|
-
}
|
|
1547
|
-
/**
|
|
1548
|
-
* 添加 WMTS Tiles Overlay
|
|
1549
|
-
*/
|
|
1550
|
-
addWMTSOverlay(e) {
|
|
1551
|
-
return this.overlayManager.addWMTS(e);
|
|
1533
|
+
async addOverlay(e) {
|
|
1534
|
+
switch (e.type) {
|
|
1535
|
+
case h.GEOJSON:
|
|
1536
|
+
return this.overlayManager.addGeoJSONOverlay(e);
|
|
1537
|
+
case h.CESIUM_ION:
|
|
1538
|
+
return this.overlayManager.addCesiumIonOverlay(e);
|
|
1539
|
+
case h.TMS:
|
|
1540
|
+
return this.overlayManager.addTMSOverlay(e);
|
|
1541
|
+
case h.XYZ:
|
|
1542
|
+
return this.overlayManager.addXYZOverlay(e);
|
|
1543
|
+
case h.WMS:
|
|
1544
|
+
return await this.overlayManager.addWMSOverlay(e);
|
|
1545
|
+
case h.WMTS:
|
|
1546
|
+
return await this.overlayManager.addWMTSOverlay(e);
|
|
1547
|
+
default:
|
|
1548
|
+
return this.overlayManager.addUrlTemplateOverlay(e);
|
|
1549
|
+
}
|
|
1552
1550
|
}
|
|
1553
1551
|
/**
|
|
1554
1552
|
* 移除指定 overlay
|
|
@@ -1560,8 +1558,8 @@ class mt {
|
|
|
1560
1558
|
* 更新 GeoJSON 颜色
|
|
1561
1559
|
*/
|
|
1562
1560
|
updateGeoJSONColor(e, t) {
|
|
1563
|
-
const
|
|
1564
|
-
return
|
|
1561
|
+
const r = this.overlayManager.updateGeoJSONColor(e, t);
|
|
1562
|
+
return r && this.render(), r;
|
|
1565
1563
|
}
|
|
1566
1564
|
/**
|
|
1567
1565
|
* 更新 GeoJSON 模式
|
|
@@ -1570,29 +1568,38 @@ class mt {
|
|
|
1570
1568
|
* - invertMask: 只显示 GeoJSON 区域外的地形
|
|
1571
1569
|
*/
|
|
1572
1570
|
updateGeoJSONMode(e, t) {
|
|
1573
|
-
const
|
|
1574
|
-
return
|
|
1571
|
+
const r = this.overlayManager.updateGeoJSONMode(e, t);
|
|
1572
|
+
return r && this.render(), r;
|
|
1575
1573
|
}
|
|
1576
1574
|
/**
|
|
1577
1575
|
* 更新 GeoJSON 描边样式
|
|
1578
1576
|
*/
|
|
1579
1577
|
updateGeoJSONStrokeStyle(e, t) {
|
|
1580
|
-
const
|
|
1581
|
-
return
|
|
1578
|
+
const r = this.overlayManager.updateGeoJSONStrokeStyle(e, t);
|
|
1579
|
+
return r && this.render(), r;
|
|
1582
1580
|
}
|
|
1583
1581
|
/**
|
|
1584
1582
|
* 更新 GeoJSON 描边宽度
|
|
1585
1583
|
*/
|
|
1586
1584
|
updateGeoJSONStrokeWidth(e, t) {
|
|
1587
|
-
const
|
|
1588
|
-
return
|
|
1585
|
+
const r = this.overlayManager.updateGeoJSONStrokeWidth(e, t);
|
|
1586
|
+
return r && this.render(), r;
|
|
1589
1587
|
}
|
|
1590
1588
|
/**
|
|
1591
1589
|
* 更新 GeoJSON 填充样式
|
|
1592
1590
|
*/
|
|
1593
1591
|
updateGeoJSONFillStyle(e, t) {
|
|
1594
|
-
const
|
|
1595
|
-
return
|
|
1592
|
+
const r = this.overlayManager.updateGeoJSONFillStyle(e, t);
|
|
1593
|
+
return r && this.render(), r;
|
|
1594
|
+
}
|
|
1595
|
+
// =============== GeoJSON 管理 ===============
|
|
1596
|
+
/**
|
|
1597
|
+
* 合并多个 GeoJSON
|
|
1598
|
+
* @param geojsons 待合并的 GeoJSON 数组
|
|
1599
|
+
* @returns 合并后的 GeoJSON
|
|
1600
|
+
*/
|
|
1601
|
+
mergeGeoJSON(e) {
|
|
1602
|
+
return je(e);
|
|
1596
1603
|
}
|
|
1597
1604
|
// =============== Overlay 层级控制 ===============
|
|
1598
1605
|
/**
|
|
@@ -1628,15 +1635,15 @@ class mt {
|
|
|
1628
1635
|
* 设置 overlay 可见性
|
|
1629
1636
|
*/
|
|
1630
1637
|
setOverlayVisible(e, t) {
|
|
1631
|
-
const
|
|
1632
|
-
return
|
|
1638
|
+
const r = this.overlayManager.setVisible(e, t);
|
|
1639
|
+
return r && this.render(), r;
|
|
1633
1640
|
}
|
|
1634
1641
|
/**
|
|
1635
1642
|
* 设置 overlay 透明度
|
|
1636
1643
|
*/
|
|
1637
1644
|
setOverlayOpacity(e, t) {
|
|
1638
|
-
const
|
|
1639
|
-
return
|
|
1645
|
+
const r = this.overlayManager.setOpacity(e, t);
|
|
1646
|
+
return r && this.render(), r;
|
|
1640
1647
|
}
|
|
1641
1648
|
// =============== 生命周期 ===============
|
|
1642
1649
|
render = () => {
|
|
@@ -1654,21 +1661,21 @@ class mt {
|
|
|
1654
1661
|
disable() {
|
|
1655
1662
|
this._enabled = !1, this.ssp.removeObject(this.tiles.group), this.ssp.signals.beforeRender.remove(this.beforeRenderHandler);
|
|
1656
1663
|
}
|
|
1657
|
-
invalidate(e, t,
|
|
1664
|
+
invalidate(e, t, r) {
|
|
1658
1665
|
if (!this.reorientationPlugin)
|
|
1659
1666
|
return console.warn(
|
|
1660
1667
|
"TilesRenderer: reorientationPlugin is not enabled, invalidate() will not work."
|
|
1661
1668
|
), () => {
|
|
1662
1669
|
};
|
|
1663
|
-
const
|
|
1670
|
+
const s = this.reorientationPlugin;
|
|
1664
1671
|
this.options.reorientation = {
|
|
1665
1672
|
lon: e,
|
|
1666
1673
|
lat: t,
|
|
1667
|
-
height:
|
|
1674
|
+
height: r
|
|
1668
1675
|
};
|
|
1669
1676
|
const a = () => {
|
|
1670
|
-
const o =
|
|
1671
|
-
|
|
1677
|
+
const o = T.degToRad(t), l = T.degToRad(e);
|
|
1678
|
+
s.transformLatLonHeightToOrigin(o, l, r), this.render(), n();
|
|
1672
1679
|
}, n = () => {
|
|
1673
1680
|
this.tiles.removeEventListener("load-root-tileset", a), this.loedTilesSets.delete(a);
|
|
1674
1681
|
};
|
|
@@ -1680,12 +1687,12 @@ class mt {
|
|
|
1680
1687
|
), this.loedTilesSets.clear(), this.tiles.removeEventListener("needs-render", this.render), this.tiles.removeEventListener("needs-update", this.render), this.tiles.dispose();
|
|
1681
1688
|
}
|
|
1682
1689
|
}
|
|
1683
|
-
const
|
|
1690
|
+
const L = {
|
|
1684
1691
|
DEFAULT: 0,
|
|
1685
1692
|
GRADIENT: 1,
|
|
1686
1693
|
TOPOGRAPHIC_LINES: 2,
|
|
1687
1694
|
LIGHTING: 3
|
|
1688
|
-
},
|
|
1695
|
+
}, ut = {
|
|
1689
1696
|
vertexShader: (
|
|
1690
1697
|
/* glsl */
|
|
1691
1698
|
`
|
|
@@ -1711,7 +1718,7 @@ const R = {
|
|
|
1711
1718
|
}
|
|
1712
1719
|
`
|
|
1713
1720
|
)
|
|
1714
|
-
},
|
|
1721
|
+
}, ct = {
|
|
1715
1722
|
vertexShader: (
|
|
1716
1723
|
/* glsl */
|
|
1717
1724
|
`
|
|
@@ -1757,8 +1764,8 @@ const R = {
|
|
|
1757
1764
|
`
|
|
1758
1765
|
)
|
|
1759
1766
|
};
|
|
1760
|
-
let
|
|
1761
|
-
class
|
|
1767
|
+
let q = null, V = null, $ = null;
|
|
1768
|
+
class gt {
|
|
1762
1769
|
constructor(e, t) {
|
|
1763
1770
|
this.ssp = e, this.options = t, "url" in this.options ? this.tiles = new x(this.options.url) : (this.tiles = new x(), this._initCesiumIon(this.options)), this._initBasePlugins(this.options);
|
|
1764
1771
|
}
|
|
@@ -1768,10 +1775,10 @@ class nt {
|
|
|
1768
1775
|
reorientationPlugin;
|
|
1769
1776
|
options;
|
|
1770
1777
|
// 用于模型居中
|
|
1771
|
-
_box = new
|
|
1772
|
-
_sphere = new
|
|
1778
|
+
_box = new Se();
|
|
1779
|
+
_sphere = new ve();
|
|
1773
1780
|
// 当前材质类型
|
|
1774
|
-
_materialType =
|
|
1781
|
+
_materialType = L.DEFAULT;
|
|
1775
1782
|
// 按需渲染标志
|
|
1776
1783
|
_needsUpdate = !0;
|
|
1777
1784
|
_cameraTransitionStart = !1;
|
|
@@ -1781,7 +1788,7 @@ class nt {
|
|
|
1781
1788
|
*/
|
|
1782
1789
|
_initCesiumIon(e) {
|
|
1783
1790
|
this.tiles.registerPlugin(
|
|
1784
|
-
new
|
|
1791
|
+
new Oe({
|
|
1785
1792
|
apiToken: e.apiToken,
|
|
1786
1793
|
assetId: e.assetId,
|
|
1787
1794
|
autoRefreshToken: e.autoRefreshToken ?? !0
|
|
@@ -1792,9 +1799,9 @@ class nt {
|
|
|
1792
1799
|
* 初始化基础插件
|
|
1793
1800
|
*/
|
|
1794
1801
|
_initBasePlugins(e) {
|
|
1795
|
-
if (e._managedByPlugin || (
|
|
1802
|
+
if (e._managedByPlugin || (q === null ? q = this.tiles.lruCache : this.tiles.lruCache = q, 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) {
|
|
1796
1803
|
const t = this.options.reorientation || { lon: 120, lat: 30 };
|
|
1797
|
-
this.reorientationPlugin = new
|
|
1804
|
+
this.reorientationPlugin = new ne({
|
|
1798
1805
|
lon: t.lon,
|
|
1799
1806
|
lat: t.lat,
|
|
1800
1807
|
height: t.height ?? 0.1
|
|
@@ -1810,10 +1817,10 @@ class nt {
|
|
|
1810
1817
|
* 设置 GLTF Loader
|
|
1811
1818
|
*/
|
|
1812
1819
|
_setupGLTFLoader() {
|
|
1813
|
-
const e = new
|
|
1820
|
+
const e = new fe(this.tiles.manager), t = this.ssp.manager?.store?.modelManager;
|
|
1814
1821
|
if (t?.gltfLoader) {
|
|
1815
|
-
const { dracoLoader:
|
|
1816
|
-
|
|
1822
|
+
const { dracoLoader: r, ktx2Loader: s, meshoptDecoder: a } = t.gltfLoader;
|
|
1823
|
+
r && e.setDRACOLoader(r), s && e.setKTX2Loader(s), a && e.setMeshoptDecoder(a);
|
|
1817
1824
|
}
|
|
1818
1825
|
this.tiles.manager.addHandler(/\.gltf$/, e);
|
|
1819
1826
|
}
|
|
@@ -1854,29 +1861,29 @@ class nt {
|
|
|
1854
1861
|
onLoadModel = ({ scene: e }) => {
|
|
1855
1862
|
e.traverse((t) => {
|
|
1856
1863
|
t.isMesh && (t.originalMaterial = t.material);
|
|
1857
|
-
}), this._materialType !==
|
|
1864
|
+
}), this._materialType !== L.DEFAULT && this.updateMaterial(e);
|
|
1858
1865
|
};
|
|
1859
1866
|
/**
|
|
1860
1867
|
* 更新场景中所有网格的材质(参考 customMaterial.js)
|
|
1861
1868
|
*/
|
|
1862
1869
|
updateMaterial = (e) => {
|
|
1863
1870
|
const t = this._materialType;
|
|
1864
|
-
e.traverse((
|
|
1865
|
-
if (
|
|
1866
|
-
switch (
|
|
1867
|
-
case
|
|
1868
|
-
|
|
1871
|
+
e.traverse((r) => {
|
|
1872
|
+
if (r.isMesh)
|
|
1873
|
+
switch (r.material && r.material !== r.originalMaterial && r.material.dispose(), t) {
|
|
1874
|
+
case L.DEFAULT:
|
|
1875
|
+
r.material = r.originalMaterial, r.material && (r.material.side = 2), r.receiveShadow = !1, r.castShadow = !1;
|
|
1869
1876
|
break;
|
|
1870
|
-
case
|
|
1871
|
-
|
|
1877
|
+
case L.GRADIENT:
|
|
1878
|
+
r.material = new ge(ut), r.material.side = 2, r.receiveShadow = !1, r.castShadow = !1;
|
|
1872
1879
|
break;
|
|
1873
|
-
case
|
|
1874
|
-
const
|
|
1875
|
-
|
|
1880
|
+
case L.TOPOGRAPHIC_LINES: {
|
|
1881
|
+
const s = new ge(ct);
|
|
1882
|
+
s.extensions = { derivatives: !0 }, s.side = 2, r.material = s, r.receiveShadow = !1, r.castShadow = !1;
|
|
1876
1883
|
break;
|
|
1877
1884
|
}
|
|
1878
|
-
case
|
|
1879
|
-
|
|
1885
|
+
case L.LIGHTING:
|
|
1886
|
+
r.material = new Ce(), r.material.side = 2, r.receiveShadow = !0, r.castShadow = !0;
|
|
1880
1887
|
break;
|
|
1881
1888
|
}
|
|
1882
1889
|
});
|
|
@@ -1910,21 +1917,21 @@ class nt {
|
|
|
1910
1917
|
disable() {
|
|
1911
1918
|
this.ssp.removeObject(this.tiles.group), this.ssp.signals.beforeRender.remove(this.beforeRenderHandler);
|
|
1912
1919
|
}
|
|
1913
|
-
invalidate(e, t,
|
|
1920
|
+
invalidate(e, t, r) {
|
|
1914
1921
|
if (!this.reorientationPlugin)
|
|
1915
1922
|
return console.warn(
|
|
1916
1923
|
"TilesRenderer: reorientationPlugin is not enabled, invalidate() will not work."
|
|
1917
1924
|
), () => {
|
|
1918
1925
|
};
|
|
1919
|
-
const
|
|
1926
|
+
const s = this.reorientationPlugin;
|
|
1920
1927
|
this.options.reorientation = {
|
|
1921
1928
|
lon: e,
|
|
1922
1929
|
lat: t,
|
|
1923
|
-
height:
|
|
1930
|
+
height: r
|
|
1924
1931
|
};
|
|
1925
1932
|
const a = () => {
|
|
1926
|
-
const o =
|
|
1927
|
-
|
|
1933
|
+
const o = T.degToRad(t), l = T.degToRad(e);
|
|
1934
|
+
s.transformLatLonHeightToOrigin(o, l, r), this.render(), n();
|
|
1928
1935
|
}, n = () => {
|
|
1929
1936
|
this.tiles.removeEventListener("load-root-tileset", a), this.loedTilesSets.delete(a);
|
|
1930
1937
|
};
|
|
@@ -1936,14 +1943,15 @@ class nt {
|
|
|
1936
1943
|
), 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();
|
|
1937
1944
|
}
|
|
1938
1945
|
}
|
|
1939
|
-
|
|
1946
|
+
const K = 2;
|
|
1947
|
+
class wt {
|
|
1940
1948
|
constructor(e) {
|
|
1941
1949
|
this.ssp = e;
|
|
1942
|
-
const { controls: t, viewport:
|
|
1943
|
-
this._tilesCamera =
|
|
1944
|
-
this.cameraTransitionStart = !0,
|
|
1950
|
+
const { controls: t, viewport: r } = e;
|
|
1951
|
+
this._tilesCamera = r.camera, t.addEventListener("transitionstart", () => {
|
|
1952
|
+
this.cameraTransitionStart = !0, r.state.useFreq = 1;
|
|
1945
1953
|
}), t.addEventListener("rest", () => {
|
|
1946
|
-
this.cameraTransitionStart = !1, this.needsUpdate = !0,
|
|
1954
|
+
this.cameraTransitionStart = !1, this.needsUpdate = !0, r.state.useFreq = 60;
|
|
1947
1955
|
}), e.signals.beforeRender.add(this._beforeRenderHandler), e.signals.cameraObjectChange.add(this._onCameraObjectChange);
|
|
1948
1956
|
}
|
|
1949
1957
|
/** 存储多个 tiles 实例,key 为 url */
|
|
@@ -1955,6 +1963,14 @@ class ft {
|
|
|
1955
1963
|
_lruCache = null;
|
|
1956
1964
|
_parseQueue = null;
|
|
1957
1965
|
_downloadQueue = null;
|
|
1966
|
+
_referenceOrigin = null;
|
|
1967
|
+
_referencePlacements = /* @__PURE__ */ new WeakMap();
|
|
1968
|
+
_referenceFrame = new W();
|
|
1969
|
+
_targetFrame = new W();
|
|
1970
|
+
_sourceFrame = new W();
|
|
1971
|
+
_placementMatrix = new W();
|
|
1972
|
+
_upCorrectionMatrix = new W();
|
|
1973
|
+
_boundingSphere = new ve();
|
|
1958
1974
|
_beforeRenderHandler = () => {
|
|
1959
1975
|
this.needsUpdate && (this.needsUpdate = !1, this.ssp.viewport.camera.updateMatrixWorld(), this.tilesMap.forEach((e) => {
|
|
1960
1976
|
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();
|
|
@@ -1965,6 +1981,26 @@ class ft {
|
|
|
1965
1981
|
e.tiles.deleteCamera(this._tilesCamera), e.tiles.setCamera(this.ssp.viewport.camera), e.tiles.setResolutionFromRenderer(this.ssp.viewport.camera, this.ssp.viewport.renderer);
|
|
1966
1982
|
}), this._tilesCamera = this.ssp.viewport.camera;
|
|
1967
1983
|
};
|
|
1984
|
+
get referenceOrigin() {
|
|
1985
|
+
return this._referenceOrigin;
|
|
1986
|
+
}
|
|
1987
|
+
setReferenceOrigin(e, t, r = 0.1) {
|
|
1988
|
+
this._referenceOrigin = typeof e == "number" ? {
|
|
1989
|
+
lon: e,
|
|
1990
|
+
lat: t ?? 0,
|
|
1991
|
+
height: r
|
|
1992
|
+
} : {
|
|
1993
|
+
lon: e.lon,
|
|
1994
|
+
lat: e.lat,
|
|
1995
|
+
height: e.height ?? 0.1
|
|
1996
|
+
}, this.tilesMap.forEach((s) => {
|
|
1997
|
+
const a = this._referencePlacements.get(s) ?? null;
|
|
1998
|
+
this.applyReferencePlacement(s, a);
|
|
1999
|
+
});
|
|
2000
|
+
}
|
|
2001
|
+
clearReferenceOrigin() {
|
|
2002
|
+
this._referenceOrigin = null;
|
|
2003
|
+
}
|
|
1968
2004
|
/**
|
|
1969
2005
|
* 加载 3D Tiles
|
|
1970
2006
|
* @param url - tileset.json 地址
|
|
@@ -1974,18 +2010,21 @@ class ft {
|
|
|
1974
2010
|
async loadTiles(e) {
|
|
1975
2011
|
const t = "url" in e ? e.url : e.assetId;
|
|
1976
2012
|
if (this.tilesMap.has(t))
|
|
1977
|
-
return
|
|
1978
|
-
const { ssp:
|
|
1979
|
-
...
|
|
2013
|
+
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 gt(r, {
|
|
2015
|
+
...a,
|
|
1980
2016
|
_managedByPlugin: !0
|
|
1981
|
-
})
|
|
1982
|
-
|
|
1983
|
-
const
|
|
1984
|
-
|
|
2017
|
+
});
|
|
2018
|
+
s && (this._referencePlacements.set(n, s), n.options.reorientation = s);
|
|
2019
|
+
const { tiles: o } = n;
|
|
2020
|
+
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 l = () => {
|
|
2022
|
+
this.cameraTransitionStart || (this.needsUpdate = !0, r.render());
|
|
1985
2023
|
};
|
|
1986
|
-
return
|
|
1987
|
-
|
|
1988
|
-
|
|
2024
|
+
return o.addEventListener("load-model", l), new Promise((u) => {
|
|
2025
|
+
o.addEventListener("load-tile-set", () => {
|
|
2026
|
+
const d = this._referencePlacements.get(n);
|
|
2027
|
+
this._referenceOrigin && this.applyReferencePlacement(n, d ?? null), l(), u(n);
|
|
1989
2028
|
});
|
|
1990
2029
|
});
|
|
1991
2030
|
}
|
|
@@ -2018,11 +2057,104 @@ class ft {
|
|
|
2018
2057
|
e.tiles.dispose(), this.ssp.removeObject(e.tiles.group);
|
|
2019
2058
|
}), this.tilesMap.clear();
|
|
2020
2059
|
}
|
|
2021
|
-
invalidate(e, t, s) {
|
|
2022
|
-
this.tilesMap.forEach((
|
|
2023
|
-
|
|
2060
|
+
invalidate(e, t, r, s) {
|
|
2061
|
+
(s ? [s] : Array.from(this.tilesMap.values())).forEach((n) => {
|
|
2062
|
+
const o = this._referencePlacements.get(n) ?? null;
|
|
2063
|
+
this._referenceOrigin ? this.applyReferencePlacement(n, {
|
|
2064
|
+
...o ?? {},
|
|
2065
|
+
lon: e,
|
|
2066
|
+
lat: t,
|
|
2067
|
+
height: r
|
|
2068
|
+
}) : n.invalidate(e, t, r);
|
|
2024
2069
|
});
|
|
2025
2070
|
}
|
|
2071
|
+
applyReferencePlacement(e, t) {
|
|
2072
|
+
if (!this._referenceOrigin)
|
|
2073
|
+
return z.utils.warn("TilesRendererManager: reference origin is not set."), !1;
|
|
2074
|
+
const { ellipsoid: r, group: s } = e.tiles, a = this._referenceOrigin, n = this._isGeoreferenced(e);
|
|
2075
|
+
if (r.getObjectFrame(
|
|
2076
|
+
T.degToRad(a.lat),
|
|
2077
|
+
T.degToRad(a.lon),
|
|
2078
|
+
a.height ?? 0.1,
|
|
2079
|
+
0,
|
|
2080
|
+
0,
|
|
2081
|
+
0,
|
|
2082
|
+
this._referenceFrame,
|
|
2083
|
+
K
|
|
2084
|
+
), this._placementMatrix.copy(this._referenceFrame).invert(), t)
|
|
2085
|
+
r.getObjectFrame(
|
|
2086
|
+
T.degToRad(t.lat),
|
|
2087
|
+
T.degToRad(t.lon),
|
|
2088
|
+
t.height ?? 0,
|
|
2089
|
+
0,
|
|
2090
|
+
0,
|
|
2091
|
+
0,
|
|
2092
|
+
this._targetFrame,
|
|
2093
|
+
K
|
|
2094
|
+
), this._placementMatrix.multiply(this._targetFrame), n ? (this._sourceFrame.copy(this._getSourceFrame(e)).invert(), this._placementMatrix.multiply(this._sourceFrame)) : (this._getUpCorrectionMatrix(t.up ?? "+z"), this._placementMatrix.multiply(this._upCorrectionMatrix));
|
|
2095
|
+
else if (!n)
|
|
2096
|
+
return !1;
|
|
2097
|
+
return s.matrix.copy(this._placementMatrix), s.matrix.decompose(s.position, s.quaternion, s.scale), s.updateMatrixWorld(!0), t && (this._referencePlacements.set(e, t), e.options.reorientation = t), this.needsUpdate = !0, e.render(), !0;
|
|
2098
|
+
}
|
|
2099
|
+
_isGeoreferenced(e) {
|
|
2100
|
+
const { tiles: t } = e;
|
|
2101
|
+
if (!t.getBoundingSphere(this._boundingSphere)) return !1;
|
|
2102
|
+
const r = Math.min(t.ellipsoid.radius.x, t.ellipsoid.radius.y, t.ellipsoid.radius.z);
|
|
2103
|
+
return this._boundingSphere.center.length() > r * 0.5;
|
|
2104
|
+
}
|
|
2105
|
+
_getSourceFrame(e) {
|
|
2106
|
+
const { tiles: t } = e, r = {
|
|
2107
|
+
lat: 0,
|
|
2108
|
+
lon: 0,
|
|
2109
|
+
height: 0
|
|
2110
|
+
};
|
|
2111
|
+
return t.getBoundingSphere(this._boundingSphere), t.ellipsoid.getPositionToCartographic(this._boundingSphere.center, r), t.ellipsoid.getObjectFrame(
|
|
2112
|
+
r.lat,
|
|
2113
|
+
r.lon,
|
|
2114
|
+
r.height,
|
|
2115
|
+
0,
|
|
2116
|
+
0,
|
|
2117
|
+
0,
|
|
2118
|
+
this._sourceFrame,
|
|
2119
|
+
K
|
|
2120
|
+
), this._sourceFrame;
|
|
2121
|
+
}
|
|
2122
|
+
_getReferencePlacement(e) {
|
|
2123
|
+
return e.placement === !1 ? null : e.placement ? e.placement : this._referenceOrigin && e.reorientation ? e.reorientation : null;
|
|
2124
|
+
}
|
|
2125
|
+
_getTilesRendererOptions(e, t) {
|
|
2126
|
+
const { placement: r, ...s } = e;
|
|
2127
|
+
return this._referenceOrigin ? {
|
|
2128
|
+
...s,
|
|
2129
|
+
autoCenter: !1,
|
|
2130
|
+
reorientation: t ? void 0 : s.reorientation
|
|
2131
|
+
} : s;
|
|
2132
|
+
}
|
|
2133
|
+
_getUpCorrectionMatrix(e) {
|
|
2134
|
+
switch (this._upCorrectionMatrix.identity(), e.toLowerCase().replace(/\s+/, "")) {
|
|
2135
|
+
case "x":
|
|
2136
|
+
case "+x":
|
|
2137
|
+
this._upCorrectionMatrix.makeRotationZ(Math.PI / 2);
|
|
2138
|
+
break;
|
|
2139
|
+
case "-x":
|
|
2140
|
+
this._upCorrectionMatrix.makeRotationZ(-Math.PI / 2);
|
|
2141
|
+
break;
|
|
2142
|
+
case "y":
|
|
2143
|
+
case "+y":
|
|
2144
|
+
break;
|
|
2145
|
+
case "-y":
|
|
2146
|
+
this._upCorrectionMatrix.makeRotationZ(Math.PI);
|
|
2147
|
+
break;
|
|
2148
|
+
case "z":
|
|
2149
|
+
case "+z":
|
|
2150
|
+
this._upCorrectionMatrix.makeRotationX(-Math.PI / 2);
|
|
2151
|
+
break;
|
|
2152
|
+
case "-z":
|
|
2153
|
+
this._upCorrectionMatrix.makeRotationX(Math.PI / 2);
|
|
2154
|
+
break;
|
|
2155
|
+
}
|
|
2156
|
+
return this._upCorrectionMatrix;
|
|
2157
|
+
}
|
|
2026
2158
|
/**
|
|
2027
2159
|
* 销毁插件
|
|
2028
2160
|
*/
|
|
@@ -2031,24 +2163,24 @@ class ft {
|
|
|
2031
2163
|
}
|
|
2032
2164
|
}
|
|
2033
2165
|
export {
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2166
|
+
Ot as ArcgisTilesRenderer,
|
|
2167
|
+
at as GisPlotArrow,
|
|
2168
|
+
C as GisPlotBase,
|
|
2169
|
+
ot as GisPlotCircle,
|
|
2170
|
+
Ye as GisPlotLine,
|
|
2171
|
+
Xe as GisPlotPoint,
|
|
2172
|
+
Ze as GisPlotPolygon,
|
|
2173
|
+
qe as GisPlotRectangle,
|
|
2174
|
+
Ve as GisPlotSector,
|
|
2175
|
+
nt as GisPlotText,
|
|
2176
|
+
lt as GroundDecalManager,
|
|
2177
|
+
L as MaterialType,
|
|
2178
|
+
B as OverlayManager,
|
|
2179
|
+
h as OverlayType,
|
|
2180
|
+
Tt as TerrainTilesRenderer,
|
|
2181
|
+
R as TerrainType,
|
|
2182
|
+
ze as TileCustomMaterialPlugin,
|
|
2183
|
+
gt as TilesRenderer,
|
|
2184
|
+
wt as TilesRendererManager,
|
|
2185
|
+
_t as default
|
|
2054
2186
|
};
|