@maqiuyao/dxf-viewer 0.2.15 → 0.2.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/dxf-viewer.cjs +4 -4
- package/dist/dxf-viewer.js +85 -56
- package/dist/src/dxfViewer/core/helpers/TextSearchHelper.d.ts +4 -0
- package/dist/src/dxfViewer/core/utils/ObjectUtils.d.ts +7 -0
- package/dist/src/dxfViewer/core/viewers/BaseViewer.d.ts +3 -1
- package/package.json +1 -1
package/dist/dxf-viewer.js
CHANGED
|
@@ -5103,6 +5103,22 @@ const Ih = new p.Vector3(0, 1, 0), Ze = class Ze {
|
|
|
5103
5103
|
static isObjectSelectable(t) {
|
|
5104
5104
|
return t.layers.isEnabled(li);
|
|
5105
5105
|
}
|
|
5106
|
+
/**
|
|
5107
|
+
* 递归释放对象的 GPU 资源(geometry/material)。
|
|
5108
|
+
* 用于从场景移除模型后释放显存,避免切换图纸时内存泄漏。
|
|
5109
|
+
* 覆盖 Mesh/Line/Points 等所有携带 geometry 的可渲染对象。
|
|
5110
|
+
* 注意:释放后对象不可再用于渲染。
|
|
5111
|
+
*/
|
|
5112
|
+
static disposeObject(t) {
|
|
5113
|
+
t.traverse((e) => {
|
|
5114
|
+
const i = e;
|
|
5115
|
+
if (i.geometry) {
|
|
5116
|
+
i.geometry.dispose(), (Array.isArray(i.material) ? i.material : [i.material]).forEach((r) => r?.dispose());
|
|
5117
|
+
const n = e.userData?.originalMaterial;
|
|
5118
|
+
n && (Array.isArray(n) ? n : [n]).forEach((r) => r?.dispose());
|
|
5119
|
+
}
|
|
5120
|
+
});
|
|
5121
|
+
}
|
|
5106
5122
|
};
|
|
5107
5123
|
/**
|
|
5108
5124
|
* Outline default material
|
|
@@ -5118,7 +5134,7 @@ g(Ze, "OUTLINE_MATERIAL", new p.LineBasicMaterial({
|
|
|
5118
5134
|
opacity: 0.3,
|
|
5119
5135
|
side: p.FrontSide
|
|
5120
5136
|
}));
|
|
5121
|
-
let
|
|
5137
|
+
let J = Ze;
|
|
5122
5138
|
const Vs = new p.Matrix4(), Bh = new p.Matrix4(), us = class us {
|
|
5123
5139
|
static resetMergeInfo() {
|
|
5124
5140
|
this.MergeInfo.removedObjects = 0, this.MergeInfo.mergedMeshes = 0, this.MergeInfo.mergedLines = 0, this.MergeInfo.mergedPoints = 0, this.MergeInfo.mergedUnknownTypeObjects = 0, this.MergeInfo.elapsedTime = 0;
|
|
@@ -5304,7 +5320,7 @@ const Vs = new p.Matrix4(), Bh = new p.Matrix4(), us = class us {
|
|
|
5304
5320
|
const b = r.added;
|
|
5305
5321
|
return [...h, ...d, ...u].forEach((y) => {
|
|
5306
5322
|
b.push(y), i && e && (e.add(y), y.updateWorldMatrix(!1, !1));
|
|
5307
|
-
}), this.MergeInfo.removedObjects += f.length, this.MergeInfo.mergedMeshes += h.length, this.MergeInfo.mergedLines += d.length, this.MergeInfo.mergedPoints += u.length, s && e &&
|
|
5323
|
+
}), this.MergeInfo.removedObjects += f.length, this.MergeInfo.mergedMeshes += h.length, this.MergeInfo.mergedLines += d.length, this.MergeInfo.mergedPoints += u.length, s && e && J.removeEmptyObjects(e), r;
|
|
5308
5324
|
}
|
|
5309
5325
|
/**
|
|
5310
5326
|
* since we'll move geometry to another merged mesh under a group, below is the structure:
|
|
@@ -5560,7 +5576,7 @@ class zt {
|
|
|
5560
5576
|
static getVisibleObjectBoundingBox(t) {
|
|
5561
5577
|
const e = new p.Box3();
|
|
5562
5578
|
return t.traverse((i) => {
|
|
5563
|
-
i.visible && (i instanceof p.Mesh || i instanceof p.Line) &&
|
|
5579
|
+
i.visible && (i instanceof p.Mesh || i instanceof p.Line) && J.isObjectSelectable(i) && e.expandByObject(i);
|
|
5564
5580
|
}), e;
|
|
5565
5581
|
}
|
|
5566
5582
|
static getObjectsBoundingBox(t, e, i) {
|
|
@@ -15665,7 +15681,7 @@ class Dt {
|
|
|
15665
15681
|
const b = r.added;
|
|
15666
15682
|
return [...h, ...d, ...u].forEach((y) => {
|
|
15667
15683
|
b.push(y), i && e && e.add(y);
|
|
15668
|
-
}), this.MergeInfo.removedObjects += f.length, this.MergeInfo.mergedMeshes += h.length, this.MergeInfo.mergedLines += d.length, this.MergeInfo.mergedPoints += u.length, s && e &&
|
|
15684
|
+
}), this.MergeInfo.removedObjects += f.length, this.MergeInfo.mergedMeshes += h.length, this.MergeInfo.mergedLines += d.length, this.MergeInfo.mergedPoints += u.length, s && e && J.removeEmptyObjects(e), r;
|
|
15669
15685
|
}
|
|
15670
15686
|
/**
|
|
15671
15687
|
* since we'll move geometry to another merged mesh under a group, below is the structure:
|
|
@@ -20758,7 +20774,7 @@ const Ge = new p.Vector3(1, 0, 0), Xn = new p.Vector3(0, 1, 0), bi = new p.Vecto
|
|
|
20758
20774
|
!M && (M = [], y[E] = M), M.push(x);
|
|
20759
20775
|
};
|
|
20760
20776
|
m.children.forEach((x) => {
|
|
20761
|
-
if (
|
|
20777
|
+
if (J.setSharedVariablesOfObject(x), !x.userData.isLayoutLevelObject) return;
|
|
20762
20778
|
const E = x.name;
|
|
20763
20779
|
let M;
|
|
20764
20780
|
if (E !== j.MODEL_LAYOUT_NAME) {
|
|
@@ -20766,7 +20782,7 @@ const Ge = new p.Vector3(1, 0, 0), Xn = new p.Vector3(0, 1, 0), bi = new p.Vecto
|
|
|
20766
20782
|
!O.directAssociatedLeafObjectSet && (O.directAssociatedLeafObjectSet = /* @__PURE__ */ new Set()), M = O.directAssociatedLeafObjectSet;
|
|
20767
20783
|
}
|
|
20768
20784
|
x.traverse((O) => {
|
|
20769
|
-
if (
|
|
20785
|
+
if (J.setSharedVariablesOfObject(O), O.userData.isSnapGroup && (O.visible = j.SHOW_SNAP_OBJECT), O.geometry) {
|
|
20770
20786
|
const T = O.userData.layerName;
|
|
20771
20787
|
this.getLayerVisible(e, T) === !1 && (O.visible = !1, O.userData.layerVisible = !1), S(O), M && M.add(O);
|
|
20772
20788
|
}
|
|
@@ -20914,8 +20930,8 @@ const Ge = new p.Vector3(1, 0, 0), Xn = new p.Vector3(0, 1, 0), bi = new p.Vecto
|
|
|
20914
20930
|
!_ && (_ = [], M[C] = _), _.push(v);
|
|
20915
20931
|
};
|
|
20916
20932
|
E.children.forEach((v) => {
|
|
20917
|
-
|
|
20918
|
-
if (
|
|
20933
|
+
J.setSharedVariablesOfObject(v), v.userData.isLayoutLevelObject && v.traverse((C) => {
|
|
20934
|
+
if (J.setSharedVariablesOfObject(C), C.userData.isSnapGroup && (C.visible = j.SHOW_SNAP_OBJECT), C.geometry) {
|
|
20919
20935
|
const _ = C.userData.layerName;
|
|
20920
20936
|
this.getLayerVisible(f, _) === !1 && (C.visible = !1, C.userData.layerVisible = !1), O(C);
|
|
20921
20937
|
}
|
|
@@ -21819,7 +21835,7 @@ const Ge = new p.Vector3(1, 0, 0), Xn = new p.Vector3(0, 1, 0), bi = new p.Vecto
|
|
|
21819
21835
|
else {
|
|
21820
21836
|
const E = new z(H.Mesh);
|
|
21821
21837
|
E.geometry = y, E.material = wi, E.layers.enableAll(), E.layers.disable(qe), a.add(E);
|
|
21822
|
-
const M =
|
|
21838
|
+
const M = J.createOutline(y, pe, E.matrix), O = new z(H.LineSegment);
|
|
21823
21839
|
O.geometry = M.geometry, O.material = M.material, O.matrix = M.matrix, O.layers.enableAll(), O.layers.disable(qe), a.add(O);
|
|
21824
21840
|
}
|
|
21825
21841
|
}
|
|
@@ -21903,16 +21919,20 @@ const Ge = new p.Vector3(1, 0, 0), Xn = new p.Vector3(0, 1, 0), bi = new p.Vecto
|
|
|
21903
21919
|
const u = [], f = e.contextData?.leaders[0];
|
|
21904
21920
|
if (!f) return a;
|
|
21905
21921
|
const m = f.lastLeaderLinePoint;
|
|
21906
|
-
if (
|
|
21922
|
+
if (!m) return a;
|
|
21923
|
+
if (e.enableDogLeg && f.doglegVector) {
|
|
21907
21924
|
const E = new p.Vector3(m.x, m.y, m.z), M = f.doglegLength, O = new p.Vector3(f.doglegVector.x, f.doglegVector.y, f.doglegVector.z), T = O.multiplyScalar(M), v = E.clone().add(T);
|
|
21908
21925
|
u.push(v, E);
|
|
21909
21926
|
}
|
|
21910
21927
|
const b = e.contextData?.leaders[0].leaderLines || [];
|
|
21911
21928
|
for (let E = 0; E < b.length; E++) {
|
|
21912
|
-
const M = b[E].vertices[0]
|
|
21929
|
+
const M = b[E].vertices?.[0];
|
|
21930
|
+
if (!M || M.length === 0) continue;
|
|
21931
|
+
const O = M.reverse().map((B) => new p.Vector3(B.x, B.y, B.z));
|
|
21913
21932
|
let T = new p.Vector3(m.x, m.y, m.z);
|
|
21914
21933
|
for (let B = 0; B < O.length; B++)
|
|
21915
21934
|
u.push(T, O[B]), T = O[B];
|
|
21935
|
+
if (u.length < 2) continue;
|
|
21916
21936
|
const v = U.subVectors(u[0], u[1]).length(), C = e.arrowHeadSize || n.DIMASZ || 2.5, _ = e.arrowHeadScale || n.DIMSCALE || 1, A = C * _;
|
|
21917
21937
|
e.leaderLineType;
|
|
21918
21938
|
let I = "";
|
|
@@ -23816,7 +23836,7 @@ const Ge = new p.Vector3(1, 0, 0), Xn = new p.Vector3(0, 1, 0), bi = new p.Vecto
|
|
|
23816
23836
|
}
|
|
23817
23837
|
for (let k = 0; k < A.length; k++) {
|
|
23818
23838
|
const D = A[k];
|
|
23819
|
-
|
|
23839
|
+
J.setSharedVariablesOfObject(D), E.push(D), o[T].children.push(D), v && v.add(D);
|
|
23820
23840
|
}
|
|
23821
23841
|
h > l && u(), await s((m + ++O / M) / f * 100);
|
|
23822
23842
|
}
|
|
@@ -23889,7 +23909,7 @@ const Ge = new p.Vector3(1, 0, 0), Xn = new p.Vector3(0, 1, 0), bi = new p.Vecto
|
|
|
23889
23909
|
s(e), this.removeEmptyObjectsFromMark(i);
|
|
23890
23910
|
}
|
|
23891
23911
|
static removeEmptyObjectsFromMark(e) {
|
|
23892
|
-
if (e.userData.validCount === 0 ||
|
|
23912
|
+
if (e.userData.validCount === 0 || J.isEmptyObject(e)) return e.removeFromParent(), !0;
|
|
23893
23913
|
for (let i = 0; i < e.children.length; )
|
|
23894
23914
|
!this.removeEmptyObjectsFromMark(e.children[i]) && ++i;
|
|
23895
23915
|
return !1;
|
|
@@ -24323,7 +24343,7 @@ class ys extends Or {
|
|
|
24323
24343
|
}), S && S.size === 0) return;
|
|
24324
24344
|
const E = s.getModelObject();
|
|
24325
24345
|
let M = s.getLayoutLevelObject(e);
|
|
24326
|
-
!M && (M = new p.Group(),
|
|
24346
|
+
!M && (M = new p.Group(), J.setSharedVariablesOfObject(M), M.name = e, E?.add(M)), M.add(w), w.applyMatrix4(r.msToPsMatrix), w.updateMatrixWorld(!0);
|
|
24327
24347
|
let O = M.children.find((C) => C.name === X.SNAP_GROUP_NAME);
|
|
24328
24348
|
!O && (O = new p.Group(), O.visible = X.SHOW_SNAP_OBJECT, O.name = X.SNAP_GROUP_NAME, M.add(O));
|
|
24329
24349
|
const T = s.getLayoutLevelObject(X.MODEL_LAYOUT_NAME), v = T?.children.find((C) => C.name === X.SNAP_GROUP_NAME);
|
|
@@ -24332,7 +24352,7 @@ class ys extends Or {
|
|
|
24332
24352
|
const _ = C.userData.layerName;
|
|
24333
24353
|
if (this.isLayerFrozenForViewport(_, y) || (Kn.makeEmpty(), Kn.expandByObject(C), !a.intersectsBox(Kn))) return;
|
|
24334
24354
|
const A = C.clone();
|
|
24335
|
-
|
|
24355
|
+
J.setSharedVariablesOfObject(A);
|
|
24336
24356
|
let I = A.parent;
|
|
24337
24357
|
const B = vi.identity();
|
|
24338
24358
|
for (; I && I.userData.isLayoutLevelObject !== !0; )
|
|
@@ -24340,8 +24360,8 @@ class ys extends Or {
|
|
|
24340
24360
|
B.premultiply(r.msToPsMatrix), A.applyMatrix4(B), O?.add(A), S?.add(A);
|
|
24341
24361
|
const k = s.getObjectsByLayer(_);
|
|
24342
24362
|
k && k.push(A);
|
|
24343
|
-
}), x.length > 0 &&
|
|
24344
|
-
|
|
24363
|
+
}), x.length > 0 && J.removeEmptyObjectsFromRemovingObjects(x, w), w.traverse((C) => {
|
|
24364
|
+
J.setSharedVariablesOfObject(C), this.addSpatialFilterSection(C, s.dxfData, !0);
|
|
24345
24365
|
});
|
|
24346
24366
|
}
|
|
24347
24367
|
setMaterialUniforms(e, i) {
|
|
@@ -24507,12 +24527,12 @@ class Lo extends Or {
|
|
|
24507
24527
|
*/
|
|
24508
24528
|
setDoubleSidedMaterials() {
|
|
24509
24529
|
this.getModelObject().traverse((e) => {
|
|
24510
|
-
e instanceof p.Mesh &&
|
|
24530
|
+
e instanceof p.Mesh && J.setDoubleSidedMaterialToObject(e);
|
|
24511
24531
|
});
|
|
24512
24532
|
}
|
|
24513
24533
|
revertDoubleSidedMaterials() {
|
|
24514
24534
|
this.getModelObject().traverse((e) => {
|
|
24515
|
-
e instanceof p.Mesh &&
|
|
24535
|
+
e instanceof p.Mesh && J.revertDoubleSidedMaterialToObject(e);
|
|
24516
24536
|
});
|
|
24517
24537
|
}
|
|
24518
24538
|
getModelObject() {
|
|
@@ -24528,7 +24548,7 @@ class Lo extends Or {
|
|
|
24528
24548
|
* Enables/disables edges.
|
|
24529
24549
|
*/
|
|
24530
24550
|
async enableOutline(e, i) {
|
|
24531
|
-
e && !this.edges && (this.edges = await
|
|
24551
|
+
e && !this.edges && (this.edges = await J.createOutlines(this.getModelObject(), void 0, i)), this.edges && this.edges.forEach((s) => s.visible = e);
|
|
24532
24552
|
}
|
|
24533
24553
|
/**
|
|
24534
24554
|
* Sets object's color.
|
|
@@ -26862,6 +26882,7 @@ class N1 {
|
|
|
26862
26882
|
});
|
|
26863
26883
|
}
|
|
26864
26884
|
init() {
|
|
26885
|
+
this.destroy();
|
|
26865
26886
|
const t = document.createElement("div");
|
|
26866
26887
|
t.classList.add("model-layout-switch-bar");
|
|
26867
26888
|
const e = document.createElement("div");
|
|
@@ -29086,7 +29107,7 @@ function Qa(c, t, e, i, s) {
|
|
|
29086
29107
|
path: r
|
|
29087
29108
|
};
|
|
29088
29109
|
}
|
|
29089
|
-
class
|
|
29110
|
+
class Q {
|
|
29090
29111
|
static GetBytes(t) {
|
|
29091
29112
|
switch (typeof t) {
|
|
29092
29113
|
case "string": {
|
|
@@ -29111,7 +29132,7 @@ class J {
|
|
|
29111
29132
|
if (t instanceof Array) {
|
|
29112
29133
|
const e = [];
|
|
29113
29134
|
for (let r = 0; r < t.length; r++)
|
|
29114
|
-
e.push(
|
|
29135
|
+
e.push(Q.GetBytes(t[r]));
|
|
29115
29136
|
let i = 0;
|
|
29116
29137
|
for (let r = 0; r < e.length; r++)
|
|
29117
29138
|
i += e[r].length;
|
|
@@ -29341,7 +29362,7 @@ const yt = class yt {
|
|
|
29341
29362
|
*/
|
|
29342
29363
|
static getCode(t) {
|
|
29343
29364
|
const e = J1(t);
|
|
29344
|
-
return e.length < 2 ? e[0] : e.length < 4 ?
|
|
29365
|
+
return e.length < 2 ? e[0] : e.length < 4 ? Q.ToUInt16(e, 0) : Q.ToUInt32(e, 0);
|
|
29345
29366
|
}
|
|
29346
29367
|
/**
|
|
29347
29368
|
* Parses code data and generates TextShape.
|
|
@@ -29386,10 +29407,10 @@ const yt = class yt {
|
|
|
29386
29407
|
l++, d = e[l];
|
|
29387
29408
|
break;
|
|
29388
29409
|
case je.Bigfont:
|
|
29389
|
-
l++, d = e[l], d == 0 && (l++, d =
|
|
29410
|
+
l++, d = e[l], d == 0 && (l++, d = Q.ToUInt16(new Uint8Array([e[l++], e[l++]]), 0), m.x = e[l++] * i, m.y = e[l++] * i, f = e[l] * i);
|
|
29390
29411
|
break;
|
|
29391
29412
|
case je.Unifont:
|
|
29392
|
-
l += 2, d =
|
|
29413
|
+
l += 2, d = Q.ToUInt16(new Uint8Array([e[l - 1], e[l]]), 0);
|
|
29393
29414
|
break;
|
|
29394
29415
|
}
|
|
29395
29416
|
d !== 0 && (u = t.getGraphicDataByCodeWithOffset(d, f, m), u && (n.push(...u.polylines.slice()), s = u.lastPoint.clone()));
|
|
@@ -29398,19 +29419,19 @@ const yt = class yt {
|
|
|
29398
29419
|
case 8:
|
|
29399
29420
|
{
|
|
29400
29421
|
const d = new p.Vector2();
|
|
29401
|
-
d.x =
|
|
29422
|
+
d.x = Q.byteTosbyte(e[++l]), d.y = Q.byteTosbyte(e[++l]), s.add(d.multiplyScalar(i)), o && r.push(s.clone());
|
|
29402
29423
|
}
|
|
29403
29424
|
break;
|
|
29404
29425
|
case 9:
|
|
29405
29426
|
for (; ; ) {
|
|
29406
29427
|
const u = new p.Vector2();
|
|
29407
|
-
if (u.x =
|
|
29428
|
+
if (u.x = Q.byteTosbyte(e[++l]), u.y = Q.byteTosbyte(e[++l]), !Number.isFinite(u.x) || !Number.isFinite(u.y) || u.x == 0 && u.y == 0) break;
|
|
29408
29429
|
s.add(u.multiplyScalar(i)), o && r.push(s.clone());
|
|
29409
29430
|
}
|
|
29410
29431
|
break;
|
|
29411
29432
|
case 10:
|
|
29412
29433
|
{
|
|
29413
|
-
const d = e[++l] * i, u =
|
|
29434
|
+
const d = e[++l] * i, u = Q.byteTosbyte(e[++l]), f = (u & 112) >> 4;
|
|
29414
29435
|
let m = u & 7;
|
|
29415
29436
|
m == 0 && (m = 8);
|
|
29416
29437
|
const b = Math.PI / 4;
|
|
@@ -29429,7 +29450,7 @@ const yt = class yt {
|
|
|
29429
29450
|
break;
|
|
29430
29451
|
case 11:
|
|
29431
29452
|
{
|
|
29432
|
-
const d = e[++l], u = e[++l], f = e[++l], m = e[++l], b = (f * 255 + m) * i, y =
|
|
29453
|
+
const d = e[++l], u = e[++l], f = e[++l], m = e[++l], b = (f * 255 + m) * i, y = Q.byteTosbyte(e[++l]), S = (y & 112) >> 4;
|
|
29433
29454
|
let w = y & 7;
|
|
29434
29455
|
w == 0 && (w = 8), u != 0 && w--;
|
|
29435
29456
|
const x = Math.PI / 4;
|
|
@@ -29451,16 +29472,16 @@ const yt = class yt {
|
|
|
29451
29472
|
case 12:
|
|
29452
29473
|
{
|
|
29453
29474
|
const d = new p.Vector2();
|
|
29454
|
-
d.x =
|
|
29455
|
-
let u =
|
|
29475
|
+
d.x = Q.byteTosbyte(e[++l]) * i, d.y = Q.byteTosbyte(e[++l]) * i;
|
|
29476
|
+
let u = Q.byteTosbyte(e[++l]);
|
|
29456
29477
|
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
29478
|
}
|
|
29458
29479
|
break;
|
|
29459
29480
|
case 13:
|
|
29460
29481
|
for (; ; ) {
|
|
29461
29482
|
const u = new p.Vector2();
|
|
29462
|
-
if (u.x =
|
|
29463
|
-
let f =
|
|
29483
|
+
if (u.x = Q.byteTosbyte(e[++l]) * i, u.y = Q.byteTosbyte(e[++l]) * i, !Number.isFinite(u.x) || !Number.isFinite(u.y) || u.x == 0 && u.y == 0) break;
|
|
29484
|
+
let f = Q.byteTosbyte(e[++l]);
|
|
29464
29485
|
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
29486
|
}
|
|
29466
29487
|
break;
|
|
@@ -30390,13 +30411,13 @@ const rr = {
|
|
|
30390
30411
|
return this.getGraphicDataByCode(e, i)?.offset(s);
|
|
30391
30412
|
}
|
|
30392
30413
|
parseBigFont(e) {
|
|
30393
|
-
|
|
30394
|
-
const i =
|
|
30414
|
+
Q.ToInt16(e.readBytes(2), 0);
|
|
30415
|
+
const i = Q.ToInt16(e.readBytes(2), 0), s = Q.ToInt16(e.readBytes(2), 0);
|
|
30395
30416
|
for (let l = 0; l < s; l++)
|
|
30396
30417
|
e.readBytes(2), e.readBytes(2);
|
|
30397
30418
|
const n = [];
|
|
30398
30419
|
for (let l = 0; l < i; l++) {
|
|
30399
|
-
const h = e.readBytes(8), d =
|
|
30420
|
+
const h = e.readBytes(8), d = Q.ToUInt16(new Uint8Array([h[1], h[0]]), 0), u = Q.ToUInt16(h, 2), f = Q.ToUInt32(h, 4);
|
|
30400
30421
|
d === 0 && u === 0 && f === 0 || n.push({
|
|
30401
30422
|
code: d,
|
|
30402
30423
|
length: u,
|
|
@@ -30412,22 +30433,22 @@ const rr = {
|
|
|
30412
30433
|
a.length - o === 4 ? (this.baseUp = a[o++], this.baseDown = a[o++], this.orientation = a[o++]) : (this.baseUp = a[o++], o++, this.orientation = a[o++], this.baseDown = a[o++], this.isExtend = !0), this.data = r;
|
|
30413
30434
|
}
|
|
30414
30435
|
parseUniFont(e) {
|
|
30415
|
-
const i =
|
|
30436
|
+
const i = Q.ToInt32(e.readBytes(4), 0), s = Q.ToInt16(e.readBytes(2), 0), n = e.readBytes(s);
|
|
30416
30437
|
this.info = new TextDecoder().decode(n);
|
|
30417
30438
|
let r = this.info.indexOf("\0");
|
|
30418
30439
|
this.baseUp = n[++r], this.baseDown = n[++r], this.orientation = n[++r], this.isUniCode = n[++r] == 0, this.isEmbedded = n[++r] == 0;
|
|
30419
30440
|
const a = {};
|
|
30420
30441
|
for (let o = 0; o < i - 1; o++) {
|
|
30421
|
-
const l =
|
|
30442
|
+
const l = Q.ToUInt16(e.readBytes(2), 0), h = Q.ToUInt16(e.readBytes(2), 0);
|
|
30422
30443
|
a[l] = e.readBytes(h);
|
|
30423
30444
|
}
|
|
30424
30445
|
this.data = a;
|
|
30425
30446
|
}
|
|
30426
30447
|
parseShapeFont(e) {
|
|
30427
30448
|
e.readBytes(2), e.readBytes(2);
|
|
30428
|
-
const i =
|
|
30449
|
+
const i = Q.ToInt16(e.readBytes(2), 0), s = [];
|
|
30429
30450
|
for (let o = 0; o < i; o++) {
|
|
30430
|
-
const l =
|
|
30451
|
+
const l = Q.ToUInt16(e.readBytes(2), 0), h = Q.ToUInt16(e.readBytes(2), 0);
|
|
30431
30452
|
s.push({
|
|
30432
30453
|
code: l,
|
|
30433
30454
|
length: h
|
|
@@ -32104,8 +32125,8 @@ class N0 {
|
|
|
32104
32125
|
const i = t.slice(), s = [];
|
|
32105
32126
|
for (let r = 0; r < t.length && r < this.intersectionLimit; r++) {
|
|
32106
32127
|
const a = t[r].object;
|
|
32107
|
-
if (a.updateWorldMatrix(!0, !1), a instanceof p.Mesh && !
|
|
32108
|
-
const o =
|
|
32128
|
+
if (a.updateWorldMatrix(!0, !1), a instanceof p.Mesh && !J.hasOutline(a, !1)) {
|
|
32129
|
+
const o = J.createOutline(a.geometry);
|
|
32109
32130
|
o.visible = !1, a.add(o), o.updateWorldMatrix(!0, !1), s.push(o);
|
|
32110
32131
|
}
|
|
32111
32132
|
}
|
|
@@ -32398,6 +32419,12 @@ class no {
|
|
|
32398
32419
|
getMasterModel() {
|
|
32399
32420
|
return this.viewer.loadedModels.find((t) => this.viewer.masterModelId === t.modelId);
|
|
32400
32421
|
}
|
|
32422
|
+
/**
|
|
32423
|
+
* 失效已建立的文本搜索索引(模型被移除后调用),释放对旧模型对象的引用。
|
|
32424
|
+
*/
|
|
32425
|
+
invalidateIndex() {
|
|
32426
|
+
this.index = [], this.indexedModelObject = void 0;
|
|
32427
|
+
}
|
|
32401
32428
|
/**
|
|
32402
32429
|
* 遍历主模型场景图,收集所有带 userData.textContent 的文本对象。
|
|
32403
32430
|
*/
|
|
@@ -33446,7 +33473,9 @@ class Pr extends hi {
|
|
|
33446
33473
|
};
|
|
33447
33474
|
}
|
|
33448
33475
|
/**
|
|
33449
|
-
* 从场景中移除指定模型(不销毁 viewer
|
|
33476
|
+
* 从场景中移除指定模型(不销毁 viewer,用于切换图纸等场景),
|
|
33477
|
+
* 并释放模型的 GPU 资源(geometry/material)避免内存泄漏。
|
|
33478
|
+
* 注意:移除后该模型对象不可再用于渲染。
|
|
33450
33479
|
* @param modelId 加载时指定的 modelId
|
|
33451
33480
|
* @returns 被移除的模型,未找到时返回 undefined
|
|
33452
33481
|
*/
|
|
@@ -33454,7 +33483,7 @@ class Pr extends hi {
|
|
|
33454
33483
|
const i = this.loadedModels.findIndex((n) => n.modelId === e);
|
|
33455
33484
|
if (i === -1) return;
|
|
33456
33485
|
const s = this.loadedModels.splice(i, 1)[0];
|
|
33457
|
-
return this.sceneManager.removeModel(s), this.enableRender(), s;
|
|
33486
|
+
return this.sceneManager.removeModel(s), J.disposeObject(s.getModelObject()), this.enableRender(), s;
|
|
33458
33487
|
}
|
|
33459
33488
|
destroy() {
|
|
33460
33489
|
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();
|
|
@@ -33771,7 +33800,7 @@ class $o extends Pr {
|
|
|
33771
33800
|
*/
|
|
33772
33801
|
removeModel(e) {
|
|
33773
33802
|
const i = super.removeModel(e);
|
|
33774
|
-
return i && this.loadedModels.length === 0 && (this.masterModelId = "", this.activeLayoutName = "", this.layoutInfos = {}, this.units = void 0), i;
|
|
33803
|
+
return i && this.textSearchHelper?.invalidateIndex(), i && this.loadedModels.length === 0 && (this.masterModelId = "", this.activeLayoutName = "", this.layoutInfos = {}, this.units = void 0), i;
|
|
33775
33804
|
}
|
|
33776
33805
|
addModel(e) {
|
|
33777
33806
|
super.addModel(e);
|
|
@@ -33850,7 +33879,7 @@ class $o extends Pr {
|
|
|
33850
33879
|
color: "#888",
|
|
33851
33880
|
side: p.DoubleSide
|
|
33852
33881
|
});
|
|
33853
|
-
this.groundPlane = new p.Mesh(o, l), this.groundPlane.visible = !1, this.groundPlane.position.set(a.x, a.y, -r.z), this.groundPlane.scale.set(1e5, 1e5, 1), this.groundPlane.name = "groundPlane", this.groundPlane.renderOrder = vu, this.groundPlane.layers.enableAll(),
|
|
33882
|
+
this.groundPlane = new p.Mesh(o, l), this.groundPlane.visible = !1, this.groundPlane.position.set(a.x, a.y, -r.z), this.groundPlane.scale.set(1e5, 1e5, 1), this.groundPlane.name = "groundPlane", this.groundPlane.renderOrder = vu, this.groundPlane.layers.enableAll(), J.disableLayerChannels(this.groundPlane, [li]), this.scene.add(this.groundPlane);
|
|
33854
33883
|
}
|
|
33855
33884
|
this.groundPlane.updateMatrix(), this.groundPlane.updateMatrixWorld(!0);
|
|
33856
33885
|
}
|
|
@@ -33870,7 +33899,7 @@ class $o extends Pr {
|
|
|
33870
33899
|
for (const s of this.loadedModels) {
|
|
33871
33900
|
const n = s.getModelObject(), r = n.children.find((a) => a.name === this.activeLayoutName);
|
|
33872
33901
|
r && r.children.find((o) => o.name === X.SNAP_GROUP_NAME)?.traverse((o) => {
|
|
33873
|
-
if (
|
|
33902
|
+
if (J.isLeafObject(o)) {
|
|
33874
33903
|
if (ar.makeEmpty(), ar.expandByObject(o), !oo.intersectsBox(ar)) return;
|
|
33875
33904
|
e.push(o);
|
|
33876
33905
|
}
|
|
@@ -34439,7 +34468,7 @@ class $o extends Pr {
|
|
|
34439
34468
|
this.lastCameraZoom = a;
|
|
34440
34469
|
let o = 1;
|
|
34441
34470
|
e.traverse((h) => {
|
|
34442
|
-
if (h.userData.isSnapObject || !
|
|
34471
|
+
if (h.userData.isSnapObject || !J.isLeafObject(h)) return;
|
|
34443
34472
|
const d = h.geometry;
|
|
34444
34473
|
d.boundingBox || d.computeBoundingBox();
|
|
34445
34474
|
const u = d.boundingBox.clone();
|
|
@@ -35967,7 +35996,7 @@ class K0 {
|
|
|
35967
35996
|
u.geometry && u.layers.enableAll(), u instanceof p.Light && (u.visible = !1);
|
|
35968
35997
|
});
|
|
35969
35998
|
let o;
|
|
35970
|
-
r.edges && (o = await
|
|
35999
|
+
r.edges && (o = await J.createOutlines(n, void 0, a));
|
|
35971
36000
|
let l = r.modelId || r.src;
|
|
35972
36001
|
const h = (u) => !!this.loadedModels.find((f) => f.modelId === u);
|
|
35973
36002
|
if (h(l)) {
|
|
@@ -36139,10 +36168,10 @@ class K0 {
|
|
|
36139
36168
|
this.loadedModels.forEach((a) => {
|
|
36140
36169
|
const o = a.object.id;
|
|
36141
36170
|
if (t) {
|
|
36142
|
-
this.savedMaterialsForOpacity && this.savedMaterialsForOpacity.length > 0 &&
|
|
36143
|
-
const l =
|
|
36171
|
+
this.savedMaterialsForOpacity && this.savedMaterialsForOpacity.length > 0 && J.revertObjectOpacityById(n, o, this.savedMaterialsForOpacity);
|
|
36172
|
+
const l = J.setObjectOpacityById(n, o, e, i, s);
|
|
36144
36173
|
r.push(...l);
|
|
36145
|
-
} else this.savedMaterialsForOpacity &&
|
|
36174
|
+
} else this.savedMaterialsForOpacity && J.revertObjectOpacityById(n, o, this.savedMaterialsForOpacity);
|
|
36146
36175
|
}), t ? this.savedMaterialsForOpacity = r : this.savedMaterialsForOpacity = [];
|
|
36147
36176
|
}
|
|
36148
36177
|
hasTransparentObject() {
|
|
@@ -36274,7 +36303,7 @@ class K0 {
|
|
|
36274
36303
|
});
|
|
36275
36304
|
this.loadedModels.forEach((r) => {
|
|
36276
36305
|
const a = r.object.id;
|
|
36277
|
-
|
|
36306
|
+
J.applyMaterialToObjectById(this.scene, a, s, i, e);
|
|
36278
36307
|
}), this.outlineRoot.clear();
|
|
36279
36308
|
let n = [];
|
|
36280
36309
|
if (t.forEach((r) => {
|
|
@@ -36288,13 +36317,13 @@ class K0 {
|
|
|
36288
36317
|
});
|
|
36289
36318
|
}), n.length > 0) {
|
|
36290
36319
|
n.forEach((a) => {
|
|
36291
|
-
const o =
|
|
36320
|
+
const o = J.createOutline(a.geometry, this.outlineMaterial);
|
|
36292
36321
|
o.applyMatrix4(a.matrixWorld), this.outlineRoot.add(o), o.updateWorldMatrix(!0, !1);
|
|
36293
36322
|
});
|
|
36294
36323
|
const r = n.map((a) => a.id);
|
|
36295
36324
|
this.loadedModels.forEach((a) => {
|
|
36296
36325
|
const o = a.object.id;
|
|
36297
|
-
|
|
36326
|
+
J.revertAppliedMaterialToObjectById(this.scene, o, r);
|
|
36298
36327
|
}), this.transparentObjectIds = r, this.flyToObjects(n);
|
|
36299
36328
|
} else
|
|
36300
36329
|
P.warn("[Viewer] No object found with uniqueIds: " + t.map((r) => r.id));
|
|
@@ -36413,7 +36442,7 @@ export {
|
|
|
36413
36442
|
Rt as OSnapMarkerType,
|
|
36414
36443
|
cu as OSnapType,
|
|
36415
36444
|
j0 as ObjectPixelSizeHelper,
|
|
36416
|
-
|
|
36445
|
+
J as ObjectUtils,
|
|
36417
36446
|
q0 as Offset,
|
|
36418
36447
|
X1 as OrbitControls,
|
|
36419
36448
|
Rn as OutlineColorRgba,
|
|
@@ -41,6 +41,10 @@ export declare class TextSearchHelper {
|
|
|
41
41
|
private index;
|
|
42
42
|
constructor(viewer: Viewer2d);
|
|
43
43
|
private getMasterModel;
|
|
44
|
+
/**
|
|
45
|
+
* 失效已建立的文本搜索索引(模型被移除后调用),释放对旧模型对象的引用。
|
|
46
|
+
*/
|
|
47
|
+
invalidateIndex(): void;
|
|
44
48
|
/**
|
|
45
49
|
* 遍历主模型场景图,收集所有带 userData.textContent 的文本对象。
|
|
46
50
|
*/
|
|
@@ -212,4 +212,11 @@ export declare class ObjectUtils {
|
|
|
212
212
|
static isObjectHittable(obj: THREE.Object3D): boolean;
|
|
213
213
|
static isObjectSnapable(obj: THREE.Object3D): boolean;
|
|
214
214
|
static isObjectSelectable(obj: THREE.Object3D): boolean;
|
|
215
|
+
/**
|
|
216
|
+
* 递归释放对象的 GPU 资源(geometry/material)。
|
|
217
|
+
* 用于从场景移除模型后释放显存,避免切换图纸时内存泄漏。
|
|
218
|
+
* 覆盖 Mesh/Line/Points 等所有携带 geometry 的可渲染对象。
|
|
219
|
+
* 注意:释放后对象不可再用于渲染。
|
|
220
|
+
*/
|
|
221
|
+
static disposeObject(object: THREE.Object3D): void;
|
|
215
222
|
}
|
|
@@ -224,7 +224,9 @@ export declare abstract class BaseViewer extends Event<ViewerEvents> {
|
|
|
224
224
|
materials: number;
|
|
225
225
|
};
|
|
226
226
|
/**
|
|
227
|
-
* 从场景中移除指定模型(不销毁 viewer
|
|
227
|
+
* 从场景中移除指定模型(不销毁 viewer,用于切换图纸等场景),
|
|
228
|
+
* 并释放模型的 GPU 资源(geometry/material)避免内存泄漏。
|
|
229
|
+
* 注意:移除后该模型对象不可再用于渲染。
|
|
228
230
|
* @param modelId 加载时指定的 modelId
|
|
229
231
|
* @returns 被移除的模型,未找到时返回 undefined
|
|
230
232
|
*/
|