printbench 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/assets/draco_decoder.wasm +0 -0
- package/dist/assets/draco_wasm_wrapper.js +116 -0
- package/dist/assets/manifold.wasm +0 -0
- package/dist/assets/manifold.worker-C1p2Y56M.js +2944 -0
- package/dist/assets/qiu_ao.glb +0 -0
- package/dist/assets/qiu_tu_di.glb +0 -0
- package/dist/chunks/3mf-BC6RlyAs.js +136 -0
- package/dist/chunks/glb-BP9O7-y6.js +30 -0
- package/dist/chunks/index-Ci-Js4Ma.js +6376 -0
- package/dist/chunks/loadModel-B3mMwAm4.js +294 -0
- package/dist/chunks/loadQiuSnap-C3N_gz7r.js +49 -0
- package/dist/chunks/stl-ocJAIpI0.js +44 -0
- package/dist/printbench.js +8 -10001
- package/package.json +1 -1
|
@@ -0,0 +1,2944 @@
|
|
|
1
|
+
async function Yr(o = {}) {
|
|
2
|
+
var r, n = o, i = !!globalThis.window, c = !!globalThis.WorkerGlobalScope, a = globalThis.process?.versions?.node && globalThis.process?.type != "renderer";
|
|
3
|
+
if (a) {
|
|
4
|
+
const { createRequire: t } = await Promise.resolve().then(function() {
|
|
5
|
+
return Io;
|
|
6
|
+
});
|
|
7
|
+
var f = t(import.meta.url);
|
|
8
|
+
}
|
|
9
|
+
var d = !1;
|
|
10
|
+
n.setup = function() {
|
|
11
|
+
if (d) return;
|
|
12
|
+
d = !0, n.initTBB();
|
|
13
|
+
function t(u, h, C = ((W) => W)) {
|
|
14
|
+
if (h)
|
|
15
|
+
for (let W of h)
|
|
16
|
+
u.push_back(C(W));
|
|
17
|
+
return u;
|
|
18
|
+
}
|
|
19
|
+
function e(u, h = ((C) => C)) {
|
|
20
|
+
const C = [], W = u.size();
|
|
21
|
+
for (let K = 0; K < W; K++) C.push(h(u.get(K)));
|
|
22
|
+
return C;
|
|
23
|
+
}
|
|
24
|
+
function s(u, h = ((C) => C)) {
|
|
25
|
+
const C = [], W = u.size();
|
|
26
|
+
for (let K = 0; K < W; K++) {
|
|
27
|
+
const Z = u.get(K), ot = Z.size(), yt = [];
|
|
28
|
+
for (let ct = 0; ct < ot; ct++)
|
|
29
|
+
yt.push(h(Z.get(ct)));
|
|
30
|
+
C.push(yt);
|
|
31
|
+
}
|
|
32
|
+
return C;
|
|
33
|
+
}
|
|
34
|
+
function l(u) {
|
|
35
|
+
return u[0].length < 3 && (u = [u]), t(new n.Vector2_vec2(), u, (h) => t(new n.Vector_vec2(), h, (C) => C instanceof Array ? { x: C[0], y: C[1] } : C));
|
|
36
|
+
}
|
|
37
|
+
function p(u) {
|
|
38
|
+
for (let h = 0; h < u.size(); h++) u.get(h).delete();
|
|
39
|
+
u.delete();
|
|
40
|
+
}
|
|
41
|
+
function _(u) {
|
|
42
|
+
return u[0] instanceof Array ? { x: u[0][0], y: u[0][1] } : typeof u[0] == "number" ? { x: u[0] || 0, y: u[1] || 0 } : u[0];
|
|
43
|
+
}
|
|
44
|
+
function $(u) {
|
|
45
|
+
return u[0] instanceof Array ? { x: u[0][0], y: u[0][1], z: u[0][2] } : typeof u[0] == "number" ? { x: u[0] || 0, y: u[1] || 0, z: u[2] || 0 } : u[0];
|
|
46
|
+
}
|
|
47
|
+
function A(u) {
|
|
48
|
+
return u == "EvenOdd" ? 0 : u == "NonZero" ? 1 : u == "Negative" ? 3 : 2;
|
|
49
|
+
}
|
|
50
|
+
function V(u) {
|
|
51
|
+
return u == "Round" ? 1 : u == "Miter" ? 2 : 0;
|
|
52
|
+
}
|
|
53
|
+
const N = n.CrossSection;
|
|
54
|
+
function q(u, h = "Positive") {
|
|
55
|
+
if (u instanceof N)
|
|
56
|
+
return u;
|
|
57
|
+
{
|
|
58
|
+
const C = l(u), W = new N(C, A(h));
|
|
59
|
+
return p(C), W;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
n.CrossSection.prototype.translate = function(...u) {
|
|
63
|
+
return this._Translate(_(u));
|
|
64
|
+
}, n.CrossSection.prototype.scale = function(u) {
|
|
65
|
+
return typeof u == "number" ? this._Scale({ x: u, y: u }) : this._Scale(_([u]));
|
|
66
|
+
}, n.CrossSection.prototype.mirror = function(u) {
|
|
67
|
+
return this._Mirror(_([u]));
|
|
68
|
+
}, n.CrossSection.prototype.warp = function(u) {
|
|
69
|
+
const h = Vt(function(W) {
|
|
70
|
+
const K = dt(W, "double"), Z = dt(W + 8, "double"), ot = [K, Z];
|
|
71
|
+
u(ot), Dt(W, ot[0], "double"), Dt(W + 8, ot[1], "double");
|
|
72
|
+
}, "vi"), C = this._Warp(h);
|
|
73
|
+
return Bt(h), C;
|
|
74
|
+
}, n.CrossSection.prototype.decompose = function() {
|
|
75
|
+
const u = this._Decompose(), h = e(u);
|
|
76
|
+
return u.delete(), h;
|
|
77
|
+
}, n.CrossSection.prototype.bounds = function() {
|
|
78
|
+
const u = this._Bounds();
|
|
79
|
+
return { min: ["x", "y"].map((h) => u.min[h]), max: ["x", "y"].map((h) => u.max[h]) };
|
|
80
|
+
}, n.CrossSection.prototype.offset = function(u, h = "Round", C = 2, W = 0) {
|
|
81
|
+
return this._Offset(u, V(h), C, W);
|
|
82
|
+
}, n.CrossSection.prototype.simplify = function(u = 1e-6) {
|
|
83
|
+
return this._Simplify(u);
|
|
84
|
+
}, n.CrossSection.prototype.extrude = function(u, h = 0, C = 0, W = [1, 1], K = !1) {
|
|
85
|
+
W = _([W]);
|
|
86
|
+
const Z = n._Extrude(this._ToPolygons(), u, h, C, W);
|
|
87
|
+
return K ? Z.translate([0, 0, -u / 2]) : Z;
|
|
88
|
+
}, n.CrossSection.prototype.revolve = function(u = 0, h = 360) {
|
|
89
|
+
return n._Revolve(this._ToPolygons(), u, h);
|
|
90
|
+
}, n.CrossSection.prototype.add = function(u) {
|
|
91
|
+
return this._add(q(u));
|
|
92
|
+
}, n.CrossSection.prototype.subtract = function(u) {
|
|
93
|
+
return this._subtract(q(u));
|
|
94
|
+
}, n.CrossSection.prototype.intersect = function(u) {
|
|
95
|
+
return this._intersect(q(u));
|
|
96
|
+
}, n.CrossSection.prototype.toPolygons = function() {
|
|
97
|
+
const u = this._ToPolygons(), h = s(u, (C) => [C.x, C.y]);
|
|
98
|
+
return u.delete(), h;
|
|
99
|
+
}, n.Manifold.prototype.smoothOut = function(u = 52.5, h = 0) {
|
|
100
|
+
return this._SmoothOut(u, h);
|
|
101
|
+
}, n.Manifold.prototype.warp = function(u) {
|
|
102
|
+
const h = Vt(function(K) {
|
|
103
|
+
const Z = dt(K, "double"), ot = dt(K + 8, "double"), yt = dt(K + 16, "double"), ct = [Z, ot, yt];
|
|
104
|
+
u(ct), Dt(K, ct[0], "double"), Dt(K + 8, ct[1], "double"), Dt(K + 16, ct[2], "double");
|
|
105
|
+
}, "vi"), C = this._Warp(h);
|
|
106
|
+
Bt(h);
|
|
107
|
+
const W = C.status();
|
|
108
|
+
if (W !== "NoError")
|
|
109
|
+
throw new n.ManifoldError(W);
|
|
110
|
+
return C;
|
|
111
|
+
}, n.Manifold.prototype.warpBatch = function(u) {
|
|
112
|
+
const h = Vt(function(K, Z) {
|
|
113
|
+
const ot = n.HEAPF64 ?? O;
|
|
114
|
+
if (!ot)
|
|
115
|
+
throw new Error("WASM heap is not initialized (HEAPF64 unavailable)");
|
|
116
|
+
const yt = new Float64Array(ot.buffer, K, Z * 3);
|
|
117
|
+
u(yt, Z);
|
|
118
|
+
}, "vii"), C = this._WarpBatch(h);
|
|
119
|
+
Bt(h);
|
|
120
|
+
const W = C.status();
|
|
121
|
+
if (W !== "NoError")
|
|
122
|
+
throw new n.ManifoldError(W);
|
|
123
|
+
return C;
|
|
124
|
+
}, n.Manifold.prototype.calculateNormals = function(u = 0, h = 52.5) {
|
|
125
|
+
return this._CalculateNormals(u, h);
|
|
126
|
+
}, n.Manifold.prototype.smoothByNormals = function(u = 0) {
|
|
127
|
+
return this._SmoothByNormals(u);
|
|
128
|
+
}, n.Manifold.prototype.setProperties = function(u, h) {
|
|
129
|
+
const C = this.numProp(), W = Vt(function(Z, ot, yt) {
|
|
130
|
+
const ct = [];
|
|
131
|
+
for (let it = 0; it < u; ++it)
|
|
132
|
+
ct[it] = dt(Z + 8 * it, "double");
|
|
133
|
+
const kt = [];
|
|
134
|
+
for (let it = 0; it < 3; ++it)
|
|
135
|
+
kt[it] = dt(ot + 8 * it, "double");
|
|
136
|
+
const Et = [];
|
|
137
|
+
for (let it = 0; it < C; ++it)
|
|
138
|
+
Et[it] = dt(yt + 8 * it, "double");
|
|
139
|
+
h(ct, kt, Et);
|
|
140
|
+
for (let it = 0; it < u; ++it)
|
|
141
|
+
Dt(Z + 8 * it, ct[it], "double");
|
|
142
|
+
}, "viii"), K = this._SetProperties(u, W);
|
|
143
|
+
return Bt(W), K;
|
|
144
|
+
}, n.Manifold.prototype.translate = function(...u) {
|
|
145
|
+
return this._Translate($(u));
|
|
146
|
+
}, n.Manifold.prototype.rotate = function(u, h, C) {
|
|
147
|
+
return Array.isArray(u) ? this._Rotate(...u) : this._Rotate(u, h || 0, C || 0);
|
|
148
|
+
}, n.Manifold.prototype.scale = function(u) {
|
|
149
|
+
return typeof u == "number" ? this._Scale({ x: u, y: u, z: u }) : this._Scale($([u]));
|
|
150
|
+
}, n.Manifold.prototype.mirror = function(u) {
|
|
151
|
+
return this._Mirror($([u]));
|
|
152
|
+
}, n.Manifold.prototype.trimByPlane = function(u, h = 0) {
|
|
153
|
+
return this._TrimByPlane($([u]), h);
|
|
154
|
+
}, n.Manifold.prototype.slice = function(u = 0) {
|
|
155
|
+
const h = this._Slice(u), C = new N(h, A("Positive"));
|
|
156
|
+
return p(h), C;
|
|
157
|
+
}, n.Manifold.prototype.project = function() {
|
|
158
|
+
const u = this._Project(), h = new N(u, A("Positive"));
|
|
159
|
+
return p(u), h;
|
|
160
|
+
}, n.Manifold.prototype.rayCast = function(u, h) {
|
|
161
|
+
const C = this._RayCast($([u]), $([h])), W = e(C, (K) => ({ faceID: K.faceID, distance: K.distance, position: ["x", "y", "z"].map((Z) => K.position[Z]), normal: ["x", "y", "z"].map((Z) => K.normal[Z]) }));
|
|
162
|
+
return C.delete(), W;
|
|
163
|
+
}, n.Manifold.prototype.split = function(u) {
|
|
164
|
+
const h = this._Split(u), C = e(h);
|
|
165
|
+
return h.delete(), C;
|
|
166
|
+
}, n.Manifold.prototype.splitByPlane = function(u, h = 0) {
|
|
167
|
+
const C = this._SplitByPlane($([u]), h), W = e(C);
|
|
168
|
+
return C.delete(), W;
|
|
169
|
+
}, n.Manifold.prototype.decompose = function() {
|
|
170
|
+
const u = this._Decompose(), h = e(u);
|
|
171
|
+
return u.delete(), h;
|
|
172
|
+
}, n.Manifold.prototype.boundingBox = function() {
|
|
173
|
+
const u = this._boundingBox();
|
|
174
|
+
return { min: ["x", "y", "z"].map((h) => u.min[h]), max: ["x", "y", "z"].map((h) => u.max[h]) };
|
|
175
|
+
}, n.Manifold.prototype.simplify = function(u = 0) {
|
|
176
|
+
return this._Simplify(u);
|
|
177
|
+
};
|
|
178
|
+
class Q {
|
|
179
|
+
constructor({ numProp: h = 3, triVerts: C = new Uint32Array(), vertProperties: W = new Float32Array(), mergeFromVert: K, mergeToVert: Z, runIndex: ot, runOriginalID: yt, faceID: ct, halfedgeTangent: kt, runTransform: Et, runFlags: it, tolerance: Ce = 0 } = {}) {
|
|
180
|
+
this.numProp = h, this.triVerts = C, this.vertProperties = W, this.mergeFromVert = K, this.mergeToVert = Z, this.runIndex = ot, this.runOriginalID = yt, this.faceID = ct, this.halfedgeTangent = kt, this.runTransform = Et, this.runFlags = it, this.tolerance = Ce;
|
|
181
|
+
}
|
|
182
|
+
get numTri() {
|
|
183
|
+
return this.triVerts.length / 3;
|
|
184
|
+
}
|
|
185
|
+
get numVert() {
|
|
186
|
+
return this.vertProperties.length / this.numProp;
|
|
187
|
+
}
|
|
188
|
+
get numRun() {
|
|
189
|
+
return this.runOriginalID.length;
|
|
190
|
+
}
|
|
191
|
+
merge() {
|
|
192
|
+
const { changed: h, mesh: C } = n._Merge(this);
|
|
193
|
+
return Object.assign(this, { ...C }), h;
|
|
194
|
+
}
|
|
195
|
+
verts(h) {
|
|
196
|
+
return this.triVerts.subarray(3 * h, 3 * (h + 1));
|
|
197
|
+
}
|
|
198
|
+
position(h) {
|
|
199
|
+
return this.vertProperties.subarray(this.numProp * h, this.numProp * h + 3);
|
|
200
|
+
}
|
|
201
|
+
extras(h) {
|
|
202
|
+
return this.vertProperties.subarray(this.numProp * h + 3, this.numProp * (h + 1));
|
|
203
|
+
}
|
|
204
|
+
tangent(h) {
|
|
205
|
+
return this.halfedgeTangent.subarray(4 * h, 4 * (h + 1));
|
|
206
|
+
}
|
|
207
|
+
transform(h) {
|
|
208
|
+
const C = new Array(16);
|
|
209
|
+
for (const W of [0, 1, 2, 3])
|
|
210
|
+
for (const K of [0, 1, 2])
|
|
211
|
+
C[4 * W + K] = this.runTransform[12 * h + 3 * W + K];
|
|
212
|
+
return C[15] = 1, C;
|
|
213
|
+
}
|
|
214
|
+
backside(h) {
|
|
215
|
+
return this.runFlags != null && h < this.runFlags.length && (this.runFlags[h] & 1) !== 0;
|
|
216
|
+
}
|
|
217
|
+
hasNormals(h) {
|
|
218
|
+
return this.runFlags != null && h < this.runFlags.length && (this.runFlags[h] & 2) !== 0;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
n.Mesh = Q, n.Manifold.prototype.getMesh = function(u = -1) {
|
|
222
|
+
return new Q(this._GetMeshJS(u));
|
|
223
|
+
}, n.ManifoldError = function(h, ...C) {
|
|
224
|
+
let W = "Unknown error";
|
|
225
|
+
switch (h) {
|
|
226
|
+
case "NonFiniteVertex":
|
|
227
|
+
W = "Non-finite vertex";
|
|
228
|
+
break;
|
|
229
|
+
case "NotManifold":
|
|
230
|
+
W = "Not manifold";
|
|
231
|
+
break;
|
|
232
|
+
case "VertexOutOfBounds":
|
|
233
|
+
W = "Vertex index out of bounds";
|
|
234
|
+
break;
|
|
235
|
+
case "PropertiesWrongLength":
|
|
236
|
+
W = "Properties have wrong length";
|
|
237
|
+
break;
|
|
238
|
+
case "MissingPositionProperties":
|
|
239
|
+
W = "Less than three properties";
|
|
240
|
+
break;
|
|
241
|
+
case "MergeVectorsDifferentLengths":
|
|
242
|
+
W = "Merge vectors have different lengths";
|
|
243
|
+
break;
|
|
244
|
+
case "MergeIndexOutOfBounds":
|
|
245
|
+
W = "Merge index out of bounds";
|
|
246
|
+
break;
|
|
247
|
+
case "TransformWrongLength":
|
|
248
|
+
W = "Transform vector has wrong length";
|
|
249
|
+
break;
|
|
250
|
+
case "RunIndexWrongLength":
|
|
251
|
+
W = "Run index vector has wrong length";
|
|
252
|
+
break;
|
|
253
|
+
case "FaceIDWrongLength":
|
|
254
|
+
W = "Face ID vector has wrong length";
|
|
255
|
+
break;
|
|
256
|
+
case "InvalidConstruction":
|
|
257
|
+
W = "Manifold constructed with invalid parameters";
|
|
258
|
+
break;
|
|
259
|
+
case "ResultTooLarge":
|
|
260
|
+
W = "Result exceeds maximum size";
|
|
261
|
+
break;
|
|
262
|
+
case "InvalidTangents":
|
|
263
|
+
W = "Invalid halfedge tangents";
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
const K = Error.apply(this, [W, ...C]);
|
|
267
|
+
K.name = this.name = "ManifoldError", this.message = K.message, this.stack = K.stack, this.code = h;
|
|
268
|
+
}, n.ManifoldError.prototype = Object.create(Error.prototype, { constructor: { value: n.ManifoldError, writable: !0, configurable: !0 } }), n.CrossSection = function(u, h = "Positive") {
|
|
269
|
+
const C = l(u), W = new N(C, A(h));
|
|
270
|
+
return p(C), W;
|
|
271
|
+
}, n.CrossSection.ofPolygons = function(u, h = "Positive") {
|
|
272
|
+
return new n.CrossSection(u, h);
|
|
273
|
+
}, n.CrossSection.square = function(...u) {
|
|
274
|
+
let h;
|
|
275
|
+
u.length == 0 ? h = { x: 1, y: 1 } : typeof u[0] == "number" ? h = { x: u[0], y: u[0] } : h = _(u);
|
|
276
|
+
const C = u[1] || !1;
|
|
277
|
+
return n._Square(h, C);
|
|
278
|
+
}, n.CrossSection.circle = function(u, h = 0) {
|
|
279
|
+
return n._Circle(u, h);
|
|
280
|
+
};
|
|
281
|
+
function et(u) {
|
|
282
|
+
return function(...h) {
|
|
283
|
+
h.length == 1 && (h = h[0]);
|
|
284
|
+
const C = new n.Vector_crossSection();
|
|
285
|
+
for (const K of h) C.push_back(q(K));
|
|
286
|
+
const W = n["_crossSection" + u](C);
|
|
287
|
+
return C.delete(), W;
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
n.CrossSection.compose = et("Compose"), n.CrossSection.union = et("UnionN"), n.CrossSection.difference = et("DifferenceN"), n.CrossSection.intersection = et("IntersectionN");
|
|
291
|
+
function tt(u, h) {
|
|
292
|
+
t(u, h, (C) => C instanceof Array ? { x: C[0], y: C[1] } : C);
|
|
293
|
+
}
|
|
294
|
+
n.CrossSection.hull = function(...u) {
|
|
295
|
+
u.length == 1 && (u = u[0]);
|
|
296
|
+
let h = new n.Vector_vec2();
|
|
297
|
+
for (const W of u)
|
|
298
|
+
if (W instanceof N)
|
|
299
|
+
n._crossSectionCollectVertices(h, W);
|
|
300
|
+
else if (W instanceof Array && W.length == 2 && typeof W[0] == "number")
|
|
301
|
+
h.push_back({ x: W[0], y: W[1] });
|
|
302
|
+
else if (W.x)
|
|
303
|
+
h.push_back(W);
|
|
304
|
+
else {
|
|
305
|
+
const Z = W[0].length == 2 && typeof W[0][0] == "number" || W[0].x ? [W] : W;
|
|
306
|
+
for (const ot of Z) tt(h, ot);
|
|
307
|
+
}
|
|
308
|
+
const C = n._crossSectionHullPoints(h);
|
|
309
|
+
return h.delete(), C;
|
|
310
|
+
}, n.CrossSection.prototype = Object.create(N.prototype), Object.defineProperty(n.CrossSection, Symbol.hasInstance, { get: () => (u) => u instanceof N });
|
|
311
|
+
const st = n.Manifold;
|
|
312
|
+
n.Manifold = function(u) {
|
|
313
|
+
const h = new st(u), C = h.status();
|
|
314
|
+
if (C !== "NoError")
|
|
315
|
+
throw new n.ManifoldError(C);
|
|
316
|
+
return h;
|
|
317
|
+
}, n.Manifold.ofMesh = function(u) {
|
|
318
|
+
return new n.Manifold(u);
|
|
319
|
+
}, n.Manifold.tetrahedron = function() {
|
|
320
|
+
return n._Tetrahedron();
|
|
321
|
+
}, n.Manifold.cube = function(...u) {
|
|
322
|
+
let h;
|
|
323
|
+
u.length == 0 ? h = { x: 1, y: 1, z: 1 } : typeof u[0] == "number" ? h = { x: u[0], y: u[0], z: u[0] } : h = $(u);
|
|
324
|
+
const C = u[1] || !1;
|
|
325
|
+
return n._Cube(h, C);
|
|
326
|
+
}, n.Manifold.cylinder = function(u, h, C = -1, W = 0, K = !1) {
|
|
327
|
+
return n._Cylinder(u, h, C, W, K);
|
|
328
|
+
}, n.Manifold.sphere = function(u, h = 0) {
|
|
329
|
+
return n._Sphere(u, h);
|
|
330
|
+
}, n.Manifold.smooth = function(u, h = []) {
|
|
331
|
+
const C = new n.Vector_smoothness();
|
|
332
|
+
t(C, h);
|
|
333
|
+
const W = n._Smooth(u, C);
|
|
334
|
+
return C.delete(), W;
|
|
335
|
+
}, n.Manifold.extrude = function(u, h, C = 0, W = 0, K = [1, 1], Z = !1) {
|
|
336
|
+
return (u instanceof N ? u : n.CrossSection(u, "Positive")).extrude(h, C, W, K, Z);
|
|
337
|
+
}, n.Manifold.revolve = function(u, h = 0, C = 360) {
|
|
338
|
+
return (u instanceof N ? u : n.CrossSection(u, "Positive")).revolve(h, C);
|
|
339
|
+
}, n.Manifold.reserveIDs = function(u) {
|
|
340
|
+
return n._ReserveIDs(u);
|
|
341
|
+
};
|
|
342
|
+
function pt(u) {
|
|
343
|
+
return function(...h) {
|
|
344
|
+
h.length == 1 && (h = h[0]);
|
|
345
|
+
const C = new n.Vector_manifold();
|
|
346
|
+
for (const K of h) C.push_back(K);
|
|
347
|
+
const W = n["_manifold" + u + "N"](C);
|
|
348
|
+
return C.delete(), W;
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
n.Manifold.union = pt("Union"), n.Manifold.compose = n.Manifold.union, n.Manifold.difference = pt("Difference"), n.Manifold.intersection = pt("Intersection"), n.Manifold.levelSet = function(u, h, C, W = 0, K = -1) {
|
|
352
|
+
const Z = { min: { x: h.min[0], y: h.min[1], z: h.min[2] }, max: { x: h.max[0], y: h.max[1], z: h.max[2] } }, ot = Vt(function(ct) {
|
|
353
|
+
const kt = dt(ct, "double"), Et = dt(ct + 8, "double"), it = dt(ct + 16, "double");
|
|
354
|
+
return u([kt, Et, it]);
|
|
355
|
+
}, "di"), yt = n._LevelSet(ot, Z, C, W, K);
|
|
356
|
+
return Bt(ot), yt;
|
|
357
|
+
}, n.ExecutionContext.prototype.fromMesh = function(u) {
|
|
358
|
+
return this._FromMesh(u);
|
|
359
|
+
}, n.ExecutionContext.prototype.smooth = function(u, h = []) {
|
|
360
|
+
const C = new n.Vector_smoothness();
|
|
361
|
+
t(C, h);
|
|
362
|
+
const W = this._Smooth(u, C);
|
|
363
|
+
return C.delete(), W;
|
|
364
|
+
}, n.ExecutionContext.prototype.levelSet = function(u, h, C, W = 0, K = -1) {
|
|
365
|
+
const Z = { min: { x: h.min[0], y: h.min[1], z: h.min[2] }, max: { x: h.max[0], y: h.max[1], z: h.max[2] } }, ot = Vt(function(ct) {
|
|
366
|
+
const kt = dt(ct, "double"), Et = dt(ct + 8, "double"), it = dt(ct + 16, "double");
|
|
367
|
+
return u([kt, Et, it]);
|
|
368
|
+
}, "di"), yt = this._LevelSet(ot, Z, C, W, K);
|
|
369
|
+
return Bt(ot), yt;
|
|
370
|
+
};
|
|
371
|
+
function gt(u, h) {
|
|
372
|
+
t(u, h, (C) => C instanceof Array ? { x: C[0], y: C[1], z: C[2] } : C);
|
|
373
|
+
}
|
|
374
|
+
n.Manifold.hull = function(...u) {
|
|
375
|
+
u.length == 1 && (u = u[0]);
|
|
376
|
+
let h = new n.Vector_vec3();
|
|
377
|
+
for (const W of u)
|
|
378
|
+
W instanceof st ? n._manifoldCollectVertices(h, W) : W instanceof Array && W.length == 3 && typeof W[0] == "number" ? h.push_back({ x: W[0], y: W[1], z: W[2] }) : W.x ? h.push_back(W) : gt(h, W);
|
|
379
|
+
const C = n._manifoldHullPoints(h);
|
|
380
|
+
return h.delete(), C;
|
|
381
|
+
}, n.Manifold.prototype = Object.create(st.prototype), Object.defineProperty(n.Manifold, Symbol.hasInstance, { get: () => (u) => u instanceof st }), n.triangulate = function(u, h = -1, C = !0) {
|
|
382
|
+
const W = l(u), K = e(n._Triangulate(W, h, C), (Z) => [Z[0], Z[1], Z[2]]);
|
|
383
|
+
return p(W), K;
|
|
384
|
+
};
|
|
385
|
+
};
|
|
386
|
+
var v = import.meta.url, y = "";
|
|
387
|
+
function m(t) {
|
|
388
|
+
return n.locateFile ? n.locateFile(t, y) : y + t;
|
|
389
|
+
}
|
|
390
|
+
var k, b;
|
|
391
|
+
if (a) {
|
|
392
|
+
var x = f("node:fs");
|
|
393
|
+
v.startsWith("file:") && (y = f("node:path").dirname(f("node:url").fileURLToPath(v)) + "/"), b = (t) => {
|
|
394
|
+
t = M(t) ? new URL(t) : t;
|
|
395
|
+
var e = x.readFileSync(t);
|
|
396
|
+
return e;
|
|
397
|
+
}, k = async (t, e = !0) => {
|
|
398
|
+
t = M(t) ? new URL(t) : t;
|
|
399
|
+
var s = x.readFileSync(t, e ? void 0 : "utf8");
|
|
400
|
+
return s;
|
|
401
|
+
}, process.argv.length > 1 && process.argv[1].replace(/\\/g, "/"), process.argv.slice(2);
|
|
402
|
+
} else if (i || c) {
|
|
403
|
+
try {
|
|
404
|
+
y = new URL(".", v).href;
|
|
405
|
+
} catch {
|
|
406
|
+
}
|
|
407
|
+
c && (b = (t) => {
|
|
408
|
+
var e = new XMLHttpRequest();
|
|
409
|
+
return e.open("GET", t, !1), e.responseType = "arraybuffer", e.send(null), new Uint8Array(e.response);
|
|
410
|
+
}), k = async (t) => {
|
|
411
|
+
if (M(t))
|
|
412
|
+
return new Promise((s, l) => {
|
|
413
|
+
var p = new XMLHttpRequest();
|
|
414
|
+
p.open("GET", t, !0), p.responseType = "arraybuffer", p.onload = () => {
|
|
415
|
+
if (p.status == 200 || p.status == 0 && p.response) {
|
|
416
|
+
s(p.response);
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
l(p.status);
|
|
420
|
+
}, p.onerror = l, p.send(null);
|
|
421
|
+
});
|
|
422
|
+
var e = await fetch(t, { credentials: "same-origin" });
|
|
423
|
+
if (e.ok)
|
|
424
|
+
return e.arrayBuffer();
|
|
425
|
+
throw new Error(e.status + " : " + e.url);
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
console.log.bind(console);
|
|
429
|
+
var E = console.error.bind(console), g, P = !1, M = (t) => t.startsWith("file://"), F, I, z, T, S, w, B, R, j, O, D, L, U = !1;
|
|
430
|
+
function J() {
|
|
431
|
+
var t = ce.buffer;
|
|
432
|
+
z = new Int8Array(t), S = new Int16Array(t), T = new Uint8Array(t), w = new Uint16Array(t), B = new Int32Array(t), R = new Uint32Array(t), j = new Float32Array(t), O = new Float64Array(t), D = new BigInt64Array(t), L = new BigUint64Array(t);
|
|
433
|
+
}
|
|
434
|
+
function X() {
|
|
435
|
+
if (n.preRun)
|
|
436
|
+
for (typeof n.preRun == "function" && (n.preRun = [n.preRun]); n.preRun.length; )
|
|
437
|
+
qt(n.preRun.shift());
|
|
438
|
+
Mt(jt);
|
|
439
|
+
}
|
|
440
|
+
function rt() {
|
|
441
|
+
U = !0, Ot.J();
|
|
442
|
+
}
|
|
443
|
+
function H() {
|
|
444
|
+
if (n.postRun)
|
|
445
|
+
for (typeof n.postRun == "function" && (n.postRun = [n.postRun]); n.postRun.length; )
|
|
446
|
+
Lt(n.postRun.shift());
|
|
447
|
+
Mt(xt);
|
|
448
|
+
}
|
|
449
|
+
function G(t) {
|
|
450
|
+
n.onAbort?.(t), t = "Aborted(" + t + ")", E(t), P = !0, t += ". Build with -sASSERTIONS for more info.";
|
|
451
|
+
var e = new WebAssembly.RuntimeError(t);
|
|
452
|
+
throw I?.(e), e;
|
|
453
|
+
}
|
|
454
|
+
var Y;
|
|
455
|
+
function mt() {
|
|
456
|
+
return n.locateFile ? m("manifold.wasm") : "".href;
|
|
457
|
+
}
|
|
458
|
+
function ft(t) {
|
|
459
|
+
if (t == Y && g)
|
|
460
|
+
return new Uint8Array(g);
|
|
461
|
+
if (b)
|
|
462
|
+
return b(t);
|
|
463
|
+
throw "both async and sync fetching of the wasm failed";
|
|
464
|
+
}
|
|
465
|
+
async function ut(t) {
|
|
466
|
+
if (!g)
|
|
467
|
+
try {
|
|
468
|
+
var e = await k(t);
|
|
469
|
+
return new Uint8Array(e);
|
|
470
|
+
} catch {
|
|
471
|
+
}
|
|
472
|
+
return ft(t);
|
|
473
|
+
}
|
|
474
|
+
async function Pt(t, e) {
|
|
475
|
+
try {
|
|
476
|
+
var s = await ut(t), l = await WebAssembly.instantiate(s, e);
|
|
477
|
+
return l;
|
|
478
|
+
} catch (p) {
|
|
479
|
+
E(`failed to asynchronously prepare wasm: ${p}`), G(p);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
async function Ct(t, e, s) {
|
|
483
|
+
if (!t && !M(e) && !a)
|
|
484
|
+
try {
|
|
485
|
+
var l = fetch(e, { credentials: "same-origin" }), p = await WebAssembly.instantiateStreaming(l, s);
|
|
486
|
+
return p;
|
|
487
|
+
} catch (_) {
|
|
488
|
+
E(`wasm streaming compile failed: ${_}`), E("falling back to ArrayBuffer instantiation");
|
|
489
|
+
}
|
|
490
|
+
return Pt(e, s);
|
|
491
|
+
}
|
|
492
|
+
function _t() {
|
|
493
|
+
var t = { a: Gr };
|
|
494
|
+
return t;
|
|
495
|
+
}
|
|
496
|
+
async function Ft() {
|
|
497
|
+
function t(_, $) {
|
|
498
|
+
return Ot = _.exports, Ot = Kr(Ot), Jr(Ot), J(), Ot;
|
|
499
|
+
}
|
|
500
|
+
function e(_) {
|
|
501
|
+
return t(_.instance);
|
|
502
|
+
}
|
|
503
|
+
var s = _t();
|
|
504
|
+
if (n.instantiateWasm)
|
|
505
|
+
return new Promise((_, $) => {
|
|
506
|
+
n.instantiateWasm(s, (A, V) => {
|
|
507
|
+
_(t(A));
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
Y ??= mt();
|
|
511
|
+
var l = await Ct(g, Y, s), p = e(l);
|
|
512
|
+
return p;
|
|
513
|
+
}
|
|
514
|
+
var Mt = (t) => {
|
|
515
|
+
for (; t.length > 0; )
|
|
516
|
+
t.shift()(n);
|
|
517
|
+
}, xt = [], Lt = (t) => xt.push(t), jt = [], qt = (t) => jt.push(t);
|
|
518
|
+
function dt(t, e = "i8") {
|
|
519
|
+
switch (e.endsWith("*") && (e = "*"), e) {
|
|
520
|
+
case "i1":
|
|
521
|
+
return z[t >>> 0];
|
|
522
|
+
case "i8":
|
|
523
|
+
return z[t >>> 0];
|
|
524
|
+
case "i16":
|
|
525
|
+
return S[t >>> 1 >>> 0];
|
|
526
|
+
case "i32":
|
|
527
|
+
return B[t >>> 2 >>> 0];
|
|
528
|
+
case "i64":
|
|
529
|
+
return D[t >>> 3 >>> 0];
|
|
530
|
+
case "float":
|
|
531
|
+
return j[t >>> 2 >>> 0];
|
|
532
|
+
case "double":
|
|
533
|
+
return O[t >>> 3 >>> 0];
|
|
534
|
+
case "*":
|
|
535
|
+
return R[t >>> 2 >>> 0];
|
|
536
|
+
default:
|
|
537
|
+
G(`invalid type for getValue: ${e}`);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
function Dt(t, e, s = "i8") {
|
|
541
|
+
switch (s.endsWith("*") && (s = "*"), s) {
|
|
542
|
+
case "i1":
|
|
543
|
+
z[t >>> 0] = e;
|
|
544
|
+
break;
|
|
545
|
+
case "i8":
|
|
546
|
+
z[t >>> 0] = e;
|
|
547
|
+
break;
|
|
548
|
+
case "i16":
|
|
549
|
+
S[t >>> 1 >>> 0] = e;
|
|
550
|
+
break;
|
|
551
|
+
case "i32":
|
|
552
|
+
B[t >>> 2 >>> 0] = e;
|
|
553
|
+
break;
|
|
554
|
+
case "i64":
|
|
555
|
+
D[t >>> 3 >>> 0] = BigInt(e);
|
|
556
|
+
break;
|
|
557
|
+
case "float":
|
|
558
|
+
j[t >>> 2 >>> 0] = e;
|
|
559
|
+
break;
|
|
560
|
+
case "double":
|
|
561
|
+
O[t >>> 3 >>> 0] = e;
|
|
562
|
+
break;
|
|
563
|
+
case "*":
|
|
564
|
+
R[t >>> 2 >>> 0] = e;
|
|
565
|
+
break;
|
|
566
|
+
default:
|
|
567
|
+
G(`invalid type for setValue: ${s}`);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
class bn {
|
|
571
|
+
constructor(e) {
|
|
572
|
+
this.excPtr = e, this.ptr = e - 24;
|
|
573
|
+
}
|
|
574
|
+
set_type(e) {
|
|
575
|
+
R[this.ptr + 4 >>> 2 >>> 0] = e;
|
|
576
|
+
}
|
|
577
|
+
get_type() {
|
|
578
|
+
return R[this.ptr + 4 >>> 2 >>> 0];
|
|
579
|
+
}
|
|
580
|
+
set_destructor(e) {
|
|
581
|
+
R[this.ptr + 8 >>> 2 >>> 0] = e;
|
|
582
|
+
}
|
|
583
|
+
get_destructor() {
|
|
584
|
+
return R[this.ptr + 8 >>> 2 >>> 0];
|
|
585
|
+
}
|
|
586
|
+
set_caught(e) {
|
|
587
|
+
e = e ? 1 : 0, z[this.ptr + 12 >>> 0] = e;
|
|
588
|
+
}
|
|
589
|
+
get_caught() {
|
|
590
|
+
return z[this.ptr + 12 >>> 0] != 0;
|
|
591
|
+
}
|
|
592
|
+
set_rethrown(e) {
|
|
593
|
+
e = e ? 1 : 0, z[this.ptr + 13 >>> 0] = e;
|
|
594
|
+
}
|
|
595
|
+
get_rethrown() {
|
|
596
|
+
return z[this.ptr + 13 >>> 0] != 0;
|
|
597
|
+
}
|
|
598
|
+
init(e, s) {
|
|
599
|
+
this.set_adjusted_ptr(0), this.set_type(e), this.set_destructor(s);
|
|
600
|
+
}
|
|
601
|
+
set_adjusted_ptr(e) {
|
|
602
|
+
R[this.ptr + 16 >>> 2 >>> 0] = e;
|
|
603
|
+
}
|
|
604
|
+
get_adjusted_ptr() {
|
|
605
|
+
return R[this.ptr + 16 >>> 2 >>> 0];
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
var ke = 0;
|
|
609
|
+
function xn(t, e, s) {
|
|
610
|
+
t >>>= 0, e >>>= 0, s >>>= 0;
|
|
611
|
+
var l = new bn(t);
|
|
612
|
+
throw l.init(e, s), ke = t, ke;
|
|
613
|
+
}
|
|
614
|
+
var _n = () => G(""), Qt = {}, he = (t) => {
|
|
615
|
+
for (; t.length; ) {
|
|
616
|
+
var e = t.pop(), s = t.pop();
|
|
617
|
+
s(e);
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
function Jt(t) {
|
|
621
|
+
return this.fromWireType(R[t >>> 2 >>> 0]);
|
|
622
|
+
}
|
|
623
|
+
var Ut = {}, Rt = {}, te = {}, Mn = class extends Error {
|
|
624
|
+
constructor(e) {
|
|
625
|
+
super(e), this.name = "InternalError";
|
|
626
|
+
}
|
|
627
|
+
}, ee = (t) => {
|
|
628
|
+
throw new Mn(t);
|
|
629
|
+
}, It = (t, e, s) => {
|
|
630
|
+
t.forEach((A) => te[A] = e);
|
|
631
|
+
function l(A) {
|
|
632
|
+
var V = s(A);
|
|
633
|
+
V.length !== t.length && ee("Mismatched type converter count");
|
|
634
|
+
for (var N = 0; N < t.length; ++N)
|
|
635
|
+
vt(t[N], V[N]);
|
|
636
|
+
}
|
|
637
|
+
var p = new Array(e.length), _ = [], $ = 0;
|
|
638
|
+
for (let [A, V] of e.entries())
|
|
639
|
+
Rt.hasOwnProperty(V) ? p[A] = Rt[V] : (_.push(V), Ut.hasOwnProperty(V) || (Ut[V] = []), Ut[V].push(() => {
|
|
640
|
+
p[A] = Rt[V], ++$, $ === _.length && l(p);
|
|
641
|
+
}));
|
|
642
|
+
_.length === 0 && l(p);
|
|
643
|
+
}, wn = function(t) {
|
|
644
|
+
t >>>= 0;
|
|
645
|
+
var e = Qt[t];
|
|
646
|
+
delete Qt[t];
|
|
647
|
+
var s = e.rawConstructor, l = e.rawDestructor, p = e.fields, _ = p.map(($) => $.getterReturnType).concat(p.map(($) => $.setterArgumentType));
|
|
648
|
+
It([t], _, ($) => {
|
|
649
|
+
var A = {};
|
|
650
|
+
for (var [V, N] of p.entries()) {
|
|
651
|
+
const q = $[V], Q = N.getter, et = N.getterContext, tt = $[V + p.length], st = N.setter, pt = N.setterContext;
|
|
652
|
+
A[N.fieldName] = { read: (gt) => q.fromWireType(Q(et, gt)), write: (gt, u) => {
|
|
653
|
+
var h = [];
|
|
654
|
+
st(pt, gt, tt.toWireType(h, u)), he(h);
|
|
655
|
+
}, optional: q.optional };
|
|
656
|
+
}
|
|
657
|
+
return [{ name: e.name, fromWireType: (q) => {
|
|
658
|
+
var Q = {};
|
|
659
|
+
for (var et in A)
|
|
660
|
+
Q[et] = A[et].read(q);
|
|
661
|
+
return l(q), Q;
|
|
662
|
+
}, toWireType: (q, Q) => {
|
|
663
|
+
for (var et in A)
|
|
664
|
+
if (!(et in Q) && !A[et].optional)
|
|
665
|
+
throw new TypeError(`Missing field: "${et}"`);
|
|
666
|
+
var tt = s();
|
|
667
|
+
for (et in A)
|
|
668
|
+
A[et].write(tt, Q[et]);
|
|
669
|
+
return q !== null && q.push(l, tt), tt;
|
|
670
|
+
}, readValueFromPointer: Jt, destructorFunction: l }];
|
|
671
|
+
});
|
|
672
|
+
}, lt = (t) => {
|
|
673
|
+
t >>>= 0;
|
|
674
|
+
for (var e = ""; ; ) {
|
|
675
|
+
var s = T[t++ >>> 0];
|
|
676
|
+
if (!s) return e;
|
|
677
|
+
e += String.fromCharCode(s);
|
|
678
|
+
}
|
|
679
|
+
}, Gt = class extends Error {
|
|
680
|
+
constructor(e) {
|
|
681
|
+
super(e), this.name = "BindingError";
|
|
682
|
+
}
|
|
683
|
+
}, nt = (t) => {
|
|
684
|
+
throw new Gt(t);
|
|
685
|
+
};
|
|
686
|
+
function $n(t, e, s = {}) {
|
|
687
|
+
var l = e.name;
|
|
688
|
+
if (t || nt(`type "${l}" must have a positive integer typeid pointer`), Rt.hasOwnProperty(t)) {
|
|
689
|
+
if (s.ignoreDuplicateRegistrations)
|
|
690
|
+
return;
|
|
691
|
+
nt(`Cannot register type '${l}' twice`);
|
|
692
|
+
}
|
|
693
|
+
if (Rt[t] = e, delete te[t], Ut.hasOwnProperty(t)) {
|
|
694
|
+
var p = Ut[t];
|
|
695
|
+
delete Ut[t], p.forEach((_) => _());
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
function vt(t, e, s = {}) {
|
|
699
|
+
return $n(t, e, s);
|
|
700
|
+
}
|
|
701
|
+
var Ee = (t, e, s) => {
|
|
702
|
+
switch (e) {
|
|
703
|
+
case 1:
|
|
704
|
+
return s ? (l) => z[l >>> 0] : (l) => T[l >>> 0];
|
|
705
|
+
case 2:
|
|
706
|
+
return s ? (l) => S[l >>> 1 >>> 0] : (l) => w[l >>> 1 >>> 0];
|
|
707
|
+
case 4:
|
|
708
|
+
return s ? (l) => B[l >>> 2 >>> 0] : (l) => R[l >>> 2 >>> 0];
|
|
709
|
+
case 8:
|
|
710
|
+
return s ? (l) => D[l >>> 3 >>> 0] : (l) => L[l >>> 3 >>> 0];
|
|
711
|
+
default:
|
|
712
|
+
throw new TypeError(`invalid integer width (${e}): ${t}`);
|
|
713
|
+
}
|
|
714
|
+
}, Pn = function(t, e, s, l, p) {
|
|
715
|
+
t >>>= 0, e >>>= 0, s >>>= 0, e = lt(e);
|
|
716
|
+
const _ = l === 0n;
|
|
717
|
+
let $ = (A) => A;
|
|
718
|
+
if (_) {
|
|
719
|
+
const A = s * 8;
|
|
720
|
+
$ = (V) => BigInt.asUintN(A, V), p = $(p);
|
|
721
|
+
}
|
|
722
|
+
vt(t, { name: e, fromWireType: $, toWireType: (A, V) => (typeof V == "number" && (V = BigInt(V)), V), readValueFromPointer: Ee(e, s, !_), destructorFunction: null });
|
|
723
|
+
};
|
|
724
|
+
function Cn(t, e, s, l) {
|
|
725
|
+
t >>>= 0, e >>>= 0, e = lt(e), vt(t, { name: e, fromWireType: function(p) {
|
|
726
|
+
return !!p;
|
|
727
|
+
}, toWireType: function(p, _) {
|
|
728
|
+
return _ ? s : l;
|
|
729
|
+
}, readValueFromPointer: function(p) {
|
|
730
|
+
return this.fromWireType(T[p >>> 0]);
|
|
731
|
+
}, destructorFunction: null });
|
|
732
|
+
}
|
|
733
|
+
var Tn = (t) => ({ count: t.count, deleteScheduled: t.deleteScheduled, preservePointerOnDelete: t.preservePointerOnDelete, ptr: t.ptr, ptrType: t.ptrType, smartPtr: t.smartPtr, smartPtrType: t.smartPtrType }), pe = (t) => {
|
|
734
|
+
function e(s) {
|
|
735
|
+
return s.$$.ptrType.registeredClass.name;
|
|
736
|
+
}
|
|
737
|
+
nt(e(t) + " instance already deleted");
|
|
738
|
+
}, ye = !1, Re = (t) => {
|
|
739
|
+
}, Sn = (t) => {
|
|
740
|
+
t.smartPtr ? t.smartPtrType.rawDestructor(t.smartPtr) : t.ptrType.registeredClass.rawDestructor(t.ptr);
|
|
741
|
+
}, We = (t) => {
|
|
742
|
+
t.count.value -= 1;
|
|
743
|
+
var e = t.count.value === 0;
|
|
744
|
+
e && Sn(t);
|
|
745
|
+
}, Kt = (t) => globalThis.FinalizationRegistry ? (ye = new FinalizationRegistry((e) => {
|
|
746
|
+
We(e.$$);
|
|
747
|
+
}), Kt = (e) => {
|
|
748
|
+
var s = e.$$, l = !!s.smartPtr;
|
|
749
|
+
if (l) {
|
|
750
|
+
var p = { $$: s };
|
|
751
|
+
ye.register(e, p, e);
|
|
752
|
+
}
|
|
753
|
+
return e;
|
|
754
|
+
}, Re = (e) => ye.unregister(e), Kt(t)) : (Kt = (e) => e, t), Fn = () => {
|
|
755
|
+
let t = ne.prototype;
|
|
756
|
+
Object.assign(t, { isAliasOf(s) {
|
|
757
|
+
if (!(this instanceof ne) || !(s instanceof ne))
|
|
758
|
+
return !1;
|
|
759
|
+
var l = this.$$.ptrType.registeredClass, p = this.$$.ptr;
|
|
760
|
+
s.$$ = s.$$;
|
|
761
|
+
for (var _ = s.$$.ptrType.registeredClass, $ = s.$$.ptr; l.baseClass; )
|
|
762
|
+
p = l.upcast(p), l = l.baseClass;
|
|
763
|
+
for (; _.baseClass; )
|
|
764
|
+
$ = _.upcast($), _ = _.baseClass;
|
|
765
|
+
return l === _ && p === $;
|
|
766
|
+
}, clone() {
|
|
767
|
+
if (this.$$.ptr || pe(this), this.$$.preservePointerOnDelete)
|
|
768
|
+
return this.$$.count.value += 1, this;
|
|
769
|
+
var s = Kt(Object.create(Object.getPrototypeOf(this), { $$: { value: Tn(this.$$) } }));
|
|
770
|
+
return s.$$.count.value += 1, s.$$.deleteScheduled = !1, s;
|
|
771
|
+
}, delete() {
|
|
772
|
+
this.$$.ptr || pe(this), this.$$.deleteScheduled && !this.$$.preservePointerOnDelete && nt("Object already scheduled for deletion"), Re(this), We(this.$$), this.$$.preservePointerOnDelete || (this.$$.smartPtr = void 0, this.$$.ptr = void 0);
|
|
773
|
+
}, isDeleted() {
|
|
774
|
+
return !this.$$.ptr;
|
|
775
|
+
}, deleteLater() {
|
|
776
|
+
return this.$$.ptr || pe(this), this.$$.deleteScheduled && !this.$$.preservePointerOnDelete && nt("Object already scheduled for deletion"), this.$$.deleteScheduled = !0, this;
|
|
777
|
+
} });
|
|
778
|
+
const e = Symbol.dispose;
|
|
779
|
+
e && (t[e] = t.delete);
|
|
780
|
+
};
|
|
781
|
+
function ne() {
|
|
782
|
+
}
|
|
783
|
+
var re = (t, e) => Object.defineProperty(e, "name", { value: t }), ze = {}, Ve = (t, e, s) => {
|
|
784
|
+
if (t[e].overloadTable === void 0) {
|
|
785
|
+
var l = t[e];
|
|
786
|
+
t[e] = function(...p) {
|
|
787
|
+
return t[e].overloadTable.hasOwnProperty(p.length) || nt(`Function '${s}' called with an invalid number of arguments (${p.length}) - expects one of (${t[e].overloadTable})!`), t[e].overloadTable[p.length].apply(this, p);
|
|
788
|
+
}, t[e].overloadTable = [], t[e].overloadTable[l.argCount] = l;
|
|
789
|
+
}
|
|
790
|
+
}, Xt = (t, e, s) => {
|
|
791
|
+
n.hasOwnProperty(t) ? ((s === void 0 || n[t].overloadTable !== void 0 && n[t].overloadTable[s] !== void 0) && nt(`Cannot register public name '${t}' twice`), Ve(n, t, t), n[t].overloadTable.hasOwnProperty(s) && nt(`Cannot register multiple overloads of a function with the same number of arguments (${s})!`), n[t].overloadTable[s] = e) : (n[t] = e, n[t].argCount = s);
|
|
792
|
+
}, In = 48, An = 57, kn = (t) => {
|
|
793
|
+
t = t.replace(/[^a-zA-Z0-9_]/g, "$");
|
|
794
|
+
var e = t.charCodeAt(0);
|
|
795
|
+
return e >= In && e <= An ? `_${t}` : t;
|
|
796
|
+
};
|
|
797
|
+
function En(t, e, s, l, p, _, $, A) {
|
|
798
|
+
this.name = t, this.constructor = e, this.instancePrototype = s, this.rawDestructor = l, this.baseClass = p, this.getActualType = _, this.upcast = $, this.downcast = A, this.pureVirtualFunctions = [];
|
|
799
|
+
}
|
|
800
|
+
var me = (t, e, s) => {
|
|
801
|
+
for (; e !== s; )
|
|
802
|
+
e.upcast || nt(`Expected null or instance of ${s.name}, got an instance of ${e.name}`), t = e.upcast(t), e = e.baseClass;
|
|
803
|
+
return t;
|
|
804
|
+
}, ve = (t) => {
|
|
805
|
+
if (t === null)
|
|
806
|
+
return "null";
|
|
807
|
+
var e = typeof t;
|
|
808
|
+
return e === "object" || e === "array" || e === "function" ? t.toString() : "" + t;
|
|
809
|
+
};
|
|
810
|
+
function Rn(t, e) {
|
|
811
|
+
if (e === null)
|
|
812
|
+
return this.isReference && nt(`null is not a valid ${this.name}`), 0;
|
|
813
|
+
e.$$ || nt(`Cannot pass "${ve(e)}" as a ${this.name}`), e.$$.ptr || nt(`Cannot pass deleted object as a pointer of type ${this.name}`);
|
|
814
|
+
var s = e.$$.ptrType.registeredClass, l = me(e.$$.ptr, s, this.registeredClass);
|
|
815
|
+
return l;
|
|
816
|
+
}
|
|
817
|
+
function Wn(t, e) {
|
|
818
|
+
var s;
|
|
819
|
+
if (e === null)
|
|
820
|
+
return this.isReference && nt(`null is not a valid ${this.name}`), this.isSmartPointer ? (s = this.rawConstructor(), t !== null && t.push(this.rawDestructor, s), s) : 0;
|
|
821
|
+
(!e || !e.$$) && nt(`Cannot pass "${ve(e)}" as a ${this.name}`), e.$$.ptr || nt(`Cannot pass deleted object as a pointer of type ${this.name}`), !this.isConst && e.$$.ptrType.isConst && nt(`Cannot convert argument of type ${e.$$.smartPtrType ? e.$$.smartPtrType.name : e.$$.ptrType.name} to parameter type ${this.name}`);
|
|
822
|
+
var l = e.$$.ptrType.registeredClass;
|
|
823
|
+
if (s = me(e.$$.ptr, l, this.registeredClass), this.isSmartPointer)
|
|
824
|
+
switch (e.$$.smartPtr === void 0 && nt("Passing raw pointer to smart pointer is illegal"), this.sharingPolicy) {
|
|
825
|
+
case 0:
|
|
826
|
+
e.$$.smartPtrType === this ? s = e.$$.smartPtr : nt(`Cannot convert argument of type ${e.$$.smartPtrType ? e.$$.smartPtrType.name : e.$$.ptrType.name} to parameter type ${this.name}`);
|
|
827
|
+
break;
|
|
828
|
+
case 1:
|
|
829
|
+
s = e.$$.smartPtr;
|
|
830
|
+
break;
|
|
831
|
+
case 2:
|
|
832
|
+
if (e.$$.smartPtrType === this)
|
|
833
|
+
s = e.$$.smartPtr;
|
|
834
|
+
else {
|
|
835
|
+
var p = e.clone();
|
|
836
|
+
s = this.rawShare(s, ht.toHandle(() => p.delete())), t !== null && t.push(this.rawDestructor, s);
|
|
837
|
+
}
|
|
838
|
+
break;
|
|
839
|
+
default:
|
|
840
|
+
nt("Unsupported sharing policy");
|
|
841
|
+
}
|
|
842
|
+
return s;
|
|
843
|
+
}
|
|
844
|
+
function zn(t, e) {
|
|
845
|
+
if (e === null)
|
|
846
|
+
return this.isReference && nt(`null is not a valid ${this.name}`), 0;
|
|
847
|
+
e.$$ || nt(`Cannot pass "${ve(e)}" as a ${this.name}`), e.$$.ptr || nt(`Cannot pass deleted object as a pointer of type ${this.name}`), e.$$.ptrType.isConst && nt(`Cannot convert argument of type ${e.$$.ptrType.name} to parameter type ${this.name}`);
|
|
848
|
+
var s = e.$$.ptrType.registeredClass, l = me(e.$$.ptr, s, this.registeredClass);
|
|
849
|
+
return l;
|
|
850
|
+
}
|
|
851
|
+
var Be = (t, e, s) => {
|
|
852
|
+
if (e === s)
|
|
853
|
+
return t;
|
|
854
|
+
if (s.baseClass === void 0)
|
|
855
|
+
return null;
|
|
856
|
+
var l = Be(t, e, s.baseClass);
|
|
857
|
+
return l === null ? null : s.downcast(l);
|
|
858
|
+
}, Vn = {}, Bn = (t, e) => {
|
|
859
|
+
for (e === void 0 && nt("ptr should not be undefined"); t.baseClass; )
|
|
860
|
+
e = t.upcast(e), t = t.baseClass;
|
|
861
|
+
return e;
|
|
862
|
+
}, On = (t, e) => (e = Bn(t, e), Vn[e]), oe = (t, e) => {
|
|
863
|
+
(!e.ptrType || !e.ptr) && ee("makeClassHandle requires ptr and ptrType");
|
|
864
|
+
var s = !!e.smartPtrType, l = !!e.smartPtr;
|
|
865
|
+
return s !== l && ee("Both smartPtrType and smartPtr must be specified"), e.count = { value: 1 }, Kt(Object.create(t, { $$: { value: e, writable: !0 } }));
|
|
866
|
+
};
|
|
867
|
+
function jn(t) {
|
|
868
|
+
var e = this.getPointee(t);
|
|
869
|
+
if (!e)
|
|
870
|
+
return this.destructor(t), null;
|
|
871
|
+
var s = On(this.registeredClass, e);
|
|
872
|
+
if (s !== void 0) {
|
|
873
|
+
if (s.$$.count.value === 0)
|
|
874
|
+
return s.$$.ptr = e, s.$$.smartPtr = t, s.clone();
|
|
875
|
+
var l = s.clone();
|
|
876
|
+
return this.destructor(t), l;
|
|
877
|
+
}
|
|
878
|
+
function p() {
|
|
879
|
+
return this.isSmartPointer ? oe(this.registeredClass.instancePrototype, { ptrType: this.pointeeType, ptr: e, smartPtrType: this, smartPtr: t }) : oe(this.registeredClass.instancePrototype, { ptrType: this, ptr: t });
|
|
880
|
+
}
|
|
881
|
+
var _ = this.registeredClass.getActualType(e), $ = ze[_];
|
|
882
|
+
if (!$)
|
|
883
|
+
return p.call(this);
|
|
884
|
+
var A;
|
|
885
|
+
this.isConst ? A = $.constPointerType : A = $.pointerType;
|
|
886
|
+
var V = Be(e, this.registeredClass, A.registeredClass);
|
|
887
|
+
return V === null ? p.call(this) : this.isSmartPointer ? oe(A.registeredClass.instancePrototype, { ptrType: A, ptr: V, smartPtrType: this, smartPtr: t }) : oe(A.registeredClass.instancePrototype, { ptrType: A, ptr: V });
|
|
888
|
+
}
|
|
889
|
+
var Dn = () => {
|
|
890
|
+
Object.assign(se.prototype, { getPointee(t) {
|
|
891
|
+
return this.rawGetPointee && (t = this.rawGetPointee(t)), t;
|
|
892
|
+
}, destructor(t) {
|
|
893
|
+
this.rawDestructor?.(t);
|
|
894
|
+
}, readValueFromPointer: Jt, fromWireType: jn });
|
|
895
|
+
};
|
|
896
|
+
function se(t, e, s, l, p, _, $, A, V, N, q) {
|
|
897
|
+
this.name = t, this.registeredClass = e, this.isReference = s, this.isConst = l, this.isSmartPointer = p, this.pointeeType = _, this.sharingPolicy = $, this.rawGetPointee = A, this.rawConstructor = V, this.rawShare = N, this.rawDestructor = q, !p && e.baseClass === void 0 ? l ? (this.toWireType = Rn, this.destructorFunction = null) : (this.toWireType = zn, this.destructorFunction = null) : this.toWireType = Wn;
|
|
898
|
+
}
|
|
899
|
+
var Oe = (t, e, s) => {
|
|
900
|
+
n.hasOwnProperty(t) || ee("Replacing nonexistent public symbol"), n[t].overloadTable !== void 0 && s !== void 0 ? n[t].overloadTable[s] = e : (n[t] = e, n[t].argCount = s);
|
|
901
|
+
}, ie = (t) => Yt.get(t), Un = (t, e, s = [], l = !1) => {
|
|
902
|
+
var p = ie(e), _ = p(...s);
|
|
903
|
+
function $(A) {
|
|
904
|
+
return t[0] == "p" ? A >>> 0 : A;
|
|
905
|
+
}
|
|
906
|
+
return $(_);
|
|
907
|
+
}, Nn = (t, e, s = !1) => (...l) => Un(t, e, l, s), wt = (t, e, s = !1) => {
|
|
908
|
+
t = lt(t);
|
|
909
|
+
function l() {
|
|
910
|
+
if (t.includes("p"))
|
|
911
|
+
return Nn(t, e, s);
|
|
912
|
+
var _ = ie(e);
|
|
913
|
+
return _;
|
|
914
|
+
}
|
|
915
|
+
var p = l();
|
|
916
|
+
return typeof p != "function" && nt(`unknown function pointer with signature ${t}: ${e}`), p;
|
|
917
|
+
};
|
|
918
|
+
class Hn extends Error {
|
|
919
|
+
}
|
|
920
|
+
var je = (t) => {
|
|
921
|
+
var e = Ze(t), s = lt(e);
|
|
922
|
+
return At(e), s;
|
|
923
|
+
}, ae = (t, e) => {
|
|
924
|
+
var s = [], l = {};
|
|
925
|
+
function p(_) {
|
|
926
|
+
if (!l[_] && !Rt[_]) {
|
|
927
|
+
if (te[_]) {
|
|
928
|
+
te[_].forEach(p);
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
s.push(_), l[_] = !0;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
throw e.forEach(p), new Hn(`${t}: ` + s.map(je).join([", "]));
|
|
935
|
+
};
|
|
936
|
+
function Ln(t, e, s, l, p, _, $, A, V, N, q, Q, et) {
|
|
937
|
+
t >>>= 0, e >>>= 0, s >>>= 0, l >>>= 0, p >>>= 0, _ >>>= 0, $ >>>= 0, A >>>= 0, V >>>= 0, N >>>= 0, q >>>= 0, Q >>>= 0, et >>>= 0, q = lt(q), _ = wt(p, _), A &&= wt($, A), N &&= wt(V, N), et = wt(Q, et);
|
|
938
|
+
var tt = kn(q);
|
|
939
|
+
Xt(tt, function() {
|
|
940
|
+
ae(`Cannot construct ${q} due to unbound types`, [l]);
|
|
941
|
+
}), It([t, e, s], l ? [l] : [], (st) => {
|
|
942
|
+
st = st[0];
|
|
943
|
+
var pt, gt;
|
|
944
|
+
l ? (pt = st.registeredClass, gt = pt.instancePrototype) : gt = ne.prototype;
|
|
945
|
+
var u = re(q, function(...ot) {
|
|
946
|
+
if (Object.getPrototypeOf(this) !== h)
|
|
947
|
+
throw new Gt(`Use 'new' to construct ${q}`);
|
|
948
|
+
if (C.constructor_body === void 0)
|
|
949
|
+
throw new Gt(`${q} has no accessible constructor`);
|
|
950
|
+
var yt = C.constructor_body[ot.length];
|
|
951
|
+
if (yt === void 0)
|
|
952
|
+
throw new Gt(`Tried to invoke ctor of ${q} with invalid number of parameters (${ot.length}) - expected (${Object.keys(C.constructor_body).toString()}) parameters instead!`);
|
|
953
|
+
return yt.apply(this, ot);
|
|
954
|
+
}), h = Object.create(gt, { constructor: { value: u } });
|
|
955
|
+
u.prototype = h;
|
|
956
|
+
var C = new En(q, u, h, et, pt, _, A, N);
|
|
957
|
+
C.baseClass && (C.baseClass.__derivedClasses ??= [], C.baseClass.__derivedClasses.push(C));
|
|
958
|
+
var W = new se(q, C, !0, !1, !1), K = new se(q + "*", C, !1, !1, !1), Z = new se(q + " const*", C, !1, !0, !1);
|
|
959
|
+
return ze[t] = { pointerType: K, constPointerType: Z }, Oe(tt, u), [W, K, Z];
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
var ge = (t, e) => {
|
|
963
|
+
for (var s = [], l = 0; l < t; l++)
|
|
964
|
+
s.push(R[e + l * 4 >>> 2 >>> 0]);
|
|
965
|
+
return s;
|
|
966
|
+
};
|
|
967
|
+
function De(t) {
|
|
968
|
+
for (var e = 1; e < t.length; ++e)
|
|
969
|
+
if (t[e] !== null && t[e].destructorFunction === void 0)
|
|
970
|
+
return !0;
|
|
971
|
+
return !1;
|
|
972
|
+
}
|
|
973
|
+
function qn(t, e, s, l) {
|
|
974
|
+
var p = De(t), _ = t.length - 2, $ = [], A = ["fn"];
|
|
975
|
+
e && A.push("thisWired");
|
|
976
|
+
for (var V = 0; V < _; ++V)
|
|
977
|
+
$.push(`arg${V}`), A.push(`arg${V}Wired`);
|
|
978
|
+
$ = $.join(","), A = A.join(",");
|
|
979
|
+
var N = `return function (${$}) {
|
|
980
|
+
`;
|
|
981
|
+
p && (N += `var destructors = [];
|
|
982
|
+
`);
|
|
983
|
+
var q = p ? "destructors" : "null", Q = ["humanName", "throwBindingError", "invoker", "fn", "runDestructors", "fromRetWire", "toClassParamWire"];
|
|
984
|
+
e && (N += `var thisWired = toClassParamWire(${q}, this);
|
|
985
|
+
`);
|
|
986
|
+
for (var V = 0; V < _; ++V) {
|
|
987
|
+
var et = `toArg${V}Wire`;
|
|
988
|
+
N += `var arg${V}Wired = ${et}(${q}, arg${V});
|
|
989
|
+
`, Q.push(et);
|
|
990
|
+
}
|
|
991
|
+
if (N += (s || l ? "var rv = " : "") + `invoker(${A});
|
|
992
|
+
`, p)
|
|
993
|
+
N += `runDestructors(destructors);
|
|
994
|
+
`;
|
|
995
|
+
else
|
|
996
|
+
for (var V = e ? 1 : 2; V < t.length; ++V) {
|
|
997
|
+
var tt = V === 1 ? "thisWired" : "arg" + (V - 2) + "Wired";
|
|
998
|
+
t[V].destructorFunction !== null && (N += `${tt}_dtor(${tt});
|
|
999
|
+
`, Q.push(`${tt}_dtor`));
|
|
1000
|
+
}
|
|
1001
|
+
return s && (N += `var ret = fromRetWire(rv);
|
|
1002
|
+
return ret;
|
|
1003
|
+
`), N += `}
|
|
1004
|
+
`, new Function(Q, N);
|
|
1005
|
+
}
|
|
1006
|
+
function be(t, e, s, l, p, _) {
|
|
1007
|
+
var $ = e.length;
|
|
1008
|
+
$ < 2 && nt("argTypes array size mismatch! Must at least get return value and 'this' types!");
|
|
1009
|
+
for (var A = e[1] !== null && s !== null, V = De(e), N = !e[0].isVoid, q = e[0], Q = e[1], et = [t, nt, l, p, he, q.fromWireType.bind(q), Q?.toWireType.bind(Q)], tt = 2; tt < $; ++tt) {
|
|
1010
|
+
var st = e[tt];
|
|
1011
|
+
et.push(st.toWireType.bind(st));
|
|
1012
|
+
}
|
|
1013
|
+
if (!V)
|
|
1014
|
+
for (var tt = A ? 1 : 2; tt < e.length; ++tt)
|
|
1015
|
+
e[tt].destructorFunction !== null && et.push(e[tt].destructorFunction);
|
|
1016
|
+
var gt = qn(e, A, N, _)(...et);
|
|
1017
|
+
return re(t, gt);
|
|
1018
|
+
}
|
|
1019
|
+
var Jn = function(t, e, s, l, p, _) {
|
|
1020
|
+
t >>>= 0, s >>>= 0, l >>>= 0, p >>>= 0, _ >>>= 0;
|
|
1021
|
+
var $ = ge(e, s);
|
|
1022
|
+
p = wt(l, p), It([], [t], (A) => {
|
|
1023
|
+
A = A[0];
|
|
1024
|
+
var V = `constructor ${A.name}`;
|
|
1025
|
+
if (A.registeredClass.constructor_body === void 0 && (A.registeredClass.constructor_body = []), A.registeredClass.constructor_body[e - 1] !== void 0)
|
|
1026
|
+
throw new Gt(`Cannot register multiple constructors with identical number of parameters (${e - 1}) for class '${A.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);
|
|
1027
|
+
return A.registeredClass.constructor_body[e - 1] = () => {
|
|
1028
|
+
ae(`Cannot construct ${A.name} due to unbound types`, $);
|
|
1029
|
+
}, It([], $, (N) => (N.splice(1, 0, null), A.registeredClass.constructor_body[e - 1] = be(V, N, null, p, _), [])), [];
|
|
1030
|
+
});
|
|
1031
|
+
}, Ue = (t) => {
|
|
1032
|
+
t = t.trim();
|
|
1033
|
+
const e = t.indexOf("(");
|
|
1034
|
+
return e === -1 ? t : t.slice(0, e);
|
|
1035
|
+
}, Gn = function(t, e, s, l, p, _, $, A, V, N) {
|
|
1036
|
+
t >>>= 0, e >>>= 0, l >>>= 0, p >>>= 0, _ >>>= 0, $ >>>= 0;
|
|
1037
|
+
var q = ge(s, l);
|
|
1038
|
+
e = lt(e), e = Ue(e), _ = wt(p, _, V), It([], [t], (Q) => {
|
|
1039
|
+
Q = Q[0];
|
|
1040
|
+
var et = `${Q.name}.${e}`;
|
|
1041
|
+
e.startsWith("@@") && (e = Symbol[e.substring(2)]), A && Q.registeredClass.pureVirtualFunctions.push(e);
|
|
1042
|
+
function tt() {
|
|
1043
|
+
ae(`Cannot call ${et} due to unbound types`, q);
|
|
1044
|
+
}
|
|
1045
|
+
var st = Q.registeredClass.instancePrototype, pt = st[e];
|
|
1046
|
+
return pt === void 0 || pt.overloadTable === void 0 && pt.className !== Q.name && pt.argCount === s - 2 ? (tt.argCount = s - 2, tt.className = Q.name, st[e] = tt) : (Ve(st, e, et), st[e].overloadTable[s - 2] = tt), It([], q, (gt) => {
|
|
1047
|
+
var u = be(et, gt, Q, _, $, V);
|
|
1048
|
+
return st[e].overloadTable === void 0 ? (u.argCount = s - 2, st[e] = u) : st[e].overloadTable[s - 2] = u, [];
|
|
1049
|
+
}), [];
|
|
1050
|
+
});
|
|
1051
|
+
}, Ne = [], Wt = [0, 1, , 1, null, 1, !0, 1, !1, 1];
|
|
1052
|
+
function xe(t) {
|
|
1053
|
+
t >>>= 0, t > 9 && --Wt[t + 1] === 0 && (Wt[t] = void 0, Ne.push(t));
|
|
1054
|
+
}
|
|
1055
|
+
var ht = { toValue: (t) => (t || nt(`Cannot use deleted val. handle = ${t}`), Wt[t]), toHandle: (t) => {
|
|
1056
|
+
switch (t) {
|
|
1057
|
+
case void 0:
|
|
1058
|
+
return 2;
|
|
1059
|
+
case null:
|
|
1060
|
+
return 4;
|
|
1061
|
+
case !0:
|
|
1062
|
+
return 6;
|
|
1063
|
+
case !1:
|
|
1064
|
+
return 8;
|
|
1065
|
+
default: {
|
|
1066
|
+
const e = Ne.pop() || Wt.length;
|
|
1067
|
+
return Wt[e] = t, Wt[e + 1] = 1, e;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
} }, He = { name: "emscripten::val", fromWireType: (t) => {
|
|
1071
|
+
var e = ht.toValue(t);
|
|
1072
|
+
return xe(t), e;
|
|
1073
|
+
}, toWireType: (t, e) => ht.toHandle(e), readValueFromPointer: Jt, destructorFunction: null };
|
|
1074
|
+
function Kn(t) {
|
|
1075
|
+
return t >>>= 0, vt(t, He);
|
|
1076
|
+
}
|
|
1077
|
+
var _e = (t, e, s) => {
|
|
1078
|
+
switch (e) {
|
|
1079
|
+
case 1:
|
|
1080
|
+
return s ? function(l) {
|
|
1081
|
+
return this.fromWireType(z[l >>> 0]);
|
|
1082
|
+
} : function(l) {
|
|
1083
|
+
return this.fromWireType(T[l >>> 0]);
|
|
1084
|
+
};
|
|
1085
|
+
case 2:
|
|
1086
|
+
return s ? function(l) {
|
|
1087
|
+
return this.fromWireType(S[l >>> 1 >>> 0]);
|
|
1088
|
+
} : function(l) {
|
|
1089
|
+
return this.fromWireType(w[l >>> 1 >>> 0]);
|
|
1090
|
+
};
|
|
1091
|
+
case 4:
|
|
1092
|
+
return s ? function(l) {
|
|
1093
|
+
return this.fromWireType(B[l >>> 2 >>> 0]);
|
|
1094
|
+
} : function(l) {
|
|
1095
|
+
return this.fromWireType(R[l >>> 2 >>> 0]);
|
|
1096
|
+
};
|
|
1097
|
+
default:
|
|
1098
|
+
throw new TypeError(`invalid integer width (${e}): ${t}`);
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
|
+
function Xn(t) {
|
|
1102
|
+
return t === 0 ? "object" : t === 1 ? "number" : "string";
|
|
1103
|
+
}
|
|
1104
|
+
function Yn(t, e, s, l, p) {
|
|
1105
|
+
t >>>= 0, e >>>= 0, s >>>= 0, e = lt(e);
|
|
1106
|
+
const _ = Xn(p);
|
|
1107
|
+
switch (_) {
|
|
1108
|
+
case "object": {
|
|
1109
|
+
let N = function() {
|
|
1110
|
+
};
|
|
1111
|
+
N.values = {}, vt(t, { name: e, constructor: N, valueType: _, fromWireType: function(q) {
|
|
1112
|
+
return this.constructor.values[q];
|
|
1113
|
+
}, toWireType: (q, Q) => Q.value, readValueFromPointer: _e(e, s, l), destructorFunction: null }), Xt(e, N);
|
|
1114
|
+
break;
|
|
1115
|
+
}
|
|
1116
|
+
case "number": {
|
|
1117
|
+
var $ = {};
|
|
1118
|
+
vt(t, { name: e, keysMap: $, valueType: _, fromWireType: (N) => N, toWireType: (N, q) => q, readValueFromPointer: _e(e, s, l), destructorFunction: null }), Xt(e, $), delete n[e].argCount;
|
|
1119
|
+
break;
|
|
1120
|
+
}
|
|
1121
|
+
case "string": {
|
|
1122
|
+
var A = {}, V = {}, $ = {};
|
|
1123
|
+
vt(t, { name: e, valuesMap: A, reverseMap: V, keysMap: $, valueType: _, fromWireType: function(q) {
|
|
1124
|
+
return this.reverseMap[q];
|
|
1125
|
+
}, toWireType: function(q, Q) {
|
|
1126
|
+
return this.valuesMap[Q];
|
|
1127
|
+
}, readValueFromPointer: _e(e, s, l), destructorFunction: null }), Xt(e, $), delete n[e].argCount;
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
var Le = (t, e) => {
|
|
1133
|
+
var s = Rt[t];
|
|
1134
|
+
return s === void 0 && nt(`${e} has unknown type ${je(t)}`), s;
|
|
1135
|
+
};
|
|
1136
|
+
function Zn(t, e, s) {
|
|
1137
|
+
t >>>= 0, e >>>= 0;
|
|
1138
|
+
var l = Le(t, "enum");
|
|
1139
|
+
switch (e = lt(e), l.valueType) {
|
|
1140
|
+
case "object": {
|
|
1141
|
+
var p = l.constructor, _ = Object.create(l.constructor.prototype, { value: { value: s }, constructor: { value: re(`${l.name}_${e}`, function() {
|
|
1142
|
+
}) } });
|
|
1143
|
+
p.values[s] = _, p[e] = _;
|
|
1144
|
+
break;
|
|
1145
|
+
}
|
|
1146
|
+
case "number": {
|
|
1147
|
+
l.keysMap[e] = s;
|
|
1148
|
+
break;
|
|
1149
|
+
}
|
|
1150
|
+
case "string": {
|
|
1151
|
+
l.valuesMap[e] = s, l.reverseMap[s] = e, l.keysMap[e] = e;
|
|
1152
|
+
break;
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
var Qn = (t, e) => {
|
|
1157
|
+
switch (e) {
|
|
1158
|
+
case 4:
|
|
1159
|
+
return function(s) {
|
|
1160
|
+
return this.fromWireType(j[s >>> 2 >>> 0]);
|
|
1161
|
+
};
|
|
1162
|
+
case 8:
|
|
1163
|
+
return function(s) {
|
|
1164
|
+
return this.fromWireType(O[s >>> 3 >>> 0]);
|
|
1165
|
+
};
|
|
1166
|
+
default:
|
|
1167
|
+
throw new TypeError(`invalid float width (${e}): ${t}`);
|
|
1168
|
+
}
|
|
1169
|
+
}, tr = function(t, e, s) {
|
|
1170
|
+
t >>>= 0, e >>>= 0, s >>>= 0, e = lt(e), vt(t, { name: e, fromWireType: (l) => l, toWireType: (l, p) => p, readValueFromPointer: Qn(e, s), destructorFunction: null });
|
|
1171
|
+
};
|
|
1172
|
+
function er(t, e, s, l, p, _, $, A) {
|
|
1173
|
+
t >>>= 0, s >>>= 0, l >>>= 0, p >>>= 0, _ >>>= 0;
|
|
1174
|
+
var V = ge(e, s);
|
|
1175
|
+
t = lt(t), t = Ue(t), p = wt(l, p, $), Xt(t, function() {
|
|
1176
|
+
ae(`Cannot call ${t} due to unbound types`, V);
|
|
1177
|
+
}, e - 1), It([], V, (N) => {
|
|
1178
|
+
var q = [N[0], null].concat(N.slice(1));
|
|
1179
|
+
return Oe(t, be(t, q, null, p, _, $), e - 1), [];
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1182
|
+
var nr = function(t, e, s, l, p) {
|
|
1183
|
+
t >>>= 0, e >>>= 0, s >>>= 0, e = lt(e);
|
|
1184
|
+
const _ = l === 0;
|
|
1185
|
+
let $ = (V) => V;
|
|
1186
|
+
if (_) {
|
|
1187
|
+
var A = 32 - 8 * s;
|
|
1188
|
+
$ = (V) => V << A >>> A, p = $(p);
|
|
1189
|
+
}
|
|
1190
|
+
vt(t, { name: e, fromWireType: $, toWireType: (V, N) => N, readValueFromPointer: Ee(e, s, l !== 0), destructorFunction: null });
|
|
1191
|
+
}, rr = (t, e, s) => {
|
|
1192
|
+
const l = (p, _) => {
|
|
1193
|
+
let $ = 0;
|
|
1194
|
+
return { next() {
|
|
1195
|
+
if ($ >= p)
|
|
1196
|
+
return { done: !0 };
|
|
1197
|
+
const A = $;
|
|
1198
|
+
return $++, { value: _(A), done: !1 };
|
|
1199
|
+
}, [Symbol.iterator]() {
|
|
1200
|
+
return this;
|
|
1201
|
+
} };
|
|
1202
|
+
};
|
|
1203
|
+
t[Symbol.iterator] || (t[Symbol.iterator] = function() {
|
|
1204
|
+
const p = this[e]();
|
|
1205
|
+
return l(p, (_) => this[s](_));
|
|
1206
|
+
});
|
|
1207
|
+
}, or = function(t, e, s, l) {
|
|
1208
|
+
t >>>= 0, e >>>= 0, s >>>= 0, l >>>= 0, s = lt(s), l = lt(l), It([], [t, e], (p) => {
|
|
1209
|
+
const _ = p[0];
|
|
1210
|
+
return rr(_.registeredClass.instancePrototype, s, l), [];
|
|
1211
|
+
});
|
|
1212
|
+
};
|
|
1213
|
+
function sr(t, e, s) {
|
|
1214
|
+
t >>>= 0, s >>>= 0;
|
|
1215
|
+
var l = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, BigInt64Array, BigUint64Array], p = l[e];
|
|
1216
|
+
function _($) {
|
|
1217
|
+
var A = R[$ >>> 2 >>> 0], V = R[$ + 4 >>> 2 >>> 0];
|
|
1218
|
+
return new p(z.buffer, V, A);
|
|
1219
|
+
}
|
|
1220
|
+
s = lt(s), vt(t, { name: s, fromWireType: _, readValueFromPointer: _ }, { ignoreDuplicateRegistrations: !0 });
|
|
1221
|
+
}
|
|
1222
|
+
var ir = Object.assign({ optional: !0 }, He);
|
|
1223
|
+
function ar(t, e) {
|
|
1224
|
+
t >>>= 0, vt(t, ir);
|
|
1225
|
+
}
|
|
1226
|
+
var cr = (t, e, s, l) => {
|
|
1227
|
+
if (s >>>= 0, !(l > 0)) return 0;
|
|
1228
|
+
for (var p = s, _ = s + l - 1, $ = 0; $ < t.length; ++$) {
|
|
1229
|
+
var A = t.codePointAt($);
|
|
1230
|
+
if (A <= 127) {
|
|
1231
|
+
if (s >= _) break;
|
|
1232
|
+
e[s++ >>> 0] = A;
|
|
1233
|
+
} else if (A <= 2047) {
|
|
1234
|
+
if (s + 1 >= _) break;
|
|
1235
|
+
e[s++ >>> 0] = 192 | A >> 6, e[s++ >>> 0] = 128 | A & 63;
|
|
1236
|
+
} else if (A <= 65535) {
|
|
1237
|
+
if (s + 2 >= _) break;
|
|
1238
|
+
e[s++ >>> 0] = 224 | A >> 12, e[s++ >>> 0] = 128 | A >> 6 & 63, e[s++ >>> 0] = 128 | A & 63;
|
|
1239
|
+
} else {
|
|
1240
|
+
if (s + 3 >= _) break;
|
|
1241
|
+
e[s++ >>> 0] = 240 | A >> 18, e[s++ >>> 0] = 128 | A >> 12 & 63, e[s++ >>> 0] = 128 | A >> 6 & 63, e[s++ >>> 0] = 128 | A & 63, $++;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
return e[s >>> 0] = 0, s - p;
|
|
1245
|
+
}, lr = (t, e, s) => cr(t, T, e, s), ur = (t) => {
|
|
1246
|
+
for (var e = 0, s = 0; s < t.length; ++s) {
|
|
1247
|
+
var l = t.charCodeAt(s);
|
|
1248
|
+
l <= 127 ? e++ : l <= 2047 ? e += 2 : l >= 55296 && l <= 57343 ? (e += 4, ++s) : e += 3;
|
|
1249
|
+
}
|
|
1250
|
+
return e;
|
|
1251
|
+
}, qe = globalThis.TextDecoder && new TextDecoder(), Je = (t, e, s, l) => {
|
|
1252
|
+
var p = e + s;
|
|
1253
|
+
if (l) return p;
|
|
1254
|
+
for (; t[e] && !(e >= p); ) ++e;
|
|
1255
|
+
return e;
|
|
1256
|
+
}, fr = (t, e = 0, s, l) => {
|
|
1257
|
+
e >>>= 0;
|
|
1258
|
+
var p = Je(t, e, s, l);
|
|
1259
|
+
if (p - e > 16 && t.buffer && qe)
|
|
1260
|
+
return qe.decode(t.subarray(e, p));
|
|
1261
|
+
for (var _ = ""; e < p; ) {
|
|
1262
|
+
var $ = t[e++];
|
|
1263
|
+
if (!($ & 128)) {
|
|
1264
|
+
_ += String.fromCharCode($);
|
|
1265
|
+
continue;
|
|
1266
|
+
}
|
|
1267
|
+
var A = t[e++] & 63;
|
|
1268
|
+
if (($ & 224) == 192) {
|
|
1269
|
+
_ += String.fromCharCode(($ & 31) << 6 | A);
|
|
1270
|
+
continue;
|
|
1271
|
+
}
|
|
1272
|
+
var V = t[e++] & 63;
|
|
1273
|
+
if (($ & 240) == 224 ? $ = ($ & 15) << 12 | A << 6 | V : $ = ($ & 7) << 18 | A << 12 | V << 6 | t[e++] & 63, $ < 65536)
|
|
1274
|
+
_ += String.fromCharCode($);
|
|
1275
|
+
else {
|
|
1276
|
+
var N = $ - 65536;
|
|
1277
|
+
_ += String.fromCharCode(55296 | N >> 10, 56320 | N & 1023);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
return _;
|
|
1281
|
+
}, dr = (t, e, s) => (t >>>= 0, t ? fr(T, t, e, s) : "");
|
|
1282
|
+
function hr(t, e) {
|
|
1283
|
+
t >>>= 0, e >>>= 0, e = lt(e), vt(t, { name: e, fromWireType(s) {
|
|
1284
|
+
var l = R[s >>> 2 >>> 0], p = s + 4, _;
|
|
1285
|
+
return _ = dr(p, l, !0), At(s), _;
|
|
1286
|
+
}, toWireType(s, l) {
|
|
1287
|
+
l instanceof ArrayBuffer && (l = new Uint8Array(l));
|
|
1288
|
+
var p, _ = typeof l == "string";
|
|
1289
|
+
_ || ArrayBuffer.isView(l) && l.BYTES_PER_ELEMENT == 1 || nt("Cannot pass non-string to std::string"), _ ? p = ur(l) : p = l.length;
|
|
1290
|
+
var $ = Pe(4 + p + 1), A = $ + 4;
|
|
1291
|
+
return R[$ >>> 2 >>> 0] = p, _ ? lr(l, A, p + 1) : T.set(l, A >>> 0), s !== null && s.push(At, $), $;
|
|
1292
|
+
}, readValueFromPointer: Jt, destructorFunction(s) {
|
|
1293
|
+
At(s);
|
|
1294
|
+
} });
|
|
1295
|
+
}
|
|
1296
|
+
var Ge = globalThis.TextDecoder ? new TextDecoder("utf-16le") : void 0, pr = (t, e, s) => {
|
|
1297
|
+
var l = t >>> 1, p = Je(w, l, e / 2, s);
|
|
1298
|
+
if (p - l > 16 && Ge) return Ge.decode(w.subarray(l >>> 0, p >>> 0));
|
|
1299
|
+
for (var _ = "", $ = l; $ < p; ++$) {
|
|
1300
|
+
var A = w[$ >>> 0];
|
|
1301
|
+
_ += String.fromCharCode(A);
|
|
1302
|
+
}
|
|
1303
|
+
return _;
|
|
1304
|
+
}, yr = (t, e, s) => {
|
|
1305
|
+
if (s ??= 2147483647, s < 2) return 0;
|
|
1306
|
+
s -= 2;
|
|
1307
|
+
for (var l = e, p = s < t.length * 2 ? s / 2 : t.length, _ = 0; _ < p; ++_) {
|
|
1308
|
+
var $ = t.charCodeAt(_);
|
|
1309
|
+
S[e >>> 1 >>> 0] = $, e += 2;
|
|
1310
|
+
}
|
|
1311
|
+
return S[e >>> 1 >>> 0] = 0, e - l;
|
|
1312
|
+
}, mr = (t) => t.length * 2, vr = (t, e, s) => {
|
|
1313
|
+
for (var l = "", p = t >>> 2, _ = 0; !(_ >= e / 4); _++) {
|
|
1314
|
+
var $ = R[p + _ >>> 0];
|
|
1315
|
+
if (!$ && !s) break;
|
|
1316
|
+
l += String.fromCodePoint($);
|
|
1317
|
+
}
|
|
1318
|
+
return l;
|
|
1319
|
+
}, gr = (t, e, s) => {
|
|
1320
|
+
if (e >>>= 0, s ??= 2147483647, s < 4) return 0;
|
|
1321
|
+
for (var l = e, p = l + s - 4, _ = 0; _ < t.length; ++_) {
|
|
1322
|
+
var $ = t.codePointAt(_);
|
|
1323
|
+
if ($ > 65535 && _++, B[e >>> 2 >>> 0] = $, e += 4, e + 4 > p) break;
|
|
1324
|
+
}
|
|
1325
|
+
return B[e >>> 2 >>> 0] = 0, e - l;
|
|
1326
|
+
}, br = (t) => {
|
|
1327
|
+
for (var e = 0, s = 0; s < t.length; ++s) {
|
|
1328
|
+
var l = t.codePointAt(s);
|
|
1329
|
+
l > 65535 && s++, e += 4;
|
|
1330
|
+
}
|
|
1331
|
+
return e;
|
|
1332
|
+
};
|
|
1333
|
+
function xr(t, e, s) {
|
|
1334
|
+
t >>>= 0, e >>>= 0, s >>>= 0, s = lt(s);
|
|
1335
|
+
var l, p, _;
|
|
1336
|
+
e === 2 ? (l = pr, p = yr, _ = mr) : (l = vr, p = gr, _ = br), vt(t, { name: s, fromWireType: ($) => {
|
|
1337
|
+
var A = R[$ >>> 2 >>> 0], V = l($ + 4, A * e, !0);
|
|
1338
|
+
return At($), V;
|
|
1339
|
+
}, toWireType: ($, A) => {
|
|
1340
|
+
typeof A != "string" && nt(`Cannot pass non-string to C++ string type ${s}`);
|
|
1341
|
+
var V = _(A), N = Pe(4 + V + e);
|
|
1342
|
+
return R[N >>> 2 >>> 0] = V / e, p(A, N + 4, V + e), $ !== null && $.push(At, N), N;
|
|
1343
|
+
}, readValueFromPointer: Jt, destructorFunction($) {
|
|
1344
|
+
At($);
|
|
1345
|
+
} });
|
|
1346
|
+
}
|
|
1347
|
+
function _r(t, e, s, l, p, _) {
|
|
1348
|
+
t >>>= 0, e >>>= 0, s >>>= 0, l >>>= 0, p >>>= 0, _ >>>= 0, Qt[t] = { name: lt(e), rawConstructor: wt(s, l), rawDestructor: wt(p, _), fields: [] };
|
|
1349
|
+
}
|
|
1350
|
+
function Mr(t, e, s, l, p, _, $, A, V, N) {
|
|
1351
|
+
t >>>= 0, e >>>= 0, s >>>= 0, l >>>= 0, p >>>= 0, _ >>>= 0, $ >>>= 0, A >>>= 0, V >>>= 0, N >>>= 0, Qt[t].fields.push({ fieldName: lt(e), getterReturnType: s, getter: wt(l, p), getterContext: _, setterArgumentType: $, setter: wt(A, V), setterContext: N });
|
|
1352
|
+
}
|
|
1353
|
+
var wr = function(t, e) {
|
|
1354
|
+
t >>>= 0, e >>>= 0, e = lt(e), vt(t, { isVoid: !0, name: e, fromWireType: () => {
|
|
1355
|
+
}, toWireType: (s, l) => {
|
|
1356
|
+
} });
|
|
1357
|
+
};
|
|
1358
|
+
function $r(t, e) {
|
|
1359
|
+
t >>>= 0, e >>>= 0, t = ht.toValue(t), e = ht.toValue(e), t.set(e);
|
|
1360
|
+
}
|
|
1361
|
+
var Me = [], Pr = (t) => {
|
|
1362
|
+
var e = Me.length;
|
|
1363
|
+
return Me.push(t), e;
|
|
1364
|
+
}, Cr = (t, e) => {
|
|
1365
|
+
for (var s = new Array(t), l = 0; l < t; ++l)
|
|
1366
|
+
s[l] = Le(R[e + l * 4 >>> 2 >>> 0], `parameter ${l}`);
|
|
1367
|
+
return s;
|
|
1368
|
+
}, Tr = (t, e, s) => {
|
|
1369
|
+
var l = [], p = t(l, s);
|
|
1370
|
+
return l.length && (R[e >>> 2 >>> 0] = ht.toHandle(l)), p;
|
|
1371
|
+
}, Sr = {}, Ke = (t) => {
|
|
1372
|
+
var e = Sr[t];
|
|
1373
|
+
return e === void 0 ? lt(t) : e;
|
|
1374
|
+
}, Fr = function(t, e, s) {
|
|
1375
|
+
e >>>= 0;
|
|
1376
|
+
var l = 8, [p, ..._] = Cr(t, e), $ = p.toWireType.bind(p), A = _.map((tt) => tt.readValueFromPointer.bind(tt));
|
|
1377
|
+
t--;
|
|
1378
|
+
var V = { toValue: ht.toValue }, N = A.map((tt, st) => {
|
|
1379
|
+
var pt = `argFromPtr${st}`;
|
|
1380
|
+
return V[pt] = tt, `${pt}(args${st ? "+" + st * l : ""})`;
|
|
1381
|
+
}), q;
|
|
1382
|
+
switch (s) {
|
|
1383
|
+
case 0:
|
|
1384
|
+
q = "toValue(handle)";
|
|
1385
|
+
break;
|
|
1386
|
+
case 2:
|
|
1387
|
+
q = "new (toValue(handle))";
|
|
1388
|
+
break;
|
|
1389
|
+
case 3:
|
|
1390
|
+
q = "";
|
|
1391
|
+
break;
|
|
1392
|
+
case 1:
|
|
1393
|
+
V.getStringOrSymbol = Ke, q = "toValue(handle)[getStringOrSymbol(methodName)]";
|
|
1394
|
+
break;
|
|
1395
|
+
}
|
|
1396
|
+
q += `(${N})`, p.isVoid || (V.toReturnWire = $, V.emval_returnValue = Tr, q = `return emval_returnValue(toReturnWire, destructorsRef, ${q})`), q = `return function (handle, methodName, destructorsRef, args) {
|
|
1397
|
+
${q}
|
|
1398
|
+
}`;
|
|
1399
|
+
var Q = new Function(Object.keys(V), q)(...Object.values(V)), et = `methodCaller<(${_.map((tt) => tt.name)}) => ${p.name}>`;
|
|
1400
|
+
return Pr(re(et, Q));
|
|
1401
|
+
};
|
|
1402
|
+
function Ir(t, e) {
|
|
1403
|
+
return t >>>= 0, e >>>= 0, t = ht.toValue(t), e = ht.toValue(e), t == e;
|
|
1404
|
+
}
|
|
1405
|
+
function Ar(t, e) {
|
|
1406
|
+
return t >>>= 0, e >>>= 0, t = ht.toValue(t), e = ht.toValue(e), ht.toHandle(t[e]);
|
|
1407
|
+
}
|
|
1408
|
+
function kr(t) {
|
|
1409
|
+
t >>>= 0, t > 9 && (Wt[t + 1] += 1);
|
|
1410
|
+
}
|
|
1411
|
+
function Er(t, e, s, l, p) {
|
|
1412
|
+
return t >>>= 0, e >>>= 0, s >>>= 0, l >>>= 0, p >>>= 0, Me[t](e, s, l, p);
|
|
1413
|
+
}
|
|
1414
|
+
function Rr(t) {
|
|
1415
|
+
return t >>>= 0, ht.toHandle(Ke(t));
|
|
1416
|
+
}
|
|
1417
|
+
function Wr() {
|
|
1418
|
+
return ht.toHandle({});
|
|
1419
|
+
}
|
|
1420
|
+
function zr(t) {
|
|
1421
|
+
t >>>= 0;
|
|
1422
|
+
var e = ht.toValue(t);
|
|
1423
|
+
he(e), xe(t);
|
|
1424
|
+
}
|
|
1425
|
+
function Vr(t, e, s) {
|
|
1426
|
+
t >>>= 0, e >>>= 0, s >>>= 0, t = ht.toValue(t), e = ht.toValue(e), s = ht.toValue(s), t[e] = s;
|
|
1427
|
+
}
|
|
1428
|
+
var Br = () => 4294901760, Or = (t, e) => Math.ceil(t / e) * e, jr = (t) => {
|
|
1429
|
+
var e = ce.buffer.byteLength, s = (t - e + 65535) / 65536 | 0;
|
|
1430
|
+
try {
|
|
1431
|
+
return ce.grow(s), J(), 1;
|
|
1432
|
+
} catch {
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
function Dr(t) {
|
|
1436
|
+
t >>>= 0;
|
|
1437
|
+
var e = T.length, s = Br();
|
|
1438
|
+
if (t > s)
|
|
1439
|
+
return !1;
|
|
1440
|
+
for (var l = 1; l <= 4; l *= 2) {
|
|
1441
|
+
var p = e * (1 + 0.2 / l);
|
|
1442
|
+
p = Math.min(p, t + 100663296);
|
|
1443
|
+
var _ = Math.min(s, Or(Math.max(t, p), 65536)), $ = jr(_);
|
|
1444
|
+
if ($)
|
|
1445
|
+
return !0;
|
|
1446
|
+
}
|
|
1447
|
+
return !1;
|
|
1448
|
+
}
|
|
1449
|
+
var Ur = (t, e) => {
|
|
1450
|
+
if (zt)
|
|
1451
|
+
for (var s = t; s < t + e; s++) {
|
|
1452
|
+
var l = ie(s);
|
|
1453
|
+
l && zt.set(l, s);
|
|
1454
|
+
}
|
|
1455
|
+
}, zt, Nr = (t) => (zt || (zt = /* @__PURE__ */ new WeakMap(), Ur(0, Yt.length)), zt.get(t) || 0), we = [], Hr = () => we.length ? we.pop() : Yt.grow(1), $e = (t, e) => Yt.set(t, e), Xe = (t) => {
|
|
1456
|
+
const e = t.length;
|
|
1457
|
+
return [e % 128 | 128, e >> 7, ...t];
|
|
1458
|
+
}, Lr = { i: 127, p: 127, j: 126, f: 125, d: 124, e: 111 }, Ye = (t) => Xe(Array.from(t, (e) => {
|
|
1459
|
+
var s = Lr[e];
|
|
1460
|
+
return s;
|
|
1461
|
+
})), qr = (t, e) => {
|
|
1462
|
+
var s = Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0, 1, ...Xe([1, 96, ...Ye(e.slice(1)), ...Ye(e[0] === "v" ? "" : e[0])]), 2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0), l = new WebAssembly.Module(s), p = new WebAssembly.Instance(l, { e: { f: t } }), _ = p.exports.f;
|
|
1463
|
+
return _;
|
|
1464
|
+
}, Vt = (t, e) => {
|
|
1465
|
+
var s = Nr(t);
|
|
1466
|
+
if (s)
|
|
1467
|
+
return s;
|
|
1468
|
+
var l = Hr();
|
|
1469
|
+
try {
|
|
1470
|
+
$e(l, t);
|
|
1471
|
+
} catch (_) {
|
|
1472
|
+
if (!(_ instanceof TypeError))
|
|
1473
|
+
throw _;
|
|
1474
|
+
var p = qr(t, e);
|
|
1475
|
+
$e(l, p);
|
|
1476
|
+
}
|
|
1477
|
+
return zt.set(t, l), l;
|
|
1478
|
+
}, Bt = (t) => {
|
|
1479
|
+
zt.delete(ie(t)), $e(t, null), we.push(t);
|
|
1480
|
+
};
|
|
1481
|
+
if (Fn(), Dn(), n.noExitRuntime && n.noExitRuntime, n.print && n.print, n.printErr && (E = n.printErr), n.wasmBinary && (g = n.wasmBinary), n.arguments && n.arguments, n.thisProgram && n.thisProgram, n.preInit)
|
|
1482
|
+
for (typeof n.preInit == "function" && (n.preInit = [n.preInit]); n.preInit.length > 0; )
|
|
1483
|
+
n.preInit.shift()();
|
|
1484
|
+
n.addFunction = Vt, n.removeFunction = Bt;
|
|
1485
|
+
var Ze, Pe, At, ce, Yt;
|
|
1486
|
+
function Jr(t) {
|
|
1487
|
+
Ze = t.K, Pe = t.M, At = t.N, ce = t.I, Yt = t.L;
|
|
1488
|
+
}
|
|
1489
|
+
var Gr = { l: xn, C: _n, q: wn, z: Pn, G: Cn, j: Ln, i: Jn, a: Gn, E: Kn, x: Yn, d: Zn, y: tr, c: er, p: nr, m: or, h: sr, n: ar, F: hr, w: xr, r: _r, k: Mr, H: wr, u: $r, g: Fr, b: xe, o: Ir, B: Ar, t: kr, f: Er, s: Rr, A: Wr, e: zr, v: Vr, D: Dr };
|
|
1490
|
+
function Kr(t) {
|
|
1491
|
+
t = Object.assign({}, t);
|
|
1492
|
+
var e = (l) => (p) => l(p) >>> 0, s = (l) => () => l() >>> 0;
|
|
1493
|
+
return t.K = e(t.K), t.M = e(t.M), t._emscripten_stack_alloc = e(t._emscripten_stack_alloc), t.emscripten_stack_get_current = s(t.emscripten_stack_get_current), t;
|
|
1494
|
+
}
|
|
1495
|
+
function Xr() {
|
|
1496
|
+
X();
|
|
1497
|
+
function t() {
|
|
1498
|
+
n.calledRun = !0, !P && (rt(), F?.(n), n.onRuntimeInitialized?.(), H());
|
|
1499
|
+
}
|
|
1500
|
+
n.setStatus ? (n.setStatus("Running..."), setTimeout(() => {
|
|
1501
|
+
setTimeout(() => n.setStatus(""), 1), t();
|
|
1502
|
+
}, 1)) : t();
|
|
1503
|
+
}
|
|
1504
|
+
var Ot;
|
|
1505
|
+
return Ot = await Ft(), Xr(), U ? r = n : r = new Promise((t, e) => {
|
|
1506
|
+
F = t, I = e;
|
|
1507
|
+
}), r;
|
|
1508
|
+
}
|
|
1509
|
+
function Zr(o, r) {
|
|
1510
|
+
return o < r ? `${o}_${r}` : `${r}_${o}`;
|
|
1511
|
+
}
|
|
1512
|
+
function $t(o, r) {
|
|
1513
|
+
const n = o.length / 3, i = r.length / 3, c = /* @__PURE__ */ new Map();
|
|
1514
|
+
let a = 0, f = 0, d = 0;
|
|
1515
|
+
const v = [1 / 0, 1 / 0, 1 / 0], y = [-1 / 0, -1 / 0, -1 / 0];
|
|
1516
|
+
for (let M = 0; M < n; M++) {
|
|
1517
|
+
const F = o[M * 3], I = o[M * 3 + 1], z = o[M * 3 + 2];
|
|
1518
|
+
F < v[0] && (v[0] = F), I < v[1] && (v[1] = I), z < v[2] && (v[2] = z), F > y[0] && (y[0] = F), I > y[1] && (y[1] = I), z > y[2] && (y[2] = z);
|
|
1519
|
+
}
|
|
1520
|
+
const m = new Int32Array(n);
|
|
1521
|
+
for (let M = 0; M < n; M++) m[M] = M;
|
|
1522
|
+
const k = (M) => {
|
|
1523
|
+
for (; m[M] !== M; )
|
|
1524
|
+
m[M] = m[m[M]], M = m[M];
|
|
1525
|
+
return M;
|
|
1526
|
+
}, b = (M, F) => {
|
|
1527
|
+
const I = k(M), z = k(F);
|
|
1528
|
+
I !== z && (m[I] = z);
|
|
1529
|
+
};
|
|
1530
|
+
for (let M = 0; M < i; M++) {
|
|
1531
|
+
const F = r[M * 3], I = r[M * 3 + 1], z = r[M * 3 + 2], T = o[F * 3], S = o[F * 3 + 1], w = o[F * 3 + 2], B = o[I * 3], R = o[I * 3 + 1], j = o[I * 3 + 2], O = o[z * 3], D = o[z * 3 + 1], L = o[z * 3 + 2], U = B - T, J = R - S, X = j - w, rt = O - T, H = D - S, G = L - w, Y = J * G - X * H, mt = X * rt - U * G, ft = U * H - J * rt, ut = 0.5 * Math.hypot(Y, mt, ft);
|
|
1532
|
+
ut < 1e-12 && d++, f += ut, a += T * Y + S * mt + w * ft;
|
|
1533
|
+
for (const [Pt, Ct] of [[F, I], [I, z], [z, F]]) {
|
|
1534
|
+
const _t = Zr(Pt, Ct);
|
|
1535
|
+
c.set(_t, (c.get(_t) ?? 0) + 1), b(Pt, Ct);
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
let x = 0, E = 0;
|
|
1539
|
+
for (const M of c.values())
|
|
1540
|
+
M === 1 ? x++ : M > 2 && E++;
|
|
1541
|
+
const g = /* @__PURE__ */ new Set();
|
|
1542
|
+
for (let M = 0; M < n; M++) g.add(k(M));
|
|
1543
|
+
const P = a / 6;
|
|
1544
|
+
return {
|
|
1545
|
+
triangleCount: i,
|
|
1546
|
+
vertexCount: n,
|
|
1547
|
+
openEdgeCount: x,
|
|
1548
|
+
nonManifoldEdgeCount: E,
|
|
1549
|
+
componentCount: Math.max(1, g.size),
|
|
1550
|
+
volume: P,
|
|
1551
|
+
surfaceArea: f,
|
|
1552
|
+
bbox: {
|
|
1553
|
+
min: v,
|
|
1554
|
+
max: y,
|
|
1555
|
+
size: [y[0] - v[0], y[1] - v[1], y[2] - v[2]]
|
|
1556
|
+
},
|
|
1557
|
+
invertedNormals: P < 0,
|
|
1558
|
+
degenerateCount: d
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1561
|
+
function Qr(o, r, n = 200) {
|
|
1562
|
+
const i = r.length / 3;
|
|
1563
|
+
if (i === 0) return 0;
|
|
1564
|
+
const c = Math.max(1, Math.floor(i / n));
|
|
1565
|
+
let a = 1 / 0;
|
|
1566
|
+
const f = [];
|
|
1567
|
+
for (let d = 0; d < i; d += c) {
|
|
1568
|
+
const v = r[d * 3], y = r[d * 3 + 1], m = r[d * 3 + 2], k = o[v * 3], b = o[v * 3 + 1], x = o[v * 3 + 2], E = o[y * 3], g = o[y * 3 + 1], P = o[y * 3 + 2], M = o[m * 3], F = o[m * 3 + 1], I = o[m * 3 + 2], z = (k + E + M) / 3, T = (b + g + F) / 3, S = (x + P + I) / 3, w = (g - b) * (I - x) - (P - x) * (F - b), B = (P - x) * (M - k) - (E - k) * (I - x), R = (E - k) * (F - b) - (g - b) * (M - k), j = Math.hypot(w, B, R) || 1;
|
|
1569
|
+
f.push([z, T, S, -w / j, -B / j, -R / j]);
|
|
1570
|
+
}
|
|
1571
|
+
for (const [d, v, y, m, k, b] of f) {
|
|
1572
|
+
let x = 1 / 0;
|
|
1573
|
+
for (let E = 0; E < i; E += Math.max(1, Math.floor(c / 2))) {
|
|
1574
|
+
const g = r[E * 3], P = r[E * 3 + 1], M = r[E * 3 + 2], F = Ae(
|
|
1575
|
+
d,
|
|
1576
|
+
v,
|
|
1577
|
+
y,
|
|
1578
|
+
m,
|
|
1579
|
+
k,
|
|
1580
|
+
b,
|
|
1581
|
+
o[g * 3],
|
|
1582
|
+
o[g * 3 + 1],
|
|
1583
|
+
o[g * 3 + 2],
|
|
1584
|
+
o[P * 3],
|
|
1585
|
+
o[P * 3 + 1],
|
|
1586
|
+
o[P * 3 + 2],
|
|
1587
|
+
o[M * 3],
|
|
1588
|
+
o[M * 3 + 1],
|
|
1589
|
+
o[M * 3 + 2]
|
|
1590
|
+
);
|
|
1591
|
+
F > 1e-3 && F < x && (x = F);
|
|
1592
|
+
}
|
|
1593
|
+
x < a && (a = x);
|
|
1594
|
+
}
|
|
1595
|
+
return Number.isFinite(a) ? a : 0;
|
|
1596
|
+
}
|
|
1597
|
+
function Ae(o, r, n, i, c, a, f, d, v, y, m, k, b, x, E) {
|
|
1598
|
+
const P = y - f, M = m - d, F = k - v, I = b - f, z = x - d, T = E - v, S = c * T - a * z, w = a * I - i * T, B = i * z - c * I, R = P * S + M * w + F * B;
|
|
1599
|
+
if (Math.abs(R) < 1e-8) return 1 / 0;
|
|
1600
|
+
const j = 1 / R, O = o - f, D = r - d, L = n - v, U = (O * S + D * w + L * B) * j;
|
|
1601
|
+
if (U < 0 || U > 1) return 1 / 0;
|
|
1602
|
+
const J = D * F - L * M, X = L * P - O * F, rt = O * M - D * P, H = (i * J + c * X + a * rt) * j;
|
|
1603
|
+
if (H < 0 || U + H > 1) return 1 / 0;
|
|
1604
|
+
const G = (I * J + z * X + T * rt) * j;
|
|
1605
|
+
return G > 0 ? G : 1 / 0;
|
|
1606
|
+
}
|
|
1607
|
+
function to(o, r, n) {
|
|
1608
|
+
const i = o.length / 3, c = new Float32Array(i * 3), a = r.length / 3, f = Math.min(i, 800), d = Math.max(1, Math.floor(i / f)), v = new Float32Array(i);
|
|
1609
|
+
v.fill(n * 4);
|
|
1610
|
+
for (let y = 0; y < i; y += d) {
|
|
1611
|
+
let m = 0, k = 0, b = 0;
|
|
1612
|
+
for (let I = 0; I < a; I++)
|
|
1613
|
+
if (r[I * 3] === y || r[I * 3 + 1] === y || r[I * 3 + 2] === y) {
|
|
1614
|
+
const z = r[I * 3], T = r[I * 3 + 1], S = r[I * 3 + 2], w = o[z * 3], B = o[z * 3 + 1], R = o[z * 3 + 2], j = o[T * 3], O = o[T * 3 + 1], D = o[T * 3 + 2], L = o[S * 3], U = o[S * 3 + 1], J = o[S * 3 + 2];
|
|
1615
|
+
m += (O - B) * (J - R) - (D - R) * (U - B), k += (D - R) * (L - w) - (j - w) * (J - R), b += (j - w) * (U - B) - (O - B) * (L - w);
|
|
1616
|
+
}
|
|
1617
|
+
const x = Math.hypot(m, k, b) || 1, E = o[y * 3], g = o[y * 3 + 1], P = o[y * 3 + 2];
|
|
1618
|
+
let M = 1 / 0;
|
|
1619
|
+
const F = Math.max(1, Math.floor(a / 120));
|
|
1620
|
+
for (let I = 0; I < a; I += F) {
|
|
1621
|
+
const z = r[I * 3], T = r[I * 3 + 1], S = r[I * 3 + 2], w = Ae(
|
|
1622
|
+
E,
|
|
1623
|
+
g,
|
|
1624
|
+
P,
|
|
1625
|
+
-m / x,
|
|
1626
|
+
-k / x,
|
|
1627
|
+
-b / x,
|
|
1628
|
+
o[z * 3],
|
|
1629
|
+
o[z * 3 + 1],
|
|
1630
|
+
o[z * 3 + 2],
|
|
1631
|
+
o[T * 3],
|
|
1632
|
+
o[T * 3 + 1],
|
|
1633
|
+
o[T * 3 + 2],
|
|
1634
|
+
o[S * 3],
|
|
1635
|
+
o[S * 3 + 1],
|
|
1636
|
+
o[S * 3 + 2]
|
|
1637
|
+
);
|
|
1638
|
+
w > 1e-3 && w < M && (M = w);
|
|
1639
|
+
}
|
|
1640
|
+
v[y] = Number.isFinite(M) ? M : n * 4;
|
|
1641
|
+
}
|
|
1642
|
+
for (let y = 0; y < i; y++) {
|
|
1643
|
+
const m = Math.min(1, v[y] / (n * 3));
|
|
1644
|
+
c[y * 3] = 1 - m, c[y * 3 + 1] = m, c[y * 3 + 2] = 0.15;
|
|
1645
|
+
}
|
|
1646
|
+
return c;
|
|
1647
|
+
}
|
|
1648
|
+
function Qe(o, r, n, i) {
|
|
1649
|
+
o.push(
|
|
1650
|
+
r[n * 3],
|
|
1651
|
+
r[n * 3 + 1],
|
|
1652
|
+
r[n * 3 + 2],
|
|
1653
|
+
r[i * 3],
|
|
1654
|
+
r[i * 3 + 1],
|
|
1655
|
+
r[i * 3 + 2]
|
|
1656
|
+
);
|
|
1657
|
+
}
|
|
1658
|
+
function tn(o, r, n) {
|
|
1659
|
+
return [
|
|
1660
|
+
(o[r * 3] + o[n * 3]) / 2,
|
|
1661
|
+
(o[r * 3 + 1] + o[n * 3 + 1]) / 2,
|
|
1662
|
+
(o[r * 3 + 2] + o[n * 3 + 2]) / 2
|
|
1663
|
+
];
|
|
1664
|
+
}
|
|
1665
|
+
function eo(o, r, n, i) {
|
|
1666
|
+
const c = o.length / 3, a = r.length / 3, f = /* @__PURE__ */ new Map(), d = new Int32Array(c);
|
|
1667
|
+
for (let w = 0; w < c; w++) d[w] = w;
|
|
1668
|
+
const v = (w) => {
|
|
1669
|
+
for (; d[w] !== w; )
|
|
1670
|
+
d[w] = d[d[w]], w = d[w];
|
|
1671
|
+
return w;
|
|
1672
|
+
}, y = (w, B) => {
|
|
1673
|
+
const R = v(w), j = v(B);
|
|
1674
|
+
R !== j && (d[R] = j);
|
|
1675
|
+
};
|
|
1676
|
+
for (let w = 0; w < a; w++) {
|
|
1677
|
+
const B = r[w * 3], R = r[w * 3 + 1], j = r[w * 3 + 2];
|
|
1678
|
+
for (const [O, D] of [[B, R], [R, j], [j, B]]) {
|
|
1679
|
+
const L = O < D ? `${O}_${D}` : `${D}_${O}`, U = f.get(L);
|
|
1680
|
+
U ? U.count++ : f.set(L, { a: O, b: D, count: 1 }), y(O, D);
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
const m = [], k = [];
|
|
1684
|
+
let b, x;
|
|
1685
|
+
for (const w of f.values())
|
|
1686
|
+
w.count === 1 && m.length < 24e3 ? (Qe(m, o, w.a, w.b), b ??= tn(o, w.a, w.b)) : w.count > 2 && k.length < 12e3 && (Qe(k, o, w.a, w.b), x ??= tn(o, w.a, w.b));
|
|
1687
|
+
const E = [];
|
|
1688
|
+
let g;
|
|
1689
|
+
const P = Math.max(1, Math.floor(a / 400));
|
|
1690
|
+
for (let w = 0; w < a && E.length < 9e3; w += P) {
|
|
1691
|
+
const B = r[w * 3], R = r[w * 3 + 1], j = r[w * 3 + 2], O = o[B * 3], D = o[B * 3 + 1], L = o[B * 3 + 2], U = o[R * 3], J = o[R * 3 + 1], X = o[R * 3 + 2], rt = o[j * 3], H = o[j * 3 + 1], G = o[j * 3 + 2], Y = (O + U + rt) / 3, mt = (D + J + H) / 3, ft = (L + X + G) / 3, ut = (J - D) * (G - L) - (X - L) * (H - D), Pt = (X - L) * (rt - O) - (U - O) * (G - L), Ct = (U - O) * (H - D) - (J - D) * (rt - O), _t = Math.hypot(ut, Pt, Ct) || 1;
|
|
1692
|
+
let Ft = 1 / 0;
|
|
1693
|
+
const Mt = Math.max(1, Math.floor(a / 80));
|
|
1694
|
+
for (let xt = 0; xt < a; xt += Mt) {
|
|
1695
|
+
const Lt = r[xt * 3], jt = r[xt * 3 + 1], qt = r[xt * 3 + 2], dt = Ae(
|
|
1696
|
+
Y,
|
|
1697
|
+
mt,
|
|
1698
|
+
ft,
|
|
1699
|
+
-ut / _t,
|
|
1700
|
+
-Pt / _t,
|
|
1701
|
+
-Ct / _t,
|
|
1702
|
+
o[Lt * 3],
|
|
1703
|
+
o[Lt * 3 + 1],
|
|
1704
|
+
o[Lt * 3 + 2],
|
|
1705
|
+
o[jt * 3],
|
|
1706
|
+
o[jt * 3 + 1],
|
|
1707
|
+
o[jt * 3 + 2],
|
|
1708
|
+
o[qt * 3],
|
|
1709
|
+
o[qt * 3 + 1],
|
|
1710
|
+
o[qt * 3 + 2]
|
|
1711
|
+
);
|
|
1712
|
+
dt > 1e-3 && dt < Ft && (Ft = dt);
|
|
1713
|
+
}
|
|
1714
|
+
Ft < n && (E.push(O, D, L, U, J, X, rt, H, G), g ??= [Y, mt, ft]);
|
|
1715
|
+
}
|
|
1716
|
+
const M = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new Map();
|
|
1717
|
+
for (let w = 0; w < c; w++) {
|
|
1718
|
+
const B = v(w);
|
|
1719
|
+
M.set(B, (M.get(B) ?? 0) + 1), F.has(B) || F.set(B, w);
|
|
1720
|
+
}
|
|
1721
|
+
let I = -1, z = -1;
|
|
1722
|
+
for (const [w, B] of M)
|
|
1723
|
+
B > z && (z = B, I = w);
|
|
1724
|
+
const T = [];
|
|
1725
|
+
let S;
|
|
1726
|
+
if (M.size > 1)
|
|
1727
|
+
for (let w = 0; w < a && T.length < 9e3; w++) {
|
|
1728
|
+
const B = r[w * 3];
|
|
1729
|
+
if (v(B) === I) continue;
|
|
1730
|
+
const R = r[w * 3 + 1], j = r[w * 3 + 2];
|
|
1731
|
+
if (T.push(
|
|
1732
|
+
o[B * 3],
|
|
1733
|
+
o[B * 3 + 1],
|
|
1734
|
+
o[B * 3 + 2],
|
|
1735
|
+
o[R * 3],
|
|
1736
|
+
o[R * 3 + 1],
|
|
1737
|
+
o[R * 3 + 2],
|
|
1738
|
+
o[j * 3],
|
|
1739
|
+
o[j * 3 + 1],
|
|
1740
|
+
o[j * 3 + 2]
|
|
1741
|
+
), !S) {
|
|
1742
|
+
const O = F.get(v(B)) ?? B;
|
|
1743
|
+
S = [o[O * 3], o[O * 3 + 1], o[O * 3 + 2]];
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
return {
|
|
1747
|
+
partIndex: i,
|
|
1748
|
+
openEdgePositions: new Float32Array(m),
|
|
1749
|
+
nonManifoldEdgePositions: new Float32Array(k),
|
|
1750
|
+
thinTriPositions: new Float32Array(E),
|
|
1751
|
+
islandTriPositions: new Float32Array(T),
|
|
1752
|
+
focus: {
|
|
1753
|
+
watertight: b,
|
|
1754
|
+
nonmanifold: x,
|
|
1755
|
+
thinwall: g,
|
|
1756
|
+
islands: S,
|
|
1757
|
+
selfintersect: x ?? b,
|
|
1758
|
+
normals: b
|
|
1759
|
+
}
|
|
1760
|
+
};
|
|
1761
|
+
}
|
|
1762
|
+
function ue(o, r, n = 1e-5, i, c) {
|
|
1763
|
+
const a = /* @__PURE__ */ new Map(), f = [], d = [], v = [], y = [], m = 1 / n, k = o.length / 3, b = !1, x = !1;
|
|
1764
|
+
for (let g = 0; g < k; g++) {
|
|
1765
|
+
const P = o[g * 3], M = o[g * 3 + 1], F = o[g * 3 + 2];
|
|
1766
|
+
let I = `${Math.round(P * m)}_${Math.round(M * m)}_${Math.round(F * m)}`, z = a.get(I);
|
|
1767
|
+
z === void 0 && (z = f.length / 3, a.set(I, z), f.push(P, M, F)), y[g] = z;
|
|
1768
|
+
}
|
|
1769
|
+
const E = [];
|
|
1770
|
+
for (let g = 0; g < r.length; g += 3) {
|
|
1771
|
+
const P = y[r[g]], M = y[r[g + 1]], F = y[r[g + 2]];
|
|
1772
|
+
P === M || M === F || P === F || E.push(P, M, F);
|
|
1773
|
+
}
|
|
1774
|
+
return {
|
|
1775
|
+
positions: new Float32Array(f),
|
|
1776
|
+
indices: new Uint32Array(E),
|
|
1777
|
+
colors: x ? new Float32Array(d) : void 0,
|
|
1778
|
+
uvs: b ? new Float32Array(v) : void 0
|
|
1779
|
+
};
|
|
1780
|
+
}
|
|
1781
|
+
function dn(o, r) {
|
|
1782
|
+
const n = /* @__PURE__ */ new Map(), i = (m, k) => {
|
|
1783
|
+
const b = m < k ? `${m}_${k}` : `${k}_${m}`, x = n.get(b) ?? [];
|
|
1784
|
+
x.push(m, k), n.set(b, x);
|
|
1785
|
+
};
|
|
1786
|
+
for (let m = 0; m < r.length; m += 3)
|
|
1787
|
+
i(r[m], r[m + 1]), i(r[m + 1], r[m + 2]), i(r[m + 2], r[m]);
|
|
1788
|
+
const c = /* @__PURE__ */ new Map();
|
|
1789
|
+
for (const [m, k] of n)
|
|
1790
|
+
if (k.length === 2) {
|
|
1791
|
+
const [b, x] = m.split("_").map(Number);
|
|
1792
|
+
n.get(m).length === 2 && c.set(b, x);
|
|
1793
|
+
}
|
|
1794
|
+
const a = [];
|
|
1795
|
+
for (const [, m] of n)
|
|
1796
|
+
m.length === 2 && a.push([m[0], m[1]]);
|
|
1797
|
+
const f = /* @__PURE__ */ new Map();
|
|
1798
|
+
for (const [m, k] of a) {
|
|
1799
|
+
const b = f.get(m) ?? [];
|
|
1800
|
+
b.push(k), f.set(m, b);
|
|
1801
|
+
}
|
|
1802
|
+
const d = /* @__PURE__ */ new Set(), v = [];
|
|
1803
|
+
for (const [m, k] of f)
|
|
1804
|
+
for (const b of k) {
|
|
1805
|
+
const x = `${m}_${b}`;
|
|
1806
|
+
if (d.has(x)) continue;
|
|
1807
|
+
const E = [m];
|
|
1808
|
+
let g = b, P = m;
|
|
1809
|
+
d.add(x);
|
|
1810
|
+
let M = 0;
|
|
1811
|
+
for (; g !== m && M++ < 1e4; ) {
|
|
1812
|
+
E.push(g);
|
|
1813
|
+
const F = f.get(g) ?? [], I = F.find((z) => z !== P) ?? F[0];
|
|
1814
|
+
if (I === void 0) break;
|
|
1815
|
+
d.add(`${g}_${I}`), P = g, g = I;
|
|
1816
|
+
}
|
|
1817
|
+
if (E.length >= 3) {
|
|
1818
|
+
const F = E[0];
|
|
1819
|
+
for (let I = 1; I < E.length - 1; I++)
|
|
1820
|
+
v.push(F, E[I], E[I + 1]);
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
if (!v.length) return { positions: o, indices: r };
|
|
1824
|
+
const y = new Uint32Array(r.length + v.length);
|
|
1825
|
+
return y.set(r, 0), y.set(v, r.length), { positions: o, indices: y };
|
|
1826
|
+
}
|
|
1827
|
+
function en(o, r) {
|
|
1828
|
+
const n = ue(o, r), i = n.indices.length, c = dn(n.positions, n.indices), a = c.indices;
|
|
1829
|
+
if (a !== n.indices && a.length > i)
|
|
1830
|
+
for (let f = i; f < a.length; f += 3) {
|
|
1831
|
+
const d = a[f + 1];
|
|
1832
|
+
a[f + 1] = a[f + 2], a[f + 2] = d;
|
|
1833
|
+
}
|
|
1834
|
+
return ue(c.positions, a, 1e-4);
|
|
1835
|
+
}
|
|
1836
|
+
function nn(o, r) {
|
|
1837
|
+
const n = new Float32Array(o.length);
|
|
1838
|
+
for (let i = 0; i < o.length; i += 3) {
|
|
1839
|
+
const c = o[i], a = o[i + 1], f = o[i + 2];
|
|
1840
|
+
n[i] = r[0] * c + r[4] * a + r[8] * f + r[12], n[i + 1] = r[1] * c + r[5] * a + r[9] * f + r[13], n[i + 2] = r[2] * c + r[6] * a + r[10] * f + r[14];
|
|
1841
|
+
}
|
|
1842
|
+
return n;
|
|
1843
|
+
}
|
|
1844
|
+
function bt(o, r) {
|
|
1845
|
+
const n = Math.hypot(o[0], o[1], o[2]);
|
|
1846
|
+
return n < 1e-12 ? { normal: [0, 1, 0], offset: r } : {
|
|
1847
|
+
normal: [o[0] / n, o[1] / n, o[2] / n],
|
|
1848
|
+
offset: r / n
|
|
1849
|
+
};
|
|
1850
|
+
}
|
|
1851
|
+
function Ht(o) {
|
|
1852
|
+
const { normal: r } = bt(o, 0), n = Math.abs(r[1]) < 0.9 ? [0, 1, 0] : [1, 0, 0], i = n[1] * r[2] - n[2] * r[1], c = n[2] * r[0] - n[0] * r[2], a = n[0] * r[1] - n[1] * r[0], f = Math.hypot(i, c, a) || 1, d = [i / f, c / f, a / f], v = [r[1] * d[2] - r[2] * d[1], r[2] * d[0] - r[0] * d[2], r[0] * d[1] - r[1] * d[0]];
|
|
1853
|
+
return { x: d, y: v, z: r };
|
|
1854
|
+
}
|
|
1855
|
+
function fe(o, r) {
|
|
1856
|
+
const { x: n, y: i, z: c } = Ht(o);
|
|
1857
|
+
return [n[0], n[1], n[2], 0, i[0], i[1], i[2], 0, c[0], c[1], c[2], 0, r[0], r[1], r[2], 1];
|
|
1858
|
+
}
|
|
1859
|
+
function no(o, r, n) {
|
|
1860
|
+
const { x: i, y: c } = Ht(n);
|
|
1861
|
+
let a = 1 / 0, f = -1 / 0, d = 1 / 0, v = -1 / 0;
|
|
1862
|
+
for (const m of [o[0], r[0]])
|
|
1863
|
+
for (const k of [o[1], r[1]])
|
|
1864
|
+
for (const b of [o[2], r[2]]) {
|
|
1865
|
+
const x = m * i[0] + k * i[1] + b * i[2], E = m * c[0] + k * c[1] + b * c[2];
|
|
1866
|
+
x < a && (a = x), x > f && (f = x), E < d && (d = E), E > v && (v = E);
|
|
1867
|
+
}
|
|
1868
|
+
const y = Math.min(f - a, v - d);
|
|
1869
|
+
return Number.isFinite(y) && y > 0 ? y : 0;
|
|
1870
|
+
}
|
|
1871
|
+
const hn = 0.4, ro = 0.3;
|
|
1872
|
+
function oo(o) {
|
|
1873
|
+
return Math.max(Math.abs(o) * 0.04, ro);
|
|
1874
|
+
}
|
|
1875
|
+
function pn(o, r = 0, n = hn) {
|
|
1876
|
+
if (!(o > 0)) return 0;
|
|
1877
|
+
const i = o * Math.max(0, n), c = o * 0.9;
|
|
1878
|
+
return r > 0 ? Math.min(r, c) : Math.min(i, c);
|
|
1879
|
+
}
|
|
1880
|
+
function yn(o, r, n, i = 0, c = hn) {
|
|
1881
|
+
const a = no(o, r, n);
|
|
1882
|
+
if (!(a > 0)) return 0;
|
|
1883
|
+
const f = a * Math.max(0, c), d = a * 0.9;
|
|
1884
|
+
return i > 0 ? Math.min(i, d) : Math.min(f, d);
|
|
1885
|
+
}
|
|
1886
|
+
function so(o, r, n) {
|
|
1887
|
+
const { normal: i } = bt(r, 0), c = n * 0.3;
|
|
1888
|
+
return [o[0] + i[0] * c, o[1] + i[1] * c, o[2] + i[2] * c];
|
|
1889
|
+
}
|
|
1890
|
+
const io = 0.65;
|
|
1891
|
+
function ao(o, r, n, i, c = io) {
|
|
1892
|
+
const { normal: a } = bt(r, 0), f = i + n * (c - 0.5);
|
|
1893
|
+
return [o[0] + a[0] * f, o[1] + a[1] * f, o[2] + a[2] * f];
|
|
1894
|
+
}
|
|
1895
|
+
function co(o, r, n = 0) {
|
|
1896
|
+
return o.min[0] <= r.max[0] + n && o.max[0] >= r.min[0] - n && o.min[1] <= r.max[1] + n && o.max[1] >= r.min[1] - n && o.min[2] <= r.max[2] + n && o.max[2] >= r.min[2] - n;
|
|
1897
|
+
}
|
|
1898
|
+
function Nt(o) {
|
|
1899
|
+
const r = o.length / 3;
|
|
1900
|
+
if (r < 1) return [0, 0, 0];
|
|
1901
|
+
let n = 0, i = 0, c = 0;
|
|
1902
|
+
for (let a = 0; a < r; a++)
|
|
1903
|
+
n += o[a * 3], i += o[a * 3 + 1], c += o[a * 3 + 2];
|
|
1904
|
+
return [n / r, i / r, c / r];
|
|
1905
|
+
}
|
|
1906
|
+
function rn(o, r, n) {
|
|
1907
|
+
return (r.x - o.x) * (n.y - o.y) - (r.y - o.y) * (n.x - o.x);
|
|
1908
|
+
}
|
|
1909
|
+
function on(o, r) {
|
|
1910
|
+
return Math.hypot(o.x - r.x, o.y - r.y);
|
|
1911
|
+
}
|
|
1912
|
+
function lo(o, r, n) {
|
|
1913
|
+
if (o.length < 3) return 0;
|
|
1914
|
+
const { normal: i } = bt(r, 0), { x: c, y: a } = Ht(i), f = o.map((b) => {
|
|
1915
|
+
const x = b[0] - n[0], E = b[1] - n[1], g = b[2] - n[2];
|
|
1916
|
+
return { x: x * c[0] + E * c[1] + g * c[2], y: x * a[0] + E * a[1] + g * a[2] };
|
|
1917
|
+
});
|
|
1918
|
+
let d = 0;
|
|
1919
|
+
for (let b = 1; b < f.length; b++)
|
|
1920
|
+
(f[b].y < f[d].y || f[b].y === f[d].y && f[b].x < f[d].x) && (d = b);
|
|
1921
|
+
const v = f[d], y = f.map((b, x) => ({ p: b, i: x })).sort((b, x) => {
|
|
1922
|
+
const E = rn(v, b.p, x.p);
|
|
1923
|
+
return Math.abs(E) < 1e-14 ? on(v, b.p) - on(v, x.p) : E > 0 ? -1 : 1;
|
|
1924
|
+
}), m = [];
|
|
1925
|
+
for (const b of y) {
|
|
1926
|
+
const x = b.p;
|
|
1927
|
+
for (; m.length >= 2 && rn(m[m.length - 2], m[m.length - 1], x) <= 0; ) m.pop();
|
|
1928
|
+
m.push(x);
|
|
1929
|
+
}
|
|
1930
|
+
if (m.length < 3) return 0;
|
|
1931
|
+
let k = 0;
|
|
1932
|
+
for (let b = 0; b < m.length; b++) {
|
|
1933
|
+
const x = (b + 1) % m.length;
|
|
1934
|
+
k += m[b].x * m[x].y - m[x].x * m[b].y;
|
|
1935
|
+
}
|
|
1936
|
+
return Math.abs(k) * 0.5;
|
|
1937
|
+
}
|
|
1938
|
+
function le(o, r) {
|
|
1939
|
+
const [n, i, c, a, f, d] = o;
|
|
1940
|
+
return [n * r[0] + i * r[1] + c * r[2], i * r[0] + a * r[1] + f * r[2], c * r[0] + f * r[1] + d * r[2]];
|
|
1941
|
+
}
|
|
1942
|
+
function uo(o) {
|
|
1943
|
+
if (o.length < 3) return null;
|
|
1944
|
+
let r = 0, n = 0, i = 0;
|
|
1945
|
+
for (const D of o)
|
|
1946
|
+
r += D[0], n += D[1], i += D[2];
|
|
1947
|
+
const c = o.length;
|
|
1948
|
+
r /= c, n /= c, i /= c;
|
|
1949
|
+
let a = 0, f = 0, d = 0, v = 0, y = 0, m = 0;
|
|
1950
|
+
for (const D of o) {
|
|
1951
|
+
const L = D[0] - r, U = D[1] - n, J = D[2] - i;
|
|
1952
|
+
a += L * L, f += L * U, d += L * J, v += U * U, y += U * J, m += J * J;
|
|
1953
|
+
}
|
|
1954
|
+
const k = [a, f, d, v, y, m], b = (D, L) => {
|
|
1955
|
+
let U = D;
|
|
1956
|
+
for (let J = 0; J < 24; J++) {
|
|
1957
|
+
const X = L(U), rt = Math.hypot(X[0], X[1], X[2]);
|
|
1958
|
+
if (rt < 1e-18) return U;
|
|
1959
|
+
U = [X[0] / rt, X[1] / rt, X[2] / rt];
|
|
1960
|
+
}
|
|
1961
|
+
return U;
|
|
1962
|
+
}, x = b([1, 0.3, 0.2], (D) => le(k, D)), E = le(k, x), g = x[0] * E[0] + x[1] * E[1] + x[2] * E[2], P = (D) => {
|
|
1963
|
+
const L = le(k, D), U = g * (x[0] * D[0] + x[1] * D[1] + x[2] * D[2]);
|
|
1964
|
+
return [L[0] - U * x[0], L[1] - U * x[1], L[2] - U * x[2]];
|
|
1965
|
+
}, M = Math.abs(x[0]) < 0.9 ? [1, 0, 0] : [0, 1, 0], F = [
|
|
1966
|
+
M[1] * x[2] - M[2] * x[1],
|
|
1967
|
+
M[2] * x[0] - M[0] * x[2],
|
|
1968
|
+
M[0] * x[1] - M[1] * x[0]
|
|
1969
|
+
], I = Math.hypot(F[0], F[1], F[2]) || 1, z = [F[0] / I, F[1] / I, F[2] / I], T = [
|
|
1970
|
+
x[1] * z[2] - x[2] * z[1],
|
|
1971
|
+
x[2] * z[0] - x[0] * z[2],
|
|
1972
|
+
x[0] * z[1] - x[1] * z[0]
|
|
1973
|
+
], S = (D) => {
|
|
1974
|
+
const L = le(k, D);
|
|
1975
|
+
return D[0] * L[0] + D[1] * L[1] + D[2] * L[2];
|
|
1976
|
+
}, w = b(z, P), B = b(T, P), R = S(w) >= S(B) ? w : B, j = [
|
|
1977
|
+
x[1] * R[2] - x[2] * R[1],
|
|
1978
|
+
x[2] * R[0] - x[0] * R[2],
|
|
1979
|
+
x[0] * R[1] - x[1] * R[0]
|
|
1980
|
+
], O = Math.hypot(j[0], j[1], j[2]);
|
|
1981
|
+
return O < 1e-12 ? null : [j[0] / O, j[1] / O, j[2] / O];
|
|
1982
|
+
}
|
|
1983
|
+
function fo(o, r) {
|
|
1984
|
+
if (o.length < 2) return 0;
|
|
1985
|
+
const { x: n, y: i } = Ht(r);
|
|
1986
|
+
let c = 1 / 0, a = -1 / 0, f = 1 / 0, d = -1 / 0;
|
|
1987
|
+
for (const y of o) {
|
|
1988
|
+
const m = y[0] * n[0] + y[1] * n[1] + y[2] * n[2], k = y[0] * i[0] + y[1] * i[1] + y[2] * i[2];
|
|
1989
|
+
m < c && (c = m), m > a && (a = m), k < f && (f = k), k > d && (d = k);
|
|
1990
|
+
}
|
|
1991
|
+
const v = Math.min(a - c, d - f);
|
|
1992
|
+
return Number.isFinite(v) && v > 0 ? v : 0;
|
|
1993
|
+
}
|
|
1994
|
+
function ho(o, r, n = 0.99) {
|
|
1995
|
+
const { normal: i } = bt(r, 0), c = Math.floor(o.length / 3);
|
|
1996
|
+
if (c < 1) return 0;
|
|
1997
|
+
const a = new Float64Array(c);
|
|
1998
|
+
for (let d = 0; d < c; d++)
|
|
1999
|
+
a[d] = i[0] * o[d * 3] + i[1] * o[d * 3 + 1] + i[2] * o[d * 3 + 2];
|
|
2000
|
+
a.sort();
|
|
2001
|
+
const f = Math.min(c - 1, Math.max(0, Math.floor((c - 1) * n)));
|
|
2002
|
+
return a[f];
|
|
2003
|
+
}
|
|
2004
|
+
function sn(o, r, n, i, c = 0.99) {
|
|
2005
|
+
if (!(i > 0)) return null;
|
|
2006
|
+
const { normal: a } = bt(n, 0), { x: f, y: d } = Ht(a), v = i * i, y = [], m = Math.floor(o.length / 3);
|
|
2007
|
+
for (let b = 0; b < m; b++) {
|
|
2008
|
+
const x = o[b * 3] - r[0], E = o[b * 3 + 1] - r[1], g = o[b * 3 + 2] - r[2], P = x * f[0] + E * f[1] + g * f[2], M = x * d[0] + E * d[1] + g * d[2];
|
|
2009
|
+
P * P + M * M > v || y.push(a[0] * o[b * 3] + a[1] * o[b * 3 + 1] + a[2] * o[b * 3 + 2]);
|
|
2010
|
+
}
|
|
2011
|
+
if (y.length < 8) return null;
|
|
2012
|
+
y.sort((b, x) => b - x);
|
|
2013
|
+
const k = Math.min(y.length - 1, Math.max(0, Math.floor((y.length - 1) * c)));
|
|
2014
|
+
return y[k];
|
|
2015
|
+
}
|
|
2016
|
+
function an(o, r, n) {
|
|
2017
|
+
const { positions: i, indices: c } = o, a = c.length / 3;
|
|
2018
|
+
if (a < 1) return null;
|
|
2019
|
+
const f = [0, 0, 0], d = [0, 0, 0];
|
|
2020
|
+
let v = 0, y = 0;
|
|
2021
|
+
const m = [1 / 0, 1 / 0, 1 / 0], k = [-1 / 0, -1 / 0, -1 / 0], b = [];
|
|
2022
|
+
for (let S = 0; S < i.length; S += 3) {
|
|
2023
|
+
const w = [i[S], i[S + 1], i[S + 2]];
|
|
2024
|
+
b.push(w), w[0] < m[0] && (m[0] = w[0]), w[1] < m[1] && (m[1] = w[1]), w[2] < m[2] && (m[2] = w[2]), w[0] > k[0] && (k[0] = w[0]), w[1] > k[1] && (k[1] = w[1]), w[2] > k[2] && (k[2] = w[2]);
|
|
2025
|
+
}
|
|
2026
|
+
for (let S = 0; S < a; S++) {
|
|
2027
|
+
const w = c[S * 3], B = c[S * 3 + 1], R = c[S * 3 + 2], j = i[w * 3], O = i[w * 3 + 1], D = i[w * 3 + 2], L = i[B * 3], U = i[B * 3 + 1], J = i[B * 3 + 2], X = i[R * 3], rt = i[R * 3 + 1], H = i[R * 3 + 2], G = L - j, Y = U - O, mt = J - D, ft = X - j, ut = rt - O, Pt = H - D, Ct = Y * Pt - mt * ut, _t = mt * ft - G * Pt, Ft = G * ut - Y * ft, Mt = 0.5 * Math.hypot(Ct, _t, Ft);
|
|
2028
|
+
if (Mt < 1e-14) continue;
|
|
2029
|
+
const xt = 1 / (2 * Mt);
|
|
2030
|
+
f[0] += Ct * xt * Mt, f[1] += _t * xt * Mt, f[2] += Ft * xt * Mt, d[0] += (j + L + X) / 3, d[1] += (O + U + rt) / 3, d[2] += (D + J + H) / 3, v += Mt, y++;
|
|
2031
|
+
}
|
|
2032
|
+
if (y === 0 || v < 1e-14) return null;
|
|
2033
|
+
d[0] /= y, d[1] /= y, d[2] /= y;
|
|
2034
|
+
const x = Math.hypot(f[0], f[1], f[2]), P = (x < v * 0.2 ? uo(b) : null) ?? (x > 1e-12 ? [f[0] / x, f[1] / x, f[2] / x] : [0, 1, 0]), M = [n[0] - r[0], n[1] - r[1], n[2] - r[2]], F = Math.hypot(M[0], M[1], M[2]);
|
|
2035
|
+
F > 1e-12 && (P[0] * M[0] + P[1] * M[1] + P[2] * M[2]) / F < 0 && (P[0] = -P[0], P[1] = -P[1], P[2] = -P[2]);
|
|
2036
|
+
let I = lo(b, P, d);
|
|
2037
|
+
I > 1e-12 || (I = v * 0.5);
|
|
2038
|
+
let z = 1 / 0, T = -1 / 0;
|
|
2039
|
+
for (const S of b) {
|
|
2040
|
+
const w = P[0] * (S[0] - d[0]) + P[1] * (S[1] - d[1]) + P[2] * (S[2] - d[2]);
|
|
2041
|
+
w < z && (z = w), w > T && (T = w);
|
|
2042
|
+
}
|
|
2043
|
+
return Number.isFinite(z) || (z = 0, T = 0), {
|
|
2044
|
+
center: d,
|
|
2045
|
+
normal: P,
|
|
2046
|
+
area: I,
|
|
2047
|
+
span: fo(b, P),
|
|
2048
|
+
along: { min: z, max: T },
|
|
2049
|
+
bbox: { min: m, max: k }
|
|
2050
|
+
};
|
|
2051
|
+
}
|
|
2052
|
+
function po(o, r) {
|
|
2053
|
+
if (!(r > 1e-12) || !(o > 0)) return !0;
|
|
2054
|
+
const n = o / r, i = Math.sqrt(r);
|
|
2055
|
+
return n < Math.max(0.4, i * 0.08);
|
|
2056
|
+
}
|
|
2057
|
+
function yo(o, r, n, i, c, a = 0) {
|
|
2058
|
+
return yn(n, i, c, a);
|
|
2059
|
+
}
|
|
2060
|
+
function mo(o, r, n) {
|
|
2061
|
+
const { normal: i } = bt(n, 0), c = [r[0] - o[0], r[1] - o[1], r[2] - o[2]];
|
|
2062
|
+
return Math.abs(c[0] * i[0]) + Math.abs(c[1] * i[1]) + Math.abs(c[2] * i[2]);
|
|
2063
|
+
}
|
|
2064
|
+
function vo(o) {
|
|
2065
|
+
const r = o.positions, n = [1 / 0, 1 / 0, 1 / 0], i = [-1 / 0, -1 / 0, -1 / 0];
|
|
2066
|
+
for (let c = 0; c < r.length; c += 3)
|
|
2067
|
+
r[c] < n[0] && (n[0] = r[c]), r[c + 1] < n[1] && (n[1] = r[c + 1]), r[c + 2] < n[2] && (n[2] = r[c + 2]), r[c] > i[0] && (i[0] = r[c]), r[c + 1] > i[1] && (i[1] = r[c + 1]), r[c + 2] > i[2] && (i[2] = r[c + 2]);
|
|
2068
|
+
return {
|
|
2069
|
+
min: n,
|
|
2070
|
+
max: i,
|
|
2071
|
+
size: [i[0] - n[0], i[1] - n[1], i[2] - n[2]]
|
|
2072
|
+
};
|
|
2073
|
+
}
|
|
2074
|
+
function mn(o, r) {
|
|
2075
|
+
const { normal: n } = bt(o, 0), { normal: i } = bt(r, 0), c = n[0] * i[0] + n[1] * i[1] + n[2] * i[2];
|
|
2076
|
+
if (c > 0.999999) return [0, 0, 0, 1];
|
|
2077
|
+
if (c < -0.999999) {
|
|
2078
|
+
let m = 0, k = 1, b = 0;
|
|
2079
|
+
Math.abs(n[1]) < 0.9 ? (m = 0, k = 1, b = 0) : (m = 1, k = 0, b = 0);
|
|
2080
|
+
let x = n[1] * b - n[2] * k, E = n[2] * m - n[0] * b, g = n[0] * k - n[1] * m;
|
|
2081
|
+
const P = Math.hypot(x, E, g) || 1;
|
|
2082
|
+
return x /= P, E /= P, g /= P, [x, E, g, 0];
|
|
2083
|
+
}
|
|
2084
|
+
let a = n[1] * i[2] - n[2] * i[1], f = n[2] * i[0] - n[0] * i[2], d = n[0] * i[1] - n[1] * i[0], v = 1 + c;
|
|
2085
|
+
const y = Math.hypot(a, f, d, v) || 1;
|
|
2086
|
+
return [a / y, f / y, d / y, v / y];
|
|
2087
|
+
}
|
|
2088
|
+
function go(o, r) {
|
|
2089
|
+
const [n, i, c, a] = o, f = a * r[0] + i * r[2] - c * r[1], d = a * r[1] + c * r[0] - n * r[2], v = a * r[2] + n * r[1] - i * r[0], y = -n * r[0] - i * r[1] - c * r[2];
|
|
2090
|
+
return [
|
|
2091
|
+
f * a + y * -n + d * -c - v * -i,
|
|
2092
|
+
d * a + y * -i + v * -n - f * -c,
|
|
2093
|
+
v * a + y * -c + f * -i - d * -n
|
|
2094
|
+
];
|
|
2095
|
+
}
|
|
2096
|
+
function bo(o, r, n, i) {
|
|
2097
|
+
const c = mn(o, r), [a, f, d, v] = c, y = a + a, m = f + f, k = d + d, b = a * y, x = a * m, E = a * k, g = f * m, P = f * k, M = d * k, F = v * y, I = v * m, z = v * k, T = n;
|
|
2098
|
+
return [
|
|
2099
|
+
(1 - (g + M)) * T,
|
|
2100
|
+
(x + z) * T,
|
|
2101
|
+
(E - I) * T,
|
|
2102
|
+
0,
|
|
2103
|
+
(x - z) * T,
|
|
2104
|
+
(1 - (b + M)) * T,
|
|
2105
|
+
(P + F) * T,
|
|
2106
|
+
0,
|
|
2107
|
+
(E + I) * T,
|
|
2108
|
+
(P - F) * T,
|
|
2109
|
+
(1 - (b + g)) * T,
|
|
2110
|
+
0,
|
|
2111
|
+
i[0],
|
|
2112
|
+
i[1],
|
|
2113
|
+
i[2],
|
|
2114
|
+
1
|
|
2115
|
+
];
|
|
2116
|
+
}
|
|
2117
|
+
function xo(o) {
|
|
2118
|
+
let r = 1, n = 1 / 0;
|
|
2119
|
+
for (let i = 0; i < 3; i++) {
|
|
2120
|
+
const c = (i + 1) % 3, a = (i + 2) % 3, f = Math.max(o[c], o[a], 1e-9), d = Math.abs(o[c] - o[a]) / f, v = Math.max(o[0], o[1], o[2], 1e-9), y = d * 10 + o[i] / v;
|
|
2121
|
+
y < n && (n = y, r = i);
|
|
2122
|
+
}
|
|
2123
|
+
return r;
|
|
2124
|
+
}
|
|
2125
|
+
function cn(o) {
|
|
2126
|
+
if (o.length < 8) return null;
|
|
2127
|
+
let n = 0, i = 0, c = 0, a = 0, f = 0, d = 0, v = 0, y = 0, m = 0, k = 0, b = 0, x = 0, E = 0, g = 0;
|
|
2128
|
+
for (const T of o) {
|
|
2129
|
+
const S = T[0], w = T[1], B = T[2], R = S * S + w * w + B * B, j = 2 * S, O = 2 * w, D = 2 * B;
|
|
2130
|
+
n += j * j, i += j * O, c += j * D, a += j, f += O * O, d += O * D, v += O, y += D * D, m += D, k += 1, b += j * R, x += O * R, E += D * R, g += R;
|
|
2131
|
+
}
|
|
2132
|
+
const P = [
|
|
2133
|
+
[n, i, c, a, b],
|
|
2134
|
+
[i, f, d, v, x],
|
|
2135
|
+
[c, d, y, m, E],
|
|
2136
|
+
[a, v, m, k, g]
|
|
2137
|
+
];
|
|
2138
|
+
for (let T = 0; T < 4; T++) {
|
|
2139
|
+
let S = T;
|
|
2140
|
+
for (let R = T + 1; R < 4; R++) Math.abs(P[R][T]) > Math.abs(P[S][T]) && (S = R);
|
|
2141
|
+
if (Math.abs(P[S][T]) < 1e-12) return null;
|
|
2142
|
+
const w = P[T];
|
|
2143
|
+
P[T] = P[S], P[S] = w;
|
|
2144
|
+
const B = P[T][T];
|
|
2145
|
+
for (let R = T; R < 5; R++) P[T][R] /= B;
|
|
2146
|
+
for (let R = 0; R < 4; R++) {
|
|
2147
|
+
if (R === T) continue;
|
|
2148
|
+
const j = P[R][T];
|
|
2149
|
+
for (let O = T; O < 5; O++) P[R][O] -= j * P[T][O];
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
const M = P[0][4], F = P[1][4], I = P[2][4], z = Math.sqrt(Math.max(0, P[3][4] + M * M + F * F + I * I));
|
|
2153
|
+
return !(z > 1e-6) || !Number.isFinite(z) ? null : { center: [M, F, I], radius: z };
|
|
2154
|
+
}
|
|
2155
|
+
function _o(o) {
|
|
2156
|
+
const r = cn(o);
|
|
2157
|
+
if (!r) return null;
|
|
2158
|
+
const n = o.filter((i) => {
|
|
2159
|
+
const c = Math.hypot(i[0] - r.center[0], i[1] - r.center[1], i[2] - r.center[2]);
|
|
2160
|
+
return Math.abs(c - r.radius) < r.radius * 0.12;
|
|
2161
|
+
});
|
|
2162
|
+
return n.length < 8 || n.length > o.length * 0.98 ? r : cn(n) ?? r;
|
|
2163
|
+
}
|
|
2164
|
+
function de(o, r) {
|
|
2165
|
+
const n = vo(o), i = xo(n.size), c = o.positions, a = c.length / 3;
|
|
2166
|
+
if (a < 8) throw new Error("爪扣网格为空");
|
|
2167
|
+
const f = [0, 0, 0];
|
|
2168
|
+
for (let H = 0; H < a; H++)
|
|
2169
|
+
f[0] += c[H * 3], f[1] += c[H * 3 + 1], f[2] += c[H * 3 + 2];
|
|
2170
|
+
const d = [f[0] / a, f[1] / a, f[2] / a], v = [0, 0, 0];
|
|
2171
|
+
v[i] = 1;
|
|
2172
|
+
const y = (H, G) => (c[H * 3] - d[0]) * G[0] + (c[H * 3 + 1] - d[1]) * G[1] + (c[H * 3 + 2] - d[2]) * G[2], m = (H, G) => {
|
|
2173
|
+
const Y = c[H * 3] - d[0], mt = c[H * 3 + 1] - d[1], ft = c[H * 3 + 2] - d[2], ut = Y * G[0] + mt * G[1] + ft * G[2];
|
|
2174
|
+
return Math.hypot(Y - G[0] * ut, mt - G[1] * ut, ft - G[2] * ut);
|
|
2175
|
+
};
|
|
2176
|
+
let k = 1 / 0, b = -1 / 0;
|
|
2177
|
+
for (let H = 0; H < a; H++) {
|
|
2178
|
+
const G = y(H, v);
|
|
2179
|
+
G < k && (k = G), G > b && (b = G);
|
|
2180
|
+
}
|
|
2181
|
+
const E = Math.max(b - k, 1e-9) * 0.08;
|
|
2182
|
+
let g = 1 / 0, P = 1 / 0;
|
|
2183
|
+
for (let H = 0; H < a; H++) {
|
|
2184
|
+
const G = y(H, v), Y = m(H, v);
|
|
2185
|
+
G <= k + E && Y < g && (g = Y), G >= b - E && Y < P && (P = Y);
|
|
2186
|
+
}
|
|
2187
|
+
const M = g <= P ? v : [-v[0], -v[1], -v[2]];
|
|
2188
|
+
let F = 1 / 0, I = -1 / 0, z = 0;
|
|
2189
|
+
const T = new Array(a), S = new Array(a);
|
|
2190
|
+
for (let H = 0; H < a; H++) {
|
|
2191
|
+
const G = y(H, M), Y = m(H, M);
|
|
2192
|
+
T[H] = G, S[H] = Y, G < F && (F = G), G > I && (I = G), Y > z && (z = Y);
|
|
2193
|
+
}
|
|
2194
|
+
const w = Math.max(I - F, 1e-9), B = [];
|
|
2195
|
+
for (let H = 0; H < a; H++) {
|
|
2196
|
+
const G = (T[H] - F) / w, Y = S[H];
|
|
2197
|
+
if (r === "peg") {
|
|
2198
|
+
if (G < 0.32 || G > 0.97 || Y < z * 0.45) continue;
|
|
2199
|
+
} else if (G < 0.3 || G > 0.92 || Y > z * 0.62 || Y < z * 0.2)
|
|
2200
|
+
continue;
|
|
2201
|
+
B.push([c[H * 3], c[H * 3 + 1], c[H * 3 + 2]]);
|
|
2202
|
+
}
|
|
2203
|
+
const R = _o(B);
|
|
2204
|
+
if (!R) throw new Error(r === "peg" ? "爪扣未能识别球头" : "爪扣未能识别凹窝");
|
|
2205
|
+
const j = [R.center[0] - d[0], R.center[1] - d[1], R.center[2] - d[2]], O = j[0] * M[0] + j[1] * M[1] + j[2] * M[2], D = [
|
|
2206
|
+
d[0] + M[0] * O,
|
|
2207
|
+
d[1] + M[1] * O,
|
|
2208
|
+
d[2] + M[2] * O
|
|
2209
|
+
];
|
|
2210
|
+
let L = 0, U = 0, J = -1 / 0;
|
|
2211
|
+
for (let H = 0; H < a; H++) {
|
|
2212
|
+
const G = (T[H] - F) / w, Y = S[H];
|
|
2213
|
+
G < 0.12 && Y > L && (L = Y), G >= 0.22 && G <= 0.82 && Y > U && (U = Y);
|
|
2214
|
+
}
|
|
2215
|
+
L > 0 || (L = z), U > 0 || (U = L);
|
|
2216
|
+
const X = Math.max(U * 1.15, L * 0.7);
|
|
2217
|
+
for (let H = 0; H < a; H++)
|
|
2218
|
+
S[H] < X || T[H] > O || T[H] > J && (J = T[H]);
|
|
2219
|
+
const rt = Number.isFinite(J) ? Math.max(J - F, w * 0.04) : w * 0.08;
|
|
2220
|
+
return {
|
|
2221
|
+
axis: M,
|
|
2222
|
+
center: D,
|
|
2223
|
+
radius: R.radius,
|
|
2224
|
+
flangeRadius: L,
|
|
2225
|
+
bodyRadius: U,
|
|
2226
|
+
base: F - O,
|
|
2227
|
+
tip: I - O,
|
|
2228
|
+
flangeThickness: rt
|
|
2229
|
+
};
|
|
2230
|
+
}
|
|
2231
|
+
function ln(o, r, n, i) {
|
|
2232
|
+
const { normal: c } = bt(r, 0), a = go(mn(o.axis, c), [
|
|
2233
|
+
o.center[0] * i,
|
|
2234
|
+
o.center[1] * i,
|
|
2235
|
+
o.center[2] * i
|
|
2236
|
+
]);
|
|
2237
|
+
return bo(o.axis, c, i, [
|
|
2238
|
+
n[0] - a[0],
|
|
2239
|
+
n[1] - a[1],
|
|
2240
|
+
n[2] - a[2]
|
|
2241
|
+
]);
|
|
2242
|
+
}
|
|
2243
|
+
function Mo(o, r, n) {
|
|
2244
|
+
const i = de(o, "socket"), c = de(r, "peg");
|
|
2245
|
+
return !(c.radius > 1e-6) || !(n > 0) ? 0 : Math.max(0, i.tip) * (n / (c.radius * 2));
|
|
2246
|
+
}
|
|
2247
|
+
function wo(o) {
|
|
2248
|
+
return o > 0 ? Math.min(0.25, o * 0.2) : 0;
|
|
2249
|
+
}
|
|
2250
|
+
function Te(o, r, n, i, c) {
|
|
2251
|
+
const { normal: a } = bt(r, 0), f = a[0] * o[0] + a[1] * o[1] + a[2] * o[2], d = n + i - c - f;
|
|
2252
|
+
return [o[0] + a[0] * d, o[1] + a[1] * d, o[2] + a[2] * d];
|
|
2253
|
+
}
|
|
2254
|
+
function $o(o, r, n, i, c, a = i) {
|
|
2255
|
+
const f = de(o, "socket"), d = de(r, "peg");
|
|
2256
|
+
if (!(d.radius > 1e-6) || !(c > 1e-9)) throw new Error("爪扣尺寸无效");
|
|
2257
|
+
const v = c / (d.radius * 2), { normal: y } = bt(n, 0), m = [-y[0], -y[1], -y[2]], k = f.base + Math.max(f.flangeThickness * 1.25, Math.abs(f.base) * 0.05), b = f.tip + f.radius * 0.12, x = Math.max(b - k, f.radius), E = (k + b) / 2, g = Math.min(Math.max(f.bodyRadius * 1.05, f.radius * 1.15), f.flangeRadius * 0.88) * v;
|
|
2258
|
+
return {
|
|
2259
|
+
aoMatrix: ln(f, m, i, v),
|
|
2260
|
+
tuMatrix: ln(d, y, a, v),
|
|
2261
|
+
scale: v,
|
|
2262
|
+
clearRadius: g,
|
|
2263
|
+
clearLength: x * v,
|
|
2264
|
+
clearCenter: [
|
|
2265
|
+
i[0] + m[0] * E * v,
|
|
2266
|
+
i[1] + m[1] * E * v,
|
|
2267
|
+
i[2] + m[2] * E * v
|
|
2268
|
+
]
|
|
2269
|
+
};
|
|
2270
|
+
}
|
|
2271
|
+
let Se = null, Ie = null;
|
|
2272
|
+
async function Zt() {
|
|
2273
|
+
if (Se) return Se;
|
|
2274
|
+
if (!Ie)
|
|
2275
|
+
throw new Error("几何内核 WASM 未传入 Worker");
|
|
2276
|
+
const o = await Yr({
|
|
2277
|
+
wasmBinary: Ie,
|
|
2278
|
+
locateFile: (r) => r
|
|
2279
|
+
});
|
|
2280
|
+
return o.setup(), Se = o, o;
|
|
2281
|
+
}
|
|
2282
|
+
function vn(o, r, n) {
|
|
2283
|
+
return new o.Mesh({
|
|
2284
|
+
numProp: 3,
|
|
2285
|
+
vertProperties: r,
|
|
2286
|
+
triVerts: n
|
|
2287
|
+
});
|
|
2288
|
+
}
|
|
2289
|
+
function at(o) {
|
|
2290
|
+
const r = o.getMesh(), n = r.numProp, i = r.vertProperties.length / n, c = new Float32Array(i * 3);
|
|
2291
|
+
for (let a = 0; a < i; a++)
|
|
2292
|
+
c[a * 3] = r.vertProperties[a * n], c[a * 3 + 1] = r.vertProperties[a * n + 1], c[a * 3 + 2] = r.vertProperties[a * n + 2];
|
|
2293
|
+
return { positions: c, indices: new Uint32Array(r.triVerts) };
|
|
2294
|
+
}
|
|
2295
|
+
function St(o, r, n) {
|
|
2296
|
+
try {
|
|
2297
|
+
const i = vn(o, r, n);
|
|
2298
|
+
return i.merge(), new o.Manifold(i);
|
|
2299
|
+
} catch {
|
|
2300
|
+
return null;
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
function un(o, r, n) {
|
|
2304
|
+
let i = null;
|
|
2305
|
+
try {
|
|
2306
|
+
const f = vn(o, r, n);
|
|
2307
|
+
f.tolerance = 1e-8, i = new o.Manifold(f);
|
|
2308
|
+
} catch {
|
|
2309
|
+
i = St(o, r, n);
|
|
2310
|
+
}
|
|
2311
|
+
if (!i) throw new Error("爪扣网格无法构建实体");
|
|
2312
|
+
const c = i.decompose();
|
|
2313
|
+
if (c.length <= 1) {
|
|
2314
|
+
for (const f of c) f.delete();
|
|
2315
|
+
return i;
|
|
2316
|
+
}
|
|
2317
|
+
i.delete();
|
|
2318
|
+
let a = c[0];
|
|
2319
|
+
for (let f = 1; f < c.length; f++) {
|
|
2320
|
+
const d = a.add(c[f]);
|
|
2321
|
+
a.delete(), c[f].delete(), a = d;
|
|
2322
|
+
}
|
|
2323
|
+
if (a.status() !== "NoError")
|
|
2324
|
+
throw a.delete(), new Error("爪扣网格无法构建实体");
|
|
2325
|
+
return a;
|
|
2326
|
+
}
|
|
2327
|
+
function Fe(o, r, n) {
|
|
2328
|
+
let i = ue(r, n);
|
|
2329
|
+
i = dn(i.positions, i.indices), i = ue(i.positions, i.indices, 1e-4);
|
|
2330
|
+
let c = St(o, i.positions, i.indices);
|
|
2331
|
+
if (!c)
|
|
2332
|
+
try {
|
|
2333
|
+
const f = o.Manifold.hull(
|
|
2334
|
+
Array.from({ length: i.positions.length / 3 }, (v, y) => [
|
|
2335
|
+
i.positions[y * 3],
|
|
2336
|
+
i.positions[y * 3 + 1],
|
|
2337
|
+
i.positions[y * 3 + 2]
|
|
2338
|
+
])
|
|
2339
|
+
), d = at(f);
|
|
2340
|
+
return f.delete(), d;
|
|
2341
|
+
} catch {
|
|
2342
|
+
return i;
|
|
2343
|
+
}
|
|
2344
|
+
const a = at(c);
|
|
2345
|
+
return c.delete(), a;
|
|
2346
|
+
}
|
|
2347
|
+
function fn(o, r, n) {
|
|
2348
|
+
const i = Math.max(1.001, n);
|
|
2349
|
+
return o.translate([-r[0], -r[1], -r[2]]).scale(i).translate(r);
|
|
2350
|
+
}
|
|
2351
|
+
function Po(o, r, n, i, c, a, f, d, v, y, m, k) {
|
|
2352
|
+
const b = r.intersect(n), x = Math.abs(b.volume());
|
|
2353
|
+
if (!(x > 1e-10))
|
|
2354
|
+
throw b.delete(), new Error("无有效交集");
|
|
2355
|
+
const E = f >= d, g = E ? r : n, P = E ? n : r, M = E ? [-a.normal[0], -a.normal[1], -a.normal[2]] : [a.normal[0], a.normal[1], a.normal[2]], F = a.center, I = at(b), z = a.bbox ?? $t(I.positions, I.indices).bbox, T = po(x, a.area), S = Math.max(mo(z.min, z.max, M), 1e-3), w = Math.sqrt(Math.max(a.area, 1e-6)), B = Math.max(Math.cbrt(x), w * 0.25, 1e-3), R = P.subtract(g);
|
|
2356
|
+
let j = R.add(b);
|
|
2357
|
+
R.delete();
|
|
2358
|
+
let O;
|
|
2359
|
+
if (T) {
|
|
2360
|
+
const L = 1 + Math.max(S * 0.15, w * 0.01, 1e-3) / B, U = fn(b, F, L);
|
|
2361
|
+
O = g.subtract(U), U.delete();
|
|
2362
|
+
} else {
|
|
2363
|
+
const D = Math.max(w * 0.04, S * 0.06, 0.15), L = 1 + D / B;
|
|
2364
|
+
let U = fn(b, F, L);
|
|
2365
|
+
const J = S * 0.35 + D, X = U.translate([M[0] * J, M[1] * J, M[2] * J]);
|
|
2366
|
+
U.delete(), U = X, O = g.subtract(U), U.delete();
|
|
2367
|
+
}
|
|
2368
|
+
if (b.delete(), v === "sphere" || v === "square" || v === "ballSnap" || v === "qiuSnap") {
|
|
2369
|
+
const D = a.span && a.span > 1e-9 ? pn(a.span, y) : yo(a.area, m, z.min, z.max, M, y);
|
|
2370
|
+
if (D > 1e-12)
|
|
2371
|
+
try {
|
|
2372
|
+
const U = ho(at(j).positions, M, 0.99) - (M[0] * F[0] + M[1] * F[1] + M[2] * F[2]), J = ao(F, M, D, U), X = v === "ballSnap" || v === "qiuSnap" ? at(g).positions : void 0, rt = gn(
|
|
2373
|
+
o,
|
|
2374
|
+
O,
|
|
2375
|
+
j,
|
|
2376
|
+
M,
|
|
2377
|
+
J,
|
|
2378
|
+
v,
|
|
2379
|
+
D,
|
|
2380
|
+
k,
|
|
2381
|
+
!0,
|
|
2382
|
+
F,
|
|
2383
|
+
X
|
|
2384
|
+
);
|
|
2385
|
+
O = rt.pos, j = rt.neg;
|
|
2386
|
+
} catch (L) {
|
|
2387
|
+
throw O.delete(), j.delete(), L;
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
return r.delete(), n.delete(), E ? { a: O, b: j } : { a: j, b: O };
|
|
2391
|
+
}
|
|
2392
|
+
function Co(o, r, n, i) {
|
|
2393
|
+
const c = o.intersect(r);
|
|
2394
|
+
if (Math.abs(c.volume()) > 1e-10) return c;
|
|
2395
|
+
c.delete();
|
|
2396
|
+
const a = i[0] - n[0], f = i[1] - n[1], d = i[2] - n[2], v = Math.hypot(a, f, d) || 1, y = Math.max(1e-3, v * 2e-3), m = a / v * y, k = f / v * y, b = d / v * y;
|
|
2397
|
+
for (const x of [1, -1]) {
|
|
2398
|
+
const E = o.translate([m * x, k * x, b * x]), g = E.intersect(r);
|
|
2399
|
+
if (E.delete(), Math.abs(g.volume()) > 1e-10) return g;
|
|
2400
|
+
g.delete();
|
|
2401
|
+
}
|
|
2402
|
+
return null;
|
|
2403
|
+
}
|
|
2404
|
+
function To(o, r, n, i, c, a, f, d, v = !1) {
|
|
2405
|
+
const y = en(a.ao.positions, a.ao.indices), m = en(a.tu.positions, a.tu.indices), k = Mo(y, m, c), { normal: b } = bt(i, 0), x = b[0] * f[0] + b[1] * f[1] + b[2] * f[2];
|
|
2406
|
+
let E = f, g = f;
|
|
2407
|
+
if (k > 0 && v) {
|
|
2408
|
+
const R = Te(f, b, x, k, wo(k));
|
|
2409
|
+
E = R, g = R;
|
|
2410
|
+
} else if (k > 0) {
|
|
2411
|
+
const j = sn(
|
|
2412
|
+
d ?? at(r).positions,
|
|
2413
|
+
f,
|
|
2414
|
+
b,
|
|
2415
|
+
Math.max(c * 0.55, 1),
|
|
2416
|
+
0.04
|
|
2417
|
+
), O = sn(
|
|
2418
|
+
at(n).positions,
|
|
2419
|
+
f,
|
|
2420
|
+
b,
|
|
2421
|
+
Math.max(c * 1.25, 1e-3),
|
|
2422
|
+
0.95
|
|
2423
|
+
);
|
|
2424
|
+
let L = (O ?? x) - 0.25;
|
|
2425
|
+
j != null && L > j && (L = j), E = Te(f, b, L, k, 0), g = O != null ? Te(f, b, O, k, 0.25) : E;
|
|
2426
|
+
}
|
|
2427
|
+
const P = $o(y, m, b, E, c, g), M = un(o, y.positions, y.indices), F = un(o, m.positions, m.indices), I = M.transform(P.aoMatrix);
|
|
2428
|
+
M.delete();
|
|
2429
|
+
const z = F.transform(P.tuMatrix);
|
|
2430
|
+
F.delete();
|
|
2431
|
+
const T = o.Manifold.cylinder(P.clearLength, P.clearRadius, P.clearRadius, 48, !0).transform(
|
|
2432
|
+
fe(i, P.clearCenter)
|
|
2433
|
+
), S = r.subtract(T);
|
|
2434
|
+
r.delete(), T.delete();
|
|
2435
|
+
const w = S.add(I);
|
|
2436
|
+
S.delete(), I.delete();
|
|
2437
|
+
const B = n.add(z);
|
|
2438
|
+
return n.delete(), z.delete(), { pos: w, neg: B };
|
|
2439
|
+
}
|
|
2440
|
+
function gn(o, r, n, i, c, a, f, d, v = !1, y, m, k = !1) {
|
|
2441
|
+
const b = v ? c : so(c, i, f), x = fe(i, b), E = oo(f);
|
|
2442
|
+
if (a === "qiuSnap" || a === "ballSnap") {
|
|
2443
|
+
if (!d) throw new Error("爪扣模型未加载");
|
|
2444
|
+
return To(
|
|
2445
|
+
o,
|
|
2446
|
+
r,
|
|
2447
|
+
n,
|
|
2448
|
+
i,
|
|
2449
|
+
f,
|
|
2450
|
+
d,
|
|
2451
|
+
y ?? c,
|
|
2452
|
+
m,
|
|
2453
|
+
k
|
|
2454
|
+
);
|
|
2455
|
+
}
|
|
2456
|
+
if (a === "sphere") {
|
|
2457
|
+
const z = f / 2, T = z + E, S = o.Manifold.sphere(T, 28).transform(x), w = o.Manifold.cylinder(f, T, T, 28, !0).transform(x), B = S.add(w);
|
|
2458
|
+
S.delete(), w.delete();
|
|
2459
|
+
const R = o.Manifold.sphere(z, 28).transform(x), j = r.subtract(B), O = n.add(R);
|
|
2460
|
+
return r.delete(), n.delete(), B.delete(), R.delete(), { pos: j, neg: O };
|
|
2461
|
+
}
|
|
2462
|
+
const g = f + 2 * E, P = o.Manifold.cube([g, g, g], !0).transform(x), M = o.Manifold.cube([f, f, f], !0).transform(x), F = r.subtract(P), I = n.add(M);
|
|
2463
|
+
return r.delete(), n.delete(), P.delete(), M.delete(), { pos: F, neg: I };
|
|
2464
|
+
}
|
|
2465
|
+
function So(o, r, n, i) {
|
|
2466
|
+
let c;
|
|
2467
|
+
if (r === "box")
|
|
2468
|
+
c = o.Manifold.cube([n[0] || 10, n[1] || 10, n[2] || 10], !0);
|
|
2469
|
+
else if (r === "cylinder")
|
|
2470
|
+
c = o.Manifold.cylinder(n[1] || 20, n[0] || 5, n[0] || 5, 32, !0);
|
|
2471
|
+
else if (r === "sphere")
|
|
2472
|
+
c = o.Manifold.sphere(n[0] || 8, 24);
|
|
2473
|
+
else {
|
|
2474
|
+
const a = Math.max(3, Math.floor(n[2] || 6)), f = n[0] || 8, d = n[1] || 16, v = Array.from({ length: a }, (y, m) => {
|
|
2475
|
+
const k = m / a * Math.PI * 2;
|
|
2476
|
+
return [Math.cos(k) * f, Math.sin(k) * f];
|
|
2477
|
+
});
|
|
2478
|
+
c = o.Manifold.extrude([v], d, 0, 0, [1, 1], !0);
|
|
2479
|
+
}
|
|
2480
|
+
return c.transform(i);
|
|
2481
|
+
}
|
|
2482
|
+
function Tt(o, r, n) {
|
|
2483
|
+
switch (r.kind) {
|
|
2484
|
+
case "primary": {
|
|
2485
|
+
const i = n[r.meshId];
|
|
2486
|
+
if (!i) return { solid: null, buffers: { positions: new Float32Array(), indices: new Uint32Array() } };
|
|
2487
|
+
const c = nn(i.positions, r.transform);
|
|
2488
|
+
return { solid: St(o, c, i.indices), buffers: { positions: c, indices: i.indices } };
|
|
2489
|
+
}
|
|
2490
|
+
case "primitive": {
|
|
2491
|
+
const i = So(o, r.type, r.params, r.transform);
|
|
2492
|
+
return { solid: i, buffers: at(i) };
|
|
2493
|
+
}
|
|
2494
|
+
case "transform": {
|
|
2495
|
+
const i = Tt(o, r.node, n);
|
|
2496
|
+
if (i.solid) {
|
|
2497
|
+
const c = i.solid.transform(r.transform);
|
|
2498
|
+
return i.solid.delete(), { solid: c, buffers: at(c) };
|
|
2499
|
+
}
|
|
2500
|
+
return {
|
|
2501
|
+
solid: null,
|
|
2502
|
+
buffers: {
|
|
2503
|
+
positions: nn(i.buffers.positions, r.transform),
|
|
2504
|
+
indices: i.buffers.indices
|
|
2505
|
+
}
|
|
2506
|
+
};
|
|
2507
|
+
}
|
|
2508
|
+
case "clean": {
|
|
2509
|
+
const i = Tt(o, r.node, n), c = Fe(o, i.buffers.positions, i.buffers.indices);
|
|
2510
|
+
return i.solid?.delete(), { solid: St(o, c.positions, c.indices), buffers: c };
|
|
2511
|
+
}
|
|
2512
|
+
case "simplify": {
|
|
2513
|
+
const i = Tt(o, r.node, n);
|
|
2514
|
+
if (i.solid) {
|
|
2515
|
+
const c = i.solid.boundingBox(), a = Math.hypot(
|
|
2516
|
+
c.max[0] - c.min[0],
|
|
2517
|
+
c.max[1] - c.min[1],
|
|
2518
|
+
c.max[2] - c.min[2]
|
|
2519
|
+
), f = i.solid.simplify(a * (1 - r.targetRatio) * 0.02);
|
|
2520
|
+
return i.solid.delete(), { solid: f, buffers: at(f) };
|
|
2521
|
+
}
|
|
2522
|
+
return i;
|
|
2523
|
+
}
|
|
2524
|
+
case "sliceBase": {
|
|
2525
|
+
const i = Tt(o, r.node, n);
|
|
2526
|
+
if (i.solid) {
|
|
2527
|
+
const c = r.axis === "x" ? [1, 0, 0] : r.axis === "y" ? [0, 1, 0] : [0, 0, 1], a = i.solid.trimByPlane(c, r.height);
|
|
2528
|
+
return i.solid.delete(), { solid: a, buffers: at(a) };
|
|
2529
|
+
}
|
|
2530
|
+
return i;
|
|
2531
|
+
}
|
|
2532
|
+
case "trimPlane": {
|
|
2533
|
+
const i = Tt(o, r.node, n);
|
|
2534
|
+
let c = i;
|
|
2535
|
+
if (!c.solid) {
|
|
2536
|
+
const a = Fe(o, c.buffers.positions, c.buffers.indices);
|
|
2537
|
+
i.solid?.delete(), c = {
|
|
2538
|
+
solid: St(o, a.positions, a.indices),
|
|
2539
|
+
buffers: a
|
|
2540
|
+
};
|
|
2541
|
+
}
|
|
2542
|
+
if (c.solid) {
|
|
2543
|
+
const a = Math.hypot(r.normal[0], r.normal[1], r.normal[2]) || 1, f = [
|
|
2544
|
+
r.normal[0] / a,
|
|
2545
|
+
r.normal[1] / a,
|
|
2546
|
+
r.normal[2] / a
|
|
2547
|
+
], d = c.solid.trimByPlane(f, r.offset / a);
|
|
2548
|
+
return c.solid.delete(), { solid: d, buffers: at(d) };
|
|
2549
|
+
}
|
|
2550
|
+
return c;
|
|
2551
|
+
}
|
|
2552
|
+
case "boolean": {
|
|
2553
|
+
const i = Tt(o, r.a, n), c = Tt(o, r.b, n), a = (v) => {
|
|
2554
|
+
if (v.solid) return v;
|
|
2555
|
+
const y = Fe(o, v.buffers.positions, v.buffers.indices);
|
|
2556
|
+
return { solid: St(o, y.positions, y.indices), buffers: y };
|
|
2557
|
+
}, f = a(i), d = a(c);
|
|
2558
|
+
if (f.solid && d.solid) {
|
|
2559
|
+
const v = r.op === "union" ? f.solid.add(d.solid) : r.op === "difference" ? f.solid.subtract(d.solid) : f.solid.intersect(d.solid);
|
|
2560
|
+
return f.solid.delete(), d.solid.delete(), { solid: v, buffers: at(v) };
|
|
2561
|
+
}
|
|
2562
|
+
return f.solid?.delete(), d.solid?.delete(), f;
|
|
2563
|
+
}
|
|
2564
|
+
case "merge": {
|
|
2565
|
+
const i = r.nodes.map((a) => Tt(o, a, n)), c = i.map((a) => a.solid).filter((a) => !!a);
|
|
2566
|
+
if (c.length) {
|
|
2567
|
+
const a = c.length === 1 ? c[0] : o.Manifold.union(c);
|
|
2568
|
+
return i.forEach((f, d) => {
|
|
2569
|
+
(c.length > 1 || d > 0) && f.solid?.delete();
|
|
2570
|
+
}), { solid: a, buffers: at(a) };
|
|
2571
|
+
}
|
|
2572
|
+
return i[0] ?? { solid: null, buffers: { positions: new Float32Array(), indices: new Uint32Array() } };
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
function Fo(o, r, n) {
|
|
2577
|
+
const i = [];
|
|
2578
|
+
let c = 0, a = 0, f = 0, d = 0, v = 0, y = 0, m = 0, k = !1;
|
|
2579
|
+
const b = [1 / 0, 1 / 0, 1 / 0], x = [-1 / 0, -1 / 0, -1 / 0];
|
|
2580
|
+
let E = 1 / 0;
|
|
2581
|
+
o.forEach((I, z) => {
|
|
2582
|
+
const T = $t(I.positions, I.indices);
|
|
2583
|
+
c += T.triangleCount, a += T.vertexCount, f += T.volume, d += T.surfaceArea, v += T.openEdgeCount, y += T.nonManifoldEdgeCount, m += T.componentCount, k = k || T.invertedNormals, E = Math.min(E, Qr(I.positions, I.indices));
|
|
2584
|
+
for (let S = 0; S < 3; S++)
|
|
2585
|
+
b[S] = Math.min(b[S], T.bbox.min[S]), x[S] = Math.max(x[S], T.bbox.max[S]);
|
|
2586
|
+
});
|
|
2587
|
+
const g = v === 0, P = y === 0 && n.every(Boolean) && g, M = !n.every(Boolean) && g, F = (I) => i.push(I);
|
|
2588
|
+
return y > 0 ? F({
|
|
2589
|
+
id: "nonmanifold",
|
|
2590
|
+
level: "red",
|
|
2591
|
+
title: "非流形边",
|
|
2592
|
+
explanation: "一条边被超过两个三角形共享,切片器无法判断内外,这会导致打印件断成两截。",
|
|
2593
|
+
count: y,
|
|
2594
|
+
blocking: !0
|
|
2595
|
+
}) : F({ id: "nonmanifold", level: "green", title: "流形边检查通过", explanation: "每条边最多被两个三角形共享。", blocking: !1 }), F(g ? { id: "watertight", level: "green", title: "水密检查通过", explanation: "网格封闭,可以计算体积。", blocking: !1 } : {
|
|
2596
|
+
id: "watertight",
|
|
2597
|
+
level: "red",
|
|
2598
|
+
title: "表面不水密",
|
|
2599
|
+
explanation: "存在开边或破洞,体积无法准确计算,切片时可能缺层。",
|
|
2600
|
+
count: v,
|
|
2601
|
+
blocking: !0
|
|
2602
|
+
}), F(M ? {
|
|
2603
|
+
id: "selfintersect",
|
|
2604
|
+
level: "red",
|
|
2605
|
+
title: "自相交或无法构建实体",
|
|
2606
|
+
explanation: "三角形互相穿透或拓扑无法形成实体,布尔与切片均不可靠。",
|
|
2607
|
+
blocking: !0
|
|
2608
|
+
} : { id: "selfintersect", level: "green", title: "自交检查通过", explanation: "几何内核可以构造成实体。", blocking: !1 }), E > 0 && E < r ? F({
|
|
2609
|
+
id: "thinwall",
|
|
2610
|
+
level: "yellow",
|
|
2611
|
+
title: "薄壁",
|
|
2612
|
+
explanation: `最薄处约 ${E.toFixed(2)} mm,低于常用打印工艺下限,切片后可能消失。`,
|
|
2613
|
+
blocking: !1
|
|
2614
|
+
}) : F({ id: "thinwall", level: "green", title: "壁厚检查通过", explanation: "采样壁厚高于设定下限。", blocking: !1 }), m > o.length ? F({
|
|
2615
|
+
id: "islands",
|
|
2616
|
+
level: "yellow",
|
|
2617
|
+
title: "浮空碎片",
|
|
2618
|
+
explanation: "与主体不连通的游离几何体,打印时可能掉落或单独成件。",
|
|
2619
|
+
count: m,
|
|
2620
|
+
blocking: !1
|
|
2621
|
+
}) : F({ id: "islands", level: "green", title: "连通性通过", explanation: "未发现多余的游离碎片。", blocking: !1 }), F(k ? {
|
|
2622
|
+
id: "normals",
|
|
2623
|
+
level: "yellow",
|
|
2624
|
+
title: "法线反向",
|
|
2625
|
+
explanation: "部分面朝向内侧,可能被切片器误判为空洞。",
|
|
2626
|
+
blocking: !1
|
|
2627
|
+
} : { id: "normals", level: "green", title: "法线方向正常", explanation: "体积符号为正,外法线朝外。", blocking: !1 }), {
|
|
2628
|
+
items: i,
|
|
2629
|
+
triangleCount: c,
|
|
2630
|
+
vertexCount: a,
|
|
2631
|
+
volumeMm3: Math.abs(f),
|
|
2632
|
+
surfaceAreaMm2: d,
|
|
2633
|
+
bbox: {
|
|
2634
|
+
min: b,
|
|
2635
|
+
max: x,
|
|
2636
|
+
size: [x[0] - b[0], x[1] - b[1], x[2] - b[2]]
|
|
2637
|
+
},
|
|
2638
|
+
watertight: g,
|
|
2639
|
+
manifold: P,
|
|
2640
|
+
selfIntersect: M,
|
|
2641
|
+
invertedNormals: k,
|
|
2642
|
+
openEdgeCount: v,
|
|
2643
|
+
nonManifoldEdgeCount: y,
|
|
2644
|
+
componentCount: m,
|
|
2645
|
+
minThicknessMm: Number.isFinite(E) ? E : 0
|
|
2646
|
+
};
|
|
2647
|
+
}
|
|
2648
|
+
self.onmessage = async (o) => {
|
|
2649
|
+
const r = o.data, n = (i) => self.postMessage(i);
|
|
2650
|
+
try {
|
|
2651
|
+
if (r.type === "init") {
|
|
2652
|
+
r.wasmBinary && (Ie = r.wasmBinary), await Zt(), n({ id: r.id, type: "ready" });
|
|
2653
|
+
return;
|
|
2654
|
+
}
|
|
2655
|
+
if (r.type === "evaluate") {
|
|
2656
|
+
const i = await Zt(), c = [], a = [], f = [];
|
|
2657
|
+
for (const y of r.roots) {
|
|
2658
|
+
const m = Tt(i, y, r.sources);
|
|
2659
|
+
c.push(m.buffers), a.push(!!m.solid && m.solid.status() === "NoError"), m.solid?.delete(), r.wantThicknessColors && f.push(to(m.buffers.positions, m.buffers.indices, r.wallMinMm));
|
|
2660
|
+
}
|
|
2661
|
+
const d = c.map((y, m) => eo(y.positions, y.indices, r.wallMinMm, m)), v = Fo(c, r.wallMinMm, a);
|
|
2662
|
+
n({
|
|
2663
|
+
id: r.id,
|
|
2664
|
+
type: "evaluated",
|
|
2665
|
+
meshes: c,
|
|
2666
|
+
diagnosis: v,
|
|
2667
|
+
thicknessColors: r.wantThicknessColors ? f : void 0,
|
|
2668
|
+
defects: d
|
|
2669
|
+
});
|
|
2670
|
+
return;
|
|
2671
|
+
}
|
|
2672
|
+
if (r.type === "decompose") {
|
|
2673
|
+
const i = await Zt(), c = St(i, r.mesh.positions, r.mesh.indices);
|
|
2674
|
+
if (!c) {
|
|
2675
|
+
n({ id: r.id, type: "decomposed", meshes: [r.mesh] });
|
|
2676
|
+
return;
|
|
2677
|
+
}
|
|
2678
|
+
const a = c.decompose();
|
|
2679
|
+
c.delete();
|
|
2680
|
+
const f = a.map((d) => {
|
|
2681
|
+
const v = at(d);
|
|
2682
|
+
return d.delete(), v;
|
|
2683
|
+
});
|
|
2684
|
+
n({ id: r.id, type: "decomposed", meshes: f.length ? f : [r.mesh] });
|
|
2685
|
+
return;
|
|
2686
|
+
}
|
|
2687
|
+
if (r.type === "splitByPlane") {
|
|
2688
|
+
const i = await Zt(), c = Math.hypot(r.normal[0], r.normal[1], r.normal[2]) || 1, a = [r.normal[0] / c, r.normal[1] / c, r.normal[2] / c], f = r.offset / c;
|
|
2689
|
+
let d = St(i, r.mesh.positions, r.mesh.indices);
|
|
2690
|
+
if (!d) {
|
|
2691
|
+
n({ id: r.id, type: "error", message: "当前网格无法构建实体,请先修复再拆件" });
|
|
2692
|
+
return;
|
|
2693
|
+
}
|
|
2694
|
+
const v = r.connector === "sphere" || r.connector === "square" || r.connector === "ballSnap" || r.connector === "qiuSnap";
|
|
2695
|
+
if ((r.connector === "ballSnap" || r.connector === "qiuSnap") && !r.qiuSnap) {
|
|
2696
|
+
d.delete(), n({ id: r.id, type: "error", message: "爪扣模型未加载" });
|
|
2697
|
+
return;
|
|
2698
|
+
}
|
|
2699
|
+
const y = r.width, m = r.height, k = !!(y && m && y > 0 && m > 0), b = $t(r.mesh.positions, r.mesh.indices), x = Nt(r.mesh.positions);
|
|
2700
|
+
let E = [r.center[0], r.center[1], r.center[2]], g = { min: b.bbox.min, max: b.bbox.max }, P = 0;
|
|
2701
|
+
const M = (T) => {
|
|
2702
|
+
if (!(Math.abs(T.volume()) > 1e-10)) return;
|
|
2703
|
+
const S = at(T), w = [
|
|
2704
|
+
x[0] + a[0],
|
|
2705
|
+
x[1] + a[1],
|
|
2706
|
+
x[2] + a[2]
|
|
2707
|
+
], B = an(S, x, w);
|
|
2708
|
+
if (B && B.area > 1e-12) {
|
|
2709
|
+
E = B.center, g = B.bbox, P = B.span;
|
|
2710
|
+
return;
|
|
2711
|
+
}
|
|
2712
|
+
E = Nt(S.positions);
|
|
2713
|
+
const R = $t(S.positions, S.indices);
|
|
2714
|
+
g = { min: R.bbox.min, max: R.bbox.max };
|
|
2715
|
+
};
|
|
2716
|
+
let F, I;
|
|
2717
|
+
if (k) {
|
|
2718
|
+
const T = v ? 1e-3 : Math.max(r.gapMm, 1e-3), S = i.Manifold.cube([y, m, T], !0).transform(
|
|
2719
|
+
fe(a, r.center)
|
|
2720
|
+
), w = d.intersect(S);
|
|
2721
|
+
if (!(Math.abs(w.volume()) > 1e-10)) {
|
|
2722
|
+
w.delete(), S.delete();
|
|
2723
|
+
const U = [at(d)];
|
|
2724
|
+
d.delete(), n({ id: r.id, type: "splitByPlane", meshes: U });
|
|
2725
|
+
return;
|
|
2726
|
+
}
|
|
2727
|
+
v && M(w), w.delete();
|
|
2728
|
+
const R = d.subtract(S);
|
|
2729
|
+
d.delete(), S.delete();
|
|
2730
|
+
const j = R.decompose();
|
|
2731
|
+
if (R.delete(), j.length < 2) {
|
|
2732
|
+
const U = j.length ? [at(j[0])] : [r.mesh];
|
|
2733
|
+
for (const J of j) J.delete();
|
|
2734
|
+
n({ id: r.id, type: "splitByPlane", meshes: U });
|
|
2735
|
+
return;
|
|
2736
|
+
}
|
|
2737
|
+
const O = [], D = [];
|
|
2738
|
+
for (const U of j) {
|
|
2739
|
+
const J = Nt(at(U).positions);
|
|
2740
|
+
a[0] * J[0] + a[1] * J[1] + a[2] * J[2] >= f ? O.push(U) : D.push(U);
|
|
2741
|
+
}
|
|
2742
|
+
const L = (U) => {
|
|
2743
|
+
let J = U[0];
|
|
2744
|
+
for (let X = 1; X < U.length; X++) {
|
|
2745
|
+
const rt = J.add(U[X]);
|
|
2746
|
+
J.delete(), U[X].delete(), J = rt;
|
|
2747
|
+
}
|
|
2748
|
+
return J;
|
|
2749
|
+
};
|
|
2750
|
+
if (O.length && D.length)
|
|
2751
|
+
F = L(O), I = L(D);
|
|
2752
|
+
else {
|
|
2753
|
+
const U = j.map((J) => ({ p: J, vol: Math.abs(J.volume()) }));
|
|
2754
|
+
U.sort((J, X) => X.vol - J.vol), F = U[0].p, I = L(U.slice(1).map((J) => J.p));
|
|
2755
|
+
}
|
|
2756
|
+
} else {
|
|
2757
|
+
if (v) {
|
|
2758
|
+
const { x: w, y: B } = Ht(a);
|
|
2759
|
+
let R = 1 / 0, j = -1 / 0, O = 1 / 0, D = -1 / 0;
|
|
2760
|
+
const L = b.bbox.min, U = b.bbox.max;
|
|
2761
|
+
for (const G of [L[0], U[0]])
|
|
2762
|
+
for (const Y of [L[1], U[1]])
|
|
2763
|
+
for (const mt of [L[2], U[2]]) {
|
|
2764
|
+
const ft = G * w[0] + Y * w[1] + mt * w[2], ut = G * B[0] + Y * B[1] + mt * B[2];
|
|
2765
|
+
ft < R && (R = ft), ft > j && (j = ft), ut < O && (O = ut), ut > D && (D = ut);
|
|
2766
|
+
}
|
|
2767
|
+
const J = Math.max(j - R, 1e-3) * 1.05, X = Math.max(D - O, 1e-3) * 1.05, rt = i.Manifold.cube([J, X, 1e-3], !0).transform(
|
|
2768
|
+
fe(a, r.center)
|
|
2769
|
+
), H = d.intersect(rt);
|
|
2770
|
+
M(H), H.delete(), rt.delete();
|
|
2771
|
+
}
|
|
2772
|
+
const T = d.splitByPlane(a, f);
|
|
2773
|
+
d.delete();
|
|
2774
|
+
const S = v ? 0 : Math.max(0, r.gapMm) / 2;
|
|
2775
|
+
if (F = T[0], I = T[1], S > 1e-9) {
|
|
2776
|
+
const w = F.trimByPlane(a, f + S), B = I.trimByPlane([-a[0], -a[1], -a[2]], -f + S);
|
|
2777
|
+
F.delete(), I.delete(), F = w, I = B;
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
if (v) {
|
|
2781
|
+
const T = P > 1e-9 ? pn(P, r.connectorSize) : yn(g.min, g.max, a, r.connectorSize);
|
|
2782
|
+
if (T > 1e-12)
|
|
2783
|
+
try {
|
|
2784
|
+
const S = gn(
|
|
2785
|
+
i,
|
|
2786
|
+
F,
|
|
2787
|
+
I,
|
|
2788
|
+
a,
|
|
2789
|
+
E,
|
|
2790
|
+
r.connector,
|
|
2791
|
+
T,
|
|
2792
|
+
r.qiuSnap,
|
|
2793
|
+
!1,
|
|
2794
|
+
E,
|
|
2795
|
+
void 0,
|
|
2796
|
+
!0
|
|
2797
|
+
);
|
|
2798
|
+
F = S.pos, I = S.neg;
|
|
2799
|
+
} catch (S) {
|
|
2800
|
+
F.delete(), I.delete(), n({
|
|
2801
|
+
id: r.id,
|
|
2802
|
+
type: "error",
|
|
2803
|
+
message: S instanceof Error ? `卡扣布尔失败:${S.message}` : "卡扣布尔失败"
|
|
2804
|
+
});
|
|
2805
|
+
return;
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
2808
|
+
const z = [at(F), at(I)];
|
|
2809
|
+
if (F.delete(), I.delete(), z.some((T) => !T.indices.length)) {
|
|
2810
|
+
n({ id: r.id, type: "error", message: "切面未把模型分成两块,请调整切面位置" });
|
|
2811
|
+
return;
|
|
2812
|
+
}
|
|
2813
|
+
n({ id: r.id, type: "splitByPlane", meshes: z });
|
|
2814
|
+
return;
|
|
2815
|
+
}
|
|
2816
|
+
if (r.type === "assembleByContacts") {
|
|
2817
|
+
const i = await Zt(), c = r.meshes.length;
|
|
2818
|
+
if (c < 2) {
|
|
2819
|
+
n({ id: r.id, type: "error", message: "至少需要 2 个零件才能按接触面装配" });
|
|
2820
|
+
return;
|
|
2821
|
+
}
|
|
2822
|
+
if ((r.connector === "ballSnap" || r.connector === "qiuSnap") && !r.qiuSnap) {
|
|
2823
|
+
n({ id: r.id, type: "error", message: "爪扣模型未加载" });
|
|
2824
|
+
return;
|
|
2825
|
+
}
|
|
2826
|
+
const a = [], f = [], d = [], v = [];
|
|
2827
|
+
for (let g = 0; g < c; g++) {
|
|
2828
|
+
const P = r.meshes[g], M = $t(P.positions, P.indices);
|
|
2829
|
+
if (M.openEdgeCount > 0 || M.nonManifoldEdgeCount > 0) {
|
|
2830
|
+
for (const I of a) I?.delete();
|
|
2831
|
+
n({
|
|
2832
|
+
id: r.id,
|
|
2833
|
+
type: "error",
|
|
2834
|
+
message: `零件 ${g + 1} 不是封闭实体,请先修复再装配`
|
|
2835
|
+
});
|
|
2836
|
+
return;
|
|
2837
|
+
}
|
|
2838
|
+
const F = St(i, P.positions, P.indices);
|
|
2839
|
+
if (!F) {
|
|
2840
|
+
for (const I of a) I?.delete();
|
|
2841
|
+
n({ id: r.id, type: "error", message: `零件 ${g + 1} 无法构建实体` });
|
|
2842
|
+
return;
|
|
2843
|
+
}
|
|
2844
|
+
a.push(F), f.push(Nt(P.positions)), d.push(Math.abs(M.volume) || Math.abs(F.volume())), v.push({ min: M.bbox.min, max: M.bbox.max });
|
|
2845
|
+
}
|
|
2846
|
+
const y = [];
|
|
2847
|
+
for (let g = 0; g < c; g++)
|
|
2848
|
+
for (let P = g + 1; P < c; P++) {
|
|
2849
|
+
if (!co(v[g], v[P], 1e-3)) continue;
|
|
2850
|
+
const M = a[g], F = a[P], I = Co(M, F, f[g], f[P]);
|
|
2851
|
+
if (!I) continue;
|
|
2852
|
+
const z = at(I), T = Math.abs(I.volume());
|
|
2853
|
+
I.delete();
|
|
2854
|
+
const S = an(z, f[g], f[P]);
|
|
2855
|
+
!S || !(S.area > 1e-12) || !(T > 1e-10) || y.push({
|
|
2856
|
+
idxA: g,
|
|
2857
|
+
idxB: P,
|
|
2858
|
+
center: S.center,
|
|
2859
|
+
normal: S.normal,
|
|
2860
|
+
area: S.area,
|
|
2861
|
+
span: S.span,
|
|
2862
|
+
along: S.along,
|
|
2863
|
+
volume: T,
|
|
2864
|
+
bbox: S.bbox
|
|
2865
|
+
});
|
|
2866
|
+
}
|
|
2867
|
+
y.sort((g, P) => P.area - g.area);
|
|
2868
|
+
const m = y.length ? y[0].area : 0, k = [];
|
|
2869
|
+
let b = 0, x = 0;
|
|
2870
|
+
for (const g of y) {
|
|
2871
|
+
const P = a[g.idxA], M = a[g.idxB];
|
|
2872
|
+
if (!P || !M) {
|
|
2873
|
+
x++;
|
|
2874
|
+
continue;
|
|
2875
|
+
}
|
|
2876
|
+
try {
|
|
2877
|
+
const F = P.intersect(M), I = Math.abs(F.volume()) > 1e-10;
|
|
2878
|
+
if (F.delete(), !I) {
|
|
2879
|
+
x++;
|
|
2880
|
+
continue;
|
|
2881
|
+
}
|
|
2882
|
+
const z = Po(
|
|
2883
|
+
i,
|
|
2884
|
+
P,
|
|
2885
|
+
M,
|
|
2886
|
+
f[g.idxA],
|
|
2887
|
+
f[g.idxB],
|
|
2888
|
+
{ center: g.center, normal: g.normal, area: g.area, span: g.span, along: g.along, bbox: g.bbox },
|
|
2889
|
+
d[g.idxA],
|
|
2890
|
+
d[g.idxB],
|
|
2891
|
+
r.connector,
|
|
2892
|
+
r.connectorSize,
|
|
2893
|
+
m,
|
|
2894
|
+
r.qiuSnap
|
|
2895
|
+
);
|
|
2896
|
+
a[g.idxA] = z.a, a[g.idxB] = z.b;
|
|
2897
|
+
const T = at(z.a), S = at(z.b);
|
|
2898
|
+
f[g.idxA] = Nt(T.positions), f[g.idxB] = Nt(S.positions), d[g.idxA] = Math.abs($t(T.positions, T.indices).volume), d[g.idxB] = Math.abs($t(S.positions, S.indices).volume), v[g.idxA] = {
|
|
2899
|
+
min: $t(T.positions, T.indices).bbox.min,
|
|
2900
|
+
max: $t(T.positions, T.indices).bbox.max
|
|
2901
|
+
}, v[g.idxB] = {
|
|
2902
|
+
min: $t(S.positions, S.indices).bbox.min,
|
|
2903
|
+
max: $t(S.positions, S.indices).bbox.max
|
|
2904
|
+
}, k.push({
|
|
2905
|
+
idxA: g.idxA,
|
|
2906
|
+
idxB: g.idxB,
|
|
2907
|
+
center: g.center,
|
|
2908
|
+
normal: g.normal,
|
|
2909
|
+
area: g.area
|
|
2910
|
+
}), b++;
|
|
2911
|
+
} catch {
|
|
2912
|
+
x++;
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2915
|
+
if (b === 0 && y.length === 0) {
|
|
2916
|
+
for (const g of a) g?.delete();
|
|
2917
|
+
n({ id: r.id, type: "error", message: "未检测到零件间接触面,无法装配" });
|
|
2918
|
+
return;
|
|
2919
|
+
}
|
|
2920
|
+
const E = [];
|
|
2921
|
+
for (let g = 0; g < c; g++) {
|
|
2922
|
+
const P = a[g];
|
|
2923
|
+
if (!P) {
|
|
2924
|
+
E.push(r.meshes[g]);
|
|
2925
|
+
continue;
|
|
2926
|
+
}
|
|
2927
|
+
E.push(at(P)), P.delete();
|
|
2928
|
+
}
|
|
2929
|
+
n({
|
|
2930
|
+
id: r.id,
|
|
2931
|
+
type: "assembleByContacts",
|
|
2932
|
+
meshes: E,
|
|
2933
|
+
contacts: k,
|
|
2934
|
+
applied: b,
|
|
2935
|
+
skipped: x
|
|
2936
|
+
});
|
|
2937
|
+
}
|
|
2938
|
+
} catch (i) {
|
|
2939
|
+
n({ id: r.id, type: "error", message: i instanceof Error ? i.message : String(i) });
|
|
2940
|
+
}
|
|
2941
|
+
};
|
|
2942
|
+
var Io = /* @__PURE__ */ Object.freeze({
|
|
2943
|
+
__proto__: null
|
|
2944
|
+
});
|