@maqiuyao/dxf-viewer 0.2.13 → 0.2.15

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.
@@ -50,17 +50,17 @@ import { UnrealBloomPass as Xl } from "three/examples/jsm/postprocessing/UnrealB
50
50
  import { FXAAShader as Zl } from "three/examples/jsm/shaders/FXAAShader.js";
51
51
  import { VertexNormalsHelper as Kl } from "three/examples/jsm/helpers/VertexNormalsHelper.js";
52
52
  import { includes as $l, get as Jl } from "lodash";
53
- const Bi = 1, ht = new p.Sphere(), Tn = new p.Vector3(), Cn = new p.Vector3(), Br = new p.Vector3(), kr = new p.Vector3();
53
+ const Bi = 1, dt = new p.Sphere(), Tn = new p.Vector3(), Cn = new p.Vector3(), Br = new p.Vector3(), kr = new p.Vector3();
54
54
  p.Line.prototype.raycast = function(c, t) {
55
55
  const e = this.geometry, i = this.matrixWorld, s = c.params.Line.threshold, n = e.drawRange;
56
- if (e.boundingSphere === null && e.computeBoundingSphere(), ht.copy(e.boundingSphere), ht.applyMatrix4(i), ht.radius += s, c.ray.intersectsSphere(ht) === !1) return;
56
+ if (e.boundingSphere === null && e.computeBoundingSphere(), dt.copy(e.boundingSphere), dt.applyMatrix4(i), dt.radius += s, c.ray.intersectsSphere(dt) === !1) return;
57
57
  const r = s * s, a = this.isLineSegments ? 2 : 1, o = e.index, l = e.attributes, h = l.position, d = t.length;
58
58
  if (o !== null) {
59
59
  const u = this.userData.batches;
60
60
  if (u && u.length > 0 && u[0].boundingSphere)
61
61
  for (let f = 0; f < u.length; f++) {
62
62
  const m = u[f];
63
- if (ht.copy(m.boundingSphere), ht.applyMatrix4(i), c.ray.intersectsSphere(ht) !== !1)
63
+ if (dt.copy(m.boundingSphere), dt.applyMatrix4(i), c.ray.intersectsSphere(dt) !== !1)
64
64
  for (let b = m.indexStart, y = m.indexStart + m.indexCount - 1; b < y; b += a) {
65
65
  const S = o.getX(b), w = o.getX(b + 1);
66
66
  if (ws(this, h, c, S, w, r, t) && (t[t.length - 1].index = b, t.length - d >= Bi))
@@ -80,7 +80,7 @@ p.Line.prototype.raycast = function(c, t) {
80
80
  if (u && u.length > 0 && u[0].boundingSphere)
81
81
  for (let f = 0; f < u.length; f++) {
82
82
  const m = u[f];
83
- if (ht.copy(m.boundingSphere), ht.applyMatrix4(i), c.ray.intersectsSphere(ht) !== !1) {
83
+ if (dt.copy(m.boundingSphere), dt.applyMatrix4(i), c.ray.intersectsSphere(dt) !== !1) {
84
84
  for (let b = m.positionStart, y = m.positionStart + m.positionCount - 1; b < y; b += a)
85
85
  if (ws(this, h, c, b, b + 1, r, t) && t.length - d >= Bi)
86
86
  return;
@@ -1230,10 +1230,10 @@ lt.prototype.intersectsTriangle = /* @__PURE__ */ (function() {
1230
1230
  if (se > 0 && ze > 0)
1231
1231
  return !1;
1232
1232
  s.copy(v.normal), n.copy(C.normal);
1233
- const ct = s.cross(n);
1234
- let ve = 0, Ni = Math.abs(ct.x);
1235
- const Qe = Math.abs(ct.y);
1236
- Qe > Ni && (Ni = Qe, ve = 1), Math.abs(ct.z) > Ni && (ve = 2);
1233
+ const ht = s.cross(n);
1234
+ let ve = 0, Ni = Math.abs(ht.x);
1235
+ const Qe = Math.abs(ht.y);
1236
+ Qe > Ni && (Ni = Qe, ve = 1), Math.abs(ht.z) > Ni && (ve = 2);
1237
1237
  const Ie = Mc[ve], At = this.a[Ie], Hi = this.b[Ie], Ht = this.c[Ie], Gt = E.a[Ie], Wt = E.b[Ie], qt = E.c[Ie];
1238
1238
  if (m(this, At, Hi, Ht, B, k, _, A, I, h, a))
1239
1239
  return u(this, E, M, O);
@@ -3519,7 +3519,7 @@ class S0 {
3519
3519
  }
3520
3520
  const xh = {
3521
3521
  "Precision from file": 99
3522
- }, E0 = (c, t) => c.toFixed(t === xh["Precision from file"] ? 2 : t), bh = "en", bt = !1, wh = 10, qe = 11, li = 12, Co = 583902, O0 = [0.031, 0.906, 0.867, 0.5], Rn = [0.3, 0.3, 0.3, 0.8], So = 0.5, Fn = 0.1, zn = 5e3, vh = 45, _0 = "x-viewer-iconfont", P0 = "x-viewer-iconfont2", Eo = 10, Qr = new p.Vector3(), ea = new p.Vector3(), ta = new p.Vector3(), cs = new p.Vector3(), St = new p.Vector3(), ia = new p.Triangle();
3522
+ }, E0 = (c, t) => c.toFixed(t === xh["Precision from file"] ? 2 : t), bh = "en", ct = !1, wh = 10, qe = 11, li = 12, Co = 583902, O0 = [0.031, 0.906, 0.867, 0.5], Rn = [0.3, 0.3, 0.3, 0.8], So = 0.5, Fn = 0.1, zn = 5e3, vh = 45, _0 = "x-viewer-iconfont", P0 = "x-viewer-iconfont2", Eo = 10, Qr = new p.Vector3(), ea = new p.Vector3(), ta = new p.Vector3(), cs = new p.Vector3(), St = new p.Vector3(), ia = new p.Triangle();
3523
3523
  function Mh(c, t, e, i, s) {
3524
3524
  const n = [], r = {};
3525
3525
  let a, o, l, h;
@@ -3613,14 +3613,14 @@ class Sh {
3613
3613
  for (let k = 0; k < 3; k++) {
3614
3614
  const D = (k + 1) % 3, R = l[k], ie = l[D], se = o[k], ze = o[D];
3615
3615
  !u[se] && (u[se] = /* @__PURE__ */ new Set()), u[se].add(ze), !u[ze] && (u[ze] = /* @__PURE__ */ new Set()), u[ze].add(se);
3616
- const ct = R + "_" + ie, ve = ie + "_" + R;
3616
+ const ht = R + "_" + ie, ve = ie + "_" + R;
3617
3617
  if (ve in b && b[ve]) {
3618
3618
  if (b[ve].outer) {
3619
3619
  P.warn("[Edge] edge: " + ve + " is already outer!");
3620
3620
  continue;
3621
3621
  }
3622
3622
  cs.dot(b[ve].normal) <= n ? b[ve].outer = !0 : b[ve].find = !0;
3623
- } else ct in b ? P.warn("[Edge] " + ct + " has existed in geometry!") : b[ct] = {
3623
+ } else ht in b ? P.warn("[Edge] " + ht + " has existed in geometry!") : b[ht] = {
3624
3624
  startIndex: se,
3625
3625
  endIndex: ze,
3626
3626
  normal: cs.clone(),
@@ -4938,7 +4938,7 @@ const Ih = new p.Vector3(0, 1, 0), Ze = class Ze {
4938
4938
  return n.layers.enableAll(), Ze.disableLayerChannels(n, [
4939
4939
  li,
4940
4940
  qe
4941
- ]), n.userData.isOutline = !0, n.matrixAutoUpdate = bt, i && n.applyMatrix4(i), n;
4941
+ ]), n.userData.isOutline = !0, n.matrixAutoUpdate = ct, i && n.applyMatrix4(i), n;
4942
4942
  }
4943
4943
  /**
4944
4944
  * Clones object
@@ -5194,7 +5194,7 @@ const Vs = new p.Matrix4(), Bh = new p.Matrix4(), us = class us {
5194
5194
  if (!x) return;
5195
5195
  x.userData = {}, w = new p.Points(x, u.material), o.push(w);
5196
5196
  }
5197
- w && (e ? w.userData.batches = S : (w.userData = u.userData, w.userData.batches = void 0), w.userData.layerName = u.userData.layerName, w.name = "[Merged] " + u.name, w.matrixAutoUpdate = bt, w.renderOrder = u.renderOrder, w.layers.mask = u.layers.mask, w.visible = u.visible, l.push(...d)), f.forEach((x) => {
5197
+ w && (e ? w.userData.batches = S : (w.userData = u.userData, w.userData.batches = void 0), w.userData.layerName = u.userData.layerName, w.name = "[Merged] " + u.name, w.matrixAutoUpdate = ct, w.renderOrder = u.renderOrder, w.layers.mask = u.layers.mask, w.visible = u.visible, l.push(...d)), f.forEach((x) => {
5198
5198
  x.dispose(), N.releaseGeometryManually(x);
5199
5199
  }), f = [];
5200
5200
  }), l.sort((h, d) => d - h), l.forEach((h) => {
@@ -5292,7 +5292,7 @@ const Vs = new p.Matrix4(), Bh = new p.Matrix4(), us = class us {
5292
5292
  if (!C) return;
5293
5293
  C.userData = {}, v = new p.Points(C, w.material), u.push(v);
5294
5294
  }
5295
- v && (n ? v.userData.batches = T : (v.userData = w.userData, v.userData.batches = void 0), v.userData.layerName = w.userData.layerName, v.name = "[Merged] " + w.name, v.matrixAutoUpdate = bt, v.renderOrder = w.renderOrder, v.layers.mask = w.layers.mask, v.visible = w.visible, S.forEach((C) => f.push(C))), x.forEach((C) => {
5295
+ v && (n ? v.userData.batches = T : (v.userData = w.userData, v.userData.batches = void 0), v.userData.layerName = w.userData.layerName, v.name = "[Merged] " + w.name, v.matrixAutoUpdate = ct, v.renderOrder = w.renderOrder, v.layers.mask = w.layers.mask, v.visible = w.visible, S.forEach((C) => f.push(C))), x.forEach((C) => {
5296
5296
  C.dispose(), N.releaseGeometryManually(C);
5297
5297
  }), x = [];
5298
5298
  }), P.debug("[Merge] Ran deepMerge() in " + (Date.now() - a) / 1e3 + "s");
@@ -15260,7 +15260,7 @@ const Mt = class Mt {
15260
15260
  }
15261
15261
  };
15262
15262
  g(Mt, "ENTITY_COLOR_ADDED", 65280), g(Mt, "ENTITY_COLOR_REMOVED", 16711680), g(Mt, "ENTITY_COLOR_NO_CHANGE", 10066329), g(Mt, "ENTITY_COLOR_MARKUP", 16744231), g(Mt, "ENTITY_TYPES_TO_IGNORE", ["ATTRIB", "SEQEND"]);
15263
- let yt = Mt;
15263
+ let xt = Mt;
15264
15264
  var H = /* @__PURE__ */ ((c) => (c[c.Object = 0] = "Object", c[c.Point = 1] = "Point", c[c.Line = 2] = "Line", c[c.LineSegment = 3] = "LineSegment", c[c.Mesh = 4] = "Mesh", c))(H || {});
15265
15265
  const Hn = new De(), Gn = new ot();
15266
15266
  class z {
@@ -15342,7 +15342,7 @@ class z {
15342
15342
  break;
15343
15343
  }
15344
15344
  if (e) {
15345
- if (e.name = this.name, e.matrixAutoUpdate = bt, e.applyMatrix4(this.matrix), e.layers.mask = this.layers.mask, e.renderOrder = this.renderOrder, e.userData = this.userData, t === !0)
15345
+ if (e.name = this.name, e.matrixAutoUpdate = ct, e.applyMatrix4(this.matrix), e.layers.mask = this.layers.mask, e.renderOrder = this.renderOrder, e.userData = this.userData, t === !0)
15346
15346
  for (let i = 0; i < this.children.length; i++) {
15347
15347
  const s = this.children[i], n = s.convertToThreejsObject(t);
15348
15348
  n && e.add(n);
@@ -18865,25 +18865,25 @@ class Yd {
18865
18865
  i.viewportId = e.value, e = t.next();
18866
18866
  break;
18867
18867
  case 10:
18868
- i.centerPoint = dt(t), e = t.lastReadGroup;
18868
+ i.centerPoint = ut(t), e = t.lastReadGroup;
18869
18869
  break;
18870
18870
  case 12:
18871
- i.centerPoint_dcs = dt(t), e = t.lastReadGroup;
18871
+ i.centerPoint_dcs = ut(t), e = t.lastReadGroup;
18872
18872
  break;
18873
18873
  case 13:
18874
- i.snapBasePoint_dcs = dt(t), e = t.lastReadGroup;
18874
+ i.snapBasePoint_dcs = ut(t), e = t.lastReadGroup;
18875
18875
  break;
18876
18876
  case 14:
18877
- i.snapSpacing_dcs = dt(t), e = t.lastReadGroup;
18877
+ i.snapSpacing_dcs = ut(t), e = t.lastReadGroup;
18878
18878
  break;
18879
18879
  case 15:
18880
- i.gridSpacing_dcs = dt(t), e = t.lastReadGroup;
18880
+ i.gridSpacing_dcs = ut(t), e = t.lastReadGroup;
18881
18881
  break;
18882
18882
  case 16:
18883
- i.viewDirection = dt(t), e = t.lastReadGroup;
18883
+ i.viewDirection = ut(t), e = t.lastReadGroup;
18884
18884
  break;
18885
18885
  case 17:
18886
- i.viewTarget = dt(t), e = t.lastReadGroup;
18886
+ i.viewTarget = ut(t), e = t.lastReadGroup;
18887
18887
  break;
18888
18888
  case 42:
18889
18889
  i.perspectiveLens = e.value, e = t.next();
@@ -18928,13 +18928,13 @@ class Yd {
18928
18928
  i.ucsIcon = e.value, e = t.next();
18929
18929
  break;
18930
18930
  case 110:
18931
- i.ucsOrigin = dt(t), e = t.lastReadGroup;
18931
+ i.ucsOrigin = ut(t), e = t.lastReadGroup;
18932
18932
  break;
18933
18933
  case 111:
18934
- i.ucsXAxis = dt(t), e = t.lastReadGroup;
18934
+ i.ucsXAxis = ut(t), e = t.lastReadGroup;
18935
18935
  break;
18936
18936
  case 112:
18937
- i.ucsYAxis = dt(t), e = t.lastReadGroup;
18937
+ i.ucsYAxis = ut(t), e = t.lastReadGroup;
18938
18938
  break;
18939
18939
  case 345:
18940
18940
  i.ucsTableRecordHandle = e.value, e = t.next();
@@ -18977,7 +18977,7 @@ class Yd {
18977
18977
  return i;
18978
18978
  }
18979
18979
  }
18980
- function dt(c) {
18980
+ function ut(c) {
18981
18981
  const t = {};
18982
18982
  let e = c.lastReadGroup || c.next();
18983
18983
  for (; !c.isEOF(); ) {
@@ -20328,7 +20328,7 @@ const Ge = new p.Vector3(1, 0, 0), Xn = new p.Vector3(0, 1, 0), bi = new p.Vecto
20328
20328
  color: Vt
20329
20329
  }), wi = new p.MeshBasicMaterial({
20330
20330
  color: Vt
20331
- }), Ba = new p.BufferGeometry().setFromPoints([new p.Vector3()]), ka = new p.Matrix4(), et = new p.Matrix4(), de = new p.Matrix4(), U = new p.Vector3(), K = new p.Vector3(), tt = new p.Vector3(), ts = new p.Vector2(), me = new p.Quaternion(), Ns = new p.Object3D(), ut = new p.Box3(), Da = new p.PointsMaterial({
20331
+ }), Ba = new p.BufferGeometry().setFromPoints([new p.Vector3()]), ka = new p.Matrix4(), et = new p.Matrix4(), de = new p.Matrix4(), U = new p.Vector3(), K = new p.Vector3(), tt = new p.Vector3(), ts = new p.Vector2(), me = new p.Quaternion(), Ns = new p.Object3D(), ft = new p.Box3(), Da = new p.PointsMaterial({
20332
20332
  color: 65280,
20333
20333
  size: 5,
20334
20334
  depthTest: !1
@@ -20882,8 +20882,8 @@ const Ge = new p.Vector3(1, 0, 0), Xn = new p.Vector3(0, 1, 0), bi = new p.Vecto
20882
20882
  const I = de.identity();
20883
20883
  for (; A && A.userData.isLayoutLevelObject !== !0; )
20884
20884
  I.premultiply(A.matrix), A = A.parent;
20885
- ut.makeEmpty();
20886
- const B = z.getBox(_, ut);
20885
+ ft.makeEmpty();
20886
+ const B = z.getBox(_, ft);
20887
20887
  B.applyMatrix4(I), C.type === We.Added ? !u && (C.box = new p.Box3().copy(B)) : C.type === We.Removed ? u && (C.box = new p.Box3().copy(B)) : C.type === We.Modified && (C.box ? C.box.union(B) : C.box = new p.Box3().copy(B));
20888
20888
  }
20889
20889
  }
@@ -20935,8 +20935,8 @@ const Ge = new p.Vector3(1, 0, 0), Xn = new p.Vector3(0, 1, 0), bi = new p.Vecto
20935
20935
  }
20936
20936
  setObjectColorByChange(e, i) {
20937
20937
  const s = (a) => {
20938
- let o = yt.ENTITY_COLOR_NO_CHANGE;
20939
- return a.type === We.Added ? o = yt.ENTITY_COLOR_ADDED : a.type === We.Removed ? o = yt.ENTITY_COLOR_REMOVED : a.type === We.Modified && (o = this.compareContext?.isTheFirstFile ? yt.ENTITY_COLOR_REMOVED : yt.ENTITY_COLOR_ADDED), o;
20938
+ let o = xt.ENTITY_COLOR_NO_CHANGE;
20939
+ return a.type === We.Added ? o = xt.ENTITY_COLOR_ADDED : a.type === We.Removed ? o = xt.ENTITY_COLOR_REMOVED : a.type === We.Modified && (o = this.compareContext?.isTheFirstFile ? xt.ENTITY_COLOR_REMOVED : xt.ENTITY_COLOR_ADDED), o;
20940
20940
  }, n = (a, o) => {
20941
20941
  a.traverse((l) => {
20942
20942
  if (l.material) {
@@ -21260,8 +21260,8 @@ const Ge = new p.Vector3(1, 0, 0), Xn = new p.Vector3(0, 1, 0), bi = new p.Vecto
21260
21260
  encoding: this.getTextEncoding(n)
21261
21261
  }), a = this.getMTextGroup(r, e, n, i, s), o = a && a.object;
21262
21262
  if (!o) return;
21263
- o.matrix.decompose(K, me, tt), e.position && (K.x += e.position.x, K.y += e.position.y, o.matrix.compose(K, me, tt)), ut.makeEmpty();
21264
- const l = z.getBox(o, ut), h = l.getSize(U), d = e.width || h.x, u = e.height || h.y, f = h.y > 0 ? h.y : u, m = e.text;
21263
+ o.matrix.decompose(K, me, tt), e.position && (K.x += e.position.x, K.y += e.position.y, o.matrix.compose(K, me, tt)), ft.makeEmpty();
21264
+ const l = z.getBox(o, ft), h = l.getSize(U), d = e.width || h.x, u = e.height || h.y, f = h.y > 0 ? h.y : u, m = e.text;
21265
21265
  let b = 0, y = 0;
21266
21266
  switch (document.createElement("canvas").getContext("2d"), e.attachmentPoint) {
21267
21267
  case 1:
@@ -21377,8 +21377,8 @@ const Ge = new p.Vector3(1, 0, 0), Xn = new p.Vector3(0, 1, 0), bi = new p.Vecto
21377
21377
  encoding: this.getTextEncoding(n)
21378
21378
  }), a = this.getMTextGroup(r, e, n, i, s), o = a && a.object;
21379
21379
  if (!o) return;
21380
- o.matrix.decompose(K, me, tt), e.position && (K.x += e.position.x, K.y += e.position.y, o.matrix.compose(K, me, tt)), ut.makeEmpty();
21381
- const l = z.getBox(o, ut), h = l.getSize(U), d = e.width || h.x, u = e.height || h.y, f = h.y > 0 ? h.y : u;
21380
+ o.matrix.decompose(K, me, tt), e.position && (K.x += e.position.x, K.y += e.position.y, o.matrix.compose(K, me, tt)), ft.makeEmpty();
21381
+ const l = z.getBox(o, ft), h = l.getSize(U), d = e.width || h.x, u = e.height || h.y, f = h.y > 0 ? h.y : u;
21382
21382
  let m = 0, b = 0;
21383
21383
  switch (e.attachmentPoint) {
21384
21384
  case 1:
@@ -21853,8 +21853,8 @@ const Ge = new p.Vector3(1, 0, 0), Xn = new p.Vector3(0, 1, 0), bi = new p.Vecto
21853
21853
  if (!r) return;
21854
21854
  const a = new z(), o = nn(r), l = this.getTextStyle(i, e), h = this.getMTextGroup(o, e, l, i, s), d = h && h.object;
21855
21855
  if (d) {
21856
- d.matrix.decompose(K, me, tt), e.contextData?.textLocation && (K.x += e.contextData.textLocation.x, K.y += e.contextData.textLocation.y, d.matrix.compose(K, me, tt)), ut.makeEmpty();
21857
- const u = z.getBox(d, ut), f = u.getSize(U), m = f.x, b = f.y;
21856
+ d.matrix.decompose(K, me, tt), e.contextData?.textLocation && (K.x += e.contextData.textLocation.x, K.y += e.contextData.textLocation.y, d.matrix.compose(K, me, tt)), ft.makeEmpty();
21857
+ const u = z.getBox(d, ft), f = u.getSize(U), m = f.x, b = f.y;
21858
21858
  let y = 0, S = 0;
21859
21859
  switch (e.contextData?.textAttachment) {
21860
21860
  case 1:
@@ -22410,8 +22410,8 @@ const Ge = new p.Vector3(1, 0, 0), Xn = new p.Vector3(0, 1, 0), bi = new p.Vecto
22410
22410
  return h;
22411
22411
  }
22412
22412
  transformTextMesh(e, i) {
22413
- ut.makeEmpty();
22414
- const s = z.getBox(i, ut), n = s.getSize(U), {
22413
+ ft.makeEmpty();
22414
+ const s = z.getBox(i, ft), n = s.getSize(U), {
22415
22415
  halign: r,
22416
22416
  valign: a
22417
22417
  } = e;
@@ -23093,7 +23093,7 @@ const Ge = new p.Vector3(1, 0, 0), Xn = new p.Vector3(0, 1, 0), bi = new p.Vecto
23093
23093
  * (DxfEntity 未收录),此处做类型桥接。
23094
23094
  */
23095
23095
  getColor(e, i, s) {
23096
- if (this.compareContext) return yt.ENTITY_COLOR_NO_CHANGE;
23096
+ if (this.compareContext) return xt.ENTITY_COLOR_NO_CHANGE;
23097
23097
  if (this.overrideColor != null) return this.overrideColor;
23098
23098
  const n = e;
23099
23099
  if (n && n.isGradientColor) {
@@ -27223,7 +27223,7 @@ function Ya(c, t, e, i, s = 1 / 0, n, r) {
27223
27223
  return C * I + _ * B + A * k > 0 && (r.x = y, r.y = S, r.z = w, e.x = (r.x - y) / n, e.y = (r.y - S) / n, e.z = (r.z - w) / n), r;
27224
27224
  }
27225
27225
  const qs = 1 / 8, q1 = Le.isBrowser && /Mac/.test(navigator.platform), Y1 = !(Le.isBrowser && "PointerEvent" in window);
27226
- let W, Xa, Ys, er, Ve, Y, te, Ti, ft, pt, Jt, Za, Ka, it, rs, Ci, $a, tr, Ja, ir, sr, Xs;
27226
+ let W, Xa, Ys, er, Ve, Y, te, Ti, pt, mt, Jt, Za, Ka, it, rs, Ci, $a, tr, Ja, ir, sr, Xs;
27227
27227
  class $ extends W1 {
27228
27228
  /**
27229
27229
  * Creates a `CameraControls` instance.
@@ -27711,7 +27711,7 @@ class $ extends W1 {
27711
27711
  * @category Statics
27712
27712
  */
27713
27713
  static install(e) {
27714
- W = e.THREE, Xa = Object.freeze(new W.Vector3(0, 0, 0)), Ys = Object.freeze(new W.Vector3(0, 1, 0)), er = Object.freeze(new W.Vector3(0, 0, 1)), Ve = new W.Vector2(), Y = new W.Vector3(), te = new W.Vector3(), Ti = new W.Vector3(), ft = new W.Vector3(), pt = new W.Vector3(), Jt = new W.Vector3(), Za = new W.Vector3(), Ka = new W.Vector3(), it = new W.Spherical(), rs = new W.Spherical(), Ci = new W.Box3(), $a = new W.Box3(), tr = new W.Sphere(), Ja = new W.Quaternion(), ir = new W.Quaternion(), sr = new W.Matrix4(), Xs = new W.Raycaster();
27714
+ W = e.THREE, Xa = Object.freeze(new W.Vector3(0, 0, 0)), Ys = Object.freeze(new W.Vector3(0, 1, 0)), er = Object.freeze(new W.Vector3(0, 0, 1)), Ve = new W.Vector2(), Y = new W.Vector3(), te = new W.Vector3(), Ti = new W.Vector3(), pt = new W.Vector3(), mt = new W.Vector3(), Jt = new W.Vector3(), Za = new W.Vector3(), Ka = new W.Vector3(), it = new W.Spherical(), rs = new W.Spherical(), Ci = new W.Box3(), $a = new W.Box3(), tr = new W.Sphere(), Ja = new W.Quaternion(), ir = new W.Quaternion(), sr = new W.Matrix4(), Xs = new W.Raycaster();
27715
27715
  }
27716
27716
  /**
27717
27717
  * list all ACTIONs
@@ -27981,8 +27981,8 @@ class $ extends W1 {
27981
27981
  * @category Methods
27982
27982
  */
27983
27983
  truck(e, i, s = !1) {
27984
- this._camera.updateMatrix(), ft.setFromMatrixColumn(this._camera.matrix, 0), pt.setFromMatrixColumn(this._camera.matrix, 1), ft.multiplyScalar(e), pt.multiplyScalar(-i);
27985
- const n = Y.copy(ft).add(pt), r = te.copy(this._targetEnd).add(n);
27984
+ this._camera.updateMatrix(), pt.setFromMatrixColumn(this._camera.matrix, 0), mt.setFromMatrixColumn(this._camera.matrix, 1), pt.multiplyScalar(e), mt.multiplyScalar(-i);
27985
+ const n = Y.copy(pt).add(mt), r = te.copy(this._targetEnd).add(n);
27986
27986
  return this.moveTo(r.x, r.y, r.z, s);
27987
27987
  }
27988
27988
  /**
@@ -28186,9 +28186,9 @@ class $ extends W1 {
28186
28186
  * @category Methods
28187
28187
  */
28188
28188
  setOrbitPoint(e, i, s) {
28189
- this._camera.updateMatrixWorld(), ft.setFromMatrixColumn(this._camera.matrixWorldInverse, 0), pt.setFromMatrixColumn(this._camera.matrixWorldInverse, 1), Jt.setFromMatrixColumn(this._camera.matrixWorldInverse, 2);
28189
+ this._camera.updateMatrixWorld(), pt.setFromMatrixColumn(this._camera.matrixWorldInverse, 0), mt.setFromMatrixColumn(this._camera.matrixWorldInverse, 1), Jt.setFromMatrixColumn(this._camera.matrixWorldInverse, 2);
28190
28190
  const n = Y.set(e, i, s), r = n.distanceTo(this._camera.position), a = n.sub(this._camera.position);
28191
- ft.multiplyScalar(a.x), pt.multiplyScalar(a.y), Jt.multiplyScalar(a.z), Y.copy(ft).add(pt).add(Jt), Y.z = Y.z + r, this.dollyTo(r, !1), this.setFocalOffset(-Y.x, Y.y, -Y.z, !1), this.moveTo(e, i, s, !1);
28191
+ pt.multiplyScalar(a.x), mt.multiplyScalar(a.y), Jt.multiplyScalar(a.z), Y.copy(pt).add(mt).add(Jt), Y.z = Y.z + r, this.dollyTo(r, !1), this.setFocalOffset(-Y.x, Y.y, -Y.z, !1), this.moveTo(e, i, s, !1);
28192
28192
  }
28193
28193
  /**
28194
28194
  * Set the boundary box that encloses the target of the camera. box3 is in THREE.Box3
@@ -28366,7 +28366,7 @@ class $ extends W1 {
28366
28366
  }
28367
28367
  this._camera.zoom !== this._zoom && (this._camera.zoom = this._zoom, this._camera.updateProjectionMatrix(), this._updateNearPlaneCorners(), this._needsUpdate = !0);
28368
28368
  const l = this._collisionTest();
28369
- this._spherical.radius = Math.min(this._spherical.radius, l), this._spherical.makeSafe(), this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target), this._camera.lookAt(this._target), (!ae(this._focalOffset.x) || !ae(this._focalOffset.y) || !ae(this._focalOffset.z)) && (this._camera.updateMatrixWorld(), ft.setFromMatrixColumn(this._camera.matrix, 0), pt.setFromMatrixColumn(this._camera.matrix, 1), Jt.setFromMatrixColumn(this._camera.matrix, 2), ft.multiplyScalar(this._focalOffset.x), pt.multiplyScalar(-this._focalOffset.y), Jt.multiplyScalar(this._focalOffset.z), Y.copy(ft).add(pt).add(Jt), this._camera.position.add(Y)), this._boundaryEnclosesCamera && this._encloseToBoundary(
28369
+ this._spherical.radius = Math.min(this._spherical.radius, l), this._spherical.makeSafe(), this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target), this._camera.lookAt(this._target), (!ae(this._focalOffset.x) || !ae(this._focalOffset.y) || !ae(this._focalOffset.z)) && (this._camera.updateMatrixWorld(), pt.setFromMatrixColumn(this._camera.matrix, 0), mt.setFromMatrixColumn(this._camera.matrix, 1), Jt.setFromMatrixColumn(this._camera.matrix, 2), pt.multiplyScalar(this._focalOffset.x), mt.multiplyScalar(-this._focalOffset.y), Jt.multiplyScalar(this._focalOffset.z), Y.copy(pt).add(mt).add(Jt), this._camera.position.add(Y)), this._boundaryEnclosesCamera && this._encloseToBoundary(
28370
28370
  this._camera.position.copy(this._target),
28371
28371
  Y.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),
28372
28372
  1
@@ -28525,12 +28525,12 @@ class $ extends W1 {
28525
28525
  }), s.radius = Math.sqrt(r), s;
28526
28526
  }
28527
28527
  }
28528
- var xt = /* @__PURE__ */ ((c) => (c[c.Orbit = 0] = "Orbit", c[c.FirstPerson = 1] = "FirstPerson", c[c.Plan = 2] = "Plan", c))(xt || {});
28528
+ var bt = /* @__PURE__ */ ((c) => (c[c.Orbit = 0] = "Orbit", c[c.FirstPerson = 1] = "FirstPerson", c[c.Plan = 2] = "Plan", c))(bt || {});
28529
28529
  class X1 {
28530
28530
  constructor(t) {
28531
28531
  g(this, "mode");
28532
28532
  g(this, "cameraManager");
28533
- this.mode = xt.Orbit, this.cameraManager = t;
28533
+ this.mode = bt.Orbit, this.cameraManager = t;
28534
28534
  }
28535
28535
  setupControl() {
28536
28536
  const t = this.cameraManager.camera, e = this.cameraManager.cameraControls;
@@ -28556,7 +28556,7 @@ class Z1 {
28556
28556
  constructor(t) {
28557
28557
  g(this, "mode");
28558
28558
  g(this, "cameraManager");
28559
- this.mode = xt.Plan, this.cameraManager = t;
28559
+ this.mode = bt.Plan, this.cameraManager = t;
28560
28560
  }
28561
28561
  setupControl() {
28562
28562
  const t = this.cameraManager.camera, e = this.cameraManager.cameraControls;
@@ -28658,9 +28658,9 @@ class K1 {
28658
28658
  this.perspectiveCamera,
28659
28659
  t.getInputManager()
28660
28660
  ), this.controlsMap = {
28661
- [xt.Orbit]: new X1(this),
28662
- [xt.Plan]: new Z1(this)
28663
- }, this.activeControls = this.controlsMap[xt.Orbit], this.setupControls(), this.setProjection(Et.Perspective), this.anchor = this.createAnchor();
28661
+ [bt.Orbit]: new X1(this),
28662
+ [bt.Plan]: new Z1(this)
28663
+ }, this.activeControls = this.controlsMap[bt.Orbit], this.setupControls(), this.setProjection(Et.Perspective), this.anchor = this.createAnchor();
28664
28664
  }
28665
28665
  get viewerContainer() {
28666
28666
  return this.viewer.viewerContainer;
@@ -28705,7 +28705,7 @@ class K1 {
28705
28705
  );
28706
28706
  }
28707
28707
  setOrthoCamera() {
28708
- if (this.activeControls.mode === xt.FirstPerson) return;
28708
+ if (this.activeControls.mode === bt.FirstPerson) return;
28709
28709
  this.previousDistance = this.cameraControls.distance, this.cameraControls.distance = 200;
28710
28710
  const { width: t, height: e } = this.getDims();
28711
28711
  this.setupOrthoCamera(e, t), this.activeCamera = this.orthographicCamera, this.projection = Et.Orthographic;
@@ -29318,7 +29318,7 @@ class xs extends p.Shape {
29318
29318
  return r.userData = { advanceWidth: this.width }, r.setAttribute("position", new p.Float32BufferAttribute(i, 3)), r.setIndex(s), r;
29319
29319
  }
29320
29320
  }
29321
- const gt = class gt {
29321
+ const yt = class yt {
29322
29322
  static parserHeader(t, e) {
29323
29323
  let i = "", s = !1, n = 0;
29324
29324
  const r = !0;
@@ -29414,7 +29414,7 @@ const gt = class gt {
29414
29414
  let m = u & 7;
29415
29415
  m == 0 && (m = 8);
29416
29416
  const b = Math.PI / 4;
29417
- let y = b * m, S = gt.CIRCLE_SPAN;
29417
+ let y = b * m, S = yt.CIRCLE_SPAN;
29418
29418
  u < 0 && (S = -S, y = -y);
29419
29419
  const w = b * f, x = w + y, E = s.clone().sub(new p.Vector2(Math.cos(w) * d, Math.sin(w) * d));
29420
29420
  if (s = E.clone().add(new p.Vector2(Math.cos(x) * d, Math.sin(x) * d)), o) {
@@ -29433,7 +29433,7 @@ const gt = class gt {
29433
29433
  let w = y & 7;
29434
29434
  w == 0 && (w = 8), u != 0 && w--;
29435
29435
  const x = Math.PI / 4;
29436
- let E = x * w, M = gt.CIRCLE_SPAN, O = 1;
29436
+ let E = x * w, M = yt.CIRCLE_SPAN, O = 1;
29437
29437
  y < 0 && (M = -M, E = -E, O = -1);
29438
29438
  let T = x * S, v = T + E;
29439
29439
  T += x * d / 256 * O, v += x * u / 256 * O;
@@ -29453,7 +29453,7 @@ const gt = class gt {
29453
29453
  const d = new p.Vector2();
29454
29454
  d.x = J.byteTosbyte(e[++l]) * i, d.y = J.byteTosbyte(e[++l]) * i;
29455
29455
  let u = J.byteTosbyte(e[++l]);
29456
- u < -127 && (u = -127), o && (u == 0 ? r.push(s.clone().add(d)) : r.push(gt.generateArcPoints(s, d, u / 127))), s.add(d);
29456
+ u < -127 && (u = -127), o && (u == 0 ? r.push(s.clone().add(d)) : r.push(yt.generateArcPoints(s, d, u / 127))), s.add(d);
29457
29457
  }
29458
29458
  break;
29459
29459
  case 13:
@@ -29461,11 +29461,11 @@ const gt = class gt {
29461
29461
  const u = new p.Vector2();
29462
29462
  if (u.x = J.byteTosbyte(e[++l]) * i, u.y = J.byteTosbyte(e[++l]) * i, !Number.isFinite(u.x) || !Number.isFinite(u.y) || u.x == 0 && u.y == 0) break;
29463
29463
  let f = J.byteTosbyte(e[++l]);
29464
- f < -127 && (f = -127), o && (f == 0 ? r.push(s.clone().add(u)) : r.push(gt.generateArcPoints(s.clone(), u, f / 127))), s.add(u);
29464
+ f < -127 && (f = -127), o && (f == 0 ? r.push(s.clone().add(u)) : r.push(yt.generateArcPoints(s.clone(), u, f / 127))), s.add(u);
29465
29465
  }
29466
29466
  break;
29467
29467
  case 14:
29468
- l = gt.skipCode(t, e, ++l);
29468
+ l = yt.skipCode(t, e, ++l);
29469
29469
  break;
29470
29470
  default:
29471
29471
  if (h > 15) {
@@ -29594,7 +29594,7 @@ const gt = class gt {
29594
29594
  const f = t.sub(u), m = s.sub(u);
29595
29595
  let b = Math.atan2(f.y, f.x);
29596
29596
  const y = Math.atan2(m.y, m.x);
29597
- let S = gt.CIRCLE_SPAN;
29597
+ let S = yt.CIRCLE_SPAN;
29598
29598
  n ? (S = -S, b < y && (b += 2 * Math.PI)) : b > y && (b -= 2 * Math.PI);
29599
29599
  let w = b;
29600
29600
  const x = !0;
@@ -29605,9 +29605,9 @@ const gt = class gt {
29605
29605
  return s;
29606
29606
  }
29607
29607
  };
29608
- g(gt, "FILE_STOP_FLAG", ["\r", `
29609
- `, ""]), g(gt, "CIRCLE_SPAN", Math.PI / 18);
29610
- let Ft = gt;
29608
+ g(yt, "FILE_STOP_FLAG", ["\r", `
29609
+ `, ""]), g(yt, "CIRCLE_SPAN", Math.PI / 18);
29610
+ let Ft = yt;
29611
29611
  const rr = {
29612
29612
  130: [
29613
29613
  [
@@ -30470,7 +30470,7 @@ const rr = {
30470
30470
  }
30471
30471
  };
30472
30472
  g(fs, "DEFAULT_SIZE", 12);
30473
- let mt = fs;
30473
+ let gt = fs;
30474
30474
  function Q1(c) {
30475
30475
  let t, e, i, s, n;
30476
30476
  t = "";
@@ -30536,7 +30536,7 @@ class Ct {
30536
30536
  } else if (o.lastIndexOf(".shx") > -1) {
30537
30537
  this.loader.setResponseType("arraybuffer");
30538
30538
  const l = await this.loader.loadAsync(r[0]);
30539
- a = new mt(
30539
+ a = new gt(
30540
30540
  s,
30541
30541
  l
30542
30542
  /* 类型桥接:同上 */
@@ -30561,7 +30561,7 @@ class Ct {
30561
30561
  } else if (Ct.isShxFile(i)) {
30562
30562
  this.loader.setResponseType("arraybuffer");
30563
30563
  const o = await this.loader.loadAsync(i);
30564
- a = new mt(
30564
+ a = new gt(
30565
30565
  s,
30566
30566
  o
30567
30567
  /* 类型桥接:同上 */
@@ -30613,7 +30613,7 @@ class Ct {
30613
30613
  e == null && (e = "");
30614
30614
  const s = t.charCodeAt(0) > 255, n = (o) => {
30615
30615
  const l = o.getCharShape(t, i);
30616
- if (l && !(s && o instanceof mt && l.width < i * 0.5))
30616
+ if (l && !(s && o instanceof gt && l.width < i * 0.5))
30617
30617
  return l;
30618
30618
  };
30619
30619
  let r = this.fontMap.get(e.toLowerCase());
@@ -30626,7 +30626,7 @@ class Ct {
30626
30626
  }
30627
30627
  }
30628
30628
  let a = r?.getCharShape(t, i);
30629
- if (a && s && r instanceof mt && a.width < i * 0.5 && (a = void 0), !a)
30629
+ if (a && s && r instanceof gt && a.width < i * 0.5 && (a = void 0), !a)
30630
30630
  for (const [, o] of this.fontMap) {
30631
30631
  if (o === r) continue;
30632
30632
  const l = n(o);
@@ -30636,7 +30636,7 @@ class Ct {
30636
30636
  }
30637
30637
  }
30638
30638
  if (a) {
30639
- if (r instanceof mt) return a.toThreeGeometry();
30639
+ if (r instanceof gt) return a.toThreeGeometry();
30640
30640
  if (r instanceof Qt) {
30641
30641
  const o = new Pl(t, {
30642
30642
  font: r,
@@ -30660,7 +30660,7 @@ class Ct {
30660
30660
  break;
30661
30661
  }
30662
30662
  }
30663
- if (i instanceof mt) return e.toThreeGeometry();
30663
+ if (i instanceof gt) return e.toThreeGeometry();
30664
30664
  if (i instanceof Qt) return new p.ExtrudeGeometry(e.toShapes(!1), {
30665
30665
  /* 类型桥接:toShapes 为 Shape 运行时方法,@types 未声明 */
30666
30666
  curveSegments: 3,
@@ -30697,7 +30697,7 @@ class Ct {
30697
30697
  } = i;
30698
30698
  if (this.fileNames && !this.fileNames.includes(s)) continue;
30699
30699
  let r;
30700
- n ? r = new mt(s, i) : r = new Qt(s, i), this.fontMap.set(s, r);
30700
+ n ? r = new gt(s, i) : r = new Qt(s, i), this.fontMap.set(s, r);
30701
30701
  }
30702
30702
  P.debug("[FontManager] Loaded font data from cache.");
30703
30703
  }
@@ -30707,7 +30707,7 @@ class Ct {
30707
30707
  return;
30708
30708
  }
30709
30709
  let e = this.fontMap.get(t);
30710
- return !e && (e = this.fontMap.get(this.fontMap.keys().next().value), !this.missingFonts[t] && (this.missingFonts[t] = 0), this.missingFonts[t]++), e instanceof mt;
30710
+ return !e && (e = this.fontMap.get(this.fontMap.keys().next().value), !this.missingFonts[t] && (this.missingFonts[t] = 0), this.missingFonts[t]++), e instanceof gt;
30711
30711
  }
30712
30712
  /**
30713
30713
  * Just for log usage
@@ -30797,7 +30797,7 @@ class U0 {
30797
30797
  const f = o[u], m = t.children[f];
30798
30798
  m.updateMatrix(), d.setMatrixAt(u, m.matrix);
30799
30799
  }
30800
- d.matrixAutoUpdate = bt, d.updateMatrix(), n.push(d);
30800
+ d.matrixAutoUpdate = ct, d.updateMatrix(), n.push(d);
30801
30801
  }), r.sort((a, o) => o - a), r.forEach((a) => t.remove(t.children[a])), n.forEach((a) => {
30802
30802
  a.parent = t, t.children.push(a);
30803
30803
  }), t.updateMatrix(), console.log("[Inst] " + r.length + "(out of " + e + ") objects instanced to " + n.length + " InstancedMesh");
@@ -31166,6 +31166,10 @@ const ps = class ps {
31166
31166
  g(this, "gltfLoader");
31167
31167
  g(this, "font");
31168
31168
  g(this, "manager");
31169
+ /**
31170
+ * 最近一次进行中的 DXF 加载器,用于中断未完成的加载(快速切换图纸场景)
31171
+ */
31172
+ g(this, "currentDxfLoader");
31169
31173
  this.manager = t;
31170
31174
  }
31171
31175
  setLoadManager(t) {
@@ -31297,10 +31301,18 @@ const ps = class ps {
31297
31301
  async loadDxfData(t, e, i, s, n) {
31298
31302
  this.font || console.warn("[LoadingHelper] Should set font first!");
31299
31303
  const r = new X(this.manager, n);
31300
- return r.setFont(this.font), await this.font?.getFontFromIndexeddb(), r.manager.onLoad = () => {
31304
+ return this.currentDxfLoader = r, r.setFont(this.font), await this.font?.getFontFromIndexeddb(), r.manager.onLoad = () => {
31301
31305
  s && s();
31302
31306
  }, r.loadEx(t, e, i);
31303
31307
  }
31308
+ /**
31309
+ * 中断当前进行中的 DXF 加载(若有)。
31310
+ * 每次加载使用独立的 DxfLoader 实例,因此只影响最近一次未完成的加载,
31311
+ * 已完成的模型与后续新加载不受影响。
31312
+ */
31313
+ abortDxfLoading() {
31314
+ this.currentDxfLoader?.abort(), this.currentDxfLoader = void 0;
31315
+ }
31304
31316
  /**
31305
31317
  * Sets font.
31306
31318
  * Font is required for Viewer2d to view Chinese, etc.
@@ -32836,7 +32848,7 @@ class bu {
32836
32848
  g(this, "modelGroup");
32837
32849
  this.viewer = t;
32838
32850
  const e = new p.Scene();
32839
- e.matrixAutoUpdate = bt, e.matrixWorldAutoUpdate = bt, this.scene = e, this.modelGroup = new p.Group(), this.modelGroup.name = "models", this.scene.add(this.modelGroup);
32851
+ e.matrixAutoUpdate = ct, e.matrixWorldAutoUpdate = ct, this.scene = e, this.modelGroup = new p.Group(), this.modelGroup.name = "models", this.scene.add(this.modelGroup);
32840
32852
  const { width: i, height: s, viewerContainer: n } = t.container;
32841
32853
  let r;
32842
32854
  try {
@@ -32903,6 +32915,9 @@ class bu {
32903
32915
  addModel(t) {
32904
32916
  this.modelGroup.add(t.getModelObject());
32905
32917
  }
32918
+ removeModel(t) {
32919
+ this.modelGroup.remove(t.getModelObject());
32920
+ }
32906
32921
  enableShadow(t) {
32907
32922
  this.renderer.shadowMap.enabled = t, this.directionalLight.castShadow = t, t && (this.tryAdjustDirectionalLight(), this.updateDirectionalLightShadow()), this.modelGroup.traverse((e) => {
32908
32923
  e.isMesh && (e.castShadow = t, e.receiveShadow = t);
@@ -33200,7 +33215,7 @@ class Pr extends hi {
33200
33215
  }
33201
33216
  addModel(e) {
33202
33217
  const i = e.getModelObject();
33203
- i.name = e.modelId, this.sceneManager.addModel(e), i.matrixAutoUpdate = bt, i.updateMatrix(), i.updateMatrixWorld(!0), this.loadedModels.push(e), this.enableRender(0);
33218
+ i.name = e.modelId, this.sceneManager.addModel(e), i.matrixAutoUpdate = ct, i.updateMatrix(), i.updateMatrixWorld(!0), this.loadedModels.push(e), this.enableRender(0);
33204
33219
  }
33205
33220
  async setFont(e) {
33206
33221
  !this.fontManager && (this.fontManager = new Ct()), await this.fontManager.loadFonts(e);
@@ -33431,10 +33446,18 @@ class Pr extends hi {
33431
33446
  };
33432
33447
  }
33433
33448
  /**
33434
- *
33449
+ * 从场景中移除指定模型(不销毁 viewer,用于切换图纸等场景)。
33450
+ * @param modelId 加载时指定的 modelId
33451
+ * @returns 被移除的模型,未找到时返回 undefined
33435
33452
  */
33453
+ removeModel(e) {
33454
+ const i = this.loadedModels.findIndex((n) => n.modelId === e);
33455
+ if (i === -1) return;
33456
+ const s = this.loadedModels.splice(i, 1)[0];
33457
+ return this.sceneManager.removeModel(s), this.enableRender(), s;
33458
+ }
33436
33459
  destroy() {
33437
- this.requestAnimationFrameHandle && cancelAnimationFrame(this.requestAnimationFrameHandle), this.css2dRenderer.domElement.remove(), this.container.destroy(), this.sceneManager.destroy(), this.cameraManager.destroy(), this.overlayRender.destroy(), this.spinner.destroy(), this.progressBar?.destroy(), this.undoManager.destroy();
33460
+ this.requestAnimationFrameHandle && cancelAnimationFrame(this.requestAnimationFrameHandle), this.loaderHelper.abortDxfLoading(), this.css2dRenderer.domElement.remove(), this.container.destroy(), this.sceneManager.destroy(), this.cameraManager.destroy(), this.overlayRender.destroy(), this.spinner.destroy(), this.progressBar?.destroy(), this.undoManager.destroy();
33438
33461
  }
33439
33462
  /**
33440
33463
  * Installs a Plugin.
@@ -33503,7 +33526,7 @@ class $o extends Pr {
33503
33526
  g(this, "requestHeaders");
33504
33527
  /** 打印截图进行中:临时强制显示所有图符/文字,避免低缩放时被"视觉过小"逻辑隐藏 */
33505
33528
  g(this, "_printCaptureMode", !1);
33506
- this.name = at.Viewer2d, this.loadedModels = [], this.masterModelId = "", this.activeLayoutName = "", this.layoutInfos = {}, this.units = void 0, this.enableHideVisuallySmallObjects = e.enableHideVisuallySmallObjects === !0, this.sortedHidableObjects = {}, this.lastCameraZoom = 1 / 0, this.loadingDxfCount = 0, e.enableLayoutBar && (this.dxfLayoutBar = new N1(this)), this.cameraManager.setProjection(Et.Orthographic), this.cameraManager.setNavigationMode(xt.Plan);
33529
+ this.name = at.Viewer2d, this.loadedModels = [], this.masterModelId = "", this.activeLayoutName = "", this.layoutInfos = {}, this.units = void 0, this.enableHideVisuallySmallObjects = e.enableHideVisuallySmallObjects === !0, this.sortedHidableObjects = {}, this.lastCameraZoom = 1 / 0, this.loadingDxfCount = 0, e.enableLayoutBar && (this.dxfLayoutBar = new N1(this)), this.cameraManager.setProjection(Et.Orthographic), this.cameraManager.setNavigationMode(bt.Plan);
33507
33530
  const i = new p.Vector3(0, 0, 100), s = new p.Vector3(0, 0, 0);
33508
33531
  this.cameraManager.setCameraConfig({
33509
33532
  eye: i,
@@ -33692,45 +33715,63 @@ class $o extends Pr {
33692
33715
  * ```
33693
33716
  */
33694
33717
  async loadModel(e, i, s) {
33718
+ this.loaderHelper.abortDxfLoading();
33695
33719
  const n = this.getUniqueModelId(e.modelId || e.src);
33696
33720
  this.spinner.increaseJobCount(), this.loaderHelper.setFont(this.fontManager), this.masterModelId || (this.masterModelId = n);
33697
- const r = n, a = Je.t("ProgressBar.Loading"), o = (b) => {
33698
- this.progressBar?.updateProgress(r, a, b), i?.(
33721
+ const r = n, a = Je.t("ProgressBar.Loading"), o = (d) => {
33722
+ this.progressBar?.updateProgress(r, a, d), i?.(
33699
33723
  new ProgressEvent("LoadProgress", {
33700
- loaded: b,
33724
+ loaded: d,
33701
33725
  total: 100
33702
33726
  })
33703
33727
  );
33704
- }, l = (b, y, S) => {
33705
- let w = b.loaded * 100 / b.total;
33706
- w = w * (S - y) / 100 + y, this.progressBar?.updateProgress(r, a, w), i?.(
33728
+ }, l = (d, u, f) => {
33729
+ let m = d.loaded * 100 / d.total;
33730
+ m = m * (f - u) / 100 + u, this.progressBar?.updateProgress(r, a, m), i?.(
33707
33731
  new ProgressEvent("LoadProgress", {
33708
- loaded: w,
33732
+ loaded: m,
33709
33733
  total: 100
33710
33734
  })
33711
33735
  );
33712
- }, h = (b) => l(b, 0, 90);
33736
+ }, h = (d) => l(d, 0, 90);
33713
33737
  this.progressBar?.addProgressItem(r), o(0);
33714
- const d = this.viewerCfg, u = await this.loaderHelper.loadDxfData(e.src, e.modelId, h, void 0, {
33715
- ignorePaperSpace: e.ignorePaperSpace,
33716
- enableLocalCache: d.enableLocalCache,
33717
- /* 类型桥接:字段位于派生配置类型 */
33718
- enableMerge: e.merge,
33719
- encoding: e.encoding,
33720
- overrideColor: e.overrideColor,
33721
- requestHeaders: e.headers ?? this.requestHeaders
33722
- }).finally(() => {
33723
- this.loadingDxfCount--, this.loadingDxfCount === 0 && this.fontManager?.releaseFontData();
33724
- }), f = u.threejsObject;
33725
- if (s && s({ threejsObject: f, llbMesh: u.llbMesh }), e.matrix && e.matrix.length === 16) {
33726
- const b = new p.Matrix4();
33727
- b.elements = e.matrix, f.applyMatrix4(b);
33728
- }
33729
- const m = new ys({
33730
- modelId: n,
33731
- dxfData: u
33732
- });
33733
- this.addModel(m), this.spinner.decreaseJobCount(), o(100), this.progressBar?.delayRemoveProgressItem(r), this.dispatchEvent(ce.ModelLoad);
33738
+ try {
33739
+ this.loadingDxfCount++;
33740
+ const d = this.viewerCfg, u = await this.loaderHelper.loadDxfData(e.src, e.modelId, h, void 0, {
33741
+ ignorePaperSpace: e.ignorePaperSpace,
33742
+ enableLocalCache: d.enableLocalCache,
33743
+ /* 类型桥接:字段位于派生配置类型 */
33744
+ enableMerge: e.merge,
33745
+ encoding: e.encoding,
33746
+ overrideColor: e.overrideColor,
33747
+ requestHeaders: e.headers ?? this.requestHeaders
33748
+ }).finally(() => {
33749
+ this.loadingDxfCount--, this.loadingDxfCount === 0 && this.fontManager?.releaseFontData();
33750
+ }), f = u.threejsObject;
33751
+ if (s && s({ threejsObject: f, llbMesh: u.llbMesh }), e.matrix && e.matrix.length === 16) {
33752
+ const b = new p.Matrix4();
33753
+ b.elements = e.matrix, f.applyMatrix4(b);
33754
+ }
33755
+ const m = new ys({
33756
+ modelId: n,
33757
+ dxfData: u
33758
+ });
33759
+ this.addModel(m), o(100), this.progressBar?.delayRemoveProgressItem(r), this.dispatchEvent(ce.ModelLoad);
33760
+ } catch (d) {
33761
+ throw this.progressBar?.removeProgressItem(r), P.error("[Viewer2d] Failed to load model '" + e.src + "'", d), d;
33762
+ } finally {
33763
+ this.spinner.decreaseJobCount();
33764
+ }
33765
+ }
33766
+ /**
33767
+ * 从场景中移除指定模型(不销毁 viewer,用于切换图纸等场景)。
33768
+ * 场景被清空后重置主模型与布局状态,保证后续加载的模型按全新流程初始化。
33769
+ * @param modelId 加载时指定的 modelId
33770
+ * @returns 被移除的模型,未找到时返回 undefined
33771
+ */
33772
+ removeModel(e) {
33773
+ const i = super.removeModel(e);
33774
+ return i && this.loadedModels.length === 0 && (this.masterModelId = "", this.activeLayoutName = "", this.layoutInfos = {}, this.units = void 0), i;
33734
33775
  }
33735
33776
  addModel(e) {
33736
33777
  super.addModel(e);
@@ -33748,7 +33789,7 @@ class $o extends Pr {
33748
33789
  this.layoutInfos[this.activeLayoutName] = {
33749
33790
  homeViewExtent: n,
33750
33791
  extent: n
33751
- }, s.matrixAutoUpdate = bt, this.scene.add(s);
33792
+ }, s.matrixAutoUpdate = ct, this.scene.add(s);
33752
33793
  const r = n.max.z;
33753
33794
  r > this.camera.position.z && (this.camera.position.z = r, this.camera.updateProjectionMatrix()), this.flyToObject(s);
33754
33795
  }
@@ -34198,10 +34239,10 @@ class $o extends Pr {
34198
34239
  l[v] = 255, l[v + 1] = 255, l[v + 2] = 255, f[T] = 255;
34199
34240
  continue;
34200
34241
  }
34201
- const D = C / 255, R = _ / 255, ie = A / 255, se = Math.max(D, R, ie), ze = Math.min(D, R, ie), ct = (se + ze) / 2, ve = se - ze, Ni = ve === 0 ? 0 : ve / (1 - Math.abs(2 * ct - 1));
34242
+ const D = C / 255, R = _ / 255, ie = A / 255, se = Math.max(D, R, ie), ze = Math.min(D, R, ie), ht = (se + ze) / 2, ve = se - ze, Ni = ve === 0 ? 0 : ve / (1 - Math.abs(2 * ht - 1));
34202
34243
  let Qe = 0;
34203
34244
  ve !== 0 && (se === D ? Qe = (R - ie) / ve % 6 : se === R ? Qe = (ie - D) / ve + 2 : Qe = (D - R) / ve + 4, Qe /= 6, Qe < 0 && (Qe += 1));
34204
- const vn = Math.min(0.55, (1 - ct) * u), Ie = (1 - Math.abs(2 * vn - 1)) * Ni, At = Ie * (1 - Math.abs(Qe * 6 % 2 - 1)), Hi = vn - Ie / 2;
34245
+ const vn = Math.min(0.55, (1 - ht) * u), Ie = (1 - Math.abs(2 * vn - 1)) * Ni, At = Ie * (1 - Math.abs(Qe * 6 % 2 - 1)), Hi = vn - Ie / 2;
34205
34246
  let Ht = 0, Gt = 0, Wt = 0;
34206
34247
  const qt = Math.floor(Qe * 6) % 6;
34207
34248
  qt === 0 ? (Ht = Ie, Gt = At) : qt === 1 ? (Ht = At, Gt = Ie) : qt === 2 ? (Gt = Ie, Wt = At) : qt === 3 ? (Gt = At, Wt = Ie) : qt === 4 ? (Ht = At, Wt = Ie) : (Ht = Ie, Wt = At), l[v] = (Ht + Hi) * 255, l[v + 1] = (Gt + Hi) * 255, l[v + 2] = (Wt + Hi) * 255, f[T] = 0.299 * l[v] + 0.587 * l[v + 1] + 0.114 * l[v + 2];
@@ -34533,44 +34574,51 @@ class Mu {
34533
34574
  } = e;
34534
34575
  this.viewer.masterModelId = r || n;
34535
34576
  const o = Date.now();
34536
- if (this.increaseJobCount(), !this.fontManager) return Promise.reject("[DxfCompareHelper] Should set font first!");
34537
- this.loader.setFont(this.fontManager), await this.fontManager.getFontFromIndexeddb();
34538
- const l = n + a, h = Je.t("ProgressBar.Comparing"), d = (B) => {
34539
- this.loadingProgressBar?.updateProgress(l, h, B), s && s(new ProgressEvent("CompareProgress", {
34540
- loaded: B,
34541
- total: 100
34542
- }));
34543
- }, u = (B, k, D) => {
34544
- let R = B.loaded * 100 / B.total;
34545
- R = R * (D - k) / 100 + k, this.loadingProgressBar?.updateProgress(l, h, R), s && s(new ProgressEvent("CompareProgress", {
34546
- loaded: R,
34547
- total: 100
34548
- }));
34549
- }, f = (B) => u(B, 0, 15), m = (B) => u(B, 15, 30), b = (B) => u(B, 30, 60), y = (B) => u(B, 60, 95);
34550
- V.printMemory("Before comparing"), this.loadingProgressBar?.addProgressItem(l), d(0);
34551
- let S = Date.now();
34552
- const w = this.loader.parse(n, f), x = this.loader.parse(a, m), [E, M] = await Promise.allSettled([w, x]);
34553
- if (E.status === "rejected") return Promise.reject("[DxfCompareHelper] Failed to parse " + n);
34554
- if (M.status === "rejected") return Promise.reject("[DxfCompareHelper] Failed to parse " + a);
34555
- if (P.info("[DxfCompareHelper] loadFiles in " + (Date.now() - S) / 1e3 + "s"), this.loader.isAborted()) return Promise.reject("[DxfCompareHelper] compare loadFile aborted");
34556
- const O = E.value, T = M.value;
34557
- S = Date.now();
34558
- const v = await new yt(O, T, i).compare(b);
34559
- if (P.info("[DxfCompareHelper] Compared in " + (Date.now() - S) / 1e3 + "s"), P.debug("[DxfCompareHelper] Compared results:", v), this.loader.isAborted()) return Promise.reject("[DxfCompareHelper] compare change aborted");
34560
- V.printMemory("After getting the comparison results"), S = Date.now(), await this.loader.loadEntitiesForCompare(O, T, v, !0, y), V.printMemory("After Creating threejs objects based on comparison result"), this.fontManager?.releaseFontData(), this.changes = v, P.info("[DxfCompareHelper] Creates threejs objects based on comparison result in " + (Date.now() - S) / 1e3 + "s");
34561
- const C = O, _ = T;
34562
- if (this.decreaseJobCount(), !Object.keys(v).length && P.info("[DxfCompareHelper] No change found"), C.threejsObject?.children.length === 0 && _.threejsObject?.children.length === 0) {
34563
- const B = "[DxfCompareHelper] Nothing was loaded from " + n + " and " + a;
34564
- return P.warn(B), Promise.reject(B);
34565
- }
34566
- const A = C.threejsObject, I = _.threejsObject;
34567
- return A.name = n, I.name = a, S = Date.now(), this.viewer.addModel(new ys({
34568
- modelId: t.modelId || t.src,
34569
- dxfData: C
34570
- })), this.viewer.flyToObject(A), V.printMemory("After adding first loaded Model to scene"), d(95), this.viewer.addModel(new ys({
34571
- modelId: e.modelId || e.src,
34572
- dxfData: _
34573
- })), V.printMemory("After adding second loaded Model to scene"), P.info("[DxfCompareHelper] Added compared objects to scene in " + (Date.now() - S) / 1e3 + "s"), P.info("[DxfCompareHelper] The comparison between " + n + "' and '" + a + "' is completed in " + (Date.now() - o) / 1e3 + "s !"), d(100), this.loadingProgressBar?.delayRemoveProgressItem(l), Promise.resolve();
34577
+ this.increaseJobCount();
34578
+ try {
34579
+ if (!this.fontManager) throw "[DxfCompareHelper] Should set font first!";
34580
+ this.loader.setFont(this.fontManager), await this.fontManager.getFontFromIndexeddb();
34581
+ const l = n + a, h = Je.t("ProgressBar.Comparing"), d = (B) => {
34582
+ this.loadingProgressBar?.updateProgress(l, h, B), s && s(new ProgressEvent("CompareProgress", {
34583
+ loaded: B,
34584
+ total: 100
34585
+ }));
34586
+ }, u = (B, k, D) => {
34587
+ let R = B.loaded * 100 / B.total;
34588
+ R = R * (D - k) / 100 + k, this.loadingProgressBar?.updateProgress(l, h, R), s && s(new ProgressEvent("CompareProgress", {
34589
+ loaded: R,
34590
+ total: 100
34591
+ }));
34592
+ }, f = (B) => u(B, 0, 15), m = (B) => u(B, 15, 30), b = (B) => u(B, 30, 60), y = (B) => u(B, 60, 95);
34593
+ V.printMemory("Before comparing"), this.loadingProgressBar?.addProgressItem(l), d(0);
34594
+ let S = Date.now();
34595
+ const w = this.loader.parse(n, f), x = this.loader.parse(a, m), [E, M] = await Promise.allSettled([w, x]);
34596
+ if (E.status === "rejected") throw "[DxfCompareHelper] Failed to parse " + n;
34597
+ if (M.status === "rejected") throw "[DxfCompareHelper] Failed to parse " + a;
34598
+ if (P.info("[DxfCompareHelper] loadFiles in " + (Date.now() - S) / 1e3 + "s"), this.loader.isAborted()) throw "[DxfCompareHelper] compare loadFile aborted";
34599
+ const O = E.value, T = M.value;
34600
+ S = Date.now();
34601
+ const v = await new xt(O, T, i).compare(b);
34602
+ if (P.info("[DxfCompareHelper] Compared in " + (Date.now() - S) / 1e3 + "s"), P.debug("[DxfCompareHelper] Compared results:", v), this.loader.isAborted()) throw "[DxfCompareHelper] compare change aborted";
34603
+ V.printMemory("After getting the comparison results"), S = Date.now(), await this.loader.loadEntitiesForCompare(O, T, v, !0, y), V.printMemory("After Creating threejs objects based on comparison result"), this.fontManager?.releaseFontData(), this.changes = v, P.info("[DxfCompareHelper] Creates threejs objects based on comparison result in " + (Date.now() - S) / 1e3 + "s");
34604
+ const C = O, _ = T;
34605
+ if (!Object.keys(v).length && P.info("[DxfCompareHelper] No change found"), C.threejsObject?.children.length === 0 && _.threejsObject?.children.length === 0) {
34606
+ const B = "[DxfCompareHelper] Nothing was loaded from " + n + " and " + a;
34607
+ throw P.warn(B), B;
34608
+ }
34609
+ const A = C.threejsObject, I = _.threejsObject;
34610
+ A.name = n, I.name = a, S = Date.now(), this.viewer.addModel(new ys({
34611
+ modelId: t.modelId || t.src,
34612
+ dxfData: C
34613
+ })), this.viewer.flyToObject(A), V.printMemory("After adding first loaded Model to scene"), d(95), this.viewer.addModel(new ys({
34614
+ modelId: e.modelId || e.src,
34615
+ dxfData: _
34616
+ })), V.printMemory("After adding second loaded Model to scene"), P.info("[DxfCompareHelper] Added compared objects to scene in " + (Date.now() - S) / 1e3 + "s"), P.info("[DxfCompareHelper] The comparison between " + n + "' and '" + a + "' is completed in " + (Date.now() - o) / 1e3 + "s !"), d(100), this.loadingProgressBar?.delayRemoveProgressItem(l);
34617
+ } catch (l) {
34618
+ throw this.loadingProgressBar?.removeProgressItem(n + a), l;
34619
+ } finally {
34620
+ this.decreaseJobCount();
34621
+ }
34574
34622
  }
34575
34623
  /**
34576
34624
  * @description {en} Gets compare changes.
@@ -34693,44 +34741,51 @@ class W0 extends Mu {
34693
34741
  } = i;
34694
34742
  this.viewer.masterModelId = a || r, this.viewer2.masterModelId = l || o;
34695
34743
  const h = Date.now();
34696
- if (this.increaseJobCount(), !this.fontManager) return Promise.reject("[DxfCompareHelper] Should set font first!");
34697
- this.loader.setFont(this.fontManager), await this.fontManager.getFontFromIndexeddb();
34698
- const d = r + o, u = Je.t("ProgressBar.Comparing"), f = (D) => {
34699
- this.loadingProgressBar?.updateProgress(d, u, D), n && n(new ProgressEvent("CompareProgress", {
34700
- loaded: D,
34701
- total: 100
34702
- }));
34703
- }, m = (D, R, ie) => {
34704
- let se = D.loaded * 100 / D.total;
34705
- se = se * (ie - R) / 100 + R, this.loadingProgressBar?.updateProgress(d, u, se), n && n(new ProgressEvent("CompareProgress", {
34706
- loaded: se,
34707
- total: 100
34708
- }));
34709
- }, b = (D) => m(D, 0, 15), y = (D) => m(D, 15, 30), S = (D) => m(D, 30, 60), w = (D) => m(D, 60, 95);
34710
- V.printMemory("Before comparing"), this.loadingProgressBar?.addProgressItem(d), f(0);
34711
- let x = Date.now();
34712
- const E = this.loader.parse(r, b), M = this.loader.parse(o, y), [O, T] = await Promise.allSettled([E, M]);
34713
- if (O.status === "rejected") return Promise.reject("[DxfCompareHelper] Failed to parse " + r);
34714
- if (T.status === "rejected") return Promise.reject("[DxfCompareHelper] Failed to parse " + o);
34715
- if (P.info("[DxfCompareHelper] loadFiles in " + (Date.now() - x) / 1e3 + "s"), this.loader.isAborted()) return Promise.reject("[DxfCompareHelper] compare loadFile aborted");
34716
- const v = O.value, C = T.value;
34717
- x = Date.now();
34718
- const _ = await new yt(v, C, s).compare(S);
34719
- if (P.info("[DxfCompareHelper] Compared in " + (Date.now() - x) / 1e3 + "s"), P.debug("Compared results:", _), this.loader.isAborted()) return Promise.reject("[DxfCompareHelper] compare change aborted");
34720
- V.printMemory("After getting the comparison results"), x = Date.now(), await this.loader.loadEntitiesForCompare(v, C, _, !1, w), V.printMemory("After Creating threejs objects based on comparison result"), this.fontManager?.releaseFontData(), this.changes = _, P.info("[DxfCompareHelper] Creates threejs objects based on comparison result in " + (Date.now() - x) / 1e3 + "s");
34721
- const A = v, I = C;
34722
- if (this.decreaseJobCount(), !Object.keys(_).length && P.info("[DxfCompareHelper] No change found"), A.threejsObject?.children.length === 0 && I.threejsObject?.children.length === 0) {
34723
- const D = "[DxfCompareHelper] Nothing was loaded from " + r + " and " + o;
34724
- return P.warn(D), Promise.reject(D);
34725
- }
34726
- const B = A.threejsObject, k = I.threejsObject;
34727
- return B.name = r, k.name = o, x = Date.now(), this.viewer.addModel(new ys({
34728
- modelId: e.modelId || e.src,
34729
- dxfData: A
34730
- })), V.printMemory("After adding first loaded Model to scene"), f(95), this.viewer2.addModel(new ys({
34731
- modelId: i.modelId || i.src,
34732
- dxfData: I
34733
- })), V.printMemory("After adding second loaded Model to scene"), this.drawCompareBoxes(), P.info("[DxfCompareHelper] Added compared objects to scene in " + (Date.now() - x) / 1e3 + "s"), P.info("[DxfCompareHelper] The comparison between " + r + "' and '" + o + "' is completed in " + (Date.now() - h) / 1e3 + "s !"), f(100), this.loadingProgressBar?.delayRemoveProgressItem(d), Promise.resolve();
34744
+ this.increaseJobCount();
34745
+ try {
34746
+ if (!this.fontManager) throw "[DxfCompareHelper] Should set font first!";
34747
+ this.loader.setFont(this.fontManager), await this.fontManager.getFontFromIndexeddb();
34748
+ const d = r + o, u = Je.t("ProgressBar.Comparing"), f = (D) => {
34749
+ this.loadingProgressBar?.updateProgress(d, u, D), n && n(new ProgressEvent("CompareProgress", {
34750
+ loaded: D,
34751
+ total: 100
34752
+ }));
34753
+ }, m = (D, R, ie) => {
34754
+ let se = D.loaded * 100 / D.total;
34755
+ se = se * (ie - R) / 100 + R, this.loadingProgressBar?.updateProgress(d, u, se), n && n(new ProgressEvent("CompareProgress", {
34756
+ loaded: se,
34757
+ total: 100
34758
+ }));
34759
+ }, b = (D) => m(D, 0, 15), y = (D) => m(D, 15, 30), S = (D) => m(D, 30, 60), w = (D) => m(D, 60, 95);
34760
+ V.printMemory("Before comparing"), this.loadingProgressBar?.addProgressItem(d), f(0);
34761
+ let x = Date.now();
34762
+ const E = this.loader.parse(r, b), M = this.loader.parse(o, y), [O, T] = await Promise.allSettled([E, M]);
34763
+ if (O.status === "rejected") throw "[DxfCompareHelper] Failed to parse " + r;
34764
+ if (T.status === "rejected") throw "[DxfCompareHelper] Failed to parse " + o;
34765
+ if (P.info("[DxfCompareHelper] loadFiles in " + (Date.now() - x) / 1e3 + "s"), this.loader.isAborted()) throw "[DxfCompareHelper] compare loadFile aborted";
34766
+ const v = O.value, C = T.value;
34767
+ x = Date.now();
34768
+ const _ = await new xt(v, C, s).compare(S);
34769
+ if (P.info("[DxfCompareHelper] Compared in " + (Date.now() - x) / 1e3 + "s"), P.debug("Compared results:", _), this.loader.isAborted()) throw "[DxfCompareHelper] compare change aborted";
34770
+ V.printMemory("After getting the comparison results"), x = Date.now(), await this.loader.loadEntitiesForCompare(v, C, _, !1, w), V.printMemory("After Creating threejs objects based on comparison result"), this.fontManager?.releaseFontData(), this.changes = _, P.info("[DxfCompareHelper] Creates threejs objects based on comparison result in " + (Date.now() - x) / 1e3 + "s");
34771
+ const A = v, I = C;
34772
+ if (!Object.keys(_).length && P.info("[DxfCompareHelper] No change found"), A.threejsObject?.children.length === 0 && I.threejsObject?.children.length === 0) {
34773
+ const D = "[DxfCompareHelper] Nothing was loaded from " + r + " and " + o;
34774
+ throw P.warn(D), D;
34775
+ }
34776
+ const B = A.threejsObject, k = I.threejsObject;
34777
+ B.name = r, k.name = o, x = Date.now(), this.viewer.addModel(new ys({
34778
+ modelId: e.modelId || e.src,
34779
+ dxfData: A
34780
+ })), V.printMemory("After adding first loaded Model to scene"), f(95), this.viewer2.addModel(new ys({
34781
+ modelId: i.modelId || i.src,
34782
+ dxfData: I
34783
+ })), V.printMemory("After adding second loaded Model to scene"), this.drawCompareBoxes(), P.info("[DxfCompareHelper] Added compared objects to scene in " + (Date.now() - x) / 1e3 + "s"), P.info("[DxfCompareHelper] The comparison between " + r + "' and '" + o + "' is completed in " + (Date.now() - h) / 1e3 + "s !"), f(100), this.loadingProgressBar?.delayRemoveProgressItem(d);
34784
+ } catch (d) {
34785
+ throw this.loadingProgressBar?.removeProgressItem(r + o), d;
34786
+ } finally {
34787
+ this.decreaseJobCount();
34788
+ }
34734
34789
  }
34735
34790
  /**
34736
34791
  * 在左右两个视口上绘制变动区域的云线框(按新增/删除/修改着色)。
@@ -35127,7 +35182,7 @@ class Y0 extends Pr {
35127
35182
  };
35128
35183
  this.cameraManager.flyToViewpoint(r);
35129
35184
  }
35130
- this.cameraManager.setProjection(Et.Perspective), this.cameraManager.setNavigationMode(xt.Orbit), this.setupDefaultEvents(), this.setDefaultBackground();
35185
+ this.cameraManager.setProjection(Et.Perspective), this.cameraManager.setNavigationMode(bt.Orbit), this.setupDefaultEvents(), this.setDefaultBackground();
35131
35186
  }
35132
35187
  setupDefaultEvents() {
35133
35188
  let e = !1, i, s = 0, n = 0, r = 0;
@@ -35173,39 +35228,45 @@ class Y0 extends Pr {
35173
35228
  }
35174
35229
  async loadModelInternal(e, i, s, n, r) {
35175
35230
  this.spinner.increaseJobCount();
35176
- const a = e.modelId || e.src, o = Je.t("ProgressBar.Loading"), l = (x) => {
35177
- this.progressBar?.updateProgress(a, o, x), i?.(
35231
+ const a = e.modelId || e.src, o = Je.t("ProgressBar.Loading"), l = (f) => {
35232
+ this.progressBar?.updateProgress(a, o, f), i?.(
35178
35233
  new ProgressEvent("LoadProgress", {
35179
- loaded: x,
35234
+ loaded: f,
35180
35235
  total: 100
35181
35236
  })
35182
35237
  );
35183
35238
  };
35184
35239
  let h = !1;
35185
- const d = (x, E, M) => {
35186
- let O = x.loaded * 100 / x.total;
35187
- O = O * (M - E) / 100 + E, O > M && (h || (P.warn("[Progress] Invalid ProgressEvent:", x), h = !0), O = M), this.progressBar?.updateProgress(a, o, O), i?.(
35240
+ const d = (f, m, b) => {
35241
+ let y = f.loaded * 100 / f.total;
35242
+ y = y * (b - m) / 100 + m, y > b && (h || (P.warn("[Progress] Invalid ProgressEvent:", f), h = !0), y = b), this.progressBar?.updateProgress(a, o, y), i?.(
35188
35243
  new ProgressEvent("LoadProgress", {
35189
- loaded: O,
35244
+ loaded: y,
35190
35245
  total: 100
35191
35246
  })
35192
35247
  );
35193
- }, u = (x) => d(x, 0, 50);
35248
+ }, u = (f) => d(f, 0, 50);
35194
35249
  this.progressBar?.addProgressItem(a), l(0);
35195
- let f;
35196
- if (s ? (this.loaderHelper.setLoadManager(r), f = await this.loaderHelper.loadLocalModel(n, e.src, i)) : f = await this.loaderHelper.loadModel(e.src, e.fileFormat, u), e.matrix && e.matrix.length === 16) {
35197
- const x = new p.Matrix4();
35198
- x.elements = e.matrix, f.applyMatrix4(x);
35250
+ try {
35251
+ let f;
35252
+ if (s ? (this.loaderHelper.setLoadManager(r), f = await this.loaderHelper.loadLocalModel(n, e.src, i)) : f = await this.loaderHelper.loadModel(e.src, e.fileFormat, u), e.matrix && e.matrix.length === 16) {
35253
+ const x = new p.Matrix4();
35254
+ x.elements = e.matrix, f.applyMatrix4(x);
35255
+ }
35256
+ const m = this.getUniqueModelId(e.modelId || e.src), b = new Lo({
35257
+ modelId: m,
35258
+ object: f
35259
+ });
35260
+ this.addModel(b), l(90);
35261
+ const y = b.getBBox();
35262
+ this.loadedModels.length === 1 && setTimeout(() => this.goToHomeView(), 0);
35263
+ const w = new p.Vector3();
35264
+ y.getCenter(w), this.cameraManager.setOrbitPoint(w), l(100), this.progressBar?.delayRemoveProgressItem(a), this.dispatchEvent(ce.ModelLoad);
35265
+ } catch (f) {
35266
+ throw this.progressBar?.removeProgressItem(a), P.error("[Viewer3d] Failed to load model '" + e.src + "'", f), f;
35267
+ } finally {
35268
+ this.spinner.decreaseJobCount();
35199
35269
  }
35200
- const m = this.getUniqueModelId(e.modelId || e.src), b = new Lo({
35201
- modelId: m,
35202
- object: f
35203
- });
35204
- this.addModel(b), l(90);
35205
- const y = b.getBBox();
35206
- this.loadedModels.length === 1 && setTimeout(() => this.goToHomeView(), 0);
35207
- const w = new p.Vector3();
35208
- y.getCenter(w), this.cameraManager.setOrbitPoint(w), this.spinner.decreaseJobCount(), l(100), this.progressBar?.delayRemoveProgressItem(a), this.dispatchEvent(ce.ModelLoad);
35209
35270
  }
35210
35271
  /**
35211
35272
  * Sets distance culling factor in order to improve performance.
@@ -35469,7 +35530,7 @@ class X0 extends Pr {
35469
35530
  };
35470
35531
  this.cameraManager.flyToViewpoint(r);
35471
35532
  }
35472
- this.cameraManager.setProjection(Et.Perspective), this.cameraManager.setNavigationMode(xt.Orbit), this.setupDefaultEvents(), this.setDefaultBackground(), this.addEventListener(ce.BeforeRender, () => {
35533
+ this.cameraManager.setProjection(Et.Perspective), this.cameraManager.setNavigationMode(bt.Orbit), this.setupDefaultEvents(), this.setDefaultBackground(), this.addEventListener(ce.BeforeRender, () => {
35473
35534
  this.update3dTiles();
35474
35535
  });
35475
35536
  }
@@ -35632,28 +35693,32 @@ class X0 extends Pr {
35632
35693
  if (!await s.parse()) return Promise.reject();
35633
35694
  let r = e.src.replace(/\/[^\\/]*\/?$/, "/");
35634
35695
  r = new URL(r, window.location.href).toString(), this.spinner.increaseJobCount();
35635
- const a = s.getView().boundingVolume.clone();
35636
- a.applyMatrix4(s.getView().transform);
35637
- const o = new No(
35638
- {
35639
- modelId: "" + Su++,
35640
- bbox: a
35641
- },
35642
- r,
35643
- s
35644
- ), l = o.getTilesRenderer(), h = l.group;
35645
- if (l.onBeforeParseTile = () => {
35646
- this.spinner.increaseJobCount();
35647
- }, l.onLoadModel = (d) => {
35648
- d.traverse((u) => {
35649
- u.matrixAutoUpdate && (u.matrixAutoUpdate = bt, u.updateMatrix()), u.isMesh && (u.castShadow = !0, u.receiveShadow = !0), u.geometry && u.layers.enableAll();
35650
- }), this.enableRender(), setTimeout(() => this.spinner.decreaseJobCount(), 100);
35651
- }, l.setCamera(this.camera), l.setResolutionFromRenderer(this.camera, this.renderer), l.update(), h) {
35652
- h.applyMatrix4(s.getView().transform), o.pickUsageGroup.applyMatrix4(s.getView().transform), this.pickUsageScene.add(o.pickUsageGroup), this.addModel(o), this.cameraManager.adjustCameraByBBox(a);
35653
- const d = new p.Vector3();
35654
- return a.getCenter(d), this.cameraManager.setOrbitPoint(d), this.loadedModels.length === 1 && this.goToHomeView(), this.spinner.decreaseJobCount(), this.dispatchEvent(ce.ModelLoad), Promise.resolve();
35655
- }
35656
- return this.spinner.decreaseJobCount(), Promise.reject();
35696
+ try {
35697
+ const a = s.getView().boundingVolume.clone();
35698
+ a.applyMatrix4(s.getView().transform);
35699
+ const o = new No(
35700
+ {
35701
+ modelId: "" + Su++,
35702
+ bbox: a
35703
+ },
35704
+ r,
35705
+ s
35706
+ ), l = o.getTilesRenderer(), h = l.group;
35707
+ if (l.onBeforeParseTile = () => {
35708
+ this.spinner.increaseJobCount();
35709
+ }, l.onLoadModel = (d) => {
35710
+ d.traverse((u) => {
35711
+ !ct && u.matrixAutoUpdate && (u.matrixAutoUpdate = ct, u.updateMatrix()), u.isMesh && (u.castShadow = !0, u.receiveShadow = !0), u.geometry && u.layers.enableAll();
35712
+ }), this.enableRender(), setTimeout(() => this.spinner.decreaseJobCount(), 100);
35713
+ }, l.setCamera(this.camera), l.setResolutionFromRenderer(this.camera, this.renderer), l.update(), h) {
35714
+ h.applyMatrix4(s.getView().transform), o.pickUsageGroup.applyMatrix4(s.getView().transform), this.pickUsageScene.add(o.pickUsageGroup), this.addModel(o), this.cameraManager.adjustCameraByBBox(a);
35715
+ const d = new p.Vector3();
35716
+ return a.getCenter(d), this.cameraManager.setOrbitPoint(d), this.loadedModels.length === 1 && this.goToHomeView(), this.dispatchEvent(ce.ModelLoad), Promise.resolve();
35717
+ }
35718
+ return Promise.reject();
35719
+ } finally {
35720
+ this.spinner.decreaseJobCount();
35721
+ }
35657
35722
  }
35658
35723
  setObjectHighlightedByUserIds(e, i, s) {
35659
35724
  this.loadedModels.find((r) => r.modelId === "" + e)?.setObjectHighlightedByUserIds(i, s), this.enableRender();
@@ -36292,7 +36357,7 @@ export {
36292
36357
  V as CommonUtils,
36293
36358
  Ot as CompareDrawable,
36294
36359
  Ho as Container,
36295
- xt as ControlsMode,
36360
+ bt as ControlsMode,
36296
36361
  Ae as CoordinateUtils,
36297
36362
  xh as DecimalPrecisionRange,
36298
36363
  zn as DefaultCameraFar,
@@ -36305,7 +36370,7 @@ export {
36305
36370
  ci as Drawable,
36306
36371
  bn as DrawableList,
36307
36372
  We as DxfChangeType,
36308
- yt as DxfCompare,
36373
+ xt as DxfCompare,
36309
36374
  W0 as DxfCompareHelper,
36310
36375
  Ua as DxfCompareMarkupManager,
36311
36376
  X as DxfLoader,
@@ -36334,7 +36399,7 @@ export {
36334
36399
  oi as LoadingHelper,
36335
36400
  Te as MaterialUtils,
36336
36401
  F as MathUtils,
36337
- bt as MatrixAutoUpdate,
36402
+ ct as MatrixAutoUpdate,
36338
36403
  ye as MergeUtils,
36339
36404
  ef as Mesh,
36340
36405
  Zo as MeshBvhHelper,