@soonspacejs/plugin-tiles 2.14.37 → 2.15.0
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.esm.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import ee from "soonspacejs";
|
|
2
|
-
import { TilesRenderer as
|
|
3
|
-
import { GLTFLoader as
|
|
4
|
-
import { MathUtils as
|
|
5
|
-
import { TilesFadePlugin as te, UpdateOnChangePlugin as se, QuantizedMeshPlugin as
|
|
6
|
-
import { PlotOverlay as Re } from "um-3d-tiles-renderer/three/plugins";
|
|
2
|
+
import { TilesRenderer as x } from "um-3d-tiles-renderer";
|
|
3
|
+
import { GLTFLoader as ge } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
4
|
+
import { MathUtils as L, MeshBasicMaterial as pe, Color as z, Vector3 as _e, Box3 as Te, Sphere as Oe, MeshStandardMaterial as we, ShaderMaterial as he } from "three";
|
|
5
|
+
import { TilesFadePlugin as te, UpdateOnChangePlugin as se, QuantizedMeshPlugin as $, ImageOverlayPlugin as me, XYZTilesOverlay as fe, ReorientationPlugin as re, GeoJSONOverlay as Se, CesiumIonOverlay as Pe, TMSTilesOverlay as Ce, UrlTemplateTilesOverlay as Le, WMSTilesOverlay as Ee, WMTSCapabilitiesLoader as Ie, WMTSTilesOverlay as be, CesiumIonAuthPlugin as ye, PlotSdfPlugin as Re } from "um-3d-tiles-renderer/plugins";
|
|
7
6
|
class xe {
|
|
8
7
|
constructor(e) {
|
|
9
8
|
this.parser = e, this.name = "KHR_texture_basisu_patch";
|
|
@@ -18,7 +17,7 @@ class xe {
|
|
|
18
17
|
return t.loadTextureImage(e, a, o);
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
|
-
class
|
|
20
|
+
class ct {
|
|
22
21
|
constructor(e) {
|
|
23
22
|
this.ssp = e;
|
|
24
23
|
const { controls: t, viewport: s } = e;
|
|
@@ -48,18 +47,18 @@ class gt {
|
|
|
48
47
|
ee.utils.warn(`${e} already loaded`);
|
|
49
48
|
return;
|
|
50
49
|
}
|
|
51
|
-
const { ssp: t, ssp: { viewport: s } } = this, r = new
|
|
50
|
+
const { ssp: t, ssp: { viewport: s } } = this, r = new x(e);
|
|
52
51
|
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
|
|
54
|
-
a.register((
|
|
55
|
-
const { dracoLoader: n, ktx2Loader: o, meshoptDecoder:
|
|
56
|
-
n && a.setDRACOLoader(n), o && a.setKTX2Loader(o),
|
|
52
|
+
const a = new ge(r.manager);
|
|
53
|
+
a.register((h) => new xe(h));
|
|
54
|
+
const { dracoLoader: n, ktx2Loader: o, meshoptDecoder: d } = t.manager.store.modelManager.gltfLoader;
|
|
55
|
+
n && a.setDRACOLoader(n), o && a.setKTX2Loader(o), d && a.setMeshoptDecoder(d), 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
56
|
const u = () => {
|
|
58
57
|
this.cameraTransitionStart || (this.needsUpdate = !0, t.render());
|
|
59
58
|
};
|
|
60
|
-
return r.addEventListener("load-model", u), new Promise((
|
|
59
|
+
return r.addEventListener("load-model", u), new Promise((h) => {
|
|
61
60
|
r.addEventListener("load-tile-set", () => {
|
|
62
|
-
u(),
|
|
61
|
+
u(), h(r);
|
|
63
62
|
});
|
|
64
63
|
});
|
|
65
64
|
}
|
|
@@ -72,23 +71,23 @@ let ke = class {
|
|
|
72
71
|
priority = -999;
|
|
73
72
|
processTileModel(e) {
|
|
74
73
|
e.traverse((t) => {
|
|
75
|
-
t.material && (t.material = new
|
|
74
|
+
t.material && (t.material = new pe());
|
|
76
75
|
});
|
|
77
76
|
}
|
|
78
77
|
};
|
|
79
78
|
const De = "https://sooncps.xwbuilders.com/api/ugis-dataprocess/v1/terrain/NhBLlMx3/";
|
|
80
|
-
class
|
|
79
|
+
class pt {
|
|
81
80
|
constructor(e) {
|
|
82
|
-
this.ssp = e, this.tiles = new
|
|
81
|
+
this.ssp = e, this.tiles = new x(De), this.tiles.fetchData = async (t, s) => {
|
|
83
82
|
if (/layer\.json$/.test(t)) {
|
|
84
83
|
const r = await fetch(t, s).then((a) => a.json());
|
|
85
84
|
return r.metadataAvailability = -1, new Response(JSON.stringify(r));
|
|
86
85
|
}
|
|
87
86
|
return fetch(t, s);
|
|
88
|
-
}, this.tilesFadePlugin = new te({ maximumFadeOutTiles: 200 }), this.updateOnChangePlugin = new se(), this.quantizedPlugin = new
|
|
87
|
+
}, this.tilesFadePlugin = new te({ maximumFadeOutTiles: 200 }), this.updateOnChangePlugin = new se(), this.quantizedPlugin = new $({}), this.customMaterialPlugin = new ke(), this.imageOverlayPlugin = new me({
|
|
89
88
|
renderer: e.viewport.renderer,
|
|
90
89
|
overlays: [
|
|
91
|
-
new
|
|
90
|
+
new fe({
|
|
92
91
|
url: "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
|
|
93
92
|
})
|
|
94
93
|
]
|
|
@@ -123,7 +122,7 @@ class mt {
|
|
|
123
122
|
}
|
|
124
123
|
invalidate(e, t, s) {
|
|
125
124
|
const r = () => {
|
|
126
|
-
const n =
|
|
125
|
+
const n = L.degToRad(t), o = L.degToRad(e);
|
|
127
126
|
this.reorientationPlugin.transformLatLonHeightToOrigin(
|
|
128
127
|
n,
|
|
129
128
|
o,
|
|
@@ -140,10 +139,10 @@ class mt {
|
|
|
140
139
|
), this.loedTilesSets.clear(), this.tiles.removeEventListener("needs-render", this.render), this.tiles.removeEventListener("needs-update", this.render), this.tiles.dispose();
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
|
-
class
|
|
142
|
+
class Fe {
|
|
144
143
|
// 使用较低的 priority 确保在 ImageOverlayPlugin 之后执行
|
|
145
144
|
// ImageOverlayPlugin 默认 priority 是 -1
|
|
146
|
-
priority = -
|
|
145
|
+
priority = -999;
|
|
147
146
|
/** Alpha 裁剪模式 */
|
|
148
147
|
alphaClipMode = "alphaTest";
|
|
149
148
|
/**
|
|
@@ -151,7 +150,7 @@ class Ne {
|
|
|
151
150
|
*/
|
|
152
151
|
processTileModel(e) {
|
|
153
152
|
e.traverse((t) => {
|
|
154
|
-
t.material &&
|
|
153
|
+
t.material && (t.material = new pe());
|
|
155
154
|
});
|
|
156
155
|
}
|
|
157
156
|
/**
|
|
@@ -161,7 +160,7 @@ class Ne {
|
|
|
161
160
|
updateAllLoadedModels(e) {
|
|
162
161
|
e.forEachLoadedModel((t) => {
|
|
163
162
|
t.traverse((s) => {
|
|
164
|
-
s.material
|
|
163
|
+
s.material;
|
|
165
164
|
});
|
|
166
165
|
});
|
|
167
166
|
}
|
|
@@ -183,8 +182,8 @@ class Ne {
|
|
|
183
182
|
e.needsUpdate = !0;
|
|
184
183
|
}
|
|
185
184
|
}
|
|
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 || {}),
|
|
187
|
-
class
|
|
185
|
+
var l = /* @__PURE__ */ ((i) => (i.GEOJSON = "geojson", i.CESIUM_ION = "cesiumIon", i.TMS = "tms", i.XYZ = "xyz", i.WMS = "wms", i.WMTS = "wmts", i.URL_TEMPLATE = "urlTemplate", i.PLOT = "plot", i))(l || {}), C = /* @__PURE__ */ ((i) => (i.QUANTIZED_MESH = "quantizedMesh", i.CESIUM_ION = "cesiumIon", i))(C || {});
|
|
186
|
+
class Ne {
|
|
188
187
|
constructor(e, t) {
|
|
189
188
|
this.imageOverlayPlugin = e, this.resourceManager = t;
|
|
190
189
|
}
|
|
@@ -204,7 +203,7 @@ class Ae {
|
|
|
204
203
|
strokeWidth: e.strokeWidth
|
|
205
204
|
};
|
|
206
205
|
e.color && (t.color = new z(e.color));
|
|
207
|
-
const s = new
|
|
206
|
+
const s = new Se(t);
|
|
208
207
|
return this.imageOverlayPlugin.addOverlay(s, e.order), this._instances.set(e.id, {
|
|
209
208
|
id: e.id,
|
|
210
209
|
type: l.GEOJSON,
|
|
@@ -250,7 +249,7 @@ class Ae {
|
|
|
250
249
|
if (!this.imageOverlayPlugin) return null;
|
|
251
250
|
if (this._instances.has(e.id))
|
|
252
251
|
return console.warn(`OverlayManager: Overlay "${e.id}" already exists`), null;
|
|
253
|
-
const t = new
|
|
252
|
+
const t = new Pe({
|
|
254
253
|
assetId: e.assetId,
|
|
255
254
|
apiToken: e.apiToken,
|
|
256
255
|
autoRefreshToken: e.autoRefreshToken ?? !0,
|
|
@@ -292,7 +291,7 @@ class Ae {
|
|
|
292
291
|
if (!this.imageOverlayPlugin) return null;
|
|
293
292
|
if (this._instances.has(e.id))
|
|
294
293
|
return console.warn(`OverlayManager: Overlay "${e.id}" already exists`), null;
|
|
295
|
-
const t = new
|
|
294
|
+
const t = new fe({
|
|
296
295
|
url: e.url,
|
|
297
296
|
color: typeof e.color == "number" ? e.color : 16777215,
|
|
298
297
|
opacity: e.opacity ?? 1
|
|
@@ -585,7 +584,7 @@ class Ae {
|
|
|
585
584
|
this.disposeInstances(), this.resourceManager?.clear();
|
|
586
585
|
}
|
|
587
586
|
}
|
|
588
|
-
class
|
|
587
|
+
class Ae {
|
|
589
588
|
/** Overlay 资源配置 */
|
|
590
589
|
_overlays = /* @__PURE__ */ new Map();
|
|
591
590
|
// =============== Overlay 资源管理 ===============
|
|
@@ -675,7 +674,7 @@ class Fe {
|
|
|
675
674
|
e.overlays && (this._overlays.clear(), e.overlays.forEach((t) => this._overlays.set(t.id, { ...t })));
|
|
676
675
|
}
|
|
677
676
|
}
|
|
678
|
-
class
|
|
677
|
+
class Ue {
|
|
679
678
|
/** 地形配置映射表 */
|
|
680
679
|
_terrains = /* @__PURE__ */ new Map();
|
|
681
680
|
/** 当前激活的地形 ID */
|
|
@@ -764,13 +763,13 @@ class Ge {
|
|
|
764
763
|
this.clear();
|
|
765
764
|
}
|
|
766
765
|
}
|
|
767
|
-
let
|
|
768
|
-
class
|
|
766
|
+
let Ge = 1;
|
|
767
|
+
class P {
|
|
769
768
|
id;
|
|
770
769
|
category = "";
|
|
771
770
|
options;
|
|
772
771
|
constructor(e) {
|
|
773
|
-
this.id = String(
|
|
772
|
+
this.id = String(Ge++), this.category = "", this.options = { ...e }, this.options.points && (this.options.points = this.options.points.map((t) => [t[0], t[1]]));
|
|
774
773
|
}
|
|
775
774
|
/**
|
|
776
775
|
* 合并更新 `options`(不可变风格:整表替换为新对象)。
|
|
@@ -803,7 +802,7 @@ class S {
|
|
|
803
802
|
return this.options.points || [];
|
|
804
803
|
}
|
|
805
804
|
}
|
|
806
|
-
class We extends
|
|
805
|
+
class We extends P {
|
|
807
806
|
category = "point";
|
|
808
807
|
constructor(e) {
|
|
809
808
|
super(e);
|
|
@@ -819,7 +818,7 @@ class We extends S {
|
|
|
819
818
|
return this.getCenterPoints();
|
|
820
819
|
}
|
|
821
820
|
}
|
|
822
|
-
class Qe extends
|
|
821
|
+
class Qe extends P {
|
|
823
822
|
category = "line";
|
|
824
823
|
constructor(e) {
|
|
825
824
|
super(e);
|
|
@@ -828,7 +827,7 @@ class Qe extends S {
|
|
|
828
827
|
this.options = { ...this.options, ...e };
|
|
829
828
|
}
|
|
830
829
|
}
|
|
831
|
-
class
|
|
830
|
+
class He extends P {
|
|
832
831
|
category = "polygon";
|
|
833
832
|
constructor(e) {
|
|
834
833
|
super(e);
|
|
@@ -837,9 +836,7 @@ class je extends S {
|
|
|
837
836
|
this.options = { ...this.options, ...e };
|
|
838
837
|
}
|
|
839
838
|
}
|
|
840
|
-
|
|
841
|
-
new _e();
|
|
842
|
-
class He extends S {
|
|
839
|
+
class je extends P {
|
|
843
840
|
category = "rectangle";
|
|
844
841
|
constructor(e) {
|
|
845
842
|
super(e);
|
|
@@ -847,18 +844,10 @@ class He extends S {
|
|
|
847
844
|
update(e) {
|
|
848
845
|
this.options = { ...this.options, ...e };
|
|
849
846
|
}
|
|
850
|
-
getExtentPoints() {
|
|
851
|
-
const e = this.options.points;
|
|
852
|
-
if (!e || e.length === 0) return [];
|
|
853
|
-
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;
|
|
854
|
-
return [
|
|
855
|
-
[t, s],
|
|
856
|
-
[t - n, s - o],
|
|
857
|
-
[t + n, s + o]
|
|
858
|
-
];
|
|
859
|
-
}
|
|
860
847
|
}
|
|
861
|
-
|
|
848
|
+
const ve = L.DEG2RAD;
|
|
849
|
+
new _e();
|
|
850
|
+
class Be extends P {
|
|
862
851
|
category = "sector";
|
|
863
852
|
constructor(e) {
|
|
864
853
|
super(e);
|
|
@@ -869,123 +858,123 @@ class Be extends S {
|
|
|
869
858
|
getExtentPoints() {
|
|
870
859
|
const e = this.options.points;
|
|
871
860
|
if (!e || e.length === 0) return [];
|
|
872
|
-
const t = e[0][0], s = e[0][1], r = this.options.radius || 0, a = r / (111320 * Math.cos(s *
|
|
861
|
+
const t = e[0][0], s = e[0][1], r = this.options.radius || 0, a = r / (111320 * Math.cos(s * ve)), n = r / 111320;
|
|
873
862
|
return [
|
|
874
863
|
[t - a, s - n],
|
|
875
864
|
[t + a, s + n]
|
|
876
865
|
];
|
|
877
866
|
}
|
|
878
867
|
}
|
|
879
|
-
const
|
|
880
|
-
function
|
|
868
|
+
const ue = 100, ie = 1e-4;
|
|
869
|
+
function O(i, e) {
|
|
881
870
|
return Math.sqrt((i[0] - e[0]) ** 2 + (i[1] - e[1]) ** 2);
|
|
882
871
|
}
|
|
883
|
-
function
|
|
872
|
+
function ae(i) {
|
|
884
873
|
let e = 0;
|
|
885
874
|
for (let t = 0; t < i.length - 1; t++)
|
|
886
|
-
e +=
|
|
875
|
+
e += O(i[t], i[t + 1]);
|
|
887
876
|
return e;
|
|
888
877
|
}
|
|
889
878
|
function Q(i) {
|
|
890
|
-
return
|
|
879
|
+
return ae(i) ** 0.99;
|
|
891
880
|
}
|
|
892
|
-
function
|
|
881
|
+
function ne(i, e) {
|
|
893
882
|
return [(i[0] + e[0]) / 2, (i[1] + e[1]) / 2];
|
|
894
883
|
}
|
|
895
|
-
function
|
|
884
|
+
function q(i, e) {
|
|
896
885
|
const t = Math.asin(
|
|
897
|
-
Math.abs(e[1] - i[1]) /
|
|
886
|
+
Math.abs(e[1] - i[1]) / O(i, e)
|
|
898
887
|
);
|
|
899
888
|
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;
|
|
900
889
|
}
|
|
901
890
|
function Je(i, e, t) {
|
|
902
|
-
const s =
|
|
891
|
+
const s = q(e, i) - q(e, t);
|
|
903
892
|
return s < 0 ? s + Math.PI * 2 : s;
|
|
904
893
|
}
|
|
905
|
-
function
|
|
894
|
+
function Me(i, e, t) {
|
|
906
895
|
return (t[1] - i[1]) * (e[0] - i[0]) > (e[1] - i[1]) * (t[0] - i[0]);
|
|
907
896
|
}
|
|
908
|
-
function
|
|
909
|
-
const a =
|
|
897
|
+
function f(i, e, t, s, r) {
|
|
898
|
+
const a = q(i, e), n = r ? a + t : a - t;
|
|
910
899
|
return [e[0] + s * Math.cos(n), e[1] + s * Math.sin(n)];
|
|
911
900
|
}
|
|
912
|
-
function
|
|
901
|
+
function oe(i, e, t) {
|
|
913
902
|
let s = i[0] - e[0], r = i[1] - e[1];
|
|
914
903
|
const a = Math.sqrt(s * s + r * r);
|
|
915
904
|
s /= a, r /= a;
|
|
916
905
|
let n = t[0] - e[0], o = t[1] - e[1];
|
|
917
|
-
const
|
|
918
|
-
return n /=
|
|
906
|
+
const d = Math.sqrt(n * n + o * o);
|
|
907
|
+
return n /= d, o /= d, [s + n, r + o];
|
|
919
908
|
}
|
|
920
|
-
function
|
|
921
|
-
const r =
|
|
922
|
-
let
|
|
923
|
-
if (a >
|
|
924
|
-
const
|
|
925
|
-
|
|
909
|
+
function le(i, e, t, s) {
|
|
910
|
+
const r = oe(e, t, s), a = Math.sqrt(r[0] ** 2 + r[1] ** 2), n = O(e, t), o = O(t, s);
|
|
911
|
+
let d, u;
|
|
912
|
+
if (a > ie) {
|
|
913
|
+
const h = r[0] / a, c = r[1] / a;
|
|
914
|
+
Me(e, t, s) ? (d = [t[0] - i * n * c, t[1] + i * n * h], u = [t[0] + i * o * c, t[1] - i * o * h]) : (d = [t[0] + i * n * c, t[1] - i * n * h], u = [t[0] - i * o * c, t[1] + i * o * h]);
|
|
926
915
|
} else
|
|
927
|
-
|
|
928
|
-
return [
|
|
916
|
+
d = [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])];
|
|
917
|
+
return [d, u];
|
|
929
918
|
}
|
|
930
919
|
function ze(i, e) {
|
|
931
|
-
const [t, s, r] = [i[0], i[1], i[2]], n =
|
|
932
|
-
if (Math.sqrt(o[0] ** 2 + o[1] ** 2) >
|
|
933
|
-
const u =
|
|
934
|
-
return [u[0] +
|
|
920
|
+
const [t, s, r] = [i[0], i[1], i[2]], n = le(0, t, s, r)[0], o = oe(t, s, r);
|
|
921
|
+
if (Math.sqrt(o[0] ** 2 + o[1] ** 2) > ie) {
|
|
922
|
+
const u = ne(t, s), h = t[0] - u[0], c = t[1] - u[1], g = 2 / O(t, s), m = -g * c, p = g * h, y = m * m - p * p, M = 2 * m * p, _ = p * p - m * m, w = n[0] - u[0], S = n[1] - u[1];
|
|
923
|
+
return [u[0] + y * w + M * S, u[1] + M * w + _ * S];
|
|
935
924
|
}
|
|
936
925
|
return [t[0] + e * (s[0] - t[0]), t[1] + e * (s[1] - t[1])];
|
|
937
926
|
}
|
|
938
927
|
function Xe(i, e) {
|
|
939
|
-
const t = i.length, [s, r, a] = [i[t - 3], i[t - 2], i[t - 1]], o =
|
|
940
|
-
if (Math.sqrt(
|
|
941
|
-
const
|
|
942
|
-
return [
|
|
928
|
+
const t = i.length, [s, r, a] = [i[t - 3], i[t - 2], i[t - 1]], o = le(0, s, r, a)[1], d = oe(s, r, a);
|
|
929
|
+
if (Math.sqrt(d[0] ** 2 + d[1] ** 2) > ie) {
|
|
930
|
+
const h = ne(r, a), c = a[0] - h[0], g = a[1] - h[1], m = 2 / O(r, a), p = -m * g, y = m * c, M = p * p - y * y, _ = 2 * p * y, w = y * y - p * p, S = o[0] - h[0], E = o[1] - h[1];
|
|
931
|
+
return [h[0] + M * S + _ * E, h[1] + _ * S + w * E];
|
|
943
932
|
}
|
|
944
933
|
return [a[0] + e * (r[0] - a[0]), a[1] + e * (r[1] - a[1])];
|
|
945
934
|
}
|
|
946
935
|
function Ye(i, e) {
|
|
947
936
|
let s = [ze(e, i)];
|
|
948
937
|
for (let n = 0; n < e.length - 2; n++) {
|
|
949
|
-
const o =
|
|
938
|
+
const o = le(i, e[n], e[n + 1], e[n + 2]);
|
|
950
939
|
s = s.concat(o);
|
|
951
940
|
}
|
|
952
941
|
const r = Xe(e, i);
|
|
953
942
|
r && s.push(r);
|
|
954
943
|
const a = [];
|
|
955
944
|
for (let n = 0; n < e.length - 1; n++) {
|
|
956
|
-
const o = e[n],
|
|
945
|
+
const o = e[n], d = e[n + 1];
|
|
957
946
|
a.push(o);
|
|
958
|
-
for (let u = 0; u <
|
|
959
|
-
const
|
|
947
|
+
for (let u = 0; u < ue; u++) {
|
|
948
|
+
const h = u / ue, c = 1 - h, g = h * h, m = g * h, p = c * c, y = p * c, M = s[n * 2], _ = s[n * 2 + 1];
|
|
960
949
|
a.push([
|
|
961
|
-
|
|
962
|
-
|
|
950
|
+
y * o[0] + 3 * p * h * M[0] + 3 * c * g * _[0] + m * d[0],
|
|
951
|
+
y * o[1] + 3 * p * h * M[1] + 3 * c * g * _[1] + m * d[1]
|
|
963
952
|
]);
|
|
964
953
|
}
|
|
965
|
-
a.push(
|
|
954
|
+
a.push(d);
|
|
966
955
|
}
|
|
967
956
|
return a;
|
|
968
957
|
}
|
|
969
|
-
function
|
|
958
|
+
function Ze(i, e) {
|
|
970
959
|
return i === 0 ? (e - 1) ** 2 / 2 : i === 1 ? (-2 * e ** 2 + 2 * e + 1) / 2 : i === 2 ? e ** 2 / 2 : 0;
|
|
971
960
|
}
|
|
972
|
-
function
|
|
961
|
+
function ce(i) {
|
|
973
962
|
if (i.length <= 2) return i;
|
|
974
963
|
const e = [i[0]], t = i.length - 3;
|
|
975
964
|
for (let s = 0; s <= t; s++)
|
|
976
965
|
for (let r = 0; r <= 1; r += 0.05) {
|
|
977
966
|
let a = 0, n = 0;
|
|
978
967
|
for (let o = 0; o <= 2; o++) {
|
|
979
|
-
const
|
|
980
|
-
a +=
|
|
968
|
+
const d = Ze(o, r);
|
|
969
|
+
a += d * i[s + o][0], n += d * i[s + o][1];
|
|
981
970
|
}
|
|
982
971
|
e.push([a, n]);
|
|
983
972
|
}
|
|
984
973
|
return e.push(i[i.length - 1]), e;
|
|
985
974
|
}
|
|
986
975
|
function V(i, e) {
|
|
987
|
-
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,
|
|
988
|
-
return [
|
|
976
|
+
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, d = f(e, i, Math.PI / 2, s, !0), u = f(e, i, Math.PI / 2, s, !1), h = f(i, e, n, a, !1), c = f(i, e, n, a, !0), g = f(i, e, o, r, !1), m = f(i, e, o, r, !0);
|
|
977
|
+
return [d, g, h, e, c, m, u, i];
|
|
989
978
|
}
|
|
990
979
|
function K(i, e) {
|
|
991
980
|
if (i.length <= e) return i;
|
|
@@ -994,43 +983,43 @@ function K(i, e) {
|
|
|
994
983
|
t.push(i[Math.round(r * s)]);
|
|
995
984
|
return t.push(i[i.length - 1]), t;
|
|
996
985
|
}
|
|
997
|
-
function
|
|
986
|
+
function $e(i) {
|
|
998
987
|
if (i.length === 2)
|
|
999
988
|
return V(i[0], i[1]);
|
|
1000
|
-
const e = Ye(0.3, i), t = K(e, 25), s =
|
|
989
|
+
const e = Ye(0.3, i), t = K(e, 25), s = ae(t), r = 0.08, a = 0.12, n = 0.2, o = Math.PI / 8.5, d = Math.PI / 13, u = 0.15, h = s * r, c = s * u, g = [], m = [];
|
|
1001
990
|
let p = 0;
|
|
1002
|
-
const
|
|
1003
|
-
for (let v = 0; v < t.length && (v > 0 && (p +=
|
|
1004
|
-
const
|
|
1005
|
-
g.push([t[v][0] + G *
|
|
991
|
+
const y = s - c;
|
|
992
|
+
for (let v = 0; v < t.length && (v > 0 && (p += O(t[v - 1], t[v])), !(p > y)); v++) {
|
|
993
|
+
const j = y > 0 ? p / y : 0, F = h * (1 - j * 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], I = W[1] - N[1], U = Math.sqrt(A * A + I * I) || 1, G = -I / U, b = A / U;
|
|
994
|
+
g.push([t[v][0] + G * F, t[v][1] + b * F]), m.push([t[v][0] - G * F, t[v][1] - b * F]);
|
|
1006
995
|
}
|
|
1007
|
-
const M = t[t.length - 1], _ = t[t.length - 2], w = s * a,
|
|
1008
|
-
return [...g,
|
|
996
|
+
const M = t[t.length - 1], _ = t[t.length - 2], w = s * a, S = s * n, E = f(_, M, d, w, !1), k = f(_, M, d, w, !0), D = f(_, M, o, S, !1), H = f(_, M, o, S, !0);
|
|
997
|
+
return [...g, E, D, M, H, k, ...m.reverse()];
|
|
1009
998
|
}
|
|
1010
|
-
function
|
|
999
|
+
function qe(i) {
|
|
1011
1000
|
let e = i[0], t = i[1];
|
|
1012
|
-
|
|
1013
|
-
const r = [
|
|
1014
|
-
let
|
|
1001
|
+
Me(i[0], i[1], i[2]) && (e = i[1], t = i[0]);
|
|
1002
|
+
const r = [ne(e, t), ...i.slice(2)], a = 0.18, n = 0.3, o = 0.85, d = 0.15, u = 0.8;
|
|
1003
|
+
let h = Q(r), c = h * a;
|
|
1015
1004
|
const g = r[r.length - 1];
|
|
1016
|
-
|
|
1017
|
-
const m =
|
|
1005
|
+
h = O(g, r[r.length - 2]);
|
|
1006
|
+
const m = O(e, t);
|
|
1018
1007
|
c > m * u && (c = m * u);
|
|
1019
|
-
const p = c * n,
|
|
1020
|
-
c = Math.min(c,
|
|
1021
|
-
const M = c * o, _ =
|
|
1022
|
-
let
|
|
1023
|
-
const
|
|
1024
|
-
for (let
|
|
1025
|
-
const J = Je(r[
|
|
1026
|
-
|
|
1027
|
-
const de = (N / 2 -
|
|
1028
|
-
|
|
1029
|
-
}
|
|
1030
|
-
let
|
|
1031
|
-
return
|
|
1008
|
+
const p = c * n, y = c * d;
|
|
1009
|
+
c = Math.min(c, h);
|
|
1010
|
+
const M = c * o, _ = f(r[r.length - 2], g, 0, c, !0), w = f(r[r.length - 2], g, 0, M, !0), S = f(g, _, Math.PI / 2, p, !1), E = f(g, _, Math.PI / 2, p, !0), k = f(g, w, Math.PI / 2, y, !1), D = f(g, w, Math.PI / 2, y, !0), H = [k, S, g, E, D], v = m / Q(r), j = ae(r), N = Q(r) * v, W = O(k, D), A = (N - W) / 2;
|
|
1011
|
+
let I = 0;
|
|
1012
|
+
const U = [], G = [];
|
|
1013
|
+
for (let T = 1; T < r.length - 1; T++) {
|
|
1014
|
+
const J = Je(r[T - 1], r[T], r[T + 1]) / 2;
|
|
1015
|
+
I += O(r[T - 1], r[T]);
|
|
1016
|
+
const de = (N / 2 - I / j * A) / Math.sin(J);
|
|
1017
|
+
U.push(f(r[T - 1], r[T], Math.PI - J, de, !0)), G.push(f(r[T - 1], r[T], J, de, !1));
|
|
1018
|
+
}
|
|
1019
|
+
let b = [e, ...U, k], B = [t, ...G, D];
|
|
1020
|
+
return b = K(ce(b), 25), B = K(ce(B), 25), [...b, ...H, ...B.reverse()];
|
|
1032
1021
|
}
|
|
1033
|
-
class Ve extends
|
|
1022
|
+
class Ve extends P {
|
|
1034
1023
|
category = "arrow";
|
|
1035
1024
|
/** `generateCoords()` 填充的闭合多边形顶点 */
|
|
1036
1025
|
generatedCoords = [];
|
|
@@ -1048,7 +1037,7 @@ class Ve extends S {
|
|
|
1048
1037
|
if (!e || e.length < 2)
|
|
1049
1038
|
return this.generatedCoords = [], [];
|
|
1050
1039
|
const t = this.options.arrowType || "straight";
|
|
1051
|
-
return t === "fine" ? this.generatedCoords = V(e[0], e[1]) : t === "curved" ? this.generatedCoords =
|
|
1040
|
+
return t === "fine" ? this.generatedCoords = V(e[0], e[1]) : t === "curved" ? this.generatedCoords = $e(e) : t === "attack" && e.length >= 3 ? this.generatedCoords = qe(e) : this.generatedCoords = V(e[0], e[e.length - 1]), this.generatedCoords;
|
|
1052
1041
|
}
|
|
1053
1042
|
/** 浅拷贝:`options`、`generatedCoords` 与内部共享引用(顶点数组仍与 `options.points` 规则一致)。 */
|
|
1054
1043
|
getSnapshot() {
|
|
@@ -1068,7 +1057,7 @@ class Ve extends S {
|
|
|
1068
1057
|
};
|
|
1069
1058
|
}
|
|
1070
1059
|
}
|
|
1071
|
-
class Ke extends
|
|
1060
|
+
class Ke extends P {
|
|
1072
1061
|
category = "text";
|
|
1073
1062
|
constructor(e) {
|
|
1074
1063
|
super(e);
|
|
@@ -1084,7 +1073,7 @@ class Ke extends S {
|
|
|
1084
1073
|
return this.getCenterPoints();
|
|
1085
1074
|
}
|
|
1086
1075
|
}
|
|
1087
|
-
class et extends
|
|
1076
|
+
class et extends P {
|
|
1088
1077
|
category = "circle";
|
|
1089
1078
|
constructor(e) {
|
|
1090
1079
|
super(e);
|
|
@@ -1095,7 +1084,7 @@ class et extends S {
|
|
|
1095
1084
|
getExtentPoints() {
|
|
1096
1085
|
const e = this.options.points;
|
|
1097
1086
|
if (!e || e.length === 0) return [];
|
|
1098
|
-
const t = e[0][0], s = e[0][1], r = this.options.radius || 0, a = r / (111320 * Math.cos(s *
|
|
1087
|
+
const t = e[0][0], s = e[0][1], r = this.options.radius || 0, a = r / (111320 * Math.cos(s * ve)), n = r / 111320;
|
|
1099
1088
|
return [
|
|
1100
1089
|
[t - a, s - n],
|
|
1101
1090
|
[t + a, s + n]
|
|
@@ -1107,32 +1096,30 @@ class tt {
|
|
|
1107
1096
|
_items = /* @__PURE__ */ new Map();
|
|
1108
1097
|
/** 标绘 id */
|
|
1109
1098
|
id = "GROUND_DECAL_PLOT";
|
|
1110
|
-
/** 标绘 overlay */
|
|
1111
|
-
_overlay;
|
|
1112
1099
|
/** SoonSpace 实例 */
|
|
1113
1100
|
ssp;
|
|
1114
|
-
/** 传入的
|
|
1115
|
-
|
|
1116
|
-
/** overlay 是否已注册到
|
|
1101
|
+
/** 传入的 PlotSDFPlugin,用于在有图形时自动注册 overlay */
|
|
1102
|
+
_plotSdfPlugin;
|
|
1103
|
+
/** overlay 是否已注册到 PlotSDFPlugin */
|
|
1117
1104
|
_overlayAttached = !1;
|
|
1118
1105
|
/** 合并同一帧内多次 `_markDirty`,值为 `requestAnimationFrame` 句柄 */
|
|
1119
1106
|
_redrawTimer = null;
|
|
1120
1107
|
constructor(e) {
|
|
1121
|
-
this.ssp = e.ssp
|
|
1108
|
+
this.ssp = e.ssp;
|
|
1122
1109
|
}
|
|
1123
1110
|
/**
|
|
1124
1111
|
* 内部使用的 `PlotOverlay` 实例。
|
|
1125
1112
|
* 注册到 `ImageOverlayPlugin` 的 `overlays` 数组中,顺序靠后者通常绘制在上层。
|
|
1126
1113
|
*/
|
|
1127
|
-
get
|
|
1128
|
-
return this.
|
|
1114
|
+
get plotSdfPlugin() {
|
|
1115
|
+
return this._plotSdfPlugin;
|
|
1129
1116
|
}
|
|
1130
1117
|
/**
|
|
1131
|
-
* 绑定 / 更换
|
|
1118
|
+
* 绑定 / 更换 PlotOverlayPlugin(切换地形重建插件后调用)。
|
|
1132
1119
|
* 如果当前已有图形,会在下一帧自动重新注册 overlay。
|
|
1133
1120
|
*/
|
|
1134
|
-
|
|
1135
|
-
this.
|
|
1121
|
+
setPlotSDFPlugin(e) {
|
|
1122
|
+
this._plotSdfPlugin = e, this._overlayAttached = !1, this._items.size > 0 && this._markDirty();
|
|
1136
1123
|
}
|
|
1137
1124
|
// ── 图形创建:返回字符串 id,可用于后续查询 / 更新 / 删除 ──
|
|
1138
1125
|
/**
|
|
@@ -1153,12 +1140,12 @@ class tt {
|
|
|
1153
1140
|
}
|
|
1154
1141
|
case "polygon": {
|
|
1155
1142
|
const { type: s, ...r } = e;
|
|
1156
|
-
t = new
|
|
1143
|
+
t = new He(r);
|
|
1157
1144
|
break;
|
|
1158
1145
|
}
|
|
1159
1146
|
case "rectangle": {
|
|
1160
1147
|
const { type: s, ...r } = e;
|
|
1161
|
-
t = new
|
|
1148
|
+
t = new je(r);
|
|
1162
1149
|
break;
|
|
1163
1150
|
}
|
|
1164
1151
|
case "circle": {
|
|
@@ -1269,7 +1256,7 @@ class tt {
|
|
|
1269
1256
|
}
|
|
1270
1257
|
/** 设置整个 overlay 不透明度(0–1,具体语义以 `PlotOverlay` 为准) */
|
|
1271
1258
|
setGlobalOpacity(e) {
|
|
1272
|
-
this.
|
|
1259
|
+
this._plotSdfPlugin.opacity = e, this._markDirty();
|
|
1273
1260
|
}
|
|
1274
1261
|
getCoordCount(e) {
|
|
1275
1262
|
const t = this._items.get(e);
|
|
@@ -1284,8 +1271,8 @@ class tt {
|
|
|
1284
1271
|
if (!r || !r.options.points || r.options.points.length === 0) return -1;
|
|
1285
1272
|
let a = 0, n = 1 / 0;
|
|
1286
1273
|
for (let o = 0; o < r.options.points.length; o++) {
|
|
1287
|
-
const
|
|
1288
|
-
|
|
1274
|
+
const d = r.options.points[o][0] - t, u = r.options.points[o][1] - s, h = d * d + u * u;
|
|
1275
|
+
h < n && (n = h, a = o);
|
|
1289
1276
|
}
|
|
1290
1277
|
return a;
|
|
1291
1278
|
}
|
|
@@ -1294,10 +1281,10 @@ class tt {
|
|
|
1294
1281
|
};
|
|
1295
1282
|
/**
|
|
1296
1283
|
* 释放 overlay 内部 RTT / 纹理等资源。
|
|
1297
|
-
* `
|
|
1284
|
+
* `PlotSDFPlugin` 的运行时实现含 `dispose`,类型声明可能未列出,故做断言。
|
|
1298
1285
|
*/
|
|
1299
1286
|
dispose() {
|
|
1300
|
-
this.
|
|
1287
|
+
this._plotSdfPlugin.dispose();
|
|
1301
1288
|
}
|
|
1302
1289
|
/**
|
|
1303
1290
|
* 标记需要在下一帧重绘瓦片标绘层;同一帧内多次调用只会调度一次。
|
|
@@ -1306,16 +1293,16 @@ class tt {
|
|
|
1306
1293
|
*/
|
|
1307
1294
|
_markDirty() {
|
|
1308
1295
|
this._redrawTimer || (this._redrawTimer = requestAnimationFrame(() => {
|
|
1309
|
-
this._redrawTimer = null, !this._overlayAttached && this._items.size > 0 && this.
|
|
1296
|
+
this._redrawTimer = null, !this._overlayAttached && this._items.size > 0 && this._plotSdfPlugin && (this._plotSdfPlugin.shapes = this._items, this._overlayAttached = !0), this._plotSdfPlugin.redraw(), this.render();
|
|
1310
1297
|
}));
|
|
1311
1298
|
}
|
|
1312
1299
|
}
|
|
1313
1300
|
const st = "https://sooncps.xwbuilders.com/api/ugis-dataprocess/v1/terrain/NhBLlMx3/", rt = "https://c.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png";
|
|
1314
|
-
class
|
|
1301
|
+
class mt {
|
|
1315
1302
|
constructor(e, t = {}) {
|
|
1316
1303
|
this.ssp = e, this.options = t;
|
|
1317
1304
|
const s = t.baseUrl || st;
|
|
1318
|
-
if (this.resourceManager = new
|
|
1305
|
+
if (this.resourceManager = new Ae(), this.terrainManager = new Ue(), t.imageryUrl !== !1) {
|
|
1319
1306
|
const r = t.imageryUrl || rt;
|
|
1320
1307
|
this.resourceManager.addOverlay({
|
|
1321
1308
|
id: this.defaultImageryId,
|
|
@@ -1325,9 +1312,9 @@ class yt {
|
|
|
1325
1312
|
}
|
|
1326
1313
|
this.groundDecalManager = new tt({ ssp: this.ssp }), this._alphaClipMode = t.alphaClipMode ?? "alphaTest", this._currentTerrainConfig = {
|
|
1327
1314
|
id: this.defaultTerrainId,
|
|
1328
|
-
type:
|
|
1315
|
+
type: C.QUANTIZED_MESH,
|
|
1329
1316
|
url: s
|
|
1330
|
-
}, this.terrainManager.add(this._currentTerrainConfig), this.terrainManager.setCurrentId(this._currentTerrainConfig.id), this.tiles = this._initTilesRenderer(this._currentTerrainConfig), this._initPlugins(this.tiles, this._currentTerrainConfig)
|
|
1317
|
+
}, this.terrainManager.add(this._currentTerrainConfig), this.terrainManager.setCurrentId(this._currentTerrainConfig.id), this.tiles = this._initTilesRenderer(this._currentTerrainConfig), this._initPlugins(this.tiles, this._currentTerrainConfig);
|
|
1331
1318
|
}
|
|
1332
1319
|
defaultTerrainId = "__default_terrain__";
|
|
1333
1320
|
defaultImageryId = "__default_imagery__";
|
|
@@ -1337,6 +1324,8 @@ class yt {
|
|
|
1337
1324
|
customMaterialPlugin;
|
|
1338
1325
|
imageOverlayPlugin;
|
|
1339
1326
|
reorientationPlugin;
|
|
1327
|
+
/** 标绘 SDF 插件(管理标绘实例) */
|
|
1328
|
+
plotSDFPlugin;
|
|
1340
1329
|
/** 资源管理器(存储配置) */
|
|
1341
1330
|
resourceManager;
|
|
1342
1331
|
/** 地形管理器(记录地形列表) */
|
|
@@ -1357,7 +1346,7 @@ class yt {
|
|
|
1357
1346
|
* 是否使用 Cesium Ion 地形
|
|
1358
1347
|
*/
|
|
1359
1348
|
get isCesiumIon() {
|
|
1360
|
-
return this._currentTerrainConfig.type ===
|
|
1349
|
+
return this._currentTerrainConfig.type === C.CESIUM_ION;
|
|
1361
1350
|
}
|
|
1362
1351
|
/**
|
|
1363
1352
|
* 获取当前地形配置
|
|
@@ -1403,9 +1392,9 @@ class yt {
|
|
|
1403
1392
|
this._alphaClipMode = e, this.customMaterialPlugin && (this.customMaterialPlugin.alphaClipMode = e), this._updateAlphaClipMode(), this.render();
|
|
1404
1393
|
}
|
|
1405
1394
|
_initTilesRenderer(e) {
|
|
1406
|
-
return e.type ===
|
|
1395
|
+
return e.type === C.CESIUM_ION ? new x() : (
|
|
1407
1396
|
// Cesium Ion 由插件设置 URL
|
|
1408
|
-
new
|
|
1397
|
+
new x(e.url)
|
|
1409
1398
|
);
|
|
1410
1399
|
}
|
|
1411
1400
|
/**
|
|
@@ -1413,30 +1402,43 @@ class yt {
|
|
|
1413
1402
|
* @param config 地形配置
|
|
1414
1403
|
*/
|
|
1415
1404
|
_initPlugins(e, t) {
|
|
1416
|
-
if (this.tilesFadePlugin = new te({ maximumFadeOutTiles: 200 }), this.updateOnChangePlugin = new se(), e.registerPlugin(this.tilesFadePlugin), e.registerPlugin(this.updateOnChangePlugin), t.type ===
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
s
|
|
1422
|
-
|
|
1423
|
-
|
|
1405
|
+
if (this.tilesFadePlugin = new te({ maximumFadeOutTiles: 200 }), this.updateOnChangePlugin = new se(), e.registerPlugin(this.tilesFadePlugin), e.registerPlugin(this.updateOnChangePlugin), t.type === C.CESIUM_ION ? e.registerPlugin(
|
|
1406
|
+
new ye({
|
|
1407
|
+
apiToken: t.apiToken,
|
|
1408
|
+
assetId: t.assetId || "1",
|
|
1409
|
+
autoRefreshToken: t.autoRefreshToken ?? !0,
|
|
1410
|
+
assetTypeHandler: (s, r) => {
|
|
1411
|
+
s === "TERRAIN" && r.getPluginByName("QUANTIZED_MESH_PLUGIN") === null && r.registerPlugin(
|
|
1412
|
+
new $({ useRecommendedSettings: !0 })
|
|
1413
|
+
);
|
|
1414
|
+
}
|
|
1415
|
+
})
|
|
1416
|
+
) : (e.registerPlugin(
|
|
1417
|
+
new $({ useRecommendedSettings: !0 })
|
|
1418
|
+
), e.fetchData = async (s) => {
|
|
1424
1419
|
const r = { method: "GET", mode: "cors" };
|
|
1425
1420
|
if (/layer\.json$/.test(s)) {
|
|
1426
1421
|
const a = await fetch(s, r).then((n) => n.json());
|
|
1427
1422
|
return a.metadataAvailability = -1, new Response(JSON.stringify(a));
|
|
1428
1423
|
}
|
|
1429
1424
|
return fetch(s, r);
|
|
1430
|
-
}), this.options.useCustomMaterial !== !1 && (this.customMaterialPlugin = new
|
|
1425
|
+
}), this.options.useCustomMaterial !== !1 && (this.customMaterialPlugin = new Fe(), this.customMaterialPlugin.alphaClipMode = this._alphaClipMode, e.registerPlugin(this.customMaterialPlugin)), this.imageOverlayPlugin = new me({
|
|
1431
1426
|
renderer: this.ssp.viewport.renderer,
|
|
1432
1427
|
overlays: []
|
|
1433
|
-
}), e.registerPlugin(this.imageOverlayPlugin), this.
|
|
1428
|
+
}), e.registerPlugin(this.imageOverlayPlugin), this.plotSDFPlugin = new Re(), this.groundDecalManager?.setPlotSDFPlugin(this.plotSDFPlugin), this.tiles.registerPlugin(this.plotSDFPlugin), this.overlayManager = new Ne(
|
|
1429
|
+
this.imageOverlayPlugin,
|
|
1430
|
+
this.resourceManager
|
|
1431
|
+
), this.overlayManager.restoreFromResourceManager(), this.options.reorientation !== !1) {
|
|
1434
1432
|
const s = this.options.reorientation || { lon: 120, lat: 30 };
|
|
1435
1433
|
this.reorientationPlugin = new re({
|
|
1436
1434
|
lon: s.lon,
|
|
1437
1435
|
lat: s.lat,
|
|
1438
1436
|
height: s.height ?? 0.1
|
|
1439
|
-
}), e.registerPlugin(this.reorientationPlugin), this.invalidate(
|
|
1437
|
+
}), e.registerPlugin(this.reorientationPlugin), this.invalidate(
|
|
1438
|
+
s.lon,
|
|
1439
|
+
s.lat,
|
|
1440
|
+
s.height ?? 0.1
|
|
1441
|
+
);
|
|
1440
1442
|
}
|
|
1441
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);
|
|
1442
1444
|
}
|
|
@@ -1473,7 +1475,11 @@ class yt {
|
|
|
1473
1475
|
* })
|
|
1474
1476
|
*/
|
|
1475
1477
|
setTerrain(e, t = void 0) {
|
|
1476
|
-
|
|
1478
|
+
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 s = this.terrainManager.getCurrent();
|
|
1480
|
+
e.type === C.QUANTIZED_MESH && s?.type === C.QUANTIZED_MESH && (s.url = e.url);
|
|
1481
|
+
}
|
|
1482
|
+
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();
|
|
1477
1483
|
}
|
|
1478
1484
|
// =============== Overlay 快捷方法 ===============
|
|
1479
1485
|
/**
|
|
@@ -1509,19 +1515,19 @@ class yt {
|
|
|
1509
1515
|
}
|
|
1510
1516
|
/**
|
|
1511
1517
|
* 添加 URL Template Overlay
|
|
1512
|
-
*
|
|
1518
|
+
*
|
|
1513
1519
|
* 支持多种 URL 模板变量:
|
|
1514
1520
|
* - `{z}`, `{x}`, `{y}` - 标准 XYZ 坐标
|
|
1515
1521
|
* - `{s}` - 子域名轮换
|
|
1516
1522
|
* - `{reverseY}` - TMS 风格的 Y 坐标
|
|
1517
1523
|
* - `{westDegrees}`, `{southDegrees}`, `{eastDegrees}`, `{northDegrees}` - 地理边界框
|
|
1518
|
-
*
|
|
1524
|
+
*
|
|
1519
1525
|
* @example
|
|
1520
1526
|
* tilesPlugin.addUrlTemplateOverlay({
|
|
1521
1527
|
* id: 'osm',
|
|
1522
1528
|
* url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
|
|
1523
1529
|
* })
|
|
1524
|
-
*
|
|
1530
|
+
*
|
|
1525
1531
|
* @example
|
|
1526
1532
|
* tilesPlugin.addUrlTemplateOverlay({
|
|
1527
1533
|
* id: 'carto',
|
|
@@ -1650,7 +1656,9 @@ class yt {
|
|
|
1650
1656
|
}
|
|
1651
1657
|
invalidate(e, t, s) {
|
|
1652
1658
|
if (!this.reorientationPlugin)
|
|
1653
|
-
return console.warn(
|
|
1659
|
+
return console.warn(
|
|
1660
|
+
"TilesRenderer: reorientationPlugin is not enabled, invalidate() will not work."
|
|
1661
|
+
), () => {
|
|
1654
1662
|
};
|
|
1655
1663
|
const r = this.reorientationPlugin;
|
|
1656
1664
|
this.options.reorientation = {
|
|
@@ -1659,12 +1667,8 @@ class yt {
|
|
|
1659
1667
|
height: s
|
|
1660
1668
|
};
|
|
1661
1669
|
const a = () => {
|
|
1662
|
-
const o =
|
|
1663
|
-
r.transformLatLonHeightToOrigin(
|
|
1664
|
-
o,
|
|
1665
|
-
h,
|
|
1666
|
-
s
|
|
1667
|
-
), this.render(), n();
|
|
1670
|
+
const o = L.degToRad(t), d = L.degToRad(e);
|
|
1671
|
+
r.transformLatLonHeightToOrigin(o, d, s), this.render(), n();
|
|
1668
1672
|
}, n = () => {
|
|
1669
1673
|
this.tiles.removeEventListener("load-root-tileset", a), this.loedTilesSets.delete(a);
|
|
1670
1674
|
};
|
|
@@ -1676,7 +1680,7 @@ class yt {
|
|
|
1676
1680
|
), this.loedTilesSets.clear(), this.tiles.removeEventListener("needs-render", this.render), this.tiles.removeEventListener("needs-update", this.render), this.tiles.dispose();
|
|
1677
1681
|
}
|
|
1678
1682
|
}
|
|
1679
|
-
const
|
|
1683
|
+
const R = {
|
|
1680
1684
|
DEFAULT: 0,
|
|
1681
1685
|
GRADIENT: 1,
|
|
1682
1686
|
TOPOGRAPHIC_LINES: 2,
|
|
@@ -1753,10 +1757,10 @@ const b = {
|
|
|
1753
1757
|
`
|
|
1754
1758
|
)
|
|
1755
1759
|
};
|
|
1756
|
-
let X = null, Y = null,
|
|
1760
|
+
let X = null, Y = null, Z = null;
|
|
1757
1761
|
class nt {
|
|
1758
1762
|
constructor(e, t) {
|
|
1759
|
-
this.ssp = e, this.options = t, "url" in this.options ? this.tiles = new
|
|
1763
|
+
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);
|
|
1760
1764
|
}
|
|
1761
1765
|
tiles;
|
|
1762
1766
|
tilesFadePlugin;
|
|
@@ -1764,10 +1768,10 @@ class nt {
|
|
|
1764
1768
|
reorientationPlugin;
|
|
1765
1769
|
options;
|
|
1766
1770
|
// 用于模型居中
|
|
1767
|
-
_box = new
|
|
1768
|
-
_sphere = new
|
|
1771
|
+
_box = new Te();
|
|
1772
|
+
_sphere = new Oe();
|
|
1769
1773
|
// 当前材质类型
|
|
1770
|
-
_materialType =
|
|
1774
|
+
_materialType = R.DEFAULT;
|
|
1771
1775
|
// 按需渲染标志
|
|
1772
1776
|
_needsUpdate = !0;
|
|
1773
1777
|
_cameraTransitionStart = !1;
|
|
@@ -1777,7 +1781,7 @@ class nt {
|
|
|
1777
1781
|
*/
|
|
1778
1782
|
_initCesiumIon(e) {
|
|
1779
1783
|
this.tiles.registerPlugin(
|
|
1780
|
-
new
|
|
1784
|
+
new ye({
|
|
1781
1785
|
apiToken: e.apiToken,
|
|
1782
1786
|
assetId: e.assetId,
|
|
1783
1787
|
autoRefreshToken: e.autoRefreshToken ?? !0
|
|
@@ -1788,7 +1792,7 @@ class nt {
|
|
|
1788
1792
|
* 初始化基础插件
|
|
1789
1793
|
*/
|
|
1790
1794
|
_initBasePlugins(e) {
|
|
1791
|
-
if (e._managedByPlugin || (X === null ? X = this.tiles.lruCache : this.tiles.lruCache = X, Y === null ? Y = this.tiles.parseQueue : this.tiles.parseQueue = Y,
|
|
1795
|
+
if (e._managedByPlugin || (X === null ? X = this.tiles.lruCache : this.tiles.lruCache = X, Y === null ? Y = this.tiles.parseQueue : this.tiles.parseQueue = Y, Z === null ? Z = this.tiles.downloadQueue : this.tiles.downloadQueue = Z, 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) {
|
|
1792
1796
|
const t = this.options.reorientation || { lon: 120, lat: 30 };
|
|
1793
1797
|
this.reorientationPlugin = new re({
|
|
1794
1798
|
lon: t.lon,
|
|
@@ -1806,7 +1810,7 @@ class nt {
|
|
|
1806
1810
|
* 设置 GLTF Loader
|
|
1807
1811
|
*/
|
|
1808
1812
|
_setupGLTFLoader() {
|
|
1809
|
-
const e = new
|
|
1813
|
+
const e = new ge(this.tiles.manager), t = this.ssp.manager?.store?.modelManager;
|
|
1810
1814
|
if (t?.gltfLoader) {
|
|
1811
1815
|
const { dracoLoader: s, ktx2Loader: r, meshoptDecoder: a } = t.gltfLoader;
|
|
1812
1816
|
s && e.setDRACOLoader(s), r && e.setKTX2Loader(r), a && e.setMeshoptDecoder(a);
|
|
@@ -1850,7 +1854,7 @@ class nt {
|
|
|
1850
1854
|
onLoadModel = ({ scene: e }) => {
|
|
1851
1855
|
e.traverse((t) => {
|
|
1852
1856
|
t.isMesh && (t.originalMaterial = t.material);
|
|
1853
|
-
}), this._materialType !==
|
|
1857
|
+
}), this._materialType !== R.DEFAULT && this.updateMaterial(e);
|
|
1854
1858
|
};
|
|
1855
1859
|
/**
|
|
1856
1860
|
* 更新场景中所有网格的材质(参考 customMaterial.js)
|
|
@@ -1860,18 +1864,18 @@ class nt {
|
|
|
1860
1864
|
e.traverse((s) => {
|
|
1861
1865
|
if (s.isMesh)
|
|
1862
1866
|
switch (s.material && s.material !== s.originalMaterial && s.material.dispose(), t) {
|
|
1863
|
-
case
|
|
1867
|
+
case R.DEFAULT:
|
|
1864
1868
|
s.material = s.originalMaterial, s.material && (s.material.side = 2), s.receiveShadow = !1, s.castShadow = !1;
|
|
1865
1869
|
break;
|
|
1866
|
-
case
|
|
1867
|
-
s.material = new
|
|
1870
|
+
case R.GRADIENT:
|
|
1871
|
+
s.material = new he(it), s.material.side = 2, s.receiveShadow = !1, s.castShadow = !1;
|
|
1868
1872
|
break;
|
|
1869
|
-
case
|
|
1870
|
-
const r = new
|
|
1873
|
+
case R.TOPOGRAPHIC_LINES: {
|
|
1874
|
+
const r = new he(at);
|
|
1871
1875
|
r.extensions = { derivatives: !0 }, r.side = 2, s.material = r, s.receiveShadow = !1, s.castShadow = !1;
|
|
1872
1876
|
break;
|
|
1873
1877
|
}
|
|
1874
|
-
case
|
|
1878
|
+
case R.LIGHTING:
|
|
1875
1879
|
s.material = new we(), s.material.side = 2, s.receiveShadow = !0, s.castShadow = !0;
|
|
1876
1880
|
break;
|
|
1877
1881
|
}
|
|
@@ -1919,8 +1923,8 @@ class nt {
|
|
|
1919
1923
|
height: s
|
|
1920
1924
|
};
|
|
1921
1925
|
const a = () => {
|
|
1922
|
-
const o =
|
|
1923
|
-
r.transformLatLonHeightToOrigin(o,
|
|
1926
|
+
const o = L.degToRad(t), d = L.degToRad(e);
|
|
1927
|
+
r.transformLatLonHeightToOrigin(o, d, s), this.render(), n();
|
|
1924
1928
|
}, n = () => {
|
|
1925
1929
|
this.tiles.removeEventListener("load-root-tileset", a), this.loedTilesSets.delete(a);
|
|
1926
1930
|
};
|
|
@@ -2027,24 +2031,24 @@ class ft {
|
|
|
2027
2031
|
}
|
|
2028
2032
|
}
|
|
2029
2033
|
export {
|
|
2030
|
-
|
|
2034
|
+
pt as ArcgisTilesRenderer,
|
|
2031
2035
|
Ve as GisPlotArrow,
|
|
2032
|
-
|
|
2036
|
+
P as GisPlotBase,
|
|
2033
2037
|
et as GisPlotCircle,
|
|
2034
2038
|
Qe as GisPlotLine,
|
|
2035
2039
|
We as GisPlotPoint,
|
|
2036
|
-
|
|
2037
|
-
|
|
2040
|
+
He as GisPlotPolygon,
|
|
2041
|
+
je as GisPlotRectangle,
|
|
2038
2042
|
Be as GisPlotSector,
|
|
2039
2043
|
Ke as GisPlotText,
|
|
2040
2044
|
tt as GroundDecalManager,
|
|
2041
|
-
|
|
2042
|
-
|
|
2045
|
+
R as MaterialType,
|
|
2046
|
+
Ne as OverlayManager,
|
|
2043
2047
|
l as OverlayType,
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2048
|
+
mt as TerrainTilesRenderer,
|
|
2049
|
+
C as TerrainType,
|
|
2050
|
+
Fe as TileCustomMaterialPlugin,
|
|
2047
2051
|
nt as TilesRenderer,
|
|
2048
2052
|
ft as TilesRendererManager,
|
|
2049
|
-
|
|
2053
|
+
ct as default
|
|
2050
2054
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlotSdfPlugin } from 'um-3d-tiles-renderer/three/plugins';
|
|
2
2
|
import { ImageOverlayPlugin } from 'um-3d-tiles-renderer/plugins';
|
|
3
3
|
import { GisPlotBase } from './plugins/base';
|
|
4
4
|
import { GisPlotArrowSnapshot, GisPlotSnapshot, LonLatPoint, PlotAddOptions } from './plugins/types';
|
|
@@ -28,13 +28,11 @@ export declare class GroundDecalManager {
|
|
|
28
28
|
private readonly _items;
|
|
29
29
|
/** 标绘 id */
|
|
30
30
|
readonly id: string;
|
|
31
|
-
/** 标绘 overlay */
|
|
32
|
-
private readonly _overlay;
|
|
33
31
|
/** SoonSpace 实例 */
|
|
34
32
|
readonly ssp: SoonSpace;
|
|
35
|
-
/** 传入的
|
|
36
|
-
private
|
|
37
|
-
/** overlay 是否已注册到
|
|
33
|
+
/** 传入的 PlotSDFPlugin,用于在有图形时自动注册 overlay */
|
|
34
|
+
private _plotSdfPlugin?;
|
|
35
|
+
/** overlay 是否已注册到 PlotSDFPlugin */
|
|
38
36
|
private _overlayAttached;
|
|
39
37
|
/** 合并同一帧内多次 `_markDirty`,值为 `requestAnimationFrame` 句柄 */
|
|
40
38
|
private _redrawTimer;
|
|
@@ -43,12 +41,12 @@ export declare class GroundDecalManager {
|
|
|
43
41
|
* 内部使用的 `PlotOverlay` 实例。
|
|
44
42
|
* 注册到 `ImageOverlayPlugin` 的 `overlays` 数组中,顺序靠后者通常绘制在上层。
|
|
45
43
|
*/
|
|
46
|
-
get
|
|
44
|
+
get plotSdfPlugin(): PlotSdfPlugin;
|
|
47
45
|
/**
|
|
48
|
-
* 绑定 / 更换
|
|
46
|
+
* 绑定 / 更换 PlotOverlayPlugin(切换地形重建插件后调用)。
|
|
49
47
|
* 如果当前已有图形,会在下一帧自动重新注册 overlay。
|
|
50
48
|
*/
|
|
51
|
-
|
|
49
|
+
setPlotSDFPlugin(plugin: PlotSdfPlugin): void;
|
|
52
50
|
/**
|
|
53
51
|
* 添加标绘:由 `options.type` 决定实例化哪一类 `GisPlot*`(与各类 `*Options` 对应)。
|
|
54
52
|
*/
|
|
@@ -102,7 +100,7 @@ export declare class GroundDecalManager {
|
|
|
102
100
|
render: () => void;
|
|
103
101
|
/**
|
|
104
102
|
* 释放 overlay 内部 RTT / 纹理等资源。
|
|
105
|
-
* `
|
|
103
|
+
* `PlotSDFPlugin` 的运行时实现含 `dispose`,类型声明可能未列出,故做断言。
|
|
106
104
|
*/
|
|
107
105
|
dispose(): void;
|
|
108
106
|
/**
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { GisPlotBase } from './base';
|
|
2
|
-
import {
|
|
2
|
+
import { PlotRectangleOptions } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* 矩形标绘 → {@link PlotRectangleOptions}
|
|
5
|
-
* `points
|
|
5
|
+
* `points` 为 4 个角点 [[lon,lat], ...],按顺/逆时针排列;
|
|
6
|
+
* 渲染端以多边形方式绘制(shader type 2)。
|
|
6
7
|
*/
|
|
7
8
|
export declare class GisPlotRectangle extends GisPlotBase {
|
|
8
9
|
readonly category: "rectangle";
|
|
9
10
|
options: PlotRectangleOptions;
|
|
10
11
|
constructor(options: PlotRectangleOptions);
|
|
11
12
|
update(patch: Partial<PlotRectangleOptions>): void;
|
|
12
|
-
getExtentPoints(): LonLatPoint[];
|
|
13
13
|
}
|
|
@@ -36,8 +36,6 @@ export type PlotLineOptions = GisPlotBaseOptions & {
|
|
|
36
36
|
showArrow?: boolean;
|
|
37
37
|
startArrowStyle?: PlotArrowStyle | null;
|
|
38
38
|
endArrowStyle?: PlotArrowStyle | null;
|
|
39
|
-
/** 线端箭头尺度(与示例 GroundDecalManager / shader 一致) */
|
|
40
|
-
arrowSize?: number;
|
|
41
39
|
};
|
|
42
40
|
export type PlotStrokeStyle = 'solid' | 'dashed';
|
|
43
41
|
export type PlotFillStyle = 'solid' | 'diagonal' | 'grid';
|
|
@@ -46,11 +44,9 @@ export type PlotPolygonOptions = GisPlotBaseOptions & {
|
|
|
46
44
|
strokeStyle?: PlotStrokeStyle;
|
|
47
45
|
fillStyle?: PlotFillStyle;
|
|
48
46
|
};
|
|
49
|
-
/**
|
|
47
|
+
/** 矩形:4 个角点 [[lon,lat], ...] 按顺时针或逆时针顺序 */
|
|
50
48
|
export type PlotRectangleOptions = GisPlotBaseOptions & {
|
|
51
49
|
strokeStyle?: PlotStrokeStyle;
|
|
52
|
-
width: number;
|
|
53
|
-
height: number;
|
|
54
50
|
};
|
|
55
51
|
/** 扇形:中心 + 半径与角度(度) */
|
|
56
52
|
export type PlotSectorOptions = GisPlotBaseOptions & {
|
|
@@ -79,6 +75,8 @@ export type PlotTextOptions = GisPlotBaseOptions & {
|
|
|
79
75
|
fontSize: number;
|
|
80
76
|
textAlign?: PlotTextAlign;
|
|
81
77
|
showBorder?: boolean;
|
|
78
|
+
fillColor?: string;
|
|
79
|
+
fillOpacity?: number;
|
|
82
80
|
offsetX?: number;
|
|
83
81
|
offsetY?: number;
|
|
84
82
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TilesRenderer } from 'um-3d-tiles-renderer';
|
|
2
|
-
import { TilesFadePlugin, UpdateOnChangePlugin, ImageOverlayPlugin, ReorientationPlugin } from 'um-3d-tiles-renderer/plugins';
|
|
2
|
+
import { TilesFadePlugin, UpdateOnChangePlugin, ImageOverlayPlugin, ReorientationPlugin, PlotSdfPlugin } from 'um-3d-tiles-renderer/plugins';
|
|
3
3
|
import { default as SoonSpace } from 'soonspacejs';
|
|
4
4
|
import { TileCustomMaterialPlugin } from './plugins';
|
|
5
5
|
import { OverlayManager } from './OverlayManager';
|
|
@@ -23,6 +23,8 @@ export declare class TerrainTilesRenderer {
|
|
|
23
23
|
customMaterialPlugin?: TileCustomMaterialPlugin;
|
|
24
24
|
imageOverlayPlugin?: ImageOverlayPlugin;
|
|
25
25
|
reorientationPlugin?: ReorientationPlugin;
|
|
26
|
+
/** 标绘 SDF 插件(管理标绘实例) */
|
|
27
|
+
plotSDFPlugin?: PlotSdfPlugin;
|
|
26
28
|
/** 资源管理器(存储配置) */
|
|
27
29
|
resourceManager: ResourceManager;
|
|
28
30
|
/** 地形管理器(记录地形列表) */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soonspacejs/plugin-tiles",
|
|
3
3
|
"pluginName": "TilesPlugin",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.15.0",
|
|
5
5
|
"description": "3D Tiles plugin for SoonSpace.js",
|
|
6
6
|
"main": "dist/index.esm.js",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"license": "UNLICENSED",
|
|
19
19
|
"gitHead": "4a87dd85050651088e11c3da777c49fab3db7e5d",
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"um-3d-tiles-renderer": "^0.4.
|
|
21
|
+
"um-3d-tiles-renderer": "^0.4.40",
|
|
22
22
|
"three": "^0.183.0",
|
|
23
|
-
"soonspacejs": "2.
|
|
23
|
+
"soonspacejs": "2.15.0"
|
|
24
24
|
}
|
|
25
25
|
}
|