printbench 0.8.3 → 0.8.6
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 +15 -13
- package/dist/assets/manifold.worker-CK5EaVev.js +2945 -0
- package/dist/chunks/{3mf-ECHCUgKd.js → 3mf-BrPsk9Z0.js} +1 -1
- package/dist/chunks/{glb-CHKLJs5K.js → glb-BUUnX9vf.js} +1 -1
- package/dist/chunks/index-DV7N04zK.js +7207 -0
- package/dist/chunks/loadModel-CVLPL06M.js +312 -0
- package/dist/chunks/{loadQiuSnap-YcUop96I.js → loadQiuSnap-BBWh09pT.js} +1 -1
- package/dist/chunks/{stl-CT_cOete.js → stl-BmF8aayc.js} +1 -1
- package/dist/printbench.css +1 -1
- package/dist/printbench.js +1 -1
- package/package.json +1 -1
- package/dist/assets/manifold.worker-C1p2Y56M.js +0 -2944
- package/dist/chunks/index-taUrTXAq.js +0 -6683
- package/dist/chunks/loadModel-C_oz9kz6.js +0 -294
|
@@ -0,0 +1,2945 @@
|
|
|
1
|
+
async function Yr(o = {}) {
|
|
2
|
+
var r, n = o, i = !!globalThis.window, a = !!globalThis.WorkerGlobalScope, c = globalThis.process?.versions?.node && globalThis.process?.type != "renderer";
|
|
3
|
+
if (c) {
|
|
4
|
+
const { createRequire: t } = await Promise.resolve().then(function() {
|
|
5
|
+
return Ao;
|
|
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, S = ((W) => W)) {
|
|
14
|
+
if (h)
|
|
15
|
+
for (let W of h)
|
|
16
|
+
u.push_back(S(W));
|
|
17
|
+
return u;
|
|
18
|
+
}
|
|
19
|
+
function e(u, h = ((S) => S)) {
|
|
20
|
+
const S = [], W = u.size();
|
|
21
|
+
for (let K = 0; K < W; K++) S.push(h(u.get(K)));
|
|
22
|
+
return S;
|
|
23
|
+
}
|
|
24
|
+
function s(u, h = ((S) => S)) {
|
|
25
|
+
const S = [], 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
|
+
S.push(yt);
|
|
31
|
+
}
|
|
32
|
+
return S;
|
|
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, (S) => S instanceof Array ? { x: S[0], y: S[1] } : S));
|
|
36
|
+
}
|
|
37
|
+
function p(u) {
|
|
38
|
+
for (let h = 0; h < u.size(); h++) u.get(h).delete();
|
|
39
|
+
u.delete();
|
|
40
|
+
}
|
|
41
|
+
function x(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 P(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 I(u) {
|
|
48
|
+
return u == "EvenOdd" ? 0 : u == "NonZero" ? 1 : u == "Negative" ? 3 : 2;
|
|
49
|
+
}
|
|
50
|
+
function B(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 S = l(u), W = new N(S, I(h));
|
|
59
|
+
return p(S), W;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
n.CrossSection.prototype.translate = function(...u) {
|
|
63
|
+
return this._Translate(x(u));
|
|
64
|
+
}, n.CrossSection.prototype.scale = function(u) {
|
|
65
|
+
return typeof u == "number" ? this._Scale({ x: u, y: u }) : this._Scale(x([u]));
|
|
66
|
+
}, n.CrossSection.prototype.mirror = function(u) {
|
|
67
|
+
return this._Mirror(x([u]));
|
|
68
|
+
}, n.CrossSection.prototype.warp = function(u) {
|
|
69
|
+
const h = Ot(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"), S = this._Warp(h);
|
|
73
|
+
return jt(h), S;
|
|
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", S = 2, W = 0) {
|
|
81
|
+
return this._Offset(u, B(h), S, W);
|
|
82
|
+
}, n.CrossSection.prototype.simplify = function(u = 1e-6) {
|
|
83
|
+
return this._Simplify(u);
|
|
84
|
+
}, n.CrossSection.prototype.extrude = function(u, h = 0, S = 0, W = [1, 1], K = !1) {
|
|
85
|
+
W = x([W]);
|
|
86
|
+
const Z = n._Extrude(this._ToPolygons(), u, h, S, 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, (S) => [S.x, S.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 = Ot(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"), S = this._Warp(h);
|
|
106
|
+
jt(h);
|
|
107
|
+
const W = S.status();
|
|
108
|
+
if (W !== "NoError")
|
|
109
|
+
throw new n.ManifoldError(W);
|
|
110
|
+
return S;
|
|
111
|
+
}, n.Manifold.prototype.warpBatch = function(u) {
|
|
112
|
+
const h = Ot(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"), S = this._WarpBatch(h);
|
|
119
|
+
jt(h);
|
|
120
|
+
const W = S.status();
|
|
121
|
+
if (W !== "NoError")
|
|
122
|
+
throw new n.ManifoldError(W);
|
|
123
|
+
return S;
|
|
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 S = this.numProp(), W = Ot(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 Et = [];
|
|
134
|
+
for (let it = 0; it < 3; ++it)
|
|
135
|
+
Et[it] = dt(ot + 8 * it, "double");
|
|
136
|
+
const Rt = [];
|
|
137
|
+
for (let it = 0; it < S; ++it)
|
|
138
|
+
Rt[it] = dt(yt + 8 * it, "double");
|
|
139
|
+
h(ct, Et, Rt);
|
|
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 jt(W), K;
|
|
144
|
+
}, n.Manifold.prototype.translate = function(...u) {
|
|
145
|
+
return this._Translate(P(u));
|
|
146
|
+
}, n.Manifold.prototype.rotate = function(u, h, S) {
|
|
147
|
+
return Array.isArray(u) ? this._Rotate(...u) : this._Rotate(u, h || 0, S || 0);
|
|
148
|
+
}, n.Manifold.prototype.scale = function(u) {
|
|
149
|
+
return typeof u == "number" ? this._Scale({ x: u, y: u, z: u }) : this._Scale(P([u]));
|
|
150
|
+
}, n.Manifold.prototype.mirror = function(u) {
|
|
151
|
+
return this._Mirror(P([u]));
|
|
152
|
+
}, n.Manifold.prototype.trimByPlane = function(u, h = 0) {
|
|
153
|
+
return this._TrimByPlane(P([u]), h);
|
|
154
|
+
}, n.Manifold.prototype.slice = function(u = 0) {
|
|
155
|
+
const h = this._Slice(u), S = new N(h, I("Positive"));
|
|
156
|
+
return p(h), S;
|
|
157
|
+
}, n.Manifold.prototype.project = function() {
|
|
158
|
+
const u = this._Project(), h = new N(u, I("Positive"));
|
|
159
|
+
return p(u), h;
|
|
160
|
+
}, n.Manifold.prototype.rayCast = function(u, h) {
|
|
161
|
+
const S = this._RayCast(P([u]), P([h])), W = e(S, (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 S.delete(), W;
|
|
163
|
+
}, n.Manifold.prototype.split = function(u) {
|
|
164
|
+
const h = this._Split(u), S = e(h);
|
|
165
|
+
return h.delete(), S;
|
|
166
|
+
}, n.Manifold.prototype.splitByPlane = function(u, h = 0) {
|
|
167
|
+
const S = this._SplitByPlane(P([u]), h), W = e(S);
|
|
168
|
+
return S.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: S = new Uint32Array(), vertProperties: W = new Float32Array(), mergeFromVert: K, mergeToVert: Z, runIndex: ot, runOriginalID: yt, faceID: ct, halfedgeTangent: Et, runTransform: Rt, runFlags: it, tolerance: Ce = 0 } = {}) {
|
|
180
|
+
this.numProp = h, this.triVerts = S, this.vertProperties = W, this.mergeFromVert = K, this.mergeToVert = Z, this.runIndex = ot, this.runOriginalID = yt, this.faceID = ct, this.halfedgeTangent = Et, this.runTransform = Rt, 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: S } = n._Merge(this);
|
|
193
|
+
return Object.assign(this, { ...S }), 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 S = new Array(16);
|
|
209
|
+
for (const W of [0, 1, 2, 3])
|
|
210
|
+
for (const K of [0, 1, 2])
|
|
211
|
+
S[4 * W + K] = this.runTransform[12 * h + 3 * W + K];
|
|
212
|
+
return S[15] = 1, S;
|
|
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, ...S) {
|
|
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, ...S]);
|
|
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 S = l(u), W = new N(S, I(h));
|
|
270
|
+
return p(S), 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 = x(u);
|
|
276
|
+
const S = u[1] || !1;
|
|
277
|
+
return n._Square(h, S);
|
|
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 S = new n.Vector_crossSection();
|
|
285
|
+
for (const K of h) S.push_back(q(K));
|
|
286
|
+
const W = n["_crossSection" + u](S);
|
|
287
|
+
return S.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, (S) => S instanceof Array ? { x: S[0], y: S[1] } : S);
|
|
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 S = n._crossSectionHullPoints(h);
|
|
309
|
+
return h.delete(), S;
|
|
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), S = h.status();
|
|
314
|
+
if (S !== "NoError")
|
|
315
|
+
throw new n.ManifoldError(S);
|
|
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 = P(u);
|
|
324
|
+
const S = u[1] || !1;
|
|
325
|
+
return n._Cube(h, S);
|
|
326
|
+
}, n.Manifold.cylinder = function(u, h, S = -1, W = 0, K = !1) {
|
|
327
|
+
return n._Cylinder(u, h, S, 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 S = new n.Vector_smoothness();
|
|
332
|
+
t(S, h);
|
|
333
|
+
const W = n._Smooth(u, S);
|
|
334
|
+
return S.delete(), W;
|
|
335
|
+
}, n.Manifold.extrude = function(u, h, S = 0, W = 0, K = [1, 1], Z = !1) {
|
|
336
|
+
return (u instanceof N ? u : n.CrossSection(u, "Positive")).extrude(h, S, W, K, Z);
|
|
337
|
+
}, n.Manifold.revolve = function(u, h = 0, S = 360) {
|
|
338
|
+
return (u instanceof N ? u : n.CrossSection(u, "Positive")).revolve(h, S);
|
|
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 S = new n.Vector_manifold();
|
|
346
|
+
for (const K of h) S.push_back(K);
|
|
347
|
+
const W = n["_manifold" + u + "N"](S);
|
|
348
|
+
return S.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, S, 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 = Ot(function(ct) {
|
|
353
|
+
const Et = dt(ct, "double"), Rt = dt(ct + 8, "double"), it = dt(ct + 16, "double");
|
|
354
|
+
return u([Et, Rt, it]);
|
|
355
|
+
}, "di"), yt = n._LevelSet(ot, Z, S, W, K);
|
|
356
|
+
return jt(ot), yt;
|
|
357
|
+
}, n.ExecutionContext.prototype.fromMesh = function(u) {
|
|
358
|
+
return this._FromMesh(u);
|
|
359
|
+
}, n.ExecutionContext.prototype.smooth = function(u, h = []) {
|
|
360
|
+
const S = new n.Vector_smoothness();
|
|
361
|
+
t(S, h);
|
|
362
|
+
const W = this._Smooth(u, S);
|
|
363
|
+
return S.delete(), W;
|
|
364
|
+
}, n.ExecutionContext.prototype.levelSet = function(u, h, S, 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 = Ot(function(ct) {
|
|
366
|
+
const Et = dt(ct, "double"), Rt = dt(ct + 8, "double"), it = dt(ct + 16, "double");
|
|
367
|
+
return u([Et, Rt, it]);
|
|
368
|
+
}, "di"), yt = this._LevelSet(ot, Z, S, W, K);
|
|
369
|
+
return jt(ot), yt;
|
|
370
|
+
};
|
|
371
|
+
function gt(u, h) {
|
|
372
|
+
t(u, h, (S) => S instanceof Array ? { x: S[0], y: S[1], z: S[2] } : S);
|
|
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 S = n._manifoldHullPoints(h);
|
|
380
|
+
return h.delete(), S;
|
|
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, S = !0) {
|
|
382
|
+
const W = l(u), K = e(n._Triangulate(W, h, S), (Z) => [Z[0], Z[1], Z[2]]);
|
|
383
|
+
return p(W), K;
|
|
384
|
+
};
|
|
385
|
+
};
|
|
386
|
+
var y = import.meta.url, m = "";
|
|
387
|
+
function v(t) {
|
|
388
|
+
return n.locateFile ? n.locateFile(t, m) : m + t;
|
|
389
|
+
}
|
|
390
|
+
var A, g;
|
|
391
|
+
if (c) {
|
|
392
|
+
var b = f("node:fs");
|
|
393
|
+
y.startsWith("file:") && (m = f("node:path").dirname(f("node:url").fileURLToPath(y)) + "/"), g = (t) => {
|
|
394
|
+
t = w(t) ? new URL(t) : t;
|
|
395
|
+
var e = b.readFileSync(t);
|
|
396
|
+
return e;
|
|
397
|
+
}, A = async (t, e = !0) => {
|
|
398
|
+
t = w(t) ? new URL(t) : t;
|
|
399
|
+
var s = b.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 || a) {
|
|
403
|
+
try {
|
|
404
|
+
m = new URL(".", y).href;
|
|
405
|
+
} catch {
|
|
406
|
+
}
|
|
407
|
+
a && (g = (t) => {
|
|
408
|
+
var e = new XMLHttpRequest();
|
|
409
|
+
return e.open("GET", t, !1), e.responseType = "arraybuffer", e.send(null), new Uint8Array(e.response);
|
|
410
|
+
}), A = async (t) => {
|
|
411
|
+
if (w(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), M, R = !1, w = (t) => t.startsWith("file://"), _, F, z, $, k, T, V, C, j, O, U, L, D = !1;
|
|
430
|
+
function J() {
|
|
431
|
+
var t = ce.buffer;
|
|
432
|
+
z = new Int8Array(t), k = new Int16Array(t), $ = new Uint8Array(t), T = new Uint16Array(t), V = new Int32Array(t), C = new Uint32Array(t), j = new Float32Array(t), O = new Float64Array(t), U = 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
|
+
Wt(Tt);
|
|
439
|
+
}
|
|
440
|
+
function rt() {
|
|
441
|
+
D = !0, Ut.J();
|
|
442
|
+
}
|
|
443
|
+
function H() {
|
|
444
|
+
if (n.postRun)
|
|
445
|
+
for (typeof n.postRun == "function" && (n.postRun = [n.postRun]); n.postRun.length; )
|
|
446
|
+
xt(n.postRun.shift());
|
|
447
|
+
Wt(Mt);
|
|
448
|
+
}
|
|
449
|
+
function G(t) {
|
|
450
|
+
n.onAbort?.(t), t = "Aborted(" + t + ")", E(t), R = !0, t += ". Build with -sASSERTIONS for more info.";
|
|
451
|
+
var e = new WebAssembly.RuntimeError(t);
|
|
452
|
+
throw F?.(e), e;
|
|
453
|
+
}
|
|
454
|
+
var Y;
|
|
455
|
+
function mt() {
|
|
456
|
+
return n.locateFile ? v("manifold.wasm") : "".href;
|
|
457
|
+
}
|
|
458
|
+
function ft(t) {
|
|
459
|
+
if (t == Y && M)
|
|
460
|
+
return new Uint8Array(M);
|
|
461
|
+
if (g)
|
|
462
|
+
return g(t);
|
|
463
|
+
throw "both async and sync fetching of the wasm failed";
|
|
464
|
+
}
|
|
465
|
+
async function ut(t) {
|
|
466
|
+
if (!M)
|
|
467
|
+
try {
|
|
468
|
+
var e = await A(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 && !w(e) && !c)
|
|
484
|
+
try {
|
|
485
|
+
var l = fetch(e, { credentials: "same-origin" }), p = await WebAssembly.instantiateStreaming(l, s);
|
|
486
|
+
return p;
|
|
487
|
+
} catch (x) {
|
|
488
|
+
E(`wasm streaming compile failed: ${x}`), 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 At() {
|
|
497
|
+
function t(x, P) {
|
|
498
|
+
return Ut = x.exports, Ut = Kr(Ut), Jr(Ut), J(), Ut;
|
|
499
|
+
}
|
|
500
|
+
function e(x) {
|
|
501
|
+
return t(x.instance);
|
|
502
|
+
}
|
|
503
|
+
var s = _t();
|
|
504
|
+
if (n.instantiateWasm)
|
|
505
|
+
return new Promise((x, P) => {
|
|
506
|
+
n.instantiateWasm(s, (I, B) => {
|
|
507
|
+
x(t(I));
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
Y ??= mt();
|
|
511
|
+
var l = await Ct(M, Y, s), p = e(l);
|
|
512
|
+
return p;
|
|
513
|
+
}
|
|
514
|
+
var Wt = (t) => {
|
|
515
|
+
for (; t.length > 0; )
|
|
516
|
+
t.shift()(n);
|
|
517
|
+
}, Mt = [], xt = (t) => Mt.push(t), Tt = [], qt = (t) => Tt.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 k[t >>> 1 >>> 0];
|
|
526
|
+
case "i32":
|
|
527
|
+
return V[t >>> 2 >>> 0];
|
|
528
|
+
case "i64":
|
|
529
|
+
return U[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 C[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
|
+
k[t >>> 1 >>> 0] = e;
|
|
550
|
+
break;
|
|
551
|
+
case "i32":
|
|
552
|
+
V[t >>> 2 >>> 0] = e;
|
|
553
|
+
break;
|
|
554
|
+
case "i64":
|
|
555
|
+
U[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
|
+
C[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
|
+
C[this.ptr + 4 >>> 2 >>> 0] = e;
|
|
576
|
+
}
|
|
577
|
+
get_type() {
|
|
578
|
+
return C[this.ptr + 4 >>> 2 >>> 0];
|
|
579
|
+
}
|
|
580
|
+
set_destructor(e) {
|
|
581
|
+
C[this.ptr + 8 >>> 2 >>> 0] = e;
|
|
582
|
+
}
|
|
583
|
+
get_destructor() {
|
|
584
|
+
return C[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
|
+
C[this.ptr + 16 >>> 2 >>> 0] = e;
|
|
603
|
+
}
|
|
604
|
+
get_adjusted_ptr() {
|
|
605
|
+
return C[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(C[t >>> 2 >>> 0]);
|
|
622
|
+
}
|
|
623
|
+
var Nt = {}, zt = {}, 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((I) => te[I] = e);
|
|
631
|
+
function l(I) {
|
|
632
|
+
var B = s(I);
|
|
633
|
+
B.length !== t.length && ee("Mismatched type converter count");
|
|
634
|
+
for (var N = 0; N < t.length; ++N)
|
|
635
|
+
vt(t[N], B[N]);
|
|
636
|
+
}
|
|
637
|
+
var p = new Array(e.length), x = [], P = 0;
|
|
638
|
+
for (let [I, B] of e.entries())
|
|
639
|
+
zt.hasOwnProperty(B) ? p[I] = zt[B] : (x.push(B), Nt.hasOwnProperty(B) || (Nt[B] = []), Nt[B].push(() => {
|
|
640
|
+
p[I] = zt[B], ++P, P === x.length && l(p);
|
|
641
|
+
}));
|
|
642
|
+
x.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, x = p.map((P) => P.getterReturnType).concat(p.map((P) => P.setterArgumentType));
|
|
648
|
+
It([t], x, (P) => {
|
|
649
|
+
var I = {};
|
|
650
|
+
for (var [B, N] of p.entries()) {
|
|
651
|
+
const q = P[B], Q = N.getter, et = N.getterContext, tt = P[B + p.length], st = N.setter, pt = N.setterContext;
|
|
652
|
+
I[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 I)
|
|
660
|
+
Q[et] = I[et].read(q);
|
|
661
|
+
return l(q), Q;
|
|
662
|
+
}, toWireType: (q, Q) => {
|
|
663
|
+
for (var et in I)
|
|
664
|
+
if (!(et in Q) && !I[et].optional)
|
|
665
|
+
throw new TypeError(`Missing field: "${et}"`);
|
|
666
|
+
var tt = s();
|
|
667
|
+
for (et in I)
|
|
668
|
+
I[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++ >>> 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`), zt.hasOwnProperty(t)) {
|
|
689
|
+
if (s.ignoreDuplicateRegistrations)
|
|
690
|
+
return;
|
|
691
|
+
nt(`Cannot register type '${l}' twice`);
|
|
692
|
+
}
|
|
693
|
+
if (zt[t] = e, delete te[t], Nt.hasOwnProperty(t)) {
|
|
694
|
+
var p = Nt[t];
|
|
695
|
+
delete Nt[t], p.forEach((x) => x());
|
|
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) => $[l >>> 0];
|
|
705
|
+
case 2:
|
|
706
|
+
return s ? (l) => k[l >>> 1 >>> 0] : (l) => T[l >>> 1 >>> 0];
|
|
707
|
+
case 4:
|
|
708
|
+
return s ? (l) => V[l >>> 2 >>> 0] : (l) => C[l >>> 2 >>> 0];
|
|
709
|
+
case 8:
|
|
710
|
+
return s ? (l) => U[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 x = l === 0n;
|
|
717
|
+
let P = (I) => I;
|
|
718
|
+
if (x) {
|
|
719
|
+
const I = s * 8;
|
|
720
|
+
P = (B) => BigInt.asUintN(I, B), p = P(p);
|
|
721
|
+
}
|
|
722
|
+
vt(t, { name: e, fromWireType: P, toWireType: (I, B) => (typeof B == "number" && (B = BigInt(B)), B), readValueFromPointer: Ee(e, s, !x), 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, x) {
|
|
728
|
+
return x ? s : l;
|
|
729
|
+
}, readValueFromPointer: function(p) {
|
|
730
|
+
return this.fromWireType($[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 x = s.$$.ptrType.registeredClass, P = s.$$.ptr; l.baseClass; )
|
|
762
|
+
p = l.upcast(p), l = l.baseClass;
|
|
763
|
+
for (; x.baseClass; )
|
|
764
|
+
P = x.upcast(P), x = x.baseClass;
|
|
765
|
+
return l === x && p === 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
|
+
}, An = 48, In = 57, kn = (t) => {
|
|
793
|
+
t = t.replace(/[^a-zA-Z0-9_]/g, "$");
|
|
794
|
+
var e = t.charCodeAt(0);
|
|
795
|
+
return e >= An && e <= In ? `_${t}` : t;
|
|
796
|
+
};
|
|
797
|
+
function En(t, e, s, l, p, x, P, I) {
|
|
798
|
+
this.name = t, this.constructor = e, this.instancePrototype = s, this.rawDestructor = l, this.baseClass = p, this.getActualType = x, this.upcast = P, this.downcast = I, 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 x = this.registeredClass.getActualType(e), P = ze[x];
|
|
882
|
+
if (!P)
|
|
883
|
+
return p.call(this);
|
|
884
|
+
var I;
|
|
885
|
+
this.isConst ? I = P.constPointerType : I = P.pointerType;
|
|
886
|
+
var B = Be(e, this.registeredClass, I.registeredClass);
|
|
887
|
+
return B === null ? p.call(this) : this.isSmartPointer ? oe(I.registeredClass.instancePrototype, { ptrType: I, ptr: B, smartPtrType: this, smartPtr: t }) : oe(I.registeredClass.instancePrototype, { ptrType: I, ptr: B });
|
|
888
|
+
}
|
|
889
|
+
var Un = () => {
|
|
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, x, P, I, B, N, q) {
|
|
897
|
+
this.name = t, this.registeredClass = e, this.isReference = s, this.isConst = l, this.isSmartPointer = p, this.pointeeType = x, this.sharingPolicy = P, this.rawGetPointee = I, this.rawConstructor = B, 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), Dn = (t, e, s = [], l = !1) => {
|
|
902
|
+
var p = ie(e), x = p(...s);
|
|
903
|
+
function P(I) {
|
|
904
|
+
return t[0] == "p" ? I >>> 0 : I;
|
|
905
|
+
}
|
|
906
|
+
return P(x);
|
|
907
|
+
}, Nn = (t, e, s = !1) => (...l) => Dn(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 x = ie(e);
|
|
913
|
+
return x;
|
|
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 kt(e), s;
|
|
923
|
+
}, ae = (t, e) => {
|
|
924
|
+
var s = [], l = {};
|
|
925
|
+
function p(x) {
|
|
926
|
+
if (!l[x] && !zt[x]) {
|
|
927
|
+
if (te[x]) {
|
|
928
|
+
te[x].forEach(p);
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
s.push(x), l[x] = !0;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
throw e.forEach(p), new Hn(`${t}: ` + s.map(je).join([", "]));
|
|
935
|
+
};
|
|
936
|
+
function Ln(t, e, s, l, p, x, P, I, B, N, q, Q, et) {
|
|
937
|
+
t >>>= 0, e >>>= 0, s >>>= 0, l >>>= 0, p >>>= 0, x >>>= 0, P >>>= 0, I >>>= 0, B >>>= 0, N >>>= 0, q >>>= 0, Q >>>= 0, et >>>= 0, q = lt(q), x = wt(p, x), I &&= wt(P, I), N &&= wt(B, 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 (S.constructor_body === void 0)
|
|
949
|
+
throw new Gt(`${q} has no accessible constructor`);
|
|
950
|
+
var yt = S.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(S.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 S = new En(q, u, h, et, pt, x, I, N);
|
|
957
|
+
S.baseClass && (S.baseClass.__derivedClasses ??= [], S.baseClass.__derivedClasses.push(S));
|
|
958
|
+
var W = new se(q, S, !0, !1, !1), K = new se(q + "*", S, !1, !1, !1), Z = new se(q + " const*", S, !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(C[e + l * 4 >>> 2 >>> 0]);
|
|
965
|
+
return s;
|
|
966
|
+
};
|
|
967
|
+
function Ue(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 = Ue(t), x = t.length - 2, P = [], I = ["fn"];
|
|
975
|
+
e && I.push("thisWired");
|
|
976
|
+
for (var B = 0; B < x; ++B)
|
|
977
|
+
P.push(`arg${B}`), I.push(`arg${B}Wired`);
|
|
978
|
+
P = P.join(","), I = I.join(",");
|
|
979
|
+
var N = `return function (${P}) {
|
|
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 B = 0; B < x; ++B) {
|
|
987
|
+
var et = `toArg${B}Wire`;
|
|
988
|
+
N += `var arg${B}Wired = ${et}(${q}, arg${B});
|
|
989
|
+
`, Q.push(et);
|
|
990
|
+
}
|
|
991
|
+
if (N += (s || l ? "var rv = " : "") + `invoker(${I});
|
|
992
|
+
`, p)
|
|
993
|
+
N += `runDestructors(destructors);
|
|
994
|
+
`;
|
|
995
|
+
else
|
|
996
|
+
for (var B = e ? 1 : 2; B < t.length; ++B) {
|
|
997
|
+
var tt = B === 1 ? "thisWired" : "arg" + (B - 2) + "Wired";
|
|
998
|
+
t[B].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, x) {
|
|
1007
|
+
var P = e.length;
|
|
1008
|
+
P < 2 && nt("argTypes array size mismatch! Must at least get return value and 'this' types!");
|
|
1009
|
+
for (var I = e[1] !== null && s !== null, B = Ue(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 < P; ++tt) {
|
|
1010
|
+
var st = e[tt];
|
|
1011
|
+
et.push(st.toWireType.bind(st));
|
|
1012
|
+
}
|
|
1013
|
+
if (!B)
|
|
1014
|
+
for (var tt = I ? 1 : 2; tt < e.length; ++tt)
|
|
1015
|
+
e[tt].destructorFunction !== null && et.push(e[tt].destructorFunction);
|
|
1016
|
+
var gt = qn(e, I, N, x)(...et);
|
|
1017
|
+
return re(t, gt);
|
|
1018
|
+
}
|
|
1019
|
+
var Jn = function(t, e, s, l, p, x) {
|
|
1020
|
+
t >>>= 0, s >>>= 0, l >>>= 0, p >>>= 0, x >>>= 0;
|
|
1021
|
+
var P = ge(e, s);
|
|
1022
|
+
p = wt(l, p), It([], [t], (I) => {
|
|
1023
|
+
I = I[0];
|
|
1024
|
+
var B = `constructor ${I.name}`;
|
|
1025
|
+
if (I.registeredClass.constructor_body === void 0 && (I.registeredClass.constructor_body = []), I.registeredClass.constructor_body[e - 1] !== void 0)
|
|
1026
|
+
throw new Gt(`Cannot register multiple constructors with identical number of parameters (${e - 1}) for class '${I.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);
|
|
1027
|
+
return I.registeredClass.constructor_body[e - 1] = () => {
|
|
1028
|
+
ae(`Cannot construct ${I.name} due to unbound types`, P);
|
|
1029
|
+
}, It([], P, (N) => (N.splice(1, 0, null), I.registeredClass.constructor_body[e - 1] = be(B, N, null, p, x), [])), [];
|
|
1030
|
+
});
|
|
1031
|
+
}, De = (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, x, P, I, B, N) {
|
|
1036
|
+
t >>>= 0, e >>>= 0, l >>>= 0, p >>>= 0, x >>>= 0, P >>>= 0;
|
|
1037
|
+
var q = ge(s, l);
|
|
1038
|
+
e = lt(e), e = De(e), x = wt(p, x, B), It([], [t], (Q) => {
|
|
1039
|
+
Q = Q[0];
|
|
1040
|
+
var et = `${Q.name}.${e}`;
|
|
1041
|
+
e.startsWith("@@") && (e = Symbol[e.substring(2)]), I && 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, x, P, B);
|
|
1048
|
+
return st[e].overloadTable === void 0 ? (u.argCount = s - 2, st[e] = u) : st[e].overloadTable[s - 2] = u, [];
|
|
1049
|
+
}), [];
|
|
1050
|
+
});
|
|
1051
|
+
}, Ne = [], Vt = [0, 1, , 1, null, 1, !0, 1, !1, 1];
|
|
1052
|
+
function xe(t) {
|
|
1053
|
+
t >>>= 0, t > 9 && --Vt[t + 1] === 0 && (Vt[t] = void 0, Ne.push(t));
|
|
1054
|
+
}
|
|
1055
|
+
var ht = { toValue: (t) => (t || nt(`Cannot use deleted val. handle = ${t}`), Vt[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() || Vt.length;
|
|
1067
|
+
return Vt[e] = t, Vt[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($[l >>> 0]);
|
|
1084
|
+
};
|
|
1085
|
+
case 2:
|
|
1086
|
+
return s ? function(l) {
|
|
1087
|
+
return this.fromWireType(k[l >>> 1 >>> 0]);
|
|
1088
|
+
} : function(l) {
|
|
1089
|
+
return this.fromWireType(T[l >>> 1 >>> 0]);
|
|
1090
|
+
};
|
|
1091
|
+
case 4:
|
|
1092
|
+
return s ? function(l) {
|
|
1093
|
+
return this.fromWireType(V[l >>> 2 >>> 0]);
|
|
1094
|
+
} : function(l) {
|
|
1095
|
+
return this.fromWireType(C[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 x = Xn(p);
|
|
1107
|
+
switch (x) {
|
|
1108
|
+
case "object": {
|
|
1109
|
+
let N = function() {
|
|
1110
|
+
};
|
|
1111
|
+
N.values = {}, vt(t, { name: e, constructor: N, valueType: x, 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 P = {};
|
|
1118
|
+
vt(t, { name: e, keysMap: P, valueType: x, fromWireType: (N) => N, toWireType: (N, q) => q, readValueFromPointer: _e(e, s, l), destructorFunction: null }), Xt(e, P), delete n[e].argCount;
|
|
1119
|
+
break;
|
|
1120
|
+
}
|
|
1121
|
+
case "string": {
|
|
1122
|
+
var I = {}, B = {}, P = {};
|
|
1123
|
+
vt(t, { name: e, valuesMap: I, reverseMap: B, keysMap: P, valueType: x, 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, P), delete n[e].argCount;
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
var Le = (t, e) => {
|
|
1133
|
+
var s = zt[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, x = Object.create(l.constructor.prototype, { value: { value: s }, constructor: { value: re(`${l.name}_${e}`, function() {
|
|
1142
|
+
}) } });
|
|
1143
|
+
p.values[s] = x, p[e] = x;
|
|
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, x, P, I) {
|
|
1173
|
+
t >>>= 0, s >>>= 0, l >>>= 0, p >>>= 0, x >>>= 0;
|
|
1174
|
+
var B = ge(e, s);
|
|
1175
|
+
t = lt(t), t = De(t), p = wt(l, p, P), Xt(t, function() {
|
|
1176
|
+
ae(`Cannot call ${t} due to unbound types`, B);
|
|
1177
|
+
}, e - 1), It([], B, (N) => {
|
|
1178
|
+
var q = [N[0], null].concat(N.slice(1));
|
|
1179
|
+
return Oe(t, be(t, q, null, p, x, 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 x = l === 0;
|
|
1185
|
+
let P = (B) => B;
|
|
1186
|
+
if (x) {
|
|
1187
|
+
var I = 32 - 8 * s;
|
|
1188
|
+
P = (B) => B << I >>> I, p = P(p);
|
|
1189
|
+
}
|
|
1190
|
+
vt(t, { name: e, fromWireType: P, toWireType: (B, N) => N, readValueFromPointer: Ee(e, s, l !== 0), destructorFunction: null });
|
|
1191
|
+
}, rr = (t, e, s) => {
|
|
1192
|
+
const l = (p, x) => {
|
|
1193
|
+
let P = 0;
|
|
1194
|
+
return { next() {
|
|
1195
|
+
if (P >= p)
|
|
1196
|
+
return { done: !0 };
|
|
1197
|
+
const I = P;
|
|
1198
|
+
return P++, { value: x(I), 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, (x) => this[s](x));
|
|
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 x = p[0];
|
|
1210
|
+
return rr(x.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 x(P) {
|
|
1217
|
+
var I = C[P >>> 2 >>> 0], B = C[P + 4 >>> 2 >>> 0];
|
|
1218
|
+
return new p(z.buffer, B, I);
|
|
1219
|
+
}
|
|
1220
|
+
s = lt(s), vt(t, { name: s, fromWireType: x, readValueFromPointer: x }, { 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, x = s + l - 1, P = 0; P < t.length; ++P) {
|
|
1229
|
+
var I = t.codePointAt(P);
|
|
1230
|
+
if (I <= 127) {
|
|
1231
|
+
if (s >= x) break;
|
|
1232
|
+
e[s++ >>> 0] = I;
|
|
1233
|
+
} else if (I <= 2047) {
|
|
1234
|
+
if (s + 1 >= x) break;
|
|
1235
|
+
e[s++ >>> 0] = 192 | I >> 6, e[s++ >>> 0] = 128 | I & 63;
|
|
1236
|
+
} else if (I <= 65535) {
|
|
1237
|
+
if (s + 2 >= x) break;
|
|
1238
|
+
e[s++ >>> 0] = 224 | I >> 12, e[s++ >>> 0] = 128 | I >> 6 & 63, e[s++ >>> 0] = 128 | I & 63;
|
|
1239
|
+
} else {
|
|
1240
|
+
if (s + 3 >= x) break;
|
|
1241
|
+
e[s++ >>> 0] = 240 | I >> 18, e[s++ >>> 0] = 128 | I >> 12 & 63, e[s++ >>> 0] = 128 | I >> 6 & 63, e[s++ >>> 0] = 128 | I & 63, P++;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
return e[s >>> 0] = 0, s - p;
|
|
1245
|
+
}, lr = (t, e, s) => cr(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 x = ""; e < p; ) {
|
|
1262
|
+
var P = t[e++];
|
|
1263
|
+
if (!(P & 128)) {
|
|
1264
|
+
x += String.fromCharCode(P);
|
|
1265
|
+
continue;
|
|
1266
|
+
}
|
|
1267
|
+
var I = t[e++] & 63;
|
|
1268
|
+
if ((P & 224) == 192) {
|
|
1269
|
+
x += String.fromCharCode((P & 31) << 6 | I);
|
|
1270
|
+
continue;
|
|
1271
|
+
}
|
|
1272
|
+
var B = t[e++] & 63;
|
|
1273
|
+
if ((P & 240) == 224 ? P = (P & 15) << 12 | I << 6 | B : P = (P & 7) << 18 | I << 12 | B << 6 | t[e++] & 63, P < 65536)
|
|
1274
|
+
x += String.fromCharCode(P);
|
|
1275
|
+
else {
|
|
1276
|
+
var N = P - 65536;
|
|
1277
|
+
x += String.fromCharCode(55296 | N >> 10, 56320 | N & 1023);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
return x;
|
|
1281
|
+
}, dr = (t, e, s) => (t >>>= 0, t ? fr($, 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 = C[s >>> 2 >>> 0], p = s + 4, x;
|
|
1285
|
+
return x = dr(p, l, !0), kt(s), x;
|
|
1286
|
+
}, toWireType(s, l) {
|
|
1287
|
+
l instanceof ArrayBuffer && (l = new Uint8Array(l));
|
|
1288
|
+
var p, x = typeof l == "string";
|
|
1289
|
+
x || ArrayBuffer.isView(l) && l.BYTES_PER_ELEMENT == 1 || nt("Cannot pass non-string to std::string"), x ? p = ur(l) : p = l.length;
|
|
1290
|
+
var P = Pe(4 + p + 1), I = P + 4;
|
|
1291
|
+
return C[P >>> 2 >>> 0] = p, x ? lr(l, I, p + 1) : $.set(l, I >>> 0), s !== null && s.push(kt, P), P;
|
|
1292
|
+
}, readValueFromPointer: Jt, destructorFunction(s) {
|
|
1293
|
+
kt(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(T, l, e / 2, s);
|
|
1298
|
+
if (p - l > 16 && Ge) return Ge.decode(T.subarray(l >>> 0, p >>> 0));
|
|
1299
|
+
for (var x = "", P = l; P < p; ++P) {
|
|
1300
|
+
var I = T[P >>> 0];
|
|
1301
|
+
x += String.fromCharCode(I);
|
|
1302
|
+
}
|
|
1303
|
+
return x;
|
|
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, x = 0; x < p; ++x) {
|
|
1308
|
+
var P = t.charCodeAt(x);
|
|
1309
|
+
k[e >>> 1 >>> 0] = P, e += 2;
|
|
1310
|
+
}
|
|
1311
|
+
return k[e >>> 1 >>> 0] = 0, e - l;
|
|
1312
|
+
}, mr = (t) => t.length * 2, vr = (t, e, s) => {
|
|
1313
|
+
for (var l = "", p = t >>> 2, x = 0; !(x >= e / 4); x++) {
|
|
1314
|
+
var P = C[p + x >>> 0];
|
|
1315
|
+
if (!P && !s) break;
|
|
1316
|
+
l += String.fromCodePoint(P);
|
|
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, x = 0; x < t.length; ++x) {
|
|
1322
|
+
var P = t.codePointAt(x);
|
|
1323
|
+
if (P > 65535 && x++, V[e >>> 2 >>> 0] = P, e += 4, e + 4 > p) break;
|
|
1324
|
+
}
|
|
1325
|
+
return V[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, x;
|
|
1336
|
+
e === 2 ? (l = pr, p = yr, x = mr) : (l = vr, p = gr, x = br), vt(t, { name: s, fromWireType: (P) => {
|
|
1337
|
+
var I = C[P >>> 2 >>> 0], B = l(P + 4, I * e, !0);
|
|
1338
|
+
return kt(P), B;
|
|
1339
|
+
}, toWireType: (P, I) => {
|
|
1340
|
+
typeof I != "string" && nt(`Cannot pass non-string to C++ string type ${s}`);
|
|
1341
|
+
var B = x(I), N = Pe(4 + B + e);
|
|
1342
|
+
return C[N >>> 2 >>> 0] = B / e, p(I, N + 4, B + e), P !== null && P.push(kt, N), N;
|
|
1343
|
+
}, readValueFromPointer: Jt, destructorFunction(P) {
|
|
1344
|
+
kt(P);
|
|
1345
|
+
} });
|
|
1346
|
+
}
|
|
1347
|
+
function _r(t, e, s, l, p, x) {
|
|
1348
|
+
t >>>= 0, e >>>= 0, s >>>= 0, l >>>= 0, p >>>= 0, x >>>= 0, Qt[t] = { name: lt(e), rawConstructor: wt(s, l), rawDestructor: wt(p, x), fields: [] };
|
|
1349
|
+
}
|
|
1350
|
+
function Mr(t, e, s, l, p, x, P, I, B, N) {
|
|
1351
|
+
t >>>= 0, e >>>= 0, s >>>= 0, l >>>= 0, p >>>= 0, x >>>= 0, P >>>= 0, I >>>= 0, B >>>= 0, N >>>= 0, Qt[t].fields.push({ fieldName: lt(e), getterReturnType: s, getter: wt(l, p), getterContext: x, setterArgumentType: P, setter: wt(I, B), 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(C[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 && (C[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, ...x] = Cr(t, e), P = p.toWireType.bind(p), I = x.map((tt) => tt.readValueFromPointer.bind(tt));
|
|
1377
|
+
t--;
|
|
1378
|
+
var B = { toValue: ht.toValue }, N = I.map((tt, st) => {
|
|
1379
|
+
var pt = `argFromPtr${st}`;
|
|
1380
|
+
return B[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
|
+
B.getStringOrSymbol = Ke, q = "toValue(handle)[getStringOrSymbol(methodName)]";
|
|
1394
|
+
break;
|
|
1395
|
+
}
|
|
1396
|
+
q += `(${N})`, p.isVoid || (B.toReturnWire = P, B.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(B), q)(...Object.values(B)), et = `methodCaller<(${x.map((tt) => tt.name)}) => ${p.name}>`;
|
|
1400
|
+
return Pr(re(et, Q));
|
|
1401
|
+
};
|
|
1402
|
+
function Ar(t, e) {
|
|
1403
|
+
return t >>>= 0, e >>>= 0, t = ht.toValue(t), e = ht.toValue(e), t == e;
|
|
1404
|
+
}
|
|
1405
|
+
function Ir(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 && (Vt[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 Ur(t) {
|
|
1436
|
+
t >>>= 0;
|
|
1437
|
+
var e = $.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 x = Math.min(s, Or(Math.max(t, p), 65536)), P = jr(x);
|
|
1444
|
+
if (P)
|
|
1445
|
+
return !0;
|
|
1446
|
+
}
|
|
1447
|
+
return !1;
|
|
1448
|
+
}
|
|
1449
|
+
var Dr = (t, e) => {
|
|
1450
|
+
if (Bt)
|
|
1451
|
+
for (var s = t; s < t + e; s++) {
|
|
1452
|
+
var l = ie(s);
|
|
1453
|
+
l && Bt.set(l, s);
|
|
1454
|
+
}
|
|
1455
|
+
}, Bt, Nr = (t) => (Bt || (Bt = /* @__PURE__ */ new WeakMap(), Dr(0, Yt.length)), Bt.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 } }), x = p.exports.f;
|
|
1463
|
+
return x;
|
|
1464
|
+
}, Ot = (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 (x) {
|
|
1472
|
+
if (!(x instanceof TypeError))
|
|
1473
|
+
throw x;
|
|
1474
|
+
var p = qr(t, e);
|
|
1475
|
+
$e(l, p);
|
|
1476
|
+
}
|
|
1477
|
+
return Bt.set(t, l), l;
|
|
1478
|
+
}, jt = (t) => {
|
|
1479
|
+
Bt.delete(ie(t)), $e(t, null), we.push(t);
|
|
1480
|
+
};
|
|
1481
|
+
if (Fn(), Un(), n.noExitRuntime && n.noExitRuntime, n.print && n.print, n.printErr && (E = n.printErr), n.wasmBinary && (M = 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 = Ot, n.removeFunction = jt;
|
|
1485
|
+
var Ze, Pe, kt, ce, Yt;
|
|
1486
|
+
function Jr(t) {
|
|
1487
|
+
Ze = t.K, Pe = t.M, kt = 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: Ar, B: Ir, t: kr, f: Er, s: Rr, A: Wr, e: zr, v: Vr, D: Ur };
|
|
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, !R && (rt(), _?.(n), n.onRuntimeInitialized?.(), H());
|
|
1499
|
+
}
|
|
1500
|
+
n.setStatus ? (n.setStatus("Running..."), setTimeout(() => {
|
|
1501
|
+
setTimeout(() => n.setStatus(""), 1), t();
|
|
1502
|
+
}, 1)) : t();
|
|
1503
|
+
}
|
|
1504
|
+
var Ut;
|
|
1505
|
+
return Ut = await At(), Xr(), D ? r = n : r = new Promise((t, e) => {
|
|
1506
|
+
_ = t, F = 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, a = /* @__PURE__ */ new Map();
|
|
1514
|
+
let c = 0, f = 0, d = 0;
|
|
1515
|
+
const y = [1 / 0, 1 / 0, 1 / 0], m = [-1 / 0, -1 / 0, -1 / 0];
|
|
1516
|
+
for (let w = 0; w < n; w++) {
|
|
1517
|
+
const _ = o[w * 3], F = o[w * 3 + 1], z = o[w * 3 + 2];
|
|
1518
|
+
_ < y[0] && (y[0] = _), F < y[1] && (y[1] = F), z < y[2] && (y[2] = z), _ > m[0] && (m[0] = _), F > m[1] && (m[1] = F), z > m[2] && (m[2] = z);
|
|
1519
|
+
}
|
|
1520
|
+
const v = new Int32Array(n);
|
|
1521
|
+
for (let w = 0; w < n; w++) v[w] = w;
|
|
1522
|
+
const A = (w) => {
|
|
1523
|
+
for (; v[w] !== w; )
|
|
1524
|
+
v[w] = v[v[w]], w = v[w];
|
|
1525
|
+
return w;
|
|
1526
|
+
}, g = (w, _) => {
|
|
1527
|
+
const F = A(w), z = A(_);
|
|
1528
|
+
F !== z && (v[F] = z);
|
|
1529
|
+
};
|
|
1530
|
+
for (let w = 0; w < i; w++) {
|
|
1531
|
+
const _ = r[w * 3], F = r[w * 3 + 1], z = r[w * 3 + 2], $ = o[_ * 3], k = o[_ * 3 + 1], T = o[_ * 3 + 2], V = o[F * 3], C = o[F * 3 + 1], j = o[F * 3 + 2], O = o[z * 3], U = o[z * 3 + 1], L = o[z * 3 + 2], D = V - $, J = C - k, X = j - T, rt = O - $, H = U - k, G = L - T, Y = J * G - X * H, mt = X * rt - D * G, ft = D * H - J * rt, ut = 0.5 * Math.hypot(Y, mt, ft);
|
|
1532
|
+
ut < 1e-12 && d++, f += ut, c += $ * Y + k * mt + T * ft;
|
|
1533
|
+
for (const [Pt, Ct] of [[_, F], [F, z], [z, _]]) {
|
|
1534
|
+
const _t = Zr(Pt, Ct);
|
|
1535
|
+
a.set(_t, (a.get(_t) ?? 0) + 1), g(Pt, Ct);
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
let b = 0, E = 0;
|
|
1539
|
+
for (const w of a.values())
|
|
1540
|
+
w === 1 ? b++ : w > 2 && E++;
|
|
1541
|
+
const M = /* @__PURE__ */ new Set();
|
|
1542
|
+
for (let w = 0; w < n; w++) M.add(A(w));
|
|
1543
|
+
const R = c / 6;
|
|
1544
|
+
return {
|
|
1545
|
+
triangleCount: i,
|
|
1546
|
+
vertexCount: n,
|
|
1547
|
+
openEdgeCount: b,
|
|
1548
|
+
nonManifoldEdgeCount: E,
|
|
1549
|
+
componentCount: Math.max(1, M.size),
|
|
1550
|
+
volume: R,
|
|
1551
|
+
surfaceArea: f,
|
|
1552
|
+
bbox: {
|
|
1553
|
+
min: y,
|
|
1554
|
+
max: m,
|
|
1555
|
+
size: [m[0] - y[0], m[1] - y[1], m[2] - y[2]]
|
|
1556
|
+
},
|
|
1557
|
+
invertedNormals: R < 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 a = Math.max(1, Math.floor(i / n));
|
|
1565
|
+
let c = 1 / 0;
|
|
1566
|
+
const f = [];
|
|
1567
|
+
for (let d = 0; d < i; d += a) {
|
|
1568
|
+
const y = r[d * 3], m = r[d * 3 + 1], v = r[d * 3 + 2], A = o[y * 3], g = o[y * 3 + 1], b = o[y * 3 + 2], E = o[m * 3], M = o[m * 3 + 1], R = o[m * 3 + 2], w = o[v * 3], _ = o[v * 3 + 1], F = o[v * 3 + 2], z = (A + E + w) / 3, $ = (g + M + _) / 3, k = (b + R + F) / 3, T = (M - g) * (F - b) - (R - b) * (_ - g), V = (R - b) * (w - A) - (E - A) * (F - b), C = (E - A) * (_ - g) - (M - g) * (w - A), j = Math.hypot(T, V, C) || 1;
|
|
1569
|
+
f.push([z, $, k, -T / j, -V / j, -C / j]);
|
|
1570
|
+
}
|
|
1571
|
+
for (const [d, y, m, v, A, g] of f) {
|
|
1572
|
+
let b = 1 / 0;
|
|
1573
|
+
for (let E = 0; E < i; E += Math.max(1, Math.floor(a / 2))) {
|
|
1574
|
+
const M = r[E * 3], R = r[E * 3 + 1], w = r[E * 3 + 2], _ = Ie(
|
|
1575
|
+
d,
|
|
1576
|
+
y,
|
|
1577
|
+
m,
|
|
1578
|
+
v,
|
|
1579
|
+
A,
|
|
1580
|
+
g,
|
|
1581
|
+
o[M * 3],
|
|
1582
|
+
o[M * 3 + 1],
|
|
1583
|
+
o[M * 3 + 2],
|
|
1584
|
+
o[R * 3],
|
|
1585
|
+
o[R * 3 + 1],
|
|
1586
|
+
o[R * 3 + 2],
|
|
1587
|
+
o[w * 3],
|
|
1588
|
+
o[w * 3 + 1],
|
|
1589
|
+
o[w * 3 + 2]
|
|
1590
|
+
);
|
|
1591
|
+
_ > 1e-3 && _ < b && (b = _);
|
|
1592
|
+
}
|
|
1593
|
+
b < c && (c = b);
|
|
1594
|
+
}
|
|
1595
|
+
return Number.isFinite(c) ? c : 0;
|
|
1596
|
+
}
|
|
1597
|
+
function Ie(o, r, n, i, a, c, f, d, y, m, v, A, g, b, E) {
|
|
1598
|
+
const R = m - f, w = v - d, _ = A - y, F = g - f, z = b - d, $ = E - y, k = a * $ - c * z, T = c * F - i * $, V = i * z - a * F, C = R * k + w * T + _ * V;
|
|
1599
|
+
if (Math.abs(C) < 1e-8) return 1 / 0;
|
|
1600
|
+
const j = 1 / C, O = o - f, U = r - d, L = n - y, D = (O * k + U * T + L * V) * j;
|
|
1601
|
+
if (D < 0 || D > 1) return 1 / 0;
|
|
1602
|
+
const J = U * _ - L * w, X = L * R - O * _, rt = O * w - U * R, H = (i * J + a * X + c * rt) * j;
|
|
1603
|
+
if (H < 0 || D + H > 1) return 1 / 0;
|
|
1604
|
+
const G = (F * J + z * X + $ * rt) * j;
|
|
1605
|
+
return G > 0 ? G : 1 / 0;
|
|
1606
|
+
}
|
|
1607
|
+
function to(o, r, n) {
|
|
1608
|
+
const i = o.length / 3, a = new Float32Array(i * 3), c = r.length / 3, f = Math.min(i, 800), d = Math.max(1, Math.floor(i / f)), y = new Float32Array(i);
|
|
1609
|
+
y.fill(n * 4);
|
|
1610
|
+
for (let m = 0; m < i; m += d) {
|
|
1611
|
+
let v = 0, A = 0, g = 0;
|
|
1612
|
+
for (let F = 0; F < c; F++)
|
|
1613
|
+
if (r[F * 3] === m || r[F * 3 + 1] === m || r[F * 3 + 2] === m) {
|
|
1614
|
+
const z = r[F * 3], $ = r[F * 3 + 1], k = r[F * 3 + 2], T = o[z * 3], V = o[z * 3 + 1], C = o[z * 3 + 2], j = o[$ * 3], O = o[$ * 3 + 1], U = o[$ * 3 + 2], L = o[k * 3], D = o[k * 3 + 1], J = o[k * 3 + 2];
|
|
1615
|
+
v += (O - V) * (J - C) - (U - C) * (D - V), A += (U - C) * (L - T) - (j - T) * (J - C), g += (j - T) * (D - V) - (O - V) * (L - T);
|
|
1616
|
+
}
|
|
1617
|
+
const b = Math.hypot(v, A, g) || 1, E = o[m * 3], M = o[m * 3 + 1], R = o[m * 3 + 2];
|
|
1618
|
+
let w = 1 / 0;
|
|
1619
|
+
const _ = Math.max(1, Math.floor(c / 120));
|
|
1620
|
+
for (let F = 0; F < c; F += _) {
|
|
1621
|
+
const z = r[F * 3], $ = r[F * 3 + 1], k = r[F * 3 + 2], T = Ie(
|
|
1622
|
+
E,
|
|
1623
|
+
M,
|
|
1624
|
+
R,
|
|
1625
|
+
-v / b,
|
|
1626
|
+
-A / b,
|
|
1627
|
+
-g / b,
|
|
1628
|
+
o[z * 3],
|
|
1629
|
+
o[z * 3 + 1],
|
|
1630
|
+
o[z * 3 + 2],
|
|
1631
|
+
o[$ * 3],
|
|
1632
|
+
o[$ * 3 + 1],
|
|
1633
|
+
o[$ * 3 + 2],
|
|
1634
|
+
o[k * 3],
|
|
1635
|
+
o[k * 3 + 1],
|
|
1636
|
+
o[k * 3 + 2]
|
|
1637
|
+
);
|
|
1638
|
+
T > 1e-3 && T < w && (w = T);
|
|
1639
|
+
}
|
|
1640
|
+
y[m] = Number.isFinite(w) ? w : n * 4;
|
|
1641
|
+
}
|
|
1642
|
+
for (let m = 0; m < i; m++) {
|
|
1643
|
+
const v = Math.min(1, y[m] / (n * 3));
|
|
1644
|
+
a[m * 3] = 1 - v, a[m * 3 + 1] = v, a[m * 3 + 2] = 0.15;
|
|
1645
|
+
}
|
|
1646
|
+
return a;
|
|
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 a = o.length / 3, c = r.length / 3, f = /* @__PURE__ */ new Map(), d = new Int32Array(a);
|
|
1667
|
+
for (let T = 0; T < a; T++) d[T] = T;
|
|
1668
|
+
const y = (T) => {
|
|
1669
|
+
for (; d[T] !== T; )
|
|
1670
|
+
d[T] = d[d[T]], T = d[T];
|
|
1671
|
+
return T;
|
|
1672
|
+
}, m = (T, V) => {
|
|
1673
|
+
const C = y(T), j = y(V);
|
|
1674
|
+
C !== j && (d[C] = j);
|
|
1675
|
+
};
|
|
1676
|
+
for (let T = 0; T < c; T++) {
|
|
1677
|
+
const V = r[T * 3], C = r[T * 3 + 1], j = r[T * 3 + 2];
|
|
1678
|
+
for (const [O, U] of [[V, C], [C, j], [j, V]]) {
|
|
1679
|
+
const L = O < U ? `${O}_${U}` : `${U}_${O}`, D = f.get(L);
|
|
1680
|
+
D ? D.count++ : f.set(L, { a: O, b: U, count: 1 }), m(O, U);
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
const v = [], A = [];
|
|
1684
|
+
let g, b;
|
|
1685
|
+
for (const T of f.values())
|
|
1686
|
+
T.count === 1 && v.length < 24e3 ? (Qe(v, o, T.a, T.b), g ??= tn(o, T.a, T.b)) : T.count > 2 && A.length < 12e3 && (Qe(A, o, T.a, T.b), b ??= tn(o, T.a, T.b));
|
|
1687
|
+
const E = [];
|
|
1688
|
+
let M;
|
|
1689
|
+
const R = Math.max(1, Math.floor(c / 400));
|
|
1690
|
+
for (let T = 0; T < c && E.length < 9e3; T += R) {
|
|
1691
|
+
const V = r[T * 3], C = r[T * 3 + 1], j = r[T * 3 + 2], O = o[V * 3], U = o[V * 3 + 1], L = o[V * 3 + 2], D = o[C * 3], J = o[C * 3 + 1], X = o[C * 3 + 2], rt = o[j * 3], H = o[j * 3 + 1], G = o[j * 3 + 2], Y = (O + D + rt) / 3, mt = (U + J + H) / 3, ft = (L + X + G) / 3, ut = (J - U) * (G - L) - (X - L) * (H - U), Pt = (X - L) * (rt - O) - (D - O) * (G - L), Ct = (D - O) * (H - U) - (J - U) * (rt - O), _t = Math.hypot(ut, Pt, Ct) || 1;
|
|
1692
|
+
let At = 1 / 0;
|
|
1693
|
+
const Wt = Math.max(1, Math.floor(c / 80));
|
|
1694
|
+
for (let Mt = 0; Mt < c; Mt += Wt) {
|
|
1695
|
+
const xt = r[Mt * 3], Tt = r[Mt * 3 + 1], qt = r[Mt * 3 + 2], dt = Ie(
|
|
1696
|
+
Y,
|
|
1697
|
+
mt,
|
|
1698
|
+
ft,
|
|
1699
|
+
-ut / _t,
|
|
1700
|
+
-Pt / _t,
|
|
1701
|
+
-Ct / _t,
|
|
1702
|
+
o[xt * 3],
|
|
1703
|
+
o[xt * 3 + 1],
|
|
1704
|
+
o[xt * 3 + 2],
|
|
1705
|
+
o[Tt * 3],
|
|
1706
|
+
o[Tt * 3 + 1],
|
|
1707
|
+
o[Tt * 3 + 2],
|
|
1708
|
+
o[qt * 3],
|
|
1709
|
+
o[qt * 3 + 1],
|
|
1710
|
+
o[qt * 3 + 2]
|
|
1711
|
+
);
|
|
1712
|
+
dt > 1e-3 && dt < At && (At = dt);
|
|
1713
|
+
}
|
|
1714
|
+
At < n && (E.push(O, U, L, D, J, X, rt, H, G), M ??= [Y, mt, ft]);
|
|
1715
|
+
}
|
|
1716
|
+
const w = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map();
|
|
1717
|
+
for (let T = 0; T < a; T++) {
|
|
1718
|
+
const V = y(T);
|
|
1719
|
+
w.set(V, (w.get(V) ?? 0) + 1), _.has(V) || _.set(V, T);
|
|
1720
|
+
}
|
|
1721
|
+
let F = -1, z = -1;
|
|
1722
|
+
for (const [T, V] of w)
|
|
1723
|
+
V > z && (z = V, F = T);
|
|
1724
|
+
const $ = [];
|
|
1725
|
+
let k;
|
|
1726
|
+
if (w.size > 1)
|
|
1727
|
+
for (let T = 0; T < c && $.length < 9e3; T++) {
|
|
1728
|
+
const V = r[T * 3];
|
|
1729
|
+
if (y(V) === F) continue;
|
|
1730
|
+
const C = r[T * 3 + 1], j = r[T * 3 + 2];
|
|
1731
|
+
if ($.push(
|
|
1732
|
+
o[V * 3],
|
|
1733
|
+
o[V * 3 + 1],
|
|
1734
|
+
o[V * 3 + 2],
|
|
1735
|
+
o[C * 3],
|
|
1736
|
+
o[C * 3 + 1],
|
|
1737
|
+
o[C * 3 + 2],
|
|
1738
|
+
o[j * 3],
|
|
1739
|
+
o[j * 3 + 1],
|
|
1740
|
+
o[j * 3 + 2]
|
|
1741
|
+
), !k) {
|
|
1742
|
+
const O = _.get(y(V)) ?? V;
|
|
1743
|
+
k = [o[O * 3], o[O * 3 + 1], o[O * 3 + 2]];
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
return {
|
|
1747
|
+
partIndex: i,
|
|
1748
|
+
openEdgePositions: new Float32Array(v),
|
|
1749
|
+
nonManifoldEdgePositions: new Float32Array(A),
|
|
1750
|
+
thinTriPositions: new Float32Array(E),
|
|
1751
|
+
islandTriPositions: new Float32Array($),
|
|
1752
|
+
focus: {
|
|
1753
|
+
watertight: g,
|
|
1754
|
+
nonmanifold: b,
|
|
1755
|
+
thinwall: M,
|
|
1756
|
+
islands: k,
|
|
1757
|
+
selfintersect: b ?? g,
|
|
1758
|
+
normals: g
|
|
1759
|
+
}
|
|
1760
|
+
};
|
|
1761
|
+
}
|
|
1762
|
+
function ue(o, r, n = 1e-5, i, a, c) {
|
|
1763
|
+
const f = /* @__PURE__ */ new Map(), d = [], y = [], m = [], v = [], A = [], g = 1 / n, b = o.length / 3, E = !1, M = !1, R = !1;
|
|
1764
|
+
for (let _ = 0; _ < b; _++) {
|
|
1765
|
+
const F = o[_ * 3], z = o[_ * 3 + 1], $ = o[_ * 3 + 2];
|
|
1766
|
+
let k = `${Math.round(F * g)}_${Math.round(z * g)}_${Math.round($ * g)}`, T = f.get(k);
|
|
1767
|
+
T === void 0 && (T = d.length / 3, f.set(k, T), d.push(F, z, $)), A[_] = T;
|
|
1768
|
+
}
|
|
1769
|
+
const w = [];
|
|
1770
|
+
for (let _ = 0; _ < r.length; _ += 3) {
|
|
1771
|
+
const F = A[r[_]], z = A[r[_ + 1]], $ = A[r[_ + 2]];
|
|
1772
|
+
F === z || z === $ || F === $ || w.push(F, z, $);
|
|
1773
|
+
}
|
|
1774
|
+
return {
|
|
1775
|
+
positions: new Float32Array(d),
|
|
1776
|
+
indices: new Uint32Array(w),
|
|
1777
|
+
colors: M ? new Float32Array(y) : void 0,
|
|
1778
|
+
uvs: E ? new Float32Array(m) : void 0,
|
|
1779
|
+
normals: R ? new Float32Array(v) : void 0
|
|
1780
|
+
};
|
|
1781
|
+
}
|
|
1782
|
+
function dn(o, r) {
|
|
1783
|
+
const n = /* @__PURE__ */ new Map(), i = (v, A) => {
|
|
1784
|
+
const g = v < A ? `${v}_${A}` : `${A}_${v}`, b = n.get(g) ?? [];
|
|
1785
|
+
b.push(v, A), n.set(g, b);
|
|
1786
|
+
};
|
|
1787
|
+
for (let v = 0; v < r.length; v += 3)
|
|
1788
|
+
i(r[v], r[v + 1]), i(r[v + 1], r[v + 2]), i(r[v + 2], r[v]);
|
|
1789
|
+
const a = /* @__PURE__ */ new Map();
|
|
1790
|
+
for (const [v, A] of n)
|
|
1791
|
+
if (A.length === 2) {
|
|
1792
|
+
const [g, b] = v.split("_").map(Number);
|
|
1793
|
+
n.get(v).length === 2 && a.set(g, b);
|
|
1794
|
+
}
|
|
1795
|
+
const c = [];
|
|
1796
|
+
for (const [, v] of n)
|
|
1797
|
+
v.length === 2 && c.push([v[0], v[1]]);
|
|
1798
|
+
const f = /* @__PURE__ */ new Map();
|
|
1799
|
+
for (const [v, A] of c) {
|
|
1800
|
+
const g = f.get(v) ?? [];
|
|
1801
|
+
g.push(A), f.set(v, g);
|
|
1802
|
+
}
|
|
1803
|
+
const d = /* @__PURE__ */ new Set(), y = [];
|
|
1804
|
+
for (const [v, A] of f)
|
|
1805
|
+
for (const g of A) {
|
|
1806
|
+
const b = `${v}_${g}`;
|
|
1807
|
+
if (d.has(b)) continue;
|
|
1808
|
+
const E = [v];
|
|
1809
|
+
let M = g, R = v;
|
|
1810
|
+
d.add(b);
|
|
1811
|
+
let w = 0;
|
|
1812
|
+
for (; M !== v && w++ < 1e4; ) {
|
|
1813
|
+
E.push(M);
|
|
1814
|
+
const _ = f.get(M) ?? [], F = _.find((z) => z !== R) ?? _[0];
|
|
1815
|
+
if (F === void 0) break;
|
|
1816
|
+
d.add(`${M}_${F}`), R = M, M = F;
|
|
1817
|
+
}
|
|
1818
|
+
if (E.length >= 3) {
|
|
1819
|
+
const _ = E[0];
|
|
1820
|
+
for (let F = 1; F < E.length - 1; F++)
|
|
1821
|
+
y.push(_, E[F], E[F + 1]);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
if (!y.length) return { positions: o, indices: r };
|
|
1825
|
+
const m = new Uint32Array(r.length + y.length);
|
|
1826
|
+
return m.set(r, 0), m.set(y, r.length), { positions: o, indices: m };
|
|
1827
|
+
}
|
|
1828
|
+
function en(o, r) {
|
|
1829
|
+
const n = ue(o, r), i = n.indices.length, a = dn(n.positions, n.indices), c = a.indices;
|
|
1830
|
+
if (c !== n.indices && c.length > i)
|
|
1831
|
+
for (let f = i; f < c.length; f += 3) {
|
|
1832
|
+
const d = c[f + 1];
|
|
1833
|
+
c[f + 1] = c[f + 2], c[f + 2] = d;
|
|
1834
|
+
}
|
|
1835
|
+
return ue(a.positions, c, 1e-4);
|
|
1836
|
+
}
|
|
1837
|
+
function nn(o, r) {
|
|
1838
|
+
const n = new Float32Array(o.length);
|
|
1839
|
+
for (let i = 0; i < o.length; i += 3) {
|
|
1840
|
+
const a = o[i], c = o[i + 1], f = o[i + 2];
|
|
1841
|
+
n[i] = r[0] * a + r[4] * c + r[8] * f + r[12], n[i + 1] = r[1] * a + r[5] * c + r[9] * f + r[13], n[i + 2] = r[2] * a + r[6] * c + r[10] * f + r[14];
|
|
1842
|
+
}
|
|
1843
|
+
return n;
|
|
1844
|
+
}
|
|
1845
|
+
function bt(o, r, n = "z-up") {
|
|
1846
|
+
const i = Math.hypot(o[0], o[1], o[2]);
|
|
1847
|
+
return i < 1e-12 ? { normal: n === "y-up" ? [0, 1, 0] : [0, 0, 1], offset: r } : {
|
|
1848
|
+
normal: [o[0] / i, o[1] / i, o[2] / i],
|
|
1849
|
+
offset: r / i
|
|
1850
|
+
};
|
|
1851
|
+
}
|
|
1852
|
+
function Lt(o) {
|
|
1853
|
+
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], a = n[2] * r[0] - n[0] * r[2], c = n[0] * r[1] - n[1] * r[0], f = Math.hypot(i, a, c) || 1, d = [i / f, a / f, c / f], y = [r[1] * d[2] - r[2] * d[1], r[2] * d[0] - r[0] * d[2], r[0] * d[1] - r[1] * d[0]];
|
|
1854
|
+
return { x: d, y, z: r };
|
|
1855
|
+
}
|
|
1856
|
+
function fe(o, r) {
|
|
1857
|
+
const { x: n, y: i, z: a } = Lt(o);
|
|
1858
|
+
return [n[0], n[1], n[2], 0, i[0], i[1], i[2], 0, a[0], a[1], a[2], 0, r[0], r[1], r[2], 1];
|
|
1859
|
+
}
|
|
1860
|
+
function no(o, r, n) {
|
|
1861
|
+
const { x: i, y: a } = Lt(n);
|
|
1862
|
+
let c = 1 / 0, f = -1 / 0, d = 1 / 0, y = -1 / 0;
|
|
1863
|
+
for (const v of [o[0], r[0]])
|
|
1864
|
+
for (const A of [o[1], r[1]])
|
|
1865
|
+
for (const g of [o[2], r[2]]) {
|
|
1866
|
+
const b = v * i[0] + A * i[1] + g * i[2], E = v * a[0] + A * a[1] + g * a[2];
|
|
1867
|
+
b < c && (c = b), b > f && (f = b), E < d && (d = E), E > y && (y = E);
|
|
1868
|
+
}
|
|
1869
|
+
const m = Math.min(f - c, y - d);
|
|
1870
|
+
return Number.isFinite(m) && m > 0 ? m : 0;
|
|
1871
|
+
}
|
|
1872
|
+
const hn = 0.4, ro = 0.3;
|
|
1873
|
+
function oo(o) {
|
|
1874
|
+
return Math.max(Math.abs(o) * 0.04, ro);
|
|
1875
|
+
}
|
|
1876
|
+
function pn(o, r = 0, n = hn) {
|
|
1877
|
+
if (!(o > 0)) return 0;
|
|
1878
|
+
const i = o * Math.max(0, n), a = o * 0.9;
|
|
1879
|
+
return r > 0 ? Math.min(r, a) : Math.min(i, a);
|
|
1880
|
+
}
|
|
1881
|
+
function yn(o, r, n, i = 0, a = hn) {
|
|
1882
|
+
const c = no(o, r, n);
|
|
1883
|
+
if (!(c > 0)) return 0;
|
|
1884
|
+
const f = c * Math.max(0, a), d = c * 0.9;
|
|
1885
|
+
return i > 0 ? Math.min(i, d) : Math.min(f, d);
|
|
1886
|
+
}
|
|
1887
|
+
function so(o, r, n) {
|
|
1888
|
+
const { normal: i } = bt(r, 0), a = n * 0.3;
|
|
1889
|
+
return [o[0] + i[0] * a, o[1] + i[1] * a, o[2] + i[2] * a];
|
|
1890
|
+
}
|
|
1891
|
+
const io = 0.65;
|
|
1892
|
+
function ao(o, r, n, i, a = io) {
|
|
1893
|
+
const { normal: c } = bt(r, 0), f = i + n * (a - 0.5);
|
|
1894
|
+
return [o[0] + c[0] * f, o[1] + c[1] * f, o[2] + c[2] * f];
|
|
1895
|
+
}
|
|
1896
|
+
function co(o, r, n = 0) {
|
|
1897
|
+
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;
|
|
1898
|
+
}
|
|
1899
|
+
function Ht(o) {
|
|
1900
|
+
const r = o.length / 3;
|
|
1901
|
+
if (r < 1) return [0, 0, 0];
|
|
1902
|
+
let n = 0, i = 0, a = 0;
|
|
1903
|
+
for (let c = 0; c < r; c++)
|
|
1904
|
+
n += o[c * 3], i += o[c * 3 + 1], a += o[c * 3 + 2];
|
|
1905
|
+
return [n / r, i / r, a / r];
|
|
1906
|
+
}
|
|
1907
|
+
function rn(o, r, n) {
|
|
1908
|
+
return (r.x - o.x) * (n.y - o.y) - (r.y - o.y) * (n.x - o.x);
|
|
1909
|
+
}
|
|
1910
|
+
function on(o, r) {
|
|
1911
|
+
return Math.hypot(o.x - r.x, o.y - r.y);
|
|
1912
|
+
}
|
|
1913
|
+
function lo(o, r, n) {
|
|
1914
|
+
if (o.length < 3) return 0;
|
|
1915
|
+
const { normal: i } = bt(r, 0), { x: a, y: c } = Lt(i), f = o.map((g) => {
|
|
1916
|
+
const b = g[0] - n[0], E = g[1] - n[1], M = g[2] - n[2];
|
|
1917
|
+
return { x: b * a[0] + E * a[1] + M * a[2], y: b * c[0] + E * c[1] + M * c[2] };
|
|
1918
|
+
});
|
|
1919
|
+
let d = 0;
|
|
1920
|
+
for (let g = 1; g < f.length; g++)
|
|
1921
|
+
(f[g].y < f[d].y || f[g].y === f[d].y && f[g].x < f[d].x) && (d = g);
|
|
1922
|
+
const y = f[d], m = f.map((g, b) => ({ p: g, i: b })).sort((g, b) => {
|
|
1923
|
+
const E = rn(y, g.p, b.p);
|
|
1924
|
+
return Math.abs(E) < 1e-14 ? on(y, g.p) - on(y, b.p) : E > 0 ? -1 : 1;
|
|
1925
|
+
}), v = [];
|
|
1926
|
+
for (const g of m) {
|
|
1927
|
+
const b = g.p;
|
|
1928
|
+
for (; v.length >= 2 && rn(v[v.length - 2], v[v.length - 1], b) <= 0; ) v.pop();
|
|
1929
|
+
v.push(b);
|
|
1930
|
+
}
|
|
1931
|
+
if (v.length < 3) return 0;
|
|
1932
|
+
let A = 0;
|
|
1933
|
+
for (let g = 0; g < v.length; g++) {
|
|
1934
|
+
const b = (g + 1) % v.length;
|
|
1935
|
+
A += v[g].x * v[b].y - v[b].x * v[g].y;
|
|
1936
|
+
}
|
|
1937
|
+
return Math.abs(A) * 0.5;
|
|
1938
|
+
}
|
|
1939
|
+
function le(o, r) {
|
|
1940
|
+
const [n, i, a, c, f, d] = o;
|
|
1941
|
+
return [n * r[0] + i * r[1] + a * r[2], i * r[0] + c * r[1] + f * r[2], a * r[0] + f * r[1] + d * r[2]];
|
|
1942
|
+
}
|
|
1943
|
+
function uo(o) {
|
|
1944
|
+
if (o.length < 3) return null;
|
|
1945
|
+
let r = 0, n = 0, i = 0;
|
|
1946
|
+
for (const U of o)
|
|
1947
|
+
r += U[0], n += U[1], i += U[2];
|
|
1948
|
+
const a = o.length;
|
|
1949
|
+
r /= a, n /= a, i /= a;
|
|
1950
|
+
let c = 0, f = 0, d = 0, y = 0, m = 0, v = 0;
|
|
1951
|
+
for (const U of o) {
|
|
1952
|
+
const L = U[0] - r, D = U[1] - n, J = U[2] - i;
|
|
1953
|
+
c += L * L, f += L * D, d += L * J, y += D * D, m += D * J, v += J * J;
|
|
1954
|
+
}
|
|
1955
|
+
const A = [c, f, d, y, m, v], g = (U, L) => {
|
|
1956
|
+
let D = U;
|
|
1957
|
+
for (let J = 0; J < 24; J++) {
|
|
1958
|
+
const X = L(D), rt = Math.hypot(X[0], X[1], X[2]);
|
|
1959
|
+
if (rt < 1e-18) return D;
|
|
1960
|
+
D = [X[0] / rt, X[1] / rt, X[2] / rt];
|
|
1961
|
+
}
|
|
1962
|
+
return D;
|
|
1963
|
+
}, b = g([1, 0.3, 0.2], (U) => le(A, U)), E = le(A, b), M = b[0] * E[0] + b[1] * E[1] + b[2] * E[2], R = (U) => {
|
|
1964
|
+
const L = le(A, U), D = M * (b[0] * U[0] + b[1] * U[1] + b[2] * U[2]);
|
|
1965
|
+
return [L[0] - D * b[0], L[1] - D * b[1], L[2] - D * b[2]];
|
|
1966
|
+
}, w = Math.abs(b[0]) < 0.9 ? [1, 0, 0] : [0, 1, 0], _ = [
|
|
1967
|
+
w[1] * b[2] - w[2] * b[1],
|
|
1968
|
+
w[2] * b[0] - w[0] * b[2],
|
|
1969
|
+
w[0] * b[1] - w[1] * b[0]
|
|
1970
|
+
], F = Math.hypot(_[0], _[1], _[2]) || 1, z = [_[0] / F, _[1] / F, _[2] / F], $ = [
|
|
1971
|
+
b[1] * z[2] - b[2] * z[1],
|
|
1972
|
+
b[2] * z[0] - b[0] * z[2],
|
|
1973
|
+
b[0] * z[1] - b[1] * z[0]
|
|
1974
|
+
], k = (U) => {
|
|
1975
|
+
const L = le(A, U);
|
|
1976
|
+
return U[0] * L[0] + U[1] * L[1] + U[2] * L[2];
|
|
1977
|
+
}, T = g(z, R), V = g($, R), C = k(T) >= k(V) ? T : V, j = [
|
|
1978
|
+
b[1] * C[2] - b[2] * C[1],
|
|
1979
|
+
b[2] * C[0] - b[0] * C[2],
|
|
1980
|
+
b[0] * C[1] - b[1] * C[0]
|
|
1981
|
+
], O = Math.hypot(j[0], j[1], j[2]);
|
|
1982
|
+
return O < 1e-12 ? null : [j[0] / O, j[1] / O, j[2] / O];
|
|
1983
|
+
}
|
|
1984
|
+
function fo(o, r) {
|
|
1985
|
+
if (o.length < 2) return 0;
|
|
1986
|
+
const { x: n, y: i } = Lt(r);
|
|
1987
|
+
let a = 1 / 0, c = -1 / 0, f = 1 / 0, d = -1 / 0;
|
|
1988
|
+
for (const m of o) {
|
|
1989
|
+
const v = m[0] * n[0] + m[1] * n[1] + m[2] * n[2], A = m[0] * i[0] + m[1] * i[1] + m[2] * i[2];
|
|
1990
|
+
v < a && (a = v), v > c && (c = v), A < f && (f = A), A > d && (d = A);
|
|
1991
|
+
}
|
|
1992
|
+
const y = Math.min(c - a, d - f);
|
|
1993
|
+
return Number.isFinite(y) && y > 0 ? y : 0;
|
|
1994
|
+
}
|
|
1995
|
+
function ho(o, r, n = 0.99) {
|
|
1996
|
+
const { normal: i } = bt(r, 0), a = Math.floor(o.length / 3);
|
|
1997
|
+
if (a < 1) return 0;
|
|
1998
|
+
const c = new Float64Array(a);
|
|
1999
|
+
for (let d = 0; d < a; d++)
|
|
2000
|
+
c[d] = i[0] * o[d * 3] + i[1] * o[d * 3 + 1] + i[2] * o[d * 3 + 2];
|
|
2001
|
+
c.sort();
|
|
2002
|
+
const f = Math.min(a - 1, Math.max(0, Math.floor((a - 1) * n)));
|
|
2003
|
+
return c[f];
|
|
2004
|
+
}
|
|
2005
|
+
function sn(o, r, n, i, a = 0.99) {
|
|
2006
|
+
if (!(i > 0)) return null;
|
|
2007
|
+
const { normal: c } = bt(n, 0), { x: f, y: d } = Lt(c), y = i * i, m = [], v = Math.floor(o.length / 3);
|
|
2008
|
+
for (let g = 0; g < v; g++) {
|
|
2009
|
+
const b = o[g * 3] - r[0], E = o[g * 3 + 1] - r[1], M = o[g * 3 + 2] - r[2], R = b * f[0] + E * f[1] + M * f[2], w = b * d[0] + E * d[1] + M * d[2];
|
|
2010
|
+
R * R + w * w > y || m.push(c[0] * o[g * 3] + c[1] * o[g * 3 + 1] + c[2] * o[g * 3 + 2]);
|
|
2011
|
+
}
|
|
2012
|
+
if (m.length < 8) return null;
|
|
2013
|
+
m.sort((g, b) => g - b);
|
|
2014
|
+
const A = Math.min(m.length - 1, Math.max(0, Math.floor((m.length - 1) * a)));
|
|
2015
|
+
return m[A];
|
|
2016
|
+
}
|
|
2017
|
+
function an(o, r, n, i = "z-up") {
|
|
2018
|
+
const { positions: a, indices: c } = o, f = c.length / 3;
|
|
2019
|
+
if (f < 1) return null;
|
|
2020
|
+
const d = [0, 0, 0], y = [0, 0, 0];
|
|
2021
|
+
let m = 0, v = 0;
|
|
2022
|
+
const A = [1 / 0, 1 / 0, 1 / 0], g = [-1 / 0, -1 / 0, -1 / 0], b = [];
|
|
2023
|
+
for (let V = 0; V < a.length; V += 3) {
|
|
2024
|
+
const C = [a[V], a[V + 1], a[V + 2]];
|
|
2025
|
+
b.push(C), C[0] < A[0] && (A[0] = C[0]), C[1] < A[1] && (A[1] = C[1]), C[2] < A[2] && (A[2] = C[2]), C[0] > g[0] && (g[0] = C[0]), C[1] > g[1] && (g[1] = C[1]), C[2] > g[2] && (g[2] = C[2]);
|
|
2026
|
+
}
|
|
2027
|
+
for (let V = 0; V < f; V++) {
|
|
2028
|
+
const C = c[V * 3], j = c[V * 3 + 1], O = c[V * 3 + 2], U = a[C * 3], L = a[C * 3 + 1], D = a[C * 3 + 2], J = a[j * 3], X = a[j * 3 + 1], rt = a[j * 3 + 2], H = a[O * 3], G = a[O * 3 + 1], Y = a[O * 3 + 2], mt = J - U, ft = X - L, ut = rt - D, Pt = H - U, Ct = G - L, _t = Y - D, At = ft * _t - ut * Ct, Wt = ut * Pt - mt * _t, Mt = mt * Ct - ft * Pt, xt = 0.5 * Math.hypot(At, Wt, Mt);
|
|
2029
|
+
if (xt < 1e-14) continue;
|
|
2030
|
+
const Tt = 1 / (2 * xt);
|
|
2031
|
+
d[0] += At * Tt * xt, d[1] += Wt * Tt * xt, d[2] += Mt * Tt * xt, y[0] += (U + J + H) / 3, y[1] += (L + X + G) / 3, y[2] += (D + rt + Y) / 3, m += xt, v++;
|
|
2032
|
+
}
|
|
2033
|
+
if (v === 0 || m < 1e-14) return null;
|
|
2034
|
+
y[0] /= v, y[1] /= v, y[2] /= v;
|
|
2035
|
+
const E = Math.hypot(d[0], d[1], d[2]), R = E < m * 0.2 ? uo(b) : null, w = i === "y-up" ? [0, 1, 0] : [0, 0, 1], _ = R ?? (E > 1e-12 ? [d[0] / E, d[1] / E, d[2] / E] : w), F = [n[0] - r[0], n[1] - r[1], n[2] - r[2]], z = Math.hypot(F[0], F[1], F[2]);
|
|
2036
|
+
z > 1e-12 && (_[0] * F[0] + _[1] * F[1] + _[2] * F[2]) / z < 0 && (_[0] = -_[0], _[1] = -_[1], _[2] = -_[2]);
|
|
2037
|
+
let $ = lo(b, _, y);
|
|
2038
|
+
$ > 1e-12 || ($ = m * 0.5);
|
|
2039
|
+
let k = 1 / 0, T = -1 / 0;
|
|
2040
|
+
for (const V of b) {
|
|
2041
|
+
const C = _[0] * (V[0] - y[0]) + _[1] * (V[1] - y[1]) + _[2] * (V[2] - y[2]);
|
|
2042
|
+
C < k && (k = C), C > T && (T = C);
|
|
2043
|
+
}
|
|
2044
|
+
return Number.isFinite(k) || (k = 0, T = 0), {
|
|
2045
|
+
center: y,
|
|
2046
|
+
normal: _,
|
|
2047
|
+
area: $,
|
|
2048
|
+
span: fo(b, _),
|
|
2049
|
+
along: { min: k, max: T },
|
|
2050
|
+
bbox: { min: A, max: g }
|
|
2051
|
+
};
|
|
2052
|
+
}
|
|
2053
|
+
function po(o, r) {
|
|
2054
|
+
if (!(r > 1e-12) || !(o > 0)) return !0;
|
|
2055
|
+
const n = o / r, i = Math.sqrt(r);
|
|
2056
|
+
return n < Math.max(0.4, i * 0.08);
|
|
2057
|
+
}
|
|
2058
|
+
function yo(o, r, n, i, a, c = 0) {
|
|
2059
|
+
return yn(n, i, a, c);
|
|
2060
|
+
}
|
|
2061
|
+
function mo(o, r, n) {
|
|
2062
|
+
const { normal: i } = bt(n, 0), a = [r[0] - o[0], r[1] - o[1], r[2] - o[2]];
|
|
2063
|
+
return Math.abs(a[0] * i[0]) + Math.abs(a[1] * i[1]) + Math.abs(a[2] * i[2]);
|
|
2064
|
+
}
|
|
2065
|
+
function vo(o) {
|
|
2066
|
+
const r = o.positions, n = [1 / 0, 1 / 0, 1 / 0], i = [-1 / 0, -1 / 0, -1 / 0];
|
|
2067
|
+
for (let a = 0; a < r.length; a += 3)
|
|
2068
|
+
r[a] < n[0] && (n[0] = r[a]), r[a + 1] < n[1] && (n[1] = r[a + 1]), r[a + 2] < n[2] && (n[2] = r[a + 2]), r[a] > i[0] && (i[0] = r[a]), r[a + 1] > i[1] && (i[1] = r[a + 1]), r[a + 2] > i[2] && (i[2] = r[a + 2]);
|
|
2069
|
+
return {
|
|
2070
|
+
min: n,
|
|
2071
|
+
max: i,
|
|
2072
|
+
size: [i[0] - n[0], i[1] - n[1], i[2] - n[2]]
|
|
2073
|
+
};
|
|
2074
|
+
}
|
|
2075
|
+
function mn(o, r) {
|
|
2076
|
+
const { normal: n } = bt(o, 0), { normal: i } = bt(r, 0), a = n[0] * i[0] + n[1] * i[1] + n[2] * i[2];
|
|
2077
|
+
if (a > 0.999999) return [0, 0, 0, 1];
|
|
2078
|
+
if (a < -0.999999) {
|
|
2079
|
+
let v = 0, A = 1, g = 0;
|
|
2080
|
+
Math.abs(n[1]) < 0.9 ? (v = 0, A = 1, g = 0) : (v = 1, A = 0, g = 0);
|
|
2081
|
+
let b = n[1] * g - n[2] * A, E = n[2] * v - n[0] * g, M = n[0] * A - n[1] * v;
|
|
2082
|
+
const R = Math.hypot(b, E, M) || 1;
|
|
2083
|
+
return b /= R, E /= R, M /= R, [b, E, M, 0];
|
|
2084
|
+
}
|
|
2085
|
+
let c = 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], y = 1 + a;
|
|
2086
|
+
const m = Math.hypot(c, f, d, y) || 1;
|
|
2087
|
+
return [c / m, f / m, d / m, y / m];
|
|
2088
|
+
}
|
|
2089
|
+
function go(o, r) {
|
|
2090
|
+
const [n, i, a, c] = o, f = c * r[0] + i * r[2] - a * r[1], d = c * r[1] + a * r[0] - n * r[2], y = c * r[2] + n * r[1] - i * r[0], m = -n * r[0] - i * r[1] - a * r[2];
|
|
2091
|
+
return [
|
|
2092
|
+
f * c + m * -n + d * -a - y * -i,
|
|
2093
|
+
d * c + m * -i + y * -n - f * -a,
|
|
2094
|
+
y * c + m * -a + f * -i - d * -n
|
|
2095
|
+
];
|
|
2096
|
+
}
|
|
2097
|
+
function bo(o, r, n, i) {
|
|
2098
|
+
const a = mn(o, r), [c, f, d, y] = a, m = c + c, v = f + f, A = d + d, g = c * m, b = c * v, E = c * A, M = f * v, R = f * A, w = d * A, _ = y * m, F = y * v, z = y * A, $ = n;
|
|
2099
|
+
return [
|
|
2100
|
+
(1 - (M + w)) * $,
|
|
2101
|
+
(b + z) * $,
|
|
2102
|
+
(E - F) * $,
|
|
2103
|
+
0,
|
|
2104
|
+
(b - z) * $,
|
|
2105
|
+
(1 - (g + w)) * $,
|
|
2106
|
+
(R + _) * $,
|
|
2107
|
+
0,
|
|
2108
|
+
(E + F) * $,
|
|
2109
|
+
(R - _) * $,
|
|
2110
|
+
(1 - (g + M)) * $,
|
|
2111
|
+
0,
|
|
2112
|
+
i[0],
|
|
2113
|
+
i[1],
|
|
2114
|
+
i[2],
|
|
2115
|
+
1
|
|
2116
|
+
];
|
|
2117
|
+
}
|
|
2118
|
+
function xo(o) {
|
|
2119
|
+
let r = 1, n = 1 / 0;
|
|
2120
|
+
for (let i = 0; i < 3; i++) {
|
|
2121
|
+
const a = (i + 1) % 3, c = (i + 2) % 3, f = Math.max(o[a], o[c], 1e-9), d = Math.abs(o[a] - o[c]) / f, y = Math.max(o[0], o[1], o[2], 1e-9), m = d * 10 + o[i] / y;
|
|
2122
|
+
m < n && (n = m, r = i);
|
|
2123
|
+
}
|
|
2124
|
+
return r;
|
|
2125
|
+
}
|
|
2126
|
+
function cn(o) {
|
|
2127
|
+
if (o.length < 8) return null;
|
|
2128
|
+
let n = 0, i = 0, a = 0, c = 0, f = 0, d = 0, y = 0, m = 0, v = 0, A = 0, g = 0, b = 0, E = 0, M = 0;
|
|
2129
|
+
for (const $ of o) {
|
|
2130
|
+
const k = $[0], T = $[1], V = $[2], C = k * k + T * T + V * V, j = 2 * k, O = 2 * T, U = 2 * V;
|
|
2131
|
+
n += j * j, i += j * O, a += j * U, c += j, f += O * O, d += O * U, y += O, m += U * U, v += U, A += 1, g += j * C, b += O * C, E += U * C, M += C;
|
|
2132
|
+
}
|
|
2133
|
+
const R = [
|
|
2134
|
+
[n, i, a, c, g],
|
|
2135
|
+
[i, f, d, y, b],
|
|
2136
|
+
[a, d, m, v, E],
|
|
2137
|
+
[c, y, v, A, M]
|
|
2138
|
+
];
|
|
2139
|
+
for (let $ = 0; $ < 4; $++) {
|
|
2140
|
+
let k = $;
|
|
2141
|
+
for (let C = $ + 1; C < 4; C++) Math.abs(R[C][$]) > Math.abs(R[k][$]) && (k = C);
|
|
2142
|
+
if (Math.abs(R[k][$]) < 1e-12) return null;
|
|
2143
|
+
const T = R[$];
|
|
2144
|
+
R[$] = R[k], R[k] = T;
|
|
2145
|
+
const V = R[$][$];
|
|
2146
|
+
for (let C = $; C < 5; C++) R[$][C] /= V;
|
|
2147
|
+
for (let C = 0; C < 4; C++) {
|
|
2148
|
+
if (C === $) continue;
|
|
2149
|
+
const j = R[C][$];
|
|
2150
|
+
for (let O = $; O < 5; O++) R[C][O] -= j * R[$][O];
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
const w = R[0][4], _ = R[1][4], F = R[2][4], z = Math.sqrt(Math.max(0, R[3][4] + w * w + _ * _ + F * F));
|
|
2154
|
+
return !(z > 1e-6) || !Number.isFinite(z) ? null : { center: [w, _, F], radius: z };
|
|
2155
|
+
}
|
|
2156
|
+
function _o(o) {
|
|
2157
|
+
const r = cn(o);
|
|
2158
|
+
if (!r) return null;
|
|
2159
|
+
const n = o.filter((i) => {
|
|
2160
|
+
const a = Math.hypot(i[0] - r.center[0], i[1] - r.center[1], i[2] - r.center[2]);
|
|
2161
|
+
return Math.abs(a - r.radius) < r.radius * 0.12;
|
|
2162
|
+
});
|
|
2163
|
+
return n.length < 8 || n.length > o.length * 0.98 ? r : cn(n) ?? r;
|
|
2164
|
+
}
|
|
2165
|
+
function de(o, r) {
|
|
2166
|
+
const n = vo(o), i = xo(n.size), a = o.positions, c = a.length / 3;
|
|
2167
|
+
if (c < 8) throw new Error("爪扣网格为空");
|
|
2168
|
+
const f = [0, 0, 0];
|
|
2169
|
+
for (let H = 0; H < c; H++)
|
|
2170
|
+
f[0] += a[H * 3], f[1] += a[H * 3 + 1], f[2] += a[H * 3 + 2];
|
|
2171
|
+
const d = [f[0] / c, f[1] / c, f[2] / c], y = [0, 0, 0];
|
|
2172
|
+
y[i] = 1;
|
|
2173
|
+
const m = (H, G) => (a[H * 3] - d[0]) * G[0] + (a[H * 3 + 1] - d[1]) * G[1] + (a[H * 3 + 2] - d[2]) * G[2], v = (H, G) => {
|
|
2174
|
+
const Y = a[H * 3] - d[0], mt = a[H * 3 + 1] - d[1], ft = a[H * 3 + 2] - d[2], ut = Y * G[0] + mt * G[1] + ft * G[2];
|
|
2175
|
+
return Math.hypot(Y - G[0] * ut, mt - G[1] * ut, ft - G[2] * ut);
|
|
2176
|
+
};
|
|
2177
|
+
let A = 1 / 0, g = -1 / 0;
|
|
2178
|
+
for (let H = 0; H < c; H++) {
|
|
2179
|
+
const G = m(H, y);
|
|
2180
|
+
G < A && (A = G), G > g && (g = G);
|
|
2181
|
+
}
|
|
2182
|
+
const E = Math.max(g - A, 1e-9) * 0.08;
|
|
2183
|
+
let M = 1 / 0, R = 1 / 0;
|
|
2184
|
+
for (let H = 0; H < c; H++) {
|
|
2185
|
+
const G = m(H, y), Y = v(H, y);
|
|
2186
|
+
G <= A + E && Y < M && (M = Y), G >= g - E && Y < R && (R = Y);
|
|
2187
|
+
}
|
|
2188
|
+
const w = M <= R ? y : [-y[0], -y[1], -y[2]];
|
|
2189
|
+
let _ = 1 / 0, F = -1 / 0, z = 0;
|
|
2190
|
+
const $ = new Array(c), k = new Array(c);
|
|
2191
|
+
for (let H = 0; H < c; H++) {
|
|
2192
|
+
const G = m(H, w), Y = v(H, w);
|
|
2193
|
+
$[H] = G, k[H] = Y, G < _ && (_ = G), G > F && (F = G), Y > z && (z = Y);
|
|
2194
|
+
}
|
|
2195
|
+
const T = Math.max(F - _, 1e-9), V = [];
|
|
2196
|
+
for (let H = 0; H < c; H++) {
|
|
2197
|
+
const G = ($[H] - _) / T, Y = k[H];
|
|
2198
|
+
if (r === "peg") {
|
|
2199
|
+
if (G < 0.32 || G > 0.97 || Y < z * 0.45) continue;
|
|
2200
|
+
} else if (G < 0.3 || G > 0.92 || Y > z * 0.62 || Y < z * 0.2)
|
|
2201
|
+
continue;
|
|
2202
|
+
V.push([a[H * 3], a[H * 3 + 1], a[H * 3 + 2]]);
|
|
2203
|
+
}
|
|
2204
|
+
const C = _o(V);
|
|
2205
|
+
if (!C) throw new Error(r === "peg" ? "爪扣未能识别球头" : "爪扣未能识别凹窝");
|
|
2206
|
+
const j = [C.center[0] - d[0], C.center[1] - d[1], C.center[2] - d[2]], O = j[0] * w[0] + j[1] * w[1] + j[2] * w[2], U = [
|
|
2207
|
+
d[0] + w[0] * O,
|
|
2208
|
+
d[1] + w[1] * O,
|
|
2209
|
+
d[2] + w[2] * O
|
|
2210
|
+
];
|
|
2211
|
+
let L = 0, D = 0, J = -1 / 0;
|
|
2212
|
+
for (let H = 0; H < c; H++) {
|
|
2213
|
+
const G = ($[H] - _) / T, Y = k[H];
|
|
2214
|
+
G < 0.12 && Y > L && (L = Y), G >= 0.22 && G <= 0.82 && Y > D && (D = Y);
|
|
2215
|
+
}
|
|
2216
|
+
L > 0 || (L = z), D > 0 || (D = L);
|
|
2217
|
+
const X = Math.max(D * 1.15, L * 0.7);
|
|
2218
|
+
for (let H = 0; H < c; H++)
|
|
2219
|
+
k[H] < X || $[H] > O || $[H] > J && (J = $[H]);
|
|
2220
|
+
const rt = Number.isFinite(J) ? Math.max(J - _, T * 0.04) : T * 0.08;
|
|
2221
|
+
return {
|
|
2222
|
+
axis: w,
|
|
2223
|
+
center: U,
|
|
2224
|
+
radius: C.radius,
|
|
2225
|
+
flangeRadius: L,
|
|
2226
|
+
bodyRadius: D,
|
|
2227
|
+
base: _ - O,
|
|
2228
|
+
tip: F - O,
|
|
2229
|
+
flangeThickness: rt
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2232
|
+
function ln(o, r, n, i) {
|
|
2233
|
+
const { normal: a } = bt(r, 0), c = go(mn(o.axis, a), [
|
|
2234
|
+
o.center[0] * i,
|
|
2235
|
+
o.center[1] * i,
|
|
2236
|
+
o.center[2] * i
|
|
2237
|
+
]);
|
|
2238
|
+
return bo(o.axis, a, i, [
|
|
2239
|
+
n[0] - c[0],
|
|
2240
|
+
n[1] - c[1],
|
|
2241
|
+
n[2] - c[2]
|
|
2242
|
+
]);
|
|
2243
|
+
}
|
|
2244
|
+
function Mo(o, r, n) {
|
|
2245
|
+
const i = de(o, "socket"), a = de(r, "peg");
|
|
2246
|
+
return !(a.radius > 1e-6) || !(n > 0) ? 0 : Math.max(0, i.tip) * (n / (a.radius * 2));
|
|
2247
|
+
}
|
|
2248
|
+
function wo(o) {
|
|
2249
|
+
return o > 0 ? Math.min(0.25, o * 0.2) : 0;
|
|
2250
|
+
}
|
|
2251
|
+
function Te(o, r, n, i, a) {
|
|
2252
|
+
const { normal: c } = bt(r, 0), f = c[0] * o[0] + c[1] * o[1] + c[2] * o[2], d = n + i - a - f;
|
|
2253
|
+
return [o[0] + c[0] * d, o[1] + c[1] * d, o[2] + c[2] * d];
|
|
2254
|
+
}
|
|
2255
|
+
function $o(o, r, n, i, a, c = i) {
|
|
2256
|
+
const f = de(o, "socket"), d = de(r, "peg");
|
|
2257
|
+
if (!(d.radius > 1e-6) || !(a > 1e-9)) throw new Error("爪扣尺寸无效");
|
|
2258
|
+
const y = a / (d.radius * 2), { normal: m } = bt(n, 0), v = [-m[0], -m[1], -m[2]], A = f.base + Math.max(f.flangeThickness * 1.25, Math.abs(f.base) * 0.05), g = f.tip + f.radius * 0.12, b = Math.max(g - A, f.radius), E = (A + g) / 2, M = Math.min(Math.max(f.bodyRadius * 1.05, f.radius * 1.15), f.flangeRadius * 0.88) * y;
|
|
2259
|
+
return {
|
|
2260
|
+
aoMatrix: ln(f, v, i, y),
|
|
2261
|
+
tuMatrix: ln(d, m, c, y),
|
|
2262
|
+
scale: y,
|
|
2263
|
+
clearRadius: M,
|
|
2264
|
+
clearLength: b * y,
|
|
2265
|
+
clearCenter: [
|
|
2266
|
+
i[0] + v[0] * E * y,
|
|
2267
|
+
i[1] + v[1] * E * y,
|
|
2268
|
+
i[2] + v[2] * E * y
|
|
2269
|
+
]
|
|
2270
|
+
};
|
|
2271
|
+
}
|
|
2272
|
+
let Se = null, Ae = null;
|
|
2273
|
+
async function Zt() {
|
|
2274
|
+
if (Se) return Se;
|
|
2275
|
+
if (!Ae)
|
|
2276
|
+
throw new Error("几何内核 WASM 未传入 Worker");
|
|
2277
|
+
const o = await Yr({
|
|
2278
|
+
wasmBinary: Ae,
|
|
2279
|
+
locateFile: (r) => r
|
|
2280
|
+
});
|
|
2281
|
+
return o.setup(), Se = o, o;
|
|
2282
|
+
}
|
|
2283
|
+
function vn(o, r, n) {
|
|
2284
|
+
return new o.Mesh({
|
|
2285
|
+
numProp: 3,
|
|
2286
|
+
vertProperties: r,
|
|
2287
|
+
triVerts: n
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
function at(o) {
|
|
2291
|
+
const r = o.getMesh(), n = r.numProp, i = r.vertProperties.length / n, a = new Float32Array(i * 3);
|
|
2292
|
+
for (let c = 0; c < i; c++)
|
|
2293
|
+
a[c * 3] = r.vertProperties[c * n], a[c * 3 + 1] = r.vertProperties[c * n + 1], a[c * 3 + 2] = r.vertProperties[c * n + 2];
|
|
2294
|
+
return { positions: a, indices: new Uint32Array(r.triVerts) };
|
|
2295
|
+
}
|
|
2296
|
+
function Ft(o, r, n) {
|
|
2297
|
+
try {
|
|
2298
|
+
const i = vn(o, r, n);
|
|
2299
|
+
return i.merge(), new o.Manifold(i);
|
|
2300
|
+
} catch {
|
|
2301
|
+
return null;
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
function un(o, r, n) {
|
|
2305
|
+
let i = null;
|
|
2306
|
+
try {
|
|
2307
|
+
const f = vn(o, r, n);
|
|
2308
|
+
f.tolerance = 1e-8, i = new o.Manifold(f);
|
|
2309
|
+
} catch {
|
|
2310
|
+
i = Ft(o, r, n);
|
|
2311
|
+
}
|
|
2312
|
+
if (!i) throw new Error("爪扣网格无法构建实体");
|
|
2313
|
+
const a = i.decompose();
|
|
2314
|
+
if (a.length <= 1) {
|
|
2315
|
+
for (const f of a) f.delete();
|
|
2316
|
+
return i;
|
|
2317
|
+
}
|
|
2318
|
+
i.delete();
|
|
2319
|
+
let c = a[0];
|
|
2320
|
+
for (let f = 1; f < a.length; f++) {
|
|
2321
|
+
const d = c.add(a[f]);
|
|
2322
|
+
c.delete(), a[f].delete(), c = d;
|
|
2323
|
+
}
|
|
2324
|
+
if (c.status() !== "NoError")
|
|
2325
|
+
throw c.delete(), new Error("爪扣网格无法构建实体");
|
|
2326
|
+
return c;
|
|
2327
|
+
}
|
|
2328
|
+
function Fe(o, r, n) {
|
|
2329
|
+
let i = ue(r, n);
|
|
2330
|
+
i = dn(i.positions, i.indices), i = ue(i.positions, i.indices, 1e-4);
|
|
2331
|
+
let a = Ft(o, i.positions, i.indices);
|
|
2332
|
+
if (!a)
|
|
2333
|
+
try {
|
|
2334
|
+
const f = o.Manifold.hull(
|
|
2335
|
+
Array.from({ length: i.positions.length / 3 }, (y, m) => [
|
|
2336
|
+
i.positions[m * 3],
|
|
2337
|
+
i.positions[m * 3 + 1],
|
|
2338
|
+
i.positions[m * 3 + 2]
|
|
2339
|
+
])
|
|
2340
|
+
), d = at(f);
|
|
2341
|
+
return f.delete(), d;
|
|
2342
|
+
} catch {
|
|
2343
|
+
return i;
|
|
2344
|
+
}
|
|
2345
|
+
const c = at(a);
|
|
2346
|
+
return a.delete(), c;
|
|
2347
|
+
}
|
|
2348
|
+
function fn(o, r, n) {
|
|
2349
|
+
const i = Math.max(1.001, n);
|
|
2350
|
+
return o.translate([-r[0], -r[1], -r[2]]).scale(i).translate(r);
|
|
2351
|
+
}
|
|
2352
|
+
function Po(o, r, n, i, a, c, f, d, y, m, v, A) {
|
|
2353
|
+
const g = r.intersect(n), b = Math.abs(g.volume());
|
|
2354
|
+
if (!(b > 1e-10))
|
|
2355
|
+
throw g.delete(), new Error("无有效交集");
|
|
2356
|
+
const E = f >= d, M = E ? r : n, R = E ? n : r, w = E ? [-c.normal[0], -c.normal[1], -c.normal[2]] : [c.normal[0], c.normal[1], c.normal[2]], _ = c.center, F = at(g), z = c.bbox ?? $t(F.positions, F.indices).bbox, $ = po(b, c.area), k = Math.max(mo(z.min, z.max, w), 1e-3), T = Math.sqrt(Math.max(c.area, 1e-6)), V = Math.max(Math.cbrt(b), T * 0.25, 1e-3), C = R.subtract(M);
|
|
2357
|
+
let j = C.add(g);
|
|
2358
|
+
C.delete();
|
|
2359
|
+
let O;
|
|
2360
|
+
if ($) {
|
|
2361
|
+
const L = 1 + Math.max(k * 0.15, T * 0.01, 1e-3) / V, D = fn(g, _, L);
|
|
2362
|
+
O = M.subtract(D), D.delete();
|
|
2363
|
+
} else {
|
|
2364
|
+
const U = Math.max(T * 0.04, k * 0.06, 0.15), L = 1 + U / V;
|
|
2365
|
+
let D = fn(g, _, L);
|
|
2366
|
+
const J = k * 0.35 + U, X = D.translate([w[0] * J, w[1] * J, w[2] * J]);
|
|
2367
|
+
D.delete(), D = X, O = M.subtract(D), D.delete();
|
|
2368
|
+
}
|
|
2369
|
+
if (g.delete(), y === "sphere" || y === "square" || y === "ballSnap" || y === "qiuSnap") {
|
|
2370
|
+
const U = c.span && c.span > 1e-9 ? pn(c.span, m) : yo(c.area, v, z.min, z.max, w, m);
|
|
2371
|
+
if (U > 1e-12)
|
|
2372
|
+
try {
|
|
2373
|
+
const D = ho(at(j).positions, w, 0.99) - (w[0] * _[0] + w[1] * _[1] + w[2] * _[2]), J = ao(_, w, U, D), X = y === "ballSnap" || y === "qiuSnap" ? at(M).positions : void 0, rt = gn(
|
|
2374
|
+
o,
|
|
2375
|
+
O,
|
|
2376
|
+
j,
|
|
2377
|
+
w,
|
|
2378
|
+
J,
|
|
2379
|
+
y,
|
|
2380
|
+
U,
|
|
2381
|
+
A,
|
|
2382
|
+
!0,
|
|
2383
|
+
_,
|
|
2384
|
+
X
|
|
2385
|
+
);
|
|
2386
|
+
O = rt.pos, j = rt.neg;
|
|
2387
|
+
} catch (L) {
|
|
2388
|
+
throw O.delete(), j.delete(), L;
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
return r.delete(), n.delete(), E ? { a: O, b: j } : { a: j, b: O };
|
|
2392
|
+
}
|
|
2393
|
+
function Co(o, r, n, i) {
|
|
2394
|
+
const a = o.intersect(r);
|
|
2395
|
+
if (Math.abs(a.volume()) > 1e-10) return a;
|
|
2396
|
+
a.delete();
|
|
2397
|
+
const c = i[0] - n[0], f = i[1] - n[1], d = i[2] - n[2], y = Math.hypot(c, f, d) || 1, m = Math.max(1e-3, y * 2e-3), v = c / y * m, A = f / y * m, g = d / y * m;
|
|
2398
|
+
for (const b of [1, -1]) {
|
|
2399
|
+
const E = o.translate([v * b, A * b, g * b]), M = E.intersect(r);
|
|
2400
|
+
if (E.delete(), Math.abs(M.volume()) > 1e-10) return M;
|
|
2401
|
+
M.delete();
|
|
2402
|
+
}
|
|
2403
|
+
return null;
|
|
2404
|
+
}
|
|
2405
|
+
function To(o, r, n, i, a, c, f, d, y = !1) {
|
|
2406
|
+
const m = en(c.ao.positions, c.ao.indices), v = en(c.tu.positions, c.tu.indices), A = Mo(m, v, a), { normal: g } = bt(i, 0), b = g[0] * f[0] + g[1] * f[1] + g[2] * f[2];
|
|
2407
|
+
let E = f, M = f;
|
|
2408
|
+
if (A > 0 && y) {
|
|
2409
|
+
const C = Te(f, g, b, A, wo(A));
|
|
2410
|
+
E = C, M = C;
|
|
2411
|
+
} else if (A > 0) {
|
|
2412
|
+
const j = sn(
|
|
2413
|
+
d ?? at(r).positions,
|
|
2414
|
+
f,
|
|
2415
|
+
g,
|
|
2416
|
+
Math.max(a * 0.55, 1),
|
|
2417
|
+
0.04
|
|
2418
|
+
), O = sn(
|
|
2419
|
+
at(n).positions,
|
|
2420
|
+
f,
|
|
2421
|
+
g,
|
|
2422
|
+
Math.max(a * 1.25, 1e-3),
|
|
2423
|
+
0.95
|
|
2424
|
+
);
|
|
2425
|
+
let L = (O ?? b) - 0.25;
|
|
2426
|
+
j != null && L > j && (L = j), E = Te(f, g, L, A, 0), M = O != null ? Te(f, g, O, A, 0.25) : E;
|
|
2427
|
+
}
|
|
2428
|
+
const R = $o(m, v, g, E, a, M), w = un(o, m.positions, m.indices), _ = un(o, v.positions, v.indices), F = w.transform(R.aoMatrix);
|
|
2429
|
+
w.delete();
|
|
2430
|
+
const z = _.transform(R.tuMatrix);
|
|
2431
|
+
_.delete();
|
|
2432
|
+
const $ = o.Manifold.cylinder(R.clearLength, R.clearRadius, R.clearRadius, 48, !0).transform(
|
|
2433
|
+
fe(i, R.clearCenter)
|
|
2434
|
+
), k = r.subtract($);
|
|
2435
|
+
r.delete(), $.delete();
|
|
2436
|
+
const T = k.add(F);
|
|
2437
|
+
k.delete(), F.delete();
|
|
2438
|
+
const V = n.add(z);
|
|
2439
|
+
return n.delete(), z.delete(), { pos: T, neg: V };
|
|
2440
|
+
}
|
|
2441
|
+
function gn(o, r, n, i, a, c, f, d, y = !1, m, v, A = !1) {
|
|
2442
|
+
const g = y ? a : so(a, i, f), b = fe(i, g), E = oo(f);
|
|
2443
|
+
if (c === "qiuSnap" || c === "ballSnap") {
|
|
2444
|
+
if (!d) throw new Error("爪扣模型未加载");
|
|
2445
|
+
return To(
|
|
2446
|
+
o,
|
|
2447
|
+
r,
|
|
2448
|
+
n,
|
|
2449
|
+
i,
|
|
2450
|
+
f,
|
|
2451
|
+
d,
|
|
2452
|
+
m ?? a,
|
|
2453
|
+
v,
|
|
2454
|
+
A
|
|
2455
|
+
);
|
|
2456
|
+
}
|
|
2457
|
+
if (c === "sphere") {
|
|
2458
|
+
const z = f / 2, $ = z + E, k = o.Manifold.sphere($, 28).transform(b), T = o.Manifold.cylinder(f, $, $, 28, !0).transform(b), V = k.add(T);
|
|
2459
|
+
k.delete(), T.delete();
|
|
2460
|
+
const C = o.Manifold.sphere(z, 28).transform(b), j = r.subtract(V), O = n.add(C);
|
|
2461
|
+
return r.delete(), n.delete(), V.delete(), C.delete(), { pos: j, neg: O };
|
|
2462
|
+
}
|
|
2463
|
+
const M = f + 2 * E, R = o.Manifold.cube([M, M, M], !0).transform(b), w = o.Manifold.cube([f, f, f], !0).transform(b), _ = r.subtract(R), F = n.add(w);
|
|
2464
|
+
return r.delete(), n.delete(), R.delete(), w.delete(), { pos: _, neg: F };
|
|
2465
|
+
}
|
|
2466
|
+
function So(o, r, n, i) {
|
|
2467
|
+
let a;
|
|
2468
|
+
if (r === "box")
|
|
2469
|
+
a = o.Manifold.cube([n[0] || 10, n[1] || 10, n[2] || 10], !0);
|
|
2470
|
+
else if (r === "cylinder")
|
|
2471
|
+
a = o.Manifold.cylinder(n[1] || 20, n[0] || 5, n[0] || 5, 32, !0);
|
|
2472
|
+
else if (r === "sphere")
|
|
2473
|
+
a = o.Manifold.sphere(n[0] || 8, 24);
|
|
2474
|
+
else {
|
|
2475
|
+
const c = Math.max(3, Math.floor(n[2] || 6)), f = n[0] || 8, d = n[1] || 16, y = Array.from({ length: c }, (m, v) => {
|
|
2476
|
+
const A = v / c * Math.PI * 2;
|
|
2477
|
+
return [Math.cos(A) * f, Math.sin(A) * f];
|
|
2478
|
+
});
|
|
2479
|
+
a = o.Manifold.extrude([y], d, 0, 0, [1, 1], !0);
|
|
2480
|
+
}
|
|
2481
|
+
return a.transform(i);
|
|
2482
|
+
}
|
|
2483
|
+
function St(o, r, n) {
|
|
2484
|
+
switch (r.kind) {
|
|
2485
|
+
case "primary": {
|
|
2486
|
+
const i = n[r.meshId];
|
|
2487
|
+
if (!i) return { solid: null, buffers: { positions: new Float32Array(), indices: new Uint32Array() } };
|
|
2488
|
+
const a = nn(i.positions, r.transform);
|
|
2489
|
+
return { solid: Ft(o, a, i.indices), buffers: { positions: a, indices: i.indices } };
|
|
2490
|
+
}
|
|
2491
|
+
case "primitive": {
|
|
2492
|
+
const i = So(o, r.type, r.params, r.transform);
|
|
2493
|
+
return { solid: i, buffers: at(i) };
|
|
2494
|
+
}
|
|
2495
|
+
case "transform": {
|
|
2496
|
+
const i = St(o, r.node, n);
|
|
2497
|
+
if (i.solid) {
|
|
2498
|
+
const a = i.solid.transform(r.transform);
|
|
2499
|
+
return i.solid.delete(), { solid: a, buffers: at(a) };
|
|
2500
|
+
}
|
|
2501
|
+
return {
|
|
2502
|
+
solid: null,
|
|
2503
|
+
buffers: {
|
|
2504
|
+
positions: nn(i.buffers.positions, r.transform),
|
|
2505
|
+
indices: i.buffers.indices
|
|
2506
|
+
}
|
|
2507
|
+
};
|
|
2508
|
+
}
|
|
2509
|
+
case "clean": {
|
|
2510
|
+
const i = St(o, r.node, n), a = Fe(o, i.buffers.positions, i.buffers.indices);
|
|
2511
|
+
return i.solid?.delete(), { solid: Ft(o, a.positions, a.indices), buffers: a };
|
|
2512
|
+
}
|
|
2513
|
+
case "simplify": {
|
|
2514
|
+
const i = St(o, r.node, n);
|
|
2515
|
+
if (i.solid) {
|
|
2516
|
+
const a = i.solid.boundingBox(), c = Math.hypot(
|
|
2517
|
+
a.max[0] - a.min[0],
|
|
2518
|
+
a.max[1] - a.min[1],
|
|
2519
|
+
a.max[2] - a.min[2]
|
|
2520
|
+
), f = i.solid.simplify(c * (1 - r.targetRatio) * 0.02);
|
|
2521
|
+
return i.solid.delete(), { solid: f, buffers: at(f) };
|
|
2522
|
+
}
|
|
2523
|
+
return i;
|
|
2524
|
+
}
|
|
2525
|
+
case "sliceBase": {
|
|
2526
|
+
const i = St(o, r.node, n);
|
|
2527
|
+
if (i.solid) {
|
|
2528
|
+
const a = r.axis === "x" ? [1, 0, 0] : r.axis === "y" ? [0, 1, 0] : [0, 0, 1], c = i.solid.trimByPlane(a, r.height);
|
|
2529
|
+
return i.solid.delete(), { solid: c, buffers: at(c) };
|
|
2530
|
+
}
|
|
2531
|
+
return i;
|
|
2532
|
+
}
|
|
2533
|
+
case "trimPlane": {
|
|
2534
|
+
const i = St(o, r.node, n);
|
|
2535
|
+
let a = i;
|
|
2536
|
+
if (!a.solid) {
|
|
2537
|
+
const c = Fe(o, a.buffers.positions, a.buffers.indices);
|
|
2538
|
+
i.solid?.delete(), a = {
|
|
2539
|
+
solid: Ft(o, c.positions, c.indices),
|
|
2540
|
+
buffers: c
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2543
|
+
if (a.solid) {
|
|
2544
|
+
const c = Math.hypot(r.normal[0], r.normal[1], r.normal[2]) || 1, f = [
|
|
2545
|
+
r.normal[0] / c,
|
|
2546
|
+
r.normal[1] / c,
|
|
2547
|
+
r.normal[2] / c
|
|
2548
|
+
], d = a.solid.trimByPlane(f, r.offset / c);
|
|
2549
|
+
return a.solid.delete(), { solid: d, buffers: at(d) };
|
|
2550
|
+
}
|
|
2551
|
+
return a;
|
|
2552
|
+
}
|
|
2553
|
+
case "boolean": {
|
|
2554
|
+
const i = St(o, r.a, n), a = St(o, r.b, n), c = (y) => {
|
|
2555
|
+
if (y.solid) return y;
|
|
2556
|
+
const m = Fe(o, y.buffers.positions, y.buffers.indices);
|
|
2557
|
+
return { solid: Ft(o, m.positions, m.indices), buffers: m };
|
|
2558
|
+
}, f = c(i), d = c(a);
|
|
2559
|
+
if (f.solid && d.solid) {
|
|
2560
|
+
const y = r.op === "union" ? f.solid.add(d.solid) : r.op === "difference" ? f.solid.subtract(d.solid) : f.solid.intersect(d.solid);
|
|
2561
|
+
return f.solid.delete(), d.solid.delete(), { solid: y, buffers: at(y) };
|
|
2562
|
+
}
|
|
2563
|
+
return f.solid?.delete(), d.solid?.delete(), f;
|
|
2564
|
+
}
|
|
2565
|
+
case "merge": {
|
|
2566
|
+
const i = r.nodes.map((c) => St(o, c, n)), a = i.map((c) => c.solid).filter((c) => !!c);
|
|
2567
|
+
if (a.length) {
|
|
2568
|
+
const c = a.length === 1 ? a[0] : o.Manifold.union(a);
|
|
2569
|
+
return i.forEach((f, d) => {
|
|
2570
|
+
(a.length > 1 || d > 0) && f.solid?.delete();
|
|
2571
|
+
}), { solid: c, buffers: at(c) };
|
|
2572
|
+
}
|
|
2573
|
+
return i[0] ?? { solid: null, buffers: { positions: new Float32Array(), indices: new Uint32Array() } };
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
function Fo(o, r, n) {
|
|
2578
|
+
const i = [];
|
|
2579
|
+
let a = 0, c = 0, f = 0, d = 0, y = 0, m = 0, v = 0, A = !1;
|
|
2580
|
+
const g = [1 / 0, 1 / 0, 1 / 0], b = [-1 / 0, -1 / 0, -1 / 0];
|
|
2581
|
+
let E = 1 / 0;
|
|
2582
|
+
o.forEach((F, z) => {
|
|
2583
|
+
const $ = $t(F.positions, F.indices);
|
|
2584
|
+
a += $.triangleCount, c += $.vertexCount, f += $.volume, d += $.surfaceArea, y += $.openEdgeCount, m += $.nonManifoldEdgeCount, v += $.componentCount, A = A || $.invertedNormals, E = Math.min(E, Qr(F.positions, F.indices));
|
|
2585
|
+
for (let k = 0; k < 3; k++)
|
|
2586
|
+
g[k] = Math.min(g[k], $.bbox.min[k]), b[k] = Math.max(b[k], $.bbox.max[k]);
|
|
2587
|
+
});
|
|
2588
|
+
const M = y === 0, R = m === 0 && n.every(Boolean) && M, w = !n.every(Boolean) && M, _ = (F) => i.push(F);
|
|
2589
|
+
return m > 0 ? _({
|
|
2590
|
+
id: "nonmanifold",
|
|
2591
|
+
level: "red",
|
|
2592
|
+
title: "非流形边",
|
|
2593
|
+
explanation: "一条边被超过两个三角形共享,切片器无法判断内外,这会导致打印件断成两截。",
|
|
2594
|
+
count: m,
|
|
2595
|
+
blocking: !0
|
|
2596
|
+
}) : _({ id: "nonmanifold", level: "green", title: "流形边检查通过", explanation: "每条边最多被两个三角形共享。", blocking: !1 }), _(M ? { id: "watertight", level: "green", title: "水密检查通过", explanation: "网格封闭,可以计算体积。", blocking: !1 } : {
|
|
2597
|
+
id: "watertight",
|
|
2598
|
+
level: "red",
|
|
2599
|
+
title: "表面不水密",
|
|
2600
|
+
explanation: "存在开边或破洞,体积无法准确计算,切片时可能缺层。",
|
|
2601
|
+
count: y,
|
|
2602
|
+
blocking: !0
|
|
2603
|
+
}), _(w ? {
|
|
2604
|
+
id: "selfintersect",
|
|
2605
|
+
level: "red",
|
|
2606
|
+
title: "自相交或无法构建实体",
|
|
2607
|
+
explanation: "三角形互相穿透或拓扑无法形成实体,布尔与切片均不可靠。",
|
|
2608
|
+
blocking: !0
|
|
2609
|
+
} : { id: "selfintersect", level: "green", title: "自交检查通过", explanation: "几何内核可以构造成实体。", blocking: !1 }), E > 0 && E < r ? _({
|
|
2610
|
+
id: "thinwall",
|
|
2611
|
+
level: "yellow",
|
|
2612
|
+
title: "薄壁",
|
|
2613
|
+
explanation: `最薄处约 ${E.toFixed(2)} mm,低于常用打印工艺下限,切片后可能消失。`,
|
|
2614
|
+
blocking: !1
|
|
2615
|
+
}) : _({ id: "thinwall", level: "green", title: "壁厚检查通过", explanation: "采样壁厚高于设定下限。", blocking: !1 }), v > o.length ? _({
|
|
2616
|
+
id: "islands",
|
|
2617
|
+
level: "yellow",
|
|
2618
|
+
title: "浮空碎片",
|
|
2619
|
+
explanation: "与主体不连通的游离几何体,打印时可能掉落或单独成件。",
|
|
2620
|
+
count: v,
|
|
2621
|
+
blocking: !1
|
|
2622
|
+
}) : _({ id: "islands", level: "green", title: "连通性通过", explanation: "未发现多余的游离碎片。", blocking: !1 }), _(A ? {
|
|
2623
|
+
id: "normals",
|
|
2624
|
+
level: "yellow",
|
|
2625
|
+
title: "法线反向",
|
|
2626
|
+
explanation: "部分面朝向内侧,可能被切片器误判为空洞。",
|
|
2627
|
+
blocking: !1
|
|
2628
|
+
} : { id: "normals", level: "green", title: "法线方向正常", explanation: "体积符号为正,外法线朝外。", blocking: !1 }), {
|
|
2629
|
+
items: i,
|
|
2630
|
+
triangleCount: a,
|
|
2631
|
+
vertexCount: c,
|
|
2632
|
+
volumeMm3: Math.abs(f),
|
|
2633
|
+
surfaceAreaMm2: d,
|
|
2634
|
+
bbox: {
|
|
2635
|
+
min: g,
|
|
2636
|
+
max: b,
|
|
2637
|
+
size: [b[0] - g[0], b[1] - g[1], b[2] - g[2]]
|
|
2638
|
+
},
|
|
2639
|
+
watertight: M,
|
|
2640
|
+
manifold: R,
|
|
2641
|
+
selfIntersect: w,
|
|
2642
|
+
invertedNormals: A,
|
|
2643
|
+
openEdgeCount: y,
|
|
2644
|
+
nonManifoldEdgeCount: m,
|
|
2645
|
+
componentCount: v,
|
|
2646
|
+
minThicknessMm: Number.isFinite(E) ? E : 0
|
|
2647
|
+
};
|
|
2648
|
+
}
|
|
2649
|
+
self.onmessage = async (o) => {
|
|
2650
|
+
const r = o.data, n = (i) => self.postMessage(i);
|
|
2651
|
+
try {
|
|
2652
|
+
if (r.type === "init") {
|
|
2653
|
+
r.wasmBinary && (Ae = r.wasmBinary), await Zt(), n({ id: r.id, type: "ready" });
|
|
2654
|
+
return;
|
|
2655
|
+
}
|
|
2656
|
+
if (r.type === "evaluate") {
|
|
2657
|
+
const i = await Zt(), a = [], c = [], f = [];
|
|
2658
|
+
for (const m of r.roots) {
|
|
2659
|
+
const v = St(i, m, r.sources);
|
|
2660
|
+
a.push(v.buffers), c.push(!!v.solid && v.solid.status() === "NoError"), v.solid?.delete(), r.wantThicknessColors && f.push(to(v.buffers.positions, v.buffers.indices, r.wallMinMm));
|
|
2661
|
+
}
|
|
2662
|
+
const d = a.map((m, v) => eo(m.positions, m.indices, r.wallMinMm, v)), y = Fo(a, r.wallMinMm, c);
|
|
2663
|
+
n({
|
|
2664
|
+
id: r.id,
|
|
2665
|
+
type: "evaluated",
|
|
2666
|
+
meshes: a,
|
|
2667
|
+
diagnosis: y,
|
|
2668
|
+
thicknessColors: r.wantThicknessColors ? f : void 0,
|
|
2669
|
+
defects: d
|
|
2670
|
+
});
|
|
2671
|
+
return;
|
|
2672
|
+
}
|
|
2673
|
+
if (r.type === "decompose") {
|
|
2674
|
+
const i = await Zt(), a = Ft(i, r.mesh.positions, r.mesh.indices);
|
|
2675
|
+
if (!a) {
|
|
2676
|
+
n({ id: r.id, type: "decomposed", meshes: [r.mesh] });
|
|
2677
|
+
return;
|
|
2678
|
+
}
|
|
2679
|
+
const c = a.decompose();
|
|
2680
|
+
a.delete();
|
|
2681
|
+
const f = c.map((d) => {
|
|
2682
|
+
const y = at(d);
|
|
2683
|
+
return d.delete(), y;
|
|
2684
|
+
});
|
|
2685
|
+
n({ id: r.id, type: "decomposed", meshes: f.length ? f : [r.mesh] });
|
|
2686
|
+
return;
|
|
2687
|
+
}
|
|
2688
|
+
if (r.type === "splitByPlane") {
|
|
2689
|
+
const i = await Zt(), a = Math.hypot(r.normal[0], r.normal[1], r.normal[2]) || 1, c = [r.normal[0] / a, r.normal[1] / a, r.normal[2] / a], f = r.offset / a;
|
|
2690
|
+
let d = Ft(i, r.mesh.positions, r.mesh.indices);
|
|
2691
|
+
if (!d) {
|
|
2692
|
+
n({ id: r.id, type: "error", message: "当前网格无法构建实体,请先修复再拆件" });
|
|
2693
|
+
return;
|
|
2694
|
+
}
|
|
2695
|
+
const y = r.connector === "sphere" || r.connector === "square" || r.connector === "ballSnap" || r.connector === "qiuSnap";
|
|
2696
|
+
if ((r.connector === "ballSnap" || r.connector === "qiuSnap") && !r.qiuSnap) {
|
|
2697
|
+
d.delete(), n({ id: r.id, type: "error", message: "爪扣模型未加载" });
|
|
2698
|
+
return;
|
|
2699
|
+
}
|
|
2700
|
+
const m = r.width, v = r.height, A = !!(m && v && m > 0 && v > 0), g = $t(r.mesh.positions, r.mesh.indices), b = Ht(r.mesh.positions);
|
|
2701
|
+
let E = [r.center[0], r.center[1], r.center[2]], M = { min: g.bbox.min, max: g.bbox.max }, R = 0;
|
|
2702
|
+
const w = ($) => {
|
|
2703
|
+
if (!(Math.abs($.volume()) > 1e-10)) return;
|
|
2704
|
+
const k = at($), T = [
|
|
2705
|
+
b[0] + c[0],
|
|
2706
|
+
b[1] + c[1],
|
|
2707
|
+
b[2] + c[2]
|
|
2708
|
+
], V = an(k, b, T, r.upAxis ?? "z-up");
|
|
2709
|
+
if (V && V.area > 1e-12) {
|
|
2710
|
+
E = V.center, M = V.bbox, R = V.span;
|
|
2711
|
+
return;
|
|
2712
|
+
}
|
|
2713
|
+
E = Ht(k.positions);
|
|
2714
|
+
const C = $t(k.positions, k.indices);
|
|
2715
|
+
M = { min: C.bbox.min, max: C.bbox.max };
|
|
2716
|
+
};
|
|
2717
|
+
let _, F;
|
|
2718
|
+
if (A) {
|
|
2719
|
+
const $ = y ? 1e-3 : Math.max(r.gapMm, 1e-3), k = i.Manifold.cube([m, v, $], !0).transform(
|
|
2720
|
+
fe(c, r.center)
|
|
2721
|
+
), T = d.intersect(k);
|
|
2722
|
+
if (!(Math.abs(T.volume()) > 1e-10)) {
|
|
2723
|
+
T.delete(), k.delete();
|
|
2724
|
+
const D = [at(d)];
|
|
2725
|
+
d.delete(), n({ id: r.id, type: "splitByPlane", meshes: D });
|
|
2726
|
+
return;
|
|
2727
|
+
}
|
|
2728
|
+
y && w(T), T.delete();
|
|
2729
|
+
const C = d.subtract(k);
|
|
2730
|
+
d.delete(), k.delete();
|
|
2731
|
+
const j = C.decompose();
|
|
2732
|
+
if (C.delete(), j.length < 2) {
|
|
2733
|
+
const D = j.length ? [at(j[0])] : [r.mesh];
|
|
2734
|
+
for (const J of j) J.delete();
|
|
2735
|
+
n({ id: r.id, type: "splitByPlane", meshes: D });
|
|
2736
|
+
return;
|
|
2737
|
+
}
|
|
2738
|
+
const O = [], U = [];
|
|
2739
|
+
for (const D of j) {
|
|
2740
|
+
const J = Ht(at(D).positions);
|
|
2741
|
+
c[0] * J[0] + c[1] * J[1] + c[2] * J[2] >= f ? O.push(D) : U.push(D);
|
|
2742
|
+
}
|
|
2743
|
+
const L = (D) => {
|
|
2744
|
+
let J = D[0];
|
|
2745
|
+
for (let X = 1; X < D.length; X++) {
|
|
2746
|
+
const rt = J.add(D[X]);
|
|
2747
|
+
J.delete(), D[X].delete(), J = rt;
|
|
2748
|
+
}
|
|
2749
|
+
return J;
|
|
2750
|
+
};
|
|
2751
|
+
if (O.length && U.length)
|
|
2752
|
+
_ = L(O), F = L(U);
|
|
2753
|
+
else {
|
|
2754
|
+
const D = j.map((J) => ({ p: J, vol: Math.abs(J.volume()) }));
|
|
2755
|
+
D.sort((J, X) => X.vol - J.vol), _ = D[0].p, F = L(D.slice(1).map((J) => J.p));
|
|
2756
|
+
}
|
|
2757
|
+
} else {
|
|
2758
|
+
if (y) {
|
|
2759
|
+
const { x: T, y: V } = Lt(c);
|
|
2760
|
+
let C = 1 / 0, j = -1 / 0, O = 1 / 0, U = -1 / 0;
|
|
2761
|
+
const L = g.bbox.min, D = g.bbox.max;
|
|
2762
|
+
for (const G of [L[0], D[0]])
|
|
2763
|
+
for (const Y of [L[1], D[1]])
|
|
2764
|
+
for (const mt of [L[2], D[2]]) {
|
|
2765
|
+
const ft = G * T[0] + Y * T[1] + mt * T[2], ut = G * V[0] + Y * V[1] + mt * V[2];
|
|
2766
|
+
ft < C && (C = ft), ft > j && (j = ft), ut < O && (O = ut), ut > U && (U = ut);
|
|
2767
|
+
}
|
|
2768
|
+
const J = Math.max(j - C, 1e-3) * 1.05, X = Math.max(U - O, 1e-3) * 1.05, rt = i.Manifold.cube([J, X, 1e-3], !0).transform(
|
|
2769
|
+
fe(c, r.center)
|
|
2770
|
+
), H = d.intersect(rt);
|
|
2771
|
+
w(H), H.delete(), rt.delete();
|
|
2772
|
+
}
|
|
2773
|
+
const $ = d.splitByPlane(c, f);
|
|
2774
|
+
d.delete();
|
|
2775
|
+
const k = y ? 0 : Math.max(0, r.gapMm) / 2;
|
|
2776
|
+
if (_ = $[0], F = $[1], k > 1e-9) {
|
|
2777
|
+
const T = _.trimByPlane(c, f + k), V = F.trimByPlane([-c[0], -c[1], -c[2]], -f + k);
|
|
2778
|
+
_.delete(), F.delete(), _ = T, F = V;
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
if (y) {
|
|
2782
|
+
const $ = R > 1e-9 ? pn(R, r.connectorSize) : yn(M.min, M.max, c, r.connectorSize);
|
|
2783
|
+
if ($ > 1e-12)
|
|
2784
|
+
try {
|
|
2785
|
+
const k = gn(
|
|
2786
|
+
i,
|
|
2787
|
+
_,
|
|
2788
|
+
F,
|
|
2789
|
+
c,
|
|
2790
|
+
E,
|
|
2791
|
+
r.connector,
|
|
2792
|
+
$,
|
|
2793
|
+
r.qiuSnap,
|
|
2794
|
+
!1,
|
|
2795
|
+
E,
|
|
2796
|
+
void 0,
|
|
2797
|
+
!0
|
|
2798
|
+
);
|
|
2799
|
+
_ = k.pos, F = k.neg;
|
|
2800
|
+
} catch (k) {
|
|
2801
|
+
_.delete(), F.delete(), n({
|
|
2802
|
+
id: r.id,
|
|
2803
|
+
type: "error",
|
|
2804
|
+
message: k instanceof Error ? `卡扣布尔失败:${k.message}` : "卡扣布尔失败"
|
|
2805
|
+
});
|
|
2806
|
+
return;
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
const z = [at(_), at(F)];
|
|
2810
|
+
if (_.delete(), F.delete(), z.some(($) => !$.indices.length)) {
|
|
2811
|
+
n({ id: r.id, type: "error", message: "切面未把模型分成两块,请调整切面位置" });
|
|
2812
|
+
return;
|
|
2813
|
+
}
|
|
2814
|
+
n({ id: r.id, type: "splitByPlane", meshes: z });
|
|
2815
|
+
return;
|
|
2816
|
+
}
|
|
2817
|
+
if (r.type === "assembleByContacts") {
|
|
2818
|
+
const i = await Zt(), a = r.meshes.length;
|
|
2819
|
+
if (a < 2) {
|
|
2820
|
+
n({ id: r.id, type: "error", message: "至少需要 2 个零件才能按接触面装配" });
|
|
2821
|
+
return;
|
|
2822
|
+
}
|
|
2823
|
+
if ((r.connector === "ballSnap" || r.connector === "qiuSnap") && !r.qiuSnap) {
|
|
2824
|
+
n({ id: r.id, type: "error", message: "爪扣模型未加载" });
|
|
2825
|
+
return;
|
|
2826
|
+
}
|
|
2827
|
+
const c = [], f = [], d = [], y = [];
|
|
2828
|
+
for (let M = 0; M < a; M++) {
|
|
2829
|
+
const R = r.meshes[M], w = $t(R.positions, R.indices);
|
|
2830
|
+
if (w.openEdgeCount > 0 || w.nonManifoldEdgeCount > 0) {
|
|
2831
|
+
for (const F of c) F?.delete();
|
|
2832
|
+
n({
|
|
2833
|
+
id: r.id,
|
|
2834
|
+
type: "error",
|
|
2835
|
+
message: `零件 ${M + 1} 不是封闭实体,请先修复再装配`
|
|
2836
|
+
});
|
|
2837
|
+
return;
|
|
2838
|
+
}
|
|
2839
|
+
const _ = Ft(i, R.positions, R.indices);
|
|
2840
|
+
if (!_) {
|
|
2841
|
+
for (const F of c) F?.delete();
|
|
2842
|
+
n({ id: r.id, type: "error", message: `零件 ${M + 1} 无法构建实体` });
|
|
2843
|
+
return;
|
|
2844
|
+
}
|
|
2845
|
+
c.push(_), f.push(Ht(R.positions)), d.push(Math.abs(w.volume) || Math.abs(_.volume())), y.push({ min: w.bbox.min, max: w.bbox.max });
|
|
2846
|
+
}
|
|
2847
|
+
const m = [];
|
|
2848
|
+
for (let M = 0; M < a; M++)
|
|
2849
|
+
for (let R = M + 1; R < a; R++) {
|
|
2850
|
+
if (!co(y[M], y[R], 1e-3)) continue;
|
|
2851
|
+
const w = c[M], _ = c[R], F = Co(w, _, f[M], f[R]);
|
|
2852
|
+
if (!F) continue;
|
|
2853
|
+
const z = at(F), $ = Math.abs(F.volume());
|
|
2854
|
+
F.delete();
|
|
2855
|
+
const k = an(z, f[M], f[R], r.upAxis ?? "z-up");
|
|
2856
|
+
!k || !(k.area > 1e-12) || !($ > 1e-10) || m.push({
|
|
2857
|
+
idxA: M,
|
|
2858
|
+
idxB: R,
|
|
2859
|
+
center: k.center,
|
|
2860
|
+
normal: k.normal,
|
|
2861
|
+
area: k.area,
|
|
2862
|
+
span: k.span,
|
|
2863
|
+
along: k.along,
|
|
2864
|
+
volume: $,
|
|
2865
|
+
bbox: k.bbox
|
|
2866
|
+
});
|
|
2867
|
+
}
|
|
2868
|
+
m.sort((M, R) => R.area - M.area);
|
|
2869
|
+
const v = m.length ? m[0].area : 0, A = [];
|
|
2870
|
+
let g = 0, b = 0;
|
|
2871
|
+
for (const M of m) {
|
|
2872
|
+
const R = c[M.idxA], w = c[M.idxB];
|
|
2873
|
+
if (!R || !w) {
|
|
2874
|
+
b++;
|
|
2875
|
+
continue;
|
|
2876
|
+
}
|
|
2877
|
+
try {
|
|
2878
|
+
const _ = R.intersect(w), F = Math.abs(_.volume()) > 1e-10;
|
|
2879
|
+
if (_.delete(), !F) {
|
|
2880
|
+
b++;
|
|
2881
|
+
continue;
|
|
2882
|
+
}
|
|
2883
|
+
const z = Po(
|
|
2884
|
+
i,
|
|
2885
|
+
R,
|
|
2886
|
+
w,
|
|
2887
|
+
f[M.idxA],
|
|
2888
|
+
f[M.idxB],
|
|
2889
|
+
{ center: M.center, normal: M.normal, area: M.area, span: M.span, along: M.along, bbox: M.bbox },
|
|
2890
|
+
d[M.idxA],
|
|
2891
|
+
d[M.idxB],
|
|
2892
|
+
r.connector,
|
|
2893
|
+
r.connectorSize,
|
|
2894
|
+
v,
|
|
2895
|
+
r.qiuSnap
|
|
2896
|
+
);
|
|
2897
|
+
c[M.idxA] = z.a, c[M.idxB] = z.b;
|
|
2898
|
+
const $ = at(z.a), k = at(z.b);
|
|
2899
|
+
f[M.idxA] = Ht($.positions), f[M.idxB] = Ht(k.positions), d[M.idxA] = Math.abs($t($.positions, $.indices).volume), d[M.idxB] = Math.abs($t(k.positions, k.indices).volume), y[M.idxA] = {
|
|
2900
|
+
min: $t($.positions, $.indices).bbox.min,
|
|
2901
|
+
max: $t($.positions, $.indices).bbox.max
|
|
2902
|
+
}, y[M.idxB] = {
|
|
2903
|
+
min: $t(k.positions, k.indices).bbox.min,
|
|
2904
|
+
max: $t(k.positions, k.indices).bbox.max
|
|
2905
|
+
}, A.push({
|
|
2906
|
+
idxA: M.idxA,
|
|
2907
|
+
idxB: M.idxB,
|
|
2908
|
+
center: M.center,
|
|
2909
|
+
normal: M.normal,
|
|
2910
|
+
area: M.area
|
|
2911
|
+
}), g++;
|
|
2912
|
+
} catch {
|
|
2913
|
+
b++;
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
if (g === 0 && m.length === 0) {
|
|
2917
|
+
for (const M of c) M?.delete();
|
|
2918
|
+
n({ id: r.id, type: "error", message: "未检测到零件间接触面,无法装配" });
|
|
2919
|
+
return;
|
|
2920
|
+
}
|
|
2921
|
+
const E = [];
|
|
2922
|
+
for (let M = 0; M < a; M++) {
|
|
2923
|
+
const R = c[M];
|
|
2924
|
+
if (!R) {
|
|
2925
|
+
E.push(r.meshes[M]);
|
|
2926
|
+
continue;
|
|
2927
|
+
}
|
|
2928
|
+
E.push(at(R)), R.delete();
|
|
2929
|
+
}
|
|
2930
|
+
n({
|
|
2931
|
+
id: r.id,
|
|
2932
|
+
type: "assembleByContacts",
|
|
2933
|
+
meshes: E,
|
|
2934
|
+
contacts: A,
|
|
2935
|
+
applied: g,
|
|
2936
|
+
skipped: b
|
|
2937
|
+
});
|
|
2938
|
+
}
|
|
2939
|
+
} catch (i) {
|
|
2940
|
+
n({ id: r.id, type: "error", message: i instanceof Error ? i.message : String(i) });
|
|
2941
|
+
}
|
|
2942
|
+
};
|
|
2943
|
+
var Ao = /* @__PURE__ */ Object.freeze({
|
|
2944
|
+
__proto__: null
|
|
2945
|
+
});
|