@skzz/components-gis 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/assets/twinPreviewWorker-COILIqOa.js +1 -0
  2. package/dist/color-DVYdxZow.js +359 -0
  3. package/dist/esm-BXiGX6xE.js +86 -0
  4. package/dist/index.css +1 -1
  5. package/dist/index.d.ts +71 -6
  6. package/dist/index.es.js +1138 -9563
  7. package/dist/index.umd.js +5 -5
  8. package/dist/interpolation-Ctw2-y9G.js +211 -0
  9. package/dist/layerStack-CbiVJONn.js +181 -0
  10. package/dist/pako.esm-D6zcBi67.js +1455 -0
  11. package/dist/query-DgSNPfJM.js +239 -0
  12. package/dist/queryPoint-BOi_hkig.js +189 -0
  13. package/dist/zz-3dtiles-BzDYB-tW.js +75 -0
  14. package/dist/zz-gltf-BDHxqQjs.js +70 -0
  15. package/dist/zz-layer/zz-layer-shp-zzts/shpZztsCacheUtils.d.ts +53 -0
  16. package/dist/zz-layer/zz-layer-shp-zzts/shpZztsRenderer.d.ts +96 -12
  17. package/dist/zz-layer/zz-layer-zzts/zztsRasterCacheUtils.d.ts +35 -0
  18. package/dist/zz-layer/zz-layer-zzts/zztsRasterPreviewPolling.d.ts +10 -0
  19. package/dist/zz-layer/zz-layer-zzts3dv2/index.vue.d.ts +1 -0
  20. package/dist/zz-layer/zz-layer-zzts3dv2/twinPreviewWorker.d.ts +1 -0
  21. package/dist/zz-layer-geojson-CtTpn_f9.js +867 -0
  22. package/dist/zz-layer-mvt-R1-GwSIW.js +609 -0
  23. package/dist/zz-layer-shp-zzts-D8BjI5tI.js +1323 -0
  24. package/dist/zz-layer-zzts3d-DqZmLdW3.js +835 -0
  25. package/dist/zz-layer-zzts3d-grid-CTHFZBpo.js +314 -0
  26. package/dist/zz-layer-zzts3d-las-hNa-nqxq.js +560 -0
  27. package/dist/zz-layer-zzts3d-point-DrB5Uuwa.js +750 -0
  28. package/dist/zz-layer-zzts3dtype-BRl3mCk9.js +493 -0
  29. package/dist/zz-layer-zzts3dv2-D5udnVGT.js +913 -0
  30. package/dist/zz-terrain-excavation-A2NXSQ5P.js +502 -0
  31. package/dist/zz-viewer/index.vue.d.ts +2 -2
  32. package/dist/zzts3dLayerSignature-Cnu6KIys.js +42 -0
  33. package/package.json +2 -2
@@ -0,0 +1,913 @@
1
+ import { a as e, r as t } from "./layerStack-CbiVJONn.js";
2
+ import { t as n } from "./pako.esm-D6zcBi67.js";
3
+ import { n as r, t as i } from "./esm-BXiGX6xE.js";
4
+ import { n as a, t as o } from "./zzts3dLayerSignature-Cnu6KIys.js";
5
+ import { computed as s, inject as c, onUnmounted as l, ref as u, watch as d } from "vue";
6
+ import { httpService as f } from "@skzz/libs-base";
7
+ import { latlng as p } from "@skzz/libs-gis";
8
+ //#region src/zz-layer/zz-layer-zzts3dv2/entityGridV2.js
9
+ var m = "/v1/zzts/layer/3d/getTwinTileGridManifest", h = "/v1/zzts/layer/3d/getTwinCapsuleBlock", g = {
10
+ 17: 1,
11
+ 16: 2,
12
+ 15: 3,
13
+ 13: 4,
14
+ 12: 5
15
+ }, _ = 128, v = "153,153,153", y = () => new Promise((e) => {
16
+ typeof requestAnimationFrame == "function" ? requestAnimationFrame(() => e()) : e();
17
+ });
18
+ function b(e) {
19
+ let t = Infinity, n = Infinity, r = Infinity, i = -Infinity, a = -Infinity, o = -Infinity;
20
+ for (let s of e) {
21
+ let e = s.positions;
22
+ for (let s = 0; s < e.length; s += 3) e[s] < t && (t = e[s]), e[s] > i && (i = e[s]), e[s + 1] < n && (n = e[s + 1]), e[s + 1] > a && (a = e[s + 1]), e[s + 2] < r && (r = e[s + 2]), e[s + 2] > o && (o = e[s + 2]);
23
+ }
24
+ if (!Number.isFinite(t)) return null;
25
+ let s = new Cesium.Cartesian3((t + i) / 2, (n + a) / 2, (r + o) / 2), c = i - t, l = a - n, u = o - r;
26
+ return new Cesium.BoundingSphere(s, Math.sqrt(c * c + l * l + u * u) / 2);
27
+ }
28
+ function x(e) {
29
+ if (!e) return null;
30
+ let t = Number(e.longitudeWest ?? e.west), n = Number(e.latitudeSouth ?? e.south), r = Number(e.longitudeEast ?? e.east), i = Number(e.latitudeNorth ?? e.north);
31
+ return ![
32
+ t,
33
+ n,
34
+ r,
35
+ i
36
+ ].every(Number.isFinite) || t < -180 || r > 180 || n < -90 || i > 90 || t >= r || n >= i ? null : {
37
+ west: t,
38
+ south: n,
39
+ east: r,
40
+ north: i
41
+ };
42
+ }
43
+ function S(e, t) {
44
+ if (!e || !t) return null;
45
+ let n = {
46
+ west: Math.max(e.west, t.west),
47
+ south: Math.max(e.south, t.south),
48
+ east: Math.min(e.east, t.east),
49
+ north: Math.min(e.north, t.north)
50
+ };
51
+ return n.west < n.east && n.south < n.north ? n : null;
52
+ }
53
+ function C(e, t) {
54
+ let n = String(e || "").trim();
55
+ if (n) {
56
+ let e = n.match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/);
57
+ if (e) {
58
+ let n = e[1];
59
+ n.length === 3 && (n = n.split("").map((e) => e + e).join(""));
60
+ let r = parseInt(n.slice(0, 2), 16), i = parseInt(n.slice(2, 4), 16), a = parseInt(n.slice(4, 6), 16), o = n.length === 8 ? parseInt(n.slice(6, 8), 16) / 255 : 1;
61
+ return new Cesium.Color(r / 255, i / 255, a / 255, t === void 0 ? o : t);
62
+ }
63
+ let r = n.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*([0-9.]+))?\s*\)/);
64
+ if (r) {
65
+ let e = r[4] === void 0 ? 1 : Math.max(0, Math.min(1, Number(r[4])));
66
+ return new Cesium.Color(Number(r[1]) / 255, Number(r[2]) / 255, Number(r[3]) / 255, t === void 0 ? e : t);
67
+ }
68
+ let i = n.split(",").map((e) => Number(e.trim()));
69
+ if (i.length >= 3 && i.slice(0, 3).every(Number.isFinite)) {
70
+ let e = i.length >= 4 && Number.isFinite(i[3]) ? Math.max(0, Math.min(1, i[3] / 255)) : 1;
71
+ return new Cesium.Color(i[0] / 255, i[1] / 255, i[2] / 255, t === void 0 ? e : t);
72
+ }
73
+ }
74
+ return new Cesium.Color(1, 1, 1, t);
75
+ }
76
+ function w(e, t, r = Infinity, i = Infinity) {
77
+ let a = e instanceof Uint8Array ? e : new Uint8Array(e), o = a[0] === 31 && a[1] === 139 ? n.ungzip(a) : a;
78
+ if (o.byteLength > r) throw Error("孪生体轻量预览数据超过限制");
79
+ if (o.length < 16) throw Error("TW2 分片过短");
80
+ let s = new DataView(o.buffer, o.byteOffset, o.byteLength);
81
+ if (s.getUint32(0, !0) !== 3299156) throw Error("TW2 magic 不匹配");
82
+ let c = s.getUint32(12, !0);
83
+ if (c > i) throw Error("孪生体轻量预览实体数量超过限制");
84
+ let l = t <= 3 ? 1 / 100 : 1, u = [], d = 16;
85
+ for (let e = 0; e < c; e++) {
86
+ let e = s.getBigUint64(d, !0), t = s.getUint32(d + 8, !0), n = s.getUint32(d + 12, !0);
87
+ d += 16;
88
+ let r = new Int32Array(o.buffer, o.byteOffset + d, t), i = new Float64Array(t);
89
+ for (let e = 0; e < t; e++) i[e] = r[e] * l;
90
+ d += t * 4;
91
+ let a = new Uint32Array(o.buffer, o.byteOffset + d, n);
92
+ d += n * 4, u.push({
93
+ id: e,
94
+ positions: i,
95
+ indices: a
96
+ });
97
+ }
98
+ return u;
99
+ }
100
+ function T(e, t) {
101
+ let n = new Float32Array(e.length);
102
+ for (let r = 0; r < t.length; r += 3) {
103
+ let i = t[r] * 3, a = t[r + 1] * 3, o = t[r + 2] * 3, s = e[a] - e[i], c = e[a + 1] - e[i + 1], l = e[a + 2] - e[i + 2], u = e[o] - e[i], d = e[o + 1] - e[i + 1], f = e[o + 2] - e[i + 2], p = c * f - l * d, m = l * u - s * f, h = s * d - c * u, g = Math.sqrt(p * p + m * m + h * h);
104
+ g > 1e-10 && Number.isFinite(g) ? (p /= g, m /= g, h /= g) : (p = 0, m = 0, h = 1), n[i] = p, n[i + 1] = m, n[i + 2] = h, n[a] = p, n[a + 1] = m, n[a + 2] = h, n[o] = p, n[o + 1] = m, n[o + 2] = h;
105
+ }
106
+ return n;
107
+ }
108
+ function E(e, t) {
109
+ let n = Math.floor(t.length / 3), r = new Float64Array(n * 9), i = new Uint32Array(n * 3);
110
+ for (let a = 0; a < n; a++) for (let n = 0; n < 3; n++) {
111
+ let o = t[a * 3 + n] * 3, s = (a * 3 + n) * 3;
112
+ r[s] = e[o], r[s + 1] = e[o + 1], r[s + 2] = e[o + 2], i[a * 3 + n] = a * 3 + n;
113
+ }
114
+ return {
115
+ positions: r,
116
+ indices: i
117
+ };
118
+ }
119
+ function D(e, t, n, r, i) {
120
+ let a = r.alpha * (i === void 0 ? 1 : i), o = a < 1, s = Cesium.ColorGeometryInstanceAttribute.fromColor(o ? r.withAlpha(a) : r), c = [], l = [];
121
+ for (let r of e) {
122
+ let e = r.id === void 0 || r.id === null ? `tw2_${t}_S${n}` : String(r.id), i = E(r.positions, r.indices);
123
+ i.positions.length !== 0 && (l.push(Cesium.BoundingSphere.fromVertices(i.positions)), c.push(new Cesium.GeometryInstance({
124
+ id: e,
125
+ geometry: new Cesium.Geometry({
126
+ attributes: {
127
+ position: new Cesium.GeometryAttribute({
128
+ componentDatatype: Cesium.ComponentDatatype.DOUBLE,
129
+ componentsPerAttribute: 3,
130
+ values: i.positions
131
+ }),
132
+ normal: new Cesium.GeometryAttribute({
133
+ componentDatatype: Cesium.ComponentDatatype.FLOAT,
134
+ componentsPerAttribute: 3,
135
+ values: T(i.positions, i.indices)
136
+ })
137
+ },
138
+ indices: i.indices,
139
+ primitiveType: Cesium.PrimitiveType.TRIANGLES,
140
+ boundingSphere: l[l.length - 1]
141
+ }),
142
+ attributes: { color: s }
143
+ })));
144
+ }
145
+ return {
146
+ primitive: new Cesium.Primitive({
147
+ geometryInstances: c,
148
+ appearance: new Cesium.PerInstanceColorAppearance({
149
+ flat: !1,
150
+ translucent: o,
151
+ vertexFormat: Cesium.VertexFormat.POSITION_AND_NORMAL
152
+ }),
153
+ asynchronous: !1,
154
+ compressVertices: !1
155
+ }),
156
+ boundingSphere: Cesium.BoundingSphere.fromBoundingSpheres(l)
157
+ };
158
+ }
159
+ function O(e, t, n, r) {
160
+ return new Promise((i, a) => {
161
+ let o = e.slice(0), s = () => {
162
+ try {
163
+ i(w(o, t, n, r));
164
+ } catch (e) {
165
+ a(e instanceof Error ? e : /* @__PURE__ */ Error("孪生体轻量预览解析失败"));
166
+ }
167
+ }, c;
168
+ try {
169
+ c = new Worker(new URL(
170
+ /* @vite-ignore */
171
+ "" + new URL("assets/twinPreviewWorker-COILIqOa.js", import.meta.url).href,
172
+ "" + import.meta.url
173
+ ), { type: "module" });
174
+ } catch {
175
+ s();
176
+ return;
177
+ }
178
+ let l = e.slice(0);
179
+ c.onmessage = (e) => {
180
+ c.terminate(), e.data?.error ? s() : i(e.data?.entities || []);
181
+ }, c.onerror = () => {
182
+ c.terminate(), s();
183
+ };
184
+ try {
185
+ c.postMessage({
186
+ buffer: l,
187
+ lod: t,
188
+ maxBytes: n,
189
+ maxEntities: r
190
+ }, [l]);
191
+ } catch {
192
+ c.terminate(), s();
193
+ }
194
+ });
195
+ }
196
+ function k(e, t = v) {
197
+ if (typeof e == "string") {
198
+ let t = e.trim();
199
+ if (/^\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*\d{1,3})?\s*$/.test(t)) return t.split(",").map((e) => Math.max(0, Math.min(255, Math.round(Number(e.trim()))))).join(",");
200
+ let n = t.match(/^#([0-9a-fA-F]{6})([0-9a-fA-F]{2})?$/);
201
+ if (n) {
202
+ let e = [
203
+ 0,
204
+ 2,
205
+ 4
206
+ ].map((e) => parseInt(n[1].slice(e, e + 2), 16)), t = n[2] === void 0 ? 255 : parseInt(n[2], 16);
207
+ return t === 255 ? e.join(",") : [...e, t].join(",");
208
+ }
209
+ let r = t.match(/^rgba?\(\s*(\d{1,3})[,\s]+(\d{1,3})[,\s]+(\d{1,3})(?:[,\s]+([0-9.]+))?\s*\)$/i);
210
+ if (r) {
211
+ let e = [
212
+ r[1],
213
+ r[2],
214
+ r[3]
215
+ ].map((e) => Math.max(0, Math.min(255, Number(e))));
216
+ return r[4] === void 0 ? e.join(",") : [...e, Math.max(0, Math.min(255, Math.round(Number(r[4]) * 255)))].join(",");
217
+ }
218
+ }
219
+ return t;
220
+ }
221
+ function A(e) {
222
+ if (e == null) return "";
223
+ let t = String(e).trim();
224
+ if (!t) return "";
225
+ let n = t.match(/^#([0-9a-f]{6})(?:[0-9a-f]{2})?$/i);
226
+ if (n) return [
227
+ 0,
228
+ 2,
229
+ 4
230
+ ].map((e) => parseInt(n[1].slice(e, e + 2), 16)).join(",");
231
+ let r = t.match(/^rgba?\(\s*(\d{1,3})[,\s]+(\d{1,3})[,\s]+(\d{1,3})/i);
232
+ return r ? `${Number(r[1])},${Number(r[2])},${Number(r[3])}` : /^\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*[\d.]+)?$/.test(t) ? t.split(",").slice(0, 3).map((e) => Math.max(0, Math.min(255, Math.round(Number(e.trim()))))).join(",") : "";
233
+ }
234
+ var j = class {
235
+ constructor(e, t = !1, n = null, r = "255,255,255", i = 1, a = {}) {
236
+ this.id = e, this.viewer = a.viewer || null, this.dataLayerId = a.dataLayerId || e, this.isStatic = t, this.fixedLevel = n, this.currentNewLevel = u(n || 15), this.color = r, this.opacity = i ?? 1, this.layerOpacity = a.layerOpacity ?? 1, this.serviceName = a.serviceName || "", this.dictCode = a.dictCode || "", this.enableServiceColor = a.enableServiceColor !== !1, this.modelColorUrl = a.modelColorUrl || "/v1/zzts/style/render/modelColors", this.modelColorCache = /* @__PURE__ */ new Map(), this.displayRange = x(a.displayRange), this.lodCalculationRange = x(a.lodCalculationRange), this.stackIndex = a.stackIndex, this.subStackIndex = a.subStackIndex ?? 0, this.groupKey = a.groupKey || String(e), this.previewMode = a.previewMode === !0, this.previewVersion = a.previewVersion ?? 0, this.previewManifest = a.previewManifest || null, this.previewBuffer = a.previewBuffer || null, this.previewColorMap = a.previewColorMap || {}, this.previewHiddenEntityIds = new Set((a.previewHiddenEntityIds || []).map(String)), this.hiddenColors = new Set((a.hiddenColors || []).map(A).filter(Boolean)), this.previewDefaultColor = k(a.previewDefaultColor, this.color), this.previewEntityLimit = Math.min(Number(a.previewEntityLimit) || 300, 300), this.previewMaxInflatedBytes = Math.min(Number(a.previewMaxInflatedBytes) || 16 * 1024 * 1024, 16 * 1024 * 1024), this.previewColorGroupLimit = Math.min(Number(a.previewColorGroupLimit) || 32, 32), this.onPreviewError = a.onPreviewError, this.onEmptyFallback = a.onEmptyFallback || null, this.viewModeFailed = !1, this.viewConfirmed = !1, this.blockCache = /* @__PURE__ */ new Map(), this.currentViewKeys = /* @__PURE__ */ new Set(), this.viewColorMap = /* @__PURE__ */ new Map(), this.lastTilesCount = 0, this.emptyFallbackNotified = !1, this.levels_add = window.levels_add_plus || 0, this.destroyed = !1, this.handlers = null, this.requestController = null, this.requestVersion = 0, this.loadedTiles = /* @__PURE__ */ new Map(), this.emptyTiles = /* @__PURE__ */ new Set(), this.shardDataCache = /* @__PURE__ */ new Map(), this._hiddenRebuildPending = !1, this._hiddenRebuildQueued = !1, this._tileStateVersion = 0;
237
+ }
238
+ async init() {
239
+ if (!this.viewer) throw Error("三维地图尚未就绪,无法初始化孪生体图层");
240
+ if (this.previewMode) {
241
+ await this.loadPreviewSnapshot();
242
+ return;
243
+ }
244
+ this.initHandler();
245
+ }
246
+ async loadPreviewSnapshot() {
247
+ if (this.destroyed) return;
248
+ let e = this.previewManifest, t = this.previewBuffer;
249
+ if (!e || !(t instanceof ArrayBuffer)) throw Error("孪生体轻量预览数据不能为空");
250
+ if (t.byteLength > this.previewMaxInflatedBytes) throw Error("孪生体轻量预览数据超过16 MB");
251
+ let n = ++this.requestVersion;
252
+ try {
253
+ let r = await O(t, e.lod, this.previewMaxInflatedBytes, this.previewEntityLimit);
254
+ if (this.destroyed || n !== this.requestVersion) return;
255
+ this.addPreviewEntities(r, e);
256
+ } catch (e) {
257
+ throw !this.destroyed && typeof this.onPreviewError == "function" && this.onPreviewError(e instanceof Error ? e.message : "孪生体轻量预览解析失败"), e;
258
+ }
259
+ }
260
+ isServiceColorEnabled() {
261
+ return !!(this.enableServiceColor && this.serviceName && this.dictCode && this.modelColorUrl);
262
+ }
263
+ async loadModelColorsByIds(e = []) {
264
+ if (!this.isServiceColorEnabled()) return /* @__PURE__ */ new Map();
265
+ let t = [...new Set(e.map((e) => String(e ?? "").trim()).filter((e) => e))];
266
+ if (t.length === 0) return /* @__PURE__ */ new Map();
267
+ let n = /* @__PURE__ */ new Map(), r = [];
268
+ if (t.forEach((e) => {
269
+ this.modelColorCache.has(e) ? n.set(e, this.modelColorCache.get(e)) : r.push(e);
270
+ }), r.length === 0) return n;
271
+ for (let e = 0; e < r.length; e += 800) {
272
+ let t = r.slice(e, e + 800);
273
+ try {
274
+ let e = await f.request({
275
+ method: "POST",
276
+ url: this.modelColorUrl,
277
+ data: {
278
+ serviceName: this.serviceName,
279
+ dictCode: this.dictCode,
280
+ modelIds: t
281
+ },
282
+ timeout: 6e4
283
+ });
284
+ ((e?.data ?? e)?.rows || []).forEach((e) => {
285
+ let t = String(e.modelId || e.model_id || "").trim(), r = e.color;
286
+ t && r && (this.modelColorCache.set(t, r), n.set(t, r));
287
+ });
288
+ } catch (e) {
289
+ console.warn(`图层 ${this.id} 查询服务配色失败(本批回退默认色):`, e);
290
+ }
291
+ }
292
+ return n;
293
+ }
294
+ addPreviewEntities(e, n) {
295
+ this.clearAllTiles();
296
+ let r = this.previewColorMap || {}, i = k(this.previewDefaultColor, this.color), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set();
297
+ for (let t of e) {
298
+ if (this.previewHiddenEntityIds?.size && this.previewHiddenEntityIds.has(String(t.id))) continue;
299
+ let e = k(r[String(t.id)], i);
300
+ e !== i && !o.has(e) && (o.size >= Math.max(0, this.previewColorGroupLimit - 1) ? e = i : o.add(e)), a.has(e) || a.set(e, []), a.get(e).push(t);
301
+ }
302
+ let s = [], c = [], l = 0;
303
+ for (let [e, r] of a) {
304
+ let { primitive: i, boundingSphere: a } = D(r, n.geosot, `${n.shard.index}_C${l}`, C(e), this.opacity);
305
+ i.layerId = this.id, i.geoSot = n.geosot, t(this.viewer, i, this.stackIndex, 0, {
306
+ layerType: "zzts3dv2",
307
+ groupKey: this.groupKey,
308
+ subStackIndex: this.subStackIndex,
309
+ tileOrder: l
310
+ }), s.push({
311
+ primitive: i,
312
+ shardIndex: n.shard.index
313
+ }), c.push(a), l += 1;
314
+ }
315
+ this.loadedTiles.set(n.geosot, s), this.flyToPreviewBounds(c);
316
+ }
317
+ flyToPreviewBounds(e) {
318
+ if (!this.viewer || !Array.isArray(e) || e.length === 0) return;
319
+ let t = Cesium.BoundingSphere.fromBoundingSpheres(e);
320
+ !t || !Number.isFinite(t.radius) || this.viewer.camera.flyToBoundingSphere(t, { duration: 1 });
321
+ }
322
+ async handleViewportGrids(e, t, n) {
323
+ if (this.destroyed) return;
324
+ if (!e.length) {
325
+ this.clearAllTiles(), this.currentViewKeys = /* @__PURE__ */ new Set();
326
+ return;
327
+ }
328
+ let r = g[t] || 5, i = encodeURIComponent(this.dataLayerId), a = [], o = [], s = /* @__PURE__ */ new Set();
329
+ for (let t of e) {
330
+ let e = String(t.geoSot || "").replace(/-/g, "");
331
+ if (!e || s.has(e)) continue;
332
+ s.add(e);
333
+ let n = `${r}:${e}`, i = this.blockCache.get(n);
334
+ i ? (this.blockCache.delete(n), this.blockCache.set(n, i), a.push(i)) : o.push({
335
+ key: n,
336
+ geosot: e,
337
+ raw: String(t.geoSot || "")
338
+ });
339
+ }
340
+ let c = [];
341
+ if (o.length) {
342
+ let e = await Promise.all(o.map((e) => this.fetchCapsuleBlock(i, r, e.raw, n)));
343
+ if (this.destroyed || n?.aborted) return;
344
+ let t = 0, s = 0;
345
+ for (let n = 0; n < e.length; n++) {
346
+ let r = e[n];
347
+ if (r.status === "ok") {
348
+ for (t++, this.blockCache.set(o[n].key, r.block); this.blockCache.size > _;) {
349
+ let e = this.blockCache.keys().next().value;
350
+ this.blockCache.delete(e);
351
+ }
352
+ a.push(r.block);
353
+ for (let e of r.block.entities) c.push(String(e.id ?? ""));
354
+ } else r.status === "miss" && s++;
355
+ }
356
+ if (t === 0 && s === e.length && !a.length) {
357
+ this.viewModeFailed = !0, this.getViewportInfo();
358
+ return;
359
+ }
360
+ t > 0 && (this.viewConfirmed = !0);
361
+ }
362
+ if (c.length) {
363
+ let e = await this.loadModelColorsByIds(c);
364
+ for (let [t, n] of e) this.viewColorMap.set(t, n);
365
+ }
366
+ if (this.destroyed || n?.aborted) return;
367
+ if (!a.length) {
368
+ this.clearAllTiles(), this.currentViewKeys = /* @__PURE__ */ new Set();
369
+ return;
370
+ }
371
+ let l = new Set(a.map((e) => `${e.lod}:${e.geosot}`));
372
+ l.size === this.currentViewKeys.size && [...l].every((e) => this.currentViewKeys.has(e)) || (this.currentViewKeys = l, await this.applyViewBlocks(a));
373
+ }
374
+ async fetchCapsuleBlock(e, t, n, r) {
375
+ try {
376
+ let i = await f.request({
377
+ method: "GET",
378
+ url: `${h}?layerId=${e}&lod=${t}&geosot=${encodeURIComponent(n)}`,
379
+ headers: { Accept: "application/octet-stream" },
380
+ responseType: "arraybuffer",
381
+ timeout: 6e4,
382
+ signal: r
383
+ }), a = i?.data ?? i;
384
+ if (!(a instanceof ArrayBuffer) || a.byteLength < 16) return { status: "miss" };
385
+ let o = w(a, t);
386
+ return {
387
+ status: "ok",
388
+ block: {
389
+ geosot: n.replace(/-/g, ""),
390
+ lod: t,
391
+ entities: o,
392
+ sphere: b(o)
393
+ }
394
+ };
395
+ } catch (e) {
396
+ return e?.name === "AbortError" ? { status: "abort" } : e?.response?.status === 404 ? { status: "miss" } : (console.warn(`[zzLayerZzts3dv2] 取块失败(已跳过): lod=${t} geosot=${n}`, e?.message || e), { status: "error" });
397
+ }
398
+ }
399
+ async applyViewBlocks(e) {
400
+ if (this.destroyed) return;
401
+ let n = ++this._tileStateVersion;
402
+ if (this.loadedTiles.size === 0) {
403
+ for (let t of e) {
404
+ if (this.destroyed || n !== this._tileStateVersion) return;
405
+ this._buildShardGroups({ geoSot: t.geosot }, { index: 0 }, t.entities, this.viewColorMap, !1), await y();
406
+ }
407
+ return;
408
+ }
409
+ let r = [];
410
+ for (let t of e) {
411
+ if (this.destroyed || n !== this._tileStateVersion) return;
412
+ r.push({
413
+ geosot: `${t.lod}:${t.geosot}`,
414
+ primitives: this._buildShardGroups({ geoSot: t.geosot }, { index: 0 }, t.entities, this.viewColorMap, !0)
415
+ }), await y();
416
+ }
417
+ if (this.destroyed || n !== this._tileStateVersion) return;
418
+ for (let e of this.loadedTiles.values()) for (let { primitive: t } of e) try {
419
+ this.viewer.scene.primitives.remove(t);
420
+ } catch (e) {
421
+ console.warn("移除旧块图元失败:", e);
422
+ }
423
+ let i = /* @__PURE__ */ new Map(), a = 0;
424
+ for (let e of r) {
425
+ for (let n of e.primitives) t(this.viewer, n, this.stackIndex, 0, {
426
+ layerType: "zzts3dv2",
427
+ groupKey: this.groupKey,
428
+ subStackIndex: this.subStackIndex,
429
+ tileOrder: a++
430
+ });
431
+ i.set(e.geosot, e.primitives.map((e) => ({
432
+ primitive: e,
433
+ shardIndex: 0
434
+ })));
435
+ }
436
+ this.loadedTiles = i;
437
+ }
438
+ initHandler() {
439
+ if (!this.viewer) return;
440
+ if (this.getViewportInfo(), this.handlers) try {
441
+ this.viewer.camera.changed.removeEventListener(this.handlers);
442
+ } catch (e) {
443
+ console.warn("移除旧的事件监听器失败:", e);
444
+ }
445
+ let e = null, t = () => {
446
+ clearTimeout(e), e = setTimeout(() => this.getViewportInfo(), 250);
447
+ };
448
+ this.viewer.camera.changed.addEventListener(t), this.handlers = t;
449
+ }
450
+ getViewportInfo() {
451
+ if (this.destroyed || !this.viewer) return;
452
+ this.requestController && this.requestController.abort(), this.requestController = new AbortController();
453
+ let e = p.getFrustumGroundIntersectionPoints(this.viewer), t = p.getCameraView(this.viewer);
454
+ if (t.pitch > -18 || !e || e.length < 4) return;
455
+ let n = i(r([
456
+ [e[0].x, e[0].y],
457
+ [e[1].x, e[1].y],
458
+ [e[2].x, e[2].y],
459
+ [e[3].x, e[3].y]
460
+ ])), a = {
461
+ west: n[0],
462
+ south: n[1],
463
+ east: n[2],
464
+ north: n[3]
465
+ }, o = this.displayRange ? S(a, this.displayRange) : a;
466
+ if (!o) {
467
+ this.clearAllTiles();
468
+ return;
469
+ }
470
+ if (!this.viewModeFailed) {
471
+ this.getEntityData([
472
+ o.west,
473
+ o.south,
474
+ o.east,
475
+ o.north
476
+ ], 0, this.requestController.signal);
477
+ return;
478
+ }
479
+ let s;
480
+ if (this.isStatic && this.fixedLevel) s = this.fixedLevel + this.levels_add;
481
+ else {
482
+ let e = p.getCenter(this.viewer), n = Cesium.Cartesian3.distance(Cesium.Cartesian3.fromDegrees(e.x, e.y, 0), Cesium.Cartesian3.fromDegrees(t.x, t.y, t.z)), r = p.entityGridLevels.filter((e) => e.max >= n && e.min <= n);
483
+ if (!r[0]) return;
484
+ s = r[0].level + this.levels_add;
485
+ }
486
+ this.currentNewLevel.value = s;
487
+ let c = this.lodCalculationRange || o;
488
+ this.getEntityData([
489
+ c.west,
490
+ c.south,
491
+ c.east,
492
+ c.north
493
+ ], s, this.requestController.signal);
494
+ }
495
+ async getEntityData(e, t, n) {
496
+ if (!this.viewer) return;
497
+ let r = this.viewer.scene.canvas, i = r.clientWidth, a = r.clientHeight, o = Number(e[2]) - Number(e[0]), s = Number(e[3]) - Number(e[1]);
498
+ if (!(o > 20 || s > 20)) try {
499
+ let t = await f.request({
500
+ method: "GET",
501
+ url: `/v1/zzts/layer/3d/calTiles?region=${e[0]},${e[1]},0,${e[2]},${e[3]},10&width=${i}&height=${a}`,
502
+ timeout: 6e4,
503
+ signal: n
504
+ });
505
+ if (n.aborted || this.destroyed) return;
506
+ let r = t.tiles || [];
507
+ this.viewModeFailed ? this.renderTiles(r, t.lodLevel) : this.handleViewportGrids(r, t.lodLevel, n);
508
+ } catch (e) {
509
+ e?.name !== "AbortError" && console.error(`图层 ${this.id} 获取格网数据出错:`, e);
510
+ }
511
+ }
512
+ renderTiles(e, t) {
513
+ if (this.destroyed) return;
514
+ let n = ++this.requestVersion;
515
+ this._tileStateVersion++;
516
+ let r = new Set(e.map((e) => e.geoSot));
517
+ this.lastTilesCount = e.length, this.emptyFallbackNotified = !1;
518
+ for (let e of [...this.loadedTiles.keys()]) r.has(e) || this.removeTile(e);
519
+ for (let e of [...this.emptyTiles]) r.has(e) || this.emptyTiles.delete(e);
520
+ e.filter((e) => !this.loadedTiles.has(e.geoSot) && !this.emptyTiles.has(e.geoSot)).forEach((e) => this.loadTile(e, t, n, this.requestController?.signal));
521
+ }
522
+ maybeNotifyEmptyFallback() {
523
+ this.previewMode || this.emptyFallbackNotified || this.destroyed || this.loadedTiles.size === 0 && this.lastTilesCount > 0 && this.emptyTiles.size >= this.lastTilesCount && (this.emptyFallbackNotified = !0, setTimeout(() => {
524
+ !this.destroyed && typeof this.onEmptyFallback == "function" && this.onEmptyFallback();
525
+ }, 0));
526
+ }
527
+ async loadTile(e, t, n, r) {
528
+ let i = () => !this.destroyed && n === this.requestVersion && !r?.aborted;
529
+ try {
530
+ let n = await f.request({
531
+ method: "GET",
532
+ url: `${m}?layerId=${encodeURIComponent(this.dataLayerId)}&geosot=${encodeURIComponent(e.geoSot)}&level=${t}`,
533
+ timeout: 6e4,
534
+ signal: r
535
+ });
536
+ if (!i()) return;
537
+ if (!n || n.protocol === "EMPTY" || !n.shards?.length) {
538
+ this.emptyTiles.add(e.geoSot), this.maybeNotifyEmptyFallback();
539
+ return;
540
+ }
541
+ let a = await Promise.all(n.shards.map((t) => f.request({
542
+ method: "GET",
543
+ url: t.url,
544
+ headers: { Accept: "application/octet-stream" },
545
+ responseType: "arraybuffer",
546
+ timeout: 6e4,
547
+ signal: r
548
+ }).then((r) => this.addShardToMap(e, t, r.data, n.lod))));
549
+ if (!i()) {
550
+ a.filter(Boolean).flat().forEach((e) => this.viewer.scene.primitives.remove(e));
551
+ return;
552
+ }
553
+ } catch (t) {
554
+ t?.name !== "AbortError" && console.error(`图层 ${this.id} 加载瓦片失败:`, e.geoSot, t);
555
+ }
556
+ }
557
+ async addShardToMap(e, t, n, r) {
558
+ let i = w(n, r), a = await this.loadModelColorsByIds(i.map((e) => String(e.id ?? "")));
559
+ return this.destroyed ? [] : (this._cacheShardData(e, t, r, i), this._buildShardGroups(e, t, i, a, !1));
560
+ }
561
+ _cacheShardData(e, t, n, r) {
562
+ let i = this.shardDataCache.get(e.geoSot);
563
+ i || (i = [], this.shardDataCache.set(e.geoSot, i));
564
+ let a = i.filter((e) => e.shard.index !== t.index);
565
+ a.push({
566
+ shard: t,
567
+ tile: e,
568
+ lod: n,
569
+ entities: r
570
+ }), this.shardDataCache.set(e.geoSot, a);
571
+ }
572
+ _buildShardGroups(e, n, r, i, a) {
573
+ let o = /* @__PURE__ */ new Map();
574
+ for (let e of r) {
575
+ let t = i.get(String(e.id ?? "").trim()), n = t ? String(t).trim() : this.color;
576
+ this.hiddenColors?.size && this.hiddenColors.has(A(n)) || (o.has(n) || o.set(n, []), o.get(n).push(e));
577
+ }
578
+ let s = [], c = 0;
579
+ for (let [r, i] of o) {
580
+ let { primitive: o } = D(i, e.geoSot, `${n.index}_C${c}`, C(r), this.opacity);
581
+ if (o.layerId = this.id, o.geoSot = e.geoSot, !a) {
582
+ t(this.viewer, o, this.stackIndex, 0, {
583
+ layerType: "zzts3dv2",
584
+ groupKey: this.groupKey,
585
+ subStackIndex: this.subStackIndex,
586
+ tileOrder: this.loadedTiles.size
587
+ });
588
+ let r = this.loadedTiles.get(e.geoSot);
589
+ r || (r = [], this.loadedTiles.set(e.geoSot, r)), r.push({
590
+ primitive: o,
591
+ shardIndex: n.index
592
+ });
593
+ }
594
+ s.push(o), c += 1;
595
+ }
596
+ return s;
597
+ }
598
+ async _rebuildForHiddenColors() {
599
+ if (this.destroyed) return;
600
+ if (this.previewMode) {
601
+ this.loadPreviewSnapshot();
602
+ return;
603
+ }
604
+ if (this._hiddenRebuildPending) {
605
+ this._hiddenRebuildQueued = !0;
606
+ return;
607
+ }
608
+ for (let e of this.loadedTiles.keys()) {
609
+ let t = this.shardDataCache.get(e);
610
+ if (!t || !t.length) {
611
+ this.clearAllTiles(), this.getViewportInfo();
612
+ return;
613
+ }
614
+ }
615
+ if (!this.loadedTiles.size) {
616
+ this.getViewportInfo();
617
+ return;
618
+ }
619
+ this._hiddenRebuildPending = !0;
620
+ let e = this._tileStateVersion, n = [];
621
+ for (let [t, r] of this.shardDataCache.entries()) {
622
+ if (!this.loadedTiles.has(t)) continue;
623
+ let i = [];
624
+ for (let t of r) {
625
+ let n = await this.loadModelColorsByIds(t.entities.map((e) => String(e.id ?? "")));
626
+ if (this.destroyed || e !== this._tileStateVersion) {
627
+ this._finishHiddenRebuild();
628
+ return;
629
+ }
630
+ i.push({
631
+ shardIndex: t.shard.index,
632
+ primitives: this._buildShardGroups(t.tile, t.shard, t.entities, n, !0)
633
+ });
634
+ }
635
+ i.length && n.push({
636
+ geoSot: t,
637
+ staged: i
638
+ });
639
+ }
640
+ for (let e of this.loadedTiles.values()) for (let { primitive: t } of e) try {
641
+ this.viewer.scene.primitives.remove(t);
642
+ } catch (e) {
643
+ console.warn("移除分片图元失败:", e);
644
+ }
645
+ let r = /* @__PURE__ */ new Map();
646
+ n.forEach(({ geoSot: e, staged: n }, i) => {
647
+ let a = [];
648
+ for (let e of n) for (let n of e.primitives) t(this.viewer, n, this.stackIndex, 0, {
649
+ layerType: "zzts3dv2",
650
+ groupKey: this.groupKey,
651
+ subStackIndex: this.subStackIndex,
652
+ tileOrder: i
653
+ }), a.push({
654
+ primitive: n,
655
+ shardIndex: e.shardIndex
656
+ });
657
+ r.set(e, a);
658
+ }), this.loadedTiles = r, this._finishHiddenRebuild();
659
+ }
660
+ _finishHiddenRebuild() {
661
+ this._hiddenRebuildPending = !1, this._hiddenRebuildQueued && (this._hiddenRebuildQueued = !1, this._rebuildForHiddenColors());
662
+ }
663
+ removeTile(e) {
664
+ let t = this.loadedTiles.get(e);
665
+ if (t) {
666
+ this._tileStateVersion++, this.shardDataCache.delete(e);
667
+ for (let { primitive: e } of t) try {
668
+ this.viewer.scene.primitives.remove(e);
669
+ } catch (e) {
670
+ console.warn("移除分片图元失败:", e);
671
+ }
672
+ this.loadedTiles.delete(e);
673
+ }
674
+ }
675
+ removeTilesOnly() {
676
+ this.clearAllTiles();
677
+ }
678
+ clearAllTiles() {
679
+ this._tileStateVersion++;
680
+ for (let e of [...this.loadedTiles.keys()]) this.removeTile(e);
681
+ this.emptyTiles.clear(), this.shardDataCache.clear(), this.viewConfirmed && (this.currentViewKeys = /* @__PURE__ */ new Set());
682
+ }
683
+ updateOptions(t = {}) {
684
+ let n = t.color !== void 0 && t.color !== this.color, r = t.opacity !== void 0 && Number(t.opacity) !== this.opacity, i = t.previewHiddenEntityIds === void 0 ? null : (t.previewHiddenEntityIds || []).map(String), a = i !== null && (i.length !== this.previewHiddenEntityIds.size || i.some((e) => !this.previewHiddenEntityIds.has(e))), o = t.hiddenColors === void 0 ? null : (t.hiddenColors || []).map(A).filter(Boolean), s = o !== null && (o.length !== this.hiddenColors.size || o.some((e) => !this.hiddenColors.has(e))), c = t.level !== void 0 && t.level !== this.fixedLevel, l = t.isStatic !== void 0 && t.isStatic !== this.isStatic, u = t.previewVersion !== void 0 && t.previewVersion !== this.previewVersion, d = n || r || c || l || u || a || s, f = (a || s) && !n && !r && !c && !l && !u;
685
+ t.dataLayerId !== void 0 && (this.dataLayerId = t.dataLayerId || this.id), t.viewer !== void 0 && (this.viewer = t.viewer || null), t.color !== void 0 && (this.color = t.color), t.opacity !== void 0 && (this.opacity = Number(t.opacity));
686
+ let p = t.serviceName !== void 0 && t.serviceName !== this.serviceName || t.dictCode !== void 0 && t.dictCode !== this.dictCode;
687
+ if (t.serviceName !== void 0 && (this.serviceName = t.serviceName || ""), t.dictCode !== void 0 && (this.dictCode = t.dictCode || ""), t.enableServiceColor !== void 0 && (this.enableServiceColor = t.enableServiceColor !== !1), t.modelColorUrl !== void 0 && (this.modelColorUrl = t.modelColorUrl || "/v1/zzts/style/render/modelColors"), p && this.modelColorCache.clear(), t.displayRange !== void 0 && (this.displayRange = x(t.displayRange)), t.lodCalculationRange !== void 0 && (this.lodCalculationRange = x(t.lodCalculationRange)), t.stackIndex !== void 0 && (this.stackIndex = t.stackIndex), t.subStackIndex !== void 0 && (this.subStackIndex = t.subStackIndex ?? 0), t.groupKey !== void 0 && (this.groupKey = t.groupKey || String(this.id)), t.previewVersion !== void 0 && (this.previewVersion = t.previewVersion), t.previewManifest !== void 0 && (this.previewManifest = t.previewManifest), t.previewBuffer !== void 0 && (this.previewBuffer = t.previewBuffer), t.previewColorMap !== void 0 && (this.previewColorMap = t.previewColorMap || {}), i !== null && (this.previewHiddenEntityIds = new Set(i)), o !== null && (this.hiddenColors = new Set(o)), t.previewDefaultColor !== void 0 && (this.previewDefaultColor = k(t.previewDefaultColor, this.color)), t.previewColorGroupLimit !== void 0 && (this.previewColorGroupLimit = Math.min(Number(t.previewColorGroupLimit) || 32, 32)), t.onPreviewError !== void 0 && (this.onPreviewError = t.onPreviewError), t.onEmptyFallback !== void 0 && (this.onEmptyFallback = t.onEmptyFallback || null), this.emptyFallbackNotified = !1, !d && t.stackIndex !== void 0) for (let t of this.loadedTiles.values()) for (let { primitive: n } of t) e(this.viewer, n, this.stackIndex, 0, {
688
+ layerType: "zzts3dv2",
689
+ groupKey: this.groupKey,
690
+ subStackIndex: this.subStackIndex
691
+ });
692
+ if (d) {
693
+ if (this.viewConfirmed && !this.viewModeFailed && this.currentViewKeys.size) {
694
+ let e = [...this.currentViewKeys].map((e) => this.blockCache.get(e)).filter(Boolean);
695
+ if (e.length) {
696
+ this.applyViewBlocks(e);
697
+ return;
698
+ }
699
+ this.getViewportInfo();
700
+ return;
701
+ }
702
+ f ? this._rebuildForHiddenColors() : (this.clearAllTiles(), this.previewMode ? this.loadPreviewSnapshot() : this.getViewportInfo());
703
+ }
704
+ }
705
+ getCurrentLevel() {
706
+ return this.currentNewLevel.value;
707
+ }
708
+ remove() {
709
+ if (this.destroyed = !0, this.handlers) {
710
+ try {
711
+ this.viewer?.camera?.changed?.removeEventListener(this.handlers);
712
+ } catch (e) {
713
+ console.warn("移除事件监听器失败:", e);
714
+ }
715
+ this.handlers = null;
716
+ }
717
+ this.clearAllTiles(), this.requestController &&= (this.requestController.abort(), null);
718
+ }
719
+ }, M = new class {
720
+ constructor() {
721
+ this.layers = /* @__PURE__ */ new Map();
722
+ }
723
+ async createLayer(e) {
724
+ let t = typeof e == "string" ? e : e?.layerId || e?.id;
725
+ if (!t) return console.error("创建图层失败:缺少id参数"), null;
726
+ if (this.layers.has(t)) {
727
+ console.warn(`图层 ${t} 已存在,更新图层配置`);
728
+ let n = this.layers.get(t);
729
+ if (n.initPromise && await n.initPromise, n.destroyed) return this.layers.delete(t), this.createLayer(e);
730
+ if (this.layers.get(t) !== n) return this.createLayer(e);
731
+ let r = a(n.renderSignature, e || {});
732
+ return typeof n.updateOptions == "function" && (r ? n.updateOptions(e || {}) : n.updateOptions({
733
+ stackIndex: e?.stackIndex,
734
+ subStackIndex: e?.subStackIndex,
735
+ groupKey: e?.groupKey
736
+ })), r && (n.renderSignature = o(e || {})), n;
737
+ }
738
+ let n = new j(t, e?.isStatic, e?.level ?? null, e?.color ?? "255,255,255", e?.opacity ?? 1, e || {});
739
+ n.renderSignature = o(e || {}), n.initPromise = n.init(), this.layers.set(t, n);
740
+ try {
741
+ if (await n.initPromise, n.destroyed) return this.layers.get(t) === n && this.layers.delete(t), null;
742
+ } catch (e) {
743
+ return console.error(`图层 ${t} 初始化失败:`, e), this.layers.delete(t), n.remove(), null;
744
+ }
745
+ return n;
746
+ }
747
+ removeLayer(e) {
748
+ let t = this.layers.get(e);
749
+ t && (t.remove(), this.layers.delete(e));
750
+ }
751
+ removeAllLayers() {
752
+ this.layers.forEach((e) => e.remove()), this.layers.clear();
753
+ }
754
+ getLayer(e) {
755
+ return this.layers.get(e);
756
+ }
757
+ getLayerIds() {
758
+ return Array.from(this.layers.keys());
759
+ }
760
+ removeTilesByLayerId(e) {
761
+ let t = this.layers.get(e);
762
+ t && t.removeTilesOnly();
763
+ }
764
+ refreshLayer(e) {
765
+ let t = this.layers.get(e);
766
+ t && t.getViewportInfo();
767
+ }
768
+ }(), N = async (e) => M.createLayer(e), P = (e) => M.removeLayer(e), F = (e) => M.getLayer(e);
769
+ s(() => {
770
+ let e = M.getLayerIds();
771
+ if (e.length > 0) {
772
+ let t = M.getLayer(e[0]);
773
+ return t ? t.getCurrentLevel() : 15;
774
+ }
775
+ return 15;
776
+ });
777
+ //#endregion
778
+ //#region src/zz-layer/zz-layer-zzts3dv2/index.vue
779
+ var I = {
780
+ __name: "index",
781
+ props: {
782
+ config: {
783
+ type: Object,
784
+ default: () => ({})
785
+ },
786
+ stackIndex: {
787
+ type: Number,
788
+ default: -1
789
+ },
790
+ subStackIndex: {
791
+ type: Number,
792
+ default: 0
793
+ },
794
+ groupKey: {
795
+ type: String,
796
+ default: ""
797
+ }
798
+ },
799
+ emits: ["empty-fallback"],
800
+ setup(e, { emit: t }) {
801
+ let n = c("cesiumViewer"), r = t, i = e, o = {
802
+ layerId: "",
803
+ dataLayerId: "",
804
+ color: "255,255,255",
805
+ isStatic: !1,
806
+ level: null,
807
+ opacity: 1,
808
+ layerOpacity: 1,
809
+ dictCode: "",
810
+ serviceName: "",
811
+ enableServiceColor: !1,
812
+ modelColorUrl: "/v1/zzts/style/render/modelColors",
813
+ displayRange: null,
814
+ lodCalculationRange: null,
815
+ previewMode: !1,
816
+ previewVersion: 0,
817
+ previewManifest: null,
818
+ previewBuffer: null,
819
+ previewColorMap: null,
820
+ previewHiddenEntityIds: [],
821
+ hiddenColors: [],
822
+ previewDefaultColor: "153,153,153",
823
+ previewEntityLimit: 300,
824
+ previewMaxInflatedBytes: 16 * 1024 * 1024,
825
+ previewColorGroupLimit: 32,
826
+ onPreviewError: null
827
+ }, u = s(() => ({
828
+ ...o,
829
+ ...i.config
830
+ })), f = "";
831
+ function p(e) {
832
+ let t = e.level ? !0 : e.isStatic;
833
+ return {
834
+ layerId: e.layerId,
835
+ dataLayerId: e.dataLayerId || e.layerId,
836
+ color: e.color,
837
+ isStatic: t,
838
+ level: e.level,
839
+ opacity: e.opacity,
840
+ layerOpacity: e.layerOpacity,
841
+ dictCode: e.dictCode,
842
+ serviceName: e.serviceName,
843
+ enableServiceColor: e.enableServiceColor,
844
+ modelColorUrl: e.modelColorUrl || "/v1/zzts/style/render/modelColors",
845
+ displayRange: e.displayRange,
846
+ lodCalculationRange: e.lodCalculationRange,
847
+ previewMode: e.previewMode,
848
+ previewVersion: e.previewVersion,
849
+ previewManifest: e.previewManifest,
850
+ previewBuffer: e.previewBuffer,
851
+ previewColorMap: e.previewColorMap,
852
+ previewHiddenEntityIds: e.previewHiddenEntityIds,
853
+ hiddenColors: e.hiddenColors,
854
+ previewDefaultColor: e.previewDefaultColor,
855
+ previewEntityLimit: e.previewEntityLimit,
856
+ previewMaxInflatedBytes: e.previewMaxInflatedBytes,
857
+ previewColorGroupLimit: e.previewColorGroupLimit,
858
+ onPreviewError: e.onPreviewError,
859
+ onEmptyFallback: () => r("empty-fallback"),
860
+ viewer: n?.value || null,
861
+ stackIndex: i.stackIndex,
862
+ subStackIndex: i.subStackIndex,
863
+ groupKey: i.groupKey || e.layerId
864
+ };
865
+ }
866
+ let m = async () => {
867
+ let e = u.value;
868
+ if (!n?.value) {
869
+ console.warn("[zzLayerZzts3dv2] 三维地图尚未就绪,等待地图初始化");
870
+ return;
871
+ }
872
+ if (!e.layerId) {
873
+ console.warn("[zzLayerZzts3dv2] 缺少 layerId,跳过初始化", e);
874
+ return;
875
+ }
876
+ let t = p(e), r = F(e.layerId);
877
+ if (r && !a(r.renderSignature, t)) {
878
+ typeof r.updateOptions == "function" && r.updateOptions(t), f = e.layerId;
879
+ return;
880
+ }
881
+ await N(t), f = e.layerId;
882
+ }, h = () => {
883
+ P(u.value.layerId);
884
+ };
885
+ return d(() => i.config, async () => {
886
+ await m();
887
+ }, {
888
+ deep: !0,
889
+ immediate: !0
890
+ }), d(() => [
891
+ i.stackIndex,
892
+ i.subStackIndex,
893
+ i.groupKey
894
+ ], () => {
895
+ let e = u.value, t = F(e.layerId);
896
+ if (t && typeof t.updateOptions == "function") {
897
+ t.updateOptions({
898
+ stackIndex: i.stackIndex,
899
+ subStackIndex: i.subStackIndex,
900
+ groupKey: i.groupKey || e.layerId
901
+ });
902
+ return;
903
+ }
904
+ m();
905
+ }), d(n, (e) => {
906
+ e && m();
907
+ }), l(() => {
908
+ f ? P(f) : h();
909
+ }), (e, t) => null;
910
+ }
911
+ };
912
+ //#endregion
913
+ export { I as default };