@equinor/videx-3d 1.0.0 → 1.0.2

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.
@@ -0,0 +1,687 @@
1
+ import { lerp as Z } from "three/src/math/MathUtils.js";
2
+ import { d as G, P as x, o as S, p as tt, a3 as N, E as st, F as et, aa as it, ag as nt, J as rt } from "./chunk-iY0wQ9Z6.js";
3
+ import { BufferGeometry as K, BufferAttribute as L } from "three";
4
+ function at(n, t) {
5
+ switch (t) {
6
+ case "Uint8Array":
7
+ return new Uint8Array(n);
8
+ case "Uint16Array":
9
+ return new Uint16Array(n);
10
+ case "Uint32Array":
11
+ return new Uint32Array(n);
12
+ case "Int8Array":
13
+ return new Int8Array(n);
14
+ case "Int16Array":
15
+ return new Int16Array(n);
16
+ case "Int32Array":
17
+ return new Int32Array(n);
18
+ case "Float32Array":
19
+ return new Float32Array(n);
20
+ case "Float64Array":
21
+ return new Float64Array(n);
22
+ default:
23
+ throw Error("Unsupported typed array!");
24
+ }
25
+ }
26
+ function ot(n, t = !1) {
27
+ if (!n.length) return null;
28
+ if (n.length === 1) return { geometry: n[0], groups: null };
29
+ const s = {
30
+ positions: Array.from(n[0].positions),
31
+ indices: Array.from(n[0].indices),
32
+ vertexCount: n[0].vertexCount,
33
+ indexCount: n[0].indexCount,
34
+ attributes: {}
35
+ };
36
+ for (const r in n[0].attributes)
37
+ s.attributes[r] = {
38
+ array: Array.from(n[0].attributes[r].array),
39
+ itemSize: n[0].attributes[r].itemSize,
40
+ type: n[0].attributes[r].type
41
+ };
42
+ const e = t ? [] : null;
43
+ let o = s.vertexCount, l = 0;
44
+ if (e) {
45
+ const r = s.indexCount;
46
+ e.push([l, r, e.length]), l += r;
47
+ }
48
+ for (let r = 1; r < n.length; r++) {
49
+ const i = n[r];
50
+ if (e) {
51
+ const a = i.indexCount;
52
+ e.push([l, a, e.length]), l += a;
53
+ }
54
+ s.positions = s.positions.concat(i.positions);
55
+ for (let a = 0; a < i.indices.length; a++)
56
+ s.indices.push(o + i.indices[a]);
57
+ s.vertexCount += i.vertexCount, s.indexCount += i.indexCount;
58
+ for (const a in s.attributes) {
59
+ if (!i.attributes || !i.attributes[a])
60
+ throw Error(`Attribute '${a}' missing in geometry`);
61
+ s.attributes[a].array = s.attributes[a].array.concat(i.attributes[a].array);
62
+ }
63
+ o += i.vertexCount, i.vertexCount = 0, i.indexCount = 0;
64
+ }
65
+ return { geometry: s, groups: e };
66
+ }
67
+ function ut(n, t = !1) {
68
+ const s = ot(n, t);
69
+ if (!s) return null;
70
+ const { geometry: e, groups: o } = s, l = new K();
71
+ o && o.forEach((i) => {
72
+ l.addGroup(i[0], i[1], i[2]);
73
+ }), l.setAttribute(
74
+ "position",
75
+ new L(Float32Array.from(e.positions), 3)
76
+ );
77
+ for (const i in e.attributes) {
78
+ const a = e.attributes[i], u = at(a.array, a.type);
79
+ l.setAttribute(i, new L(u, a.itemSize));
80
+ }
81
+ const r = e.indices.length < 65535 ? Uint16Array.from(e.indices) : Uint32Array.from(e.indices);
82
+ return l.setIndex(new L(r, 1)), l;
83
+ }
84
+ function D(n) {
85
+ const t = {
86
+ vertexCount: 0,
87
+ indexCount: 0,
88
+ positions: [],
89
+ indices: [],
90
+ attributes: {}
91
+ };
92
+ return n.computeNormals && (t.attributes.normal = {
93
+ array: [],
94
+ itemSize: 3,
95
+ type: "Float32Array"
96
+ }), n.computeLengths && (t.attributes.curveLength = {
97
+ array: [],
98
+ itemSize: 1,
99
+ type: "Float32Array"
100
+ }), n.computeRelativeLengths && (t.attributes.curveRelativeLength = {
101
+ array: [],
102
+ itemSize: 1,
103
+ type: "Float32Array"
104
+ }), n.computeCurveNormals && (t.attributes.curveNormal = {
105
+ array: [],
106
+ itemSize: 3,
107
+ type: "Float32Array"
108
+ }), n.computeCurveTangents && (t.attributes.curveTangent = {
109
+ array: [],
110
+ itemSize: 3,
111
+ type: "Float32Array"
112
+ }), n.computeCurveBinormals && (t.attributes.curveBinormal = {
113
+ array: [],
114
+ itemSize: 3,
115
+ type: "Float32Array"
116
+ }), n.computeCenterPoints && (t.attributes.centerPoint = {
117
+ array: [],
118
+ itemSize: 3,
119
+ type: "Float32Array"
120
+ }), n.computeUvs && (t.attributes.uv = {
121
+ array: [],
122
+ itemSize: 2,
123
+ type: "Float32Array"
124
+ }), t;
125
+ }
126
+ function U(n, t, s) {
127
+ if (t[0] === s[0]) return s[1];
128
+ const e = s[0] - t[0], o = G((n - t[0]) / e, 0, 1);
129
+ return Z(t[1], s[1], o);
130
+ }
131
+ function H(n, t, s, e, o, l, r, i) {
132
+ const a = [];
133
+ if (t === "none" || l.length === 0)
134
+ a.push([s, o], [e, o]);
135
+ else {
136
+ let d = [0, o], g = [1, o];
137
+ const b = l.findIndex((v) => v[0] > s);
138
+ b === -1 ? d = l[l.length - 1] : (b > 0 && (d = l[b - 1]), g = l[b]);
139
+ const y = t === "linear" ? U(s, d, g) : d[1];
140
+ a.push([s, y]);
141
+ for (let v = b; v >= 0 && v < l.length; v++) {
142
+ const p = l[v];
143
+ if (p[0] < e)
144
+ a.push(p);
145
+ else {
146
+ t === "linear" ? a.push([
147
+ e,
148
+ U(e, a[a.length - 1], p)
149
+ ]) : a.push([e, a[a.length - 1][1]]);
150
+ break;
151
+ }
152
+ }
153
+ a[a.length - 1][0] < e && (t === "linear" ? a.push([
154
+ e,
155
+ U(e, a[a.length - 1], [1, o])
156
+ ]) : a.push([e, a[a.length - 1][1]]));
157
+ }
158
+ const u = [], c = S(
159
+ n,
160
+ s,
161
+ e,
162
+ r,
163
+ i
164
+ );
165
+ let f = 0, h = c[f];
166
+ for (let d = 0; d < a.length - 1; d++) {
167
+ const g = d + 1, [b, y] = a[d], [v, p] = a[g], A = (v - b) * n.length, q = p - y, C = Math.atan2(q, A);
168
+ for (u.push([
169
+ b,
170
+ y,
171
+ t === "linear" ? C : 0
172
+ ]); h <= b && f < c.length - 1; )
173
+ h = c[++f];
174
+ for (; h < v && f < c.length; ) {
175
+ const z = t === "linear" ? U(h, a[d], a[g]) : y;
176
+ u.push([
177
+ h,
178
+ z,
179
+ t === "linear" ? C : 0
180
+ ]), h = c[f++];
181
+ }
182
+ if (g < a.length) {
183
+ if (t === "linear")
184
+ u.push([
185
+ v,
186
+ p,
187
+ t === "linear" ? C : 0
188
+ ]);
189
+ else if (t === "stepped") {
190
+ const z = C < 0 ? -x / 2 : x / 2;
191
+ u.push(
192
+ [v, y, 0],
193
+ [v, y, z],
194
+ [v, p, z]
195
+ );
196
+ }
197
+ }
198
+ g === a.length - 1 && t === "none" && u.push([v, p, C]);
199
+ }
200
+ const _ = tt(
201
+ n,
202
+ u.map((d) => d[0])
203
+ );
204
+ return u.map((d, g) => ({
205
+ radius: d[1],
206
+ theta: d[2],
207
+ ..._[g]
208
+ }));
209
+ }
210
+ function X(n, t, s, e, o, l, r = !0) {
211
+ const i = D(l), a = (u) => {
212
+ for (let c = 0; c <= t; c++) {
213
+ const f = c / t * x * 2, h = Math.sin(f), _ = -Math.cos(f), d = N([
214
+ _ * u.normal[0] + h * u.binormal[0],
215
+ _ * u.normal[1] + h * u.binormal[1],
216
+ _ * u.normal[2] + h * u.binormal[2]
217
+ ]), g = [
218
+ u.position[0] + u.radius * d[0],
219
+ u.position[1] + u.radius * d[1],
220
+ u.position[2] + u.radius * d[2]
221
+ ];
222
+ if (i.positions.push(...g), i.vertexCount++, i.attributes.normal) {
223
+ let b = st(d);
224
+ if (Number.isFinite(u.theta)) {
225
+ const y = N(
226
+ et(u.tangent, d)
227
+ );
228
+ b = it(d, y, u.theta);
229
+ }
230
+ i.attributes.normal.array.push(...b);
231
+ }
232
+ i.attributes.curveLength && i.attributes.curveLength.array.push(
233
+ u.curvePosition * e
234
+ ), i.attributes.curveRelativeLength && i.attributes.curveRelativeLength.array.push(
235
+ (u.curvePosition - o) * e
236
+ ), i.attributes.curveNormal && i.attributes.curveNormal.array.push(...u.normal), i.attributes.curveTangent && i.attributes.curveTangent.array.push(...u.tangent), i.attributes.curveBinormal && i.attributes.curveBinormal.array.push(...u.binormal), i.attributes.centerPoint && i.attributes.centerPoint.array.push(...u.position);
237
+ }
238
+ };
239
+ for (let u = 0; u < n.length; u++)
240
+ a(n[u]);
241
+ if (s && a(n[0]), i.attributes.uv)
242
+ for (let u = 0; u < n.length; u++)
243
+ for (let c = 0; c <= t; c++)
244
+ i.attributes.uv.array.push(
245
+ c / t,
246
+ u / (n.length - 1)
247
+ );
248
+ for (let u = 1; u < n.length; u++)
249
+ for (let c = 1; c <= t; c++) {
250
+ const f = (t + 1) * (u - 1) + (c - 1), h = (t + 1) * u + (c - 1), _ = (t + 1) * u + c, d = (t + 1) * (u - 1) + c;
251
+ i.indices.push(f, h, d), i.indices.push(h, _, d), i.indexCount += 6;
252
+ }
253
+ return r || i.indices.reverse(), i;
254
+ }
255
+ function Y(n, t, s = !0, e, o, l) {
256
+ const r = D(l), i = s ? [-n.tangent[0], -n.tangent[1], -n.tangent[2]] : n.tangent;
257
+ r.positions.push(...n.position), r.vertexCount++, r.attributes.normal && r.attributes.normal.array.push(...i), r.attributes.uv && r.attributes.uv.array.push(0.5, 0.5);
258
+ for (let c = 0; c <= t; c++) {
259
+ const f = c / t * x * 2, h = Math.sin(f), _ = -Math.cos(f), d = N([
260
+ _ * n.normal[0] + h * n.binormal[0],
261
+ _ * n.normal[1] + h * n.binormal[1],
262
+ _ * n.normal[2] + h * n.binormal[2]
263
+ ]);
264
+ if (r.positions.push(
265
+ n.position[0] + n.radius * d[0],
266
+ n.position[1] + n.radius * d[1],
267
+ n.position[2] + n.radius * d[2]
268
+ ), r.vertexCount++, r.attributes.normal && r.attributes.normal.array.push(...i), r.attributes.uv) {
269
+ const g = [(_ + 1) / 2, (h + 1) / 2];
270
+ s && (g[0] = 1 - g[0]), r.attributes.uv.array.push(...g);
271
+ }
272
+ }
273
+ const a = n.curvePosition * e, u = (n.curvePosition - o) * e;
274
+ for (let c = 0; c < r.vertexCount; c++)
275
+ r.attributes.curveLength && r.attributes.curveLength.array.push(a), r.attributes.curveRelativeLength && r.attributes.curveRelativeLength.array.push(u), r.attributes.curveNormal && r.attributes.curveNormal.array.push(...n.normal), r.attributes.curveTangent && r.attributes.curveTangent.array.push(...n.tangent), r.attributes.curveBinormal && r.attributes.curveBinormal.array.push(...n.binormal), r.attributes.centerPoint && r.attributes.centerPoint.array.push(...n.position);
276
+ for (let c = 1; c <= t; c++) {
277
+ let h, _;
278
+ s ? (h = c + 0, _ = c + 0 + 1) : (h = c + 0 + 1, _ = c + 0), r.indices.push(h, _, 0), r.indexCount += 3;
279
+ }
280
+ return r;
281
+ }
282
+ function J(n, t, s, e = !0, o, l, r) {
283
+ const i = D(r), a = e ? [
284
+ -n.tangent[0],
285
+ -n.tangent[1],
286
+ -n.tangent[2]
287
+ ] : [...n.tangent], u = t.radius / n.radius;
288
+ for (let h = 0; h <= s; h++) {
289
+ const _ = h / s * x * 2, d = Math.sin(_), g = -Math.cos(_), b = N([
290
+ g * n.normal[0] + d * n.binormal[0],
291
+ g * n.normal[1] + d * n.binormal[1],
292
+ g * n.normal[2] + d * n.binormal[2]
293
+ ]);
294
+ if (i.positions.push(
295
+ n.position[0] + n.radius * b[0],
296
+ n.position[1] + n.radius * b[1],
297
+ n.position[2] + n.radius * b[2]
298
+ ), i.positions.push(
299
+ t.position[0] + t.radius * b[0],
300
+ t.position[1] + t.radius * b[1],
301
+ t.position[2] + t.radius * b[2]
302
+ ), i.vertexCount += 2, i.attributes.normal && (i.attributes.normal.array.push(...a), i.attributes.normal.array.push(...a)), i.attributes.uv) {
303
+ const y = [(g + 1) / 2, (d + 1) / 2], v = [
304
+ (g * u + 1) / 2,
305
+ (d * u + 1) / 2
306
+ ];
307
+ e && (y[0] = 1 - y[0], v[0] = 1 - v[0]), i.attributes.uv.array.push(...y, ...v);
308
+ }
309
+ }
310
+ const c = n.curvePosition * o, f = (n.curvePosition - l) * o;
311
+ for (let h = 0; h < i.vertexCount; h++)
312
+ i.attributes.curveLength && i.attributes.curveLength.array.push(c), i.attributes.curveRelativeLength && i.attributes.curveRelativeLength.array.push(f), i.attributes.curveNormal && i.attributes.curveNormal.array.push(...n.normal), i.attributes.curveTangent && i.attributes.curveTangent.array.push(...n.tangent), i.attributes.curveBinormal && i.attributes.curveBinormal.array.push(...n.binormal), i.attributes.centerPoint && i.attributes.centerPoint.array.push(...n.position);
313
+ for (let h = 0; h < s; h++) {
314
+ const _ = h * 2, d = _ + 1, g = _ + 2, b = _ + 3;
315
+ e ? i.indices.push(_, g, d, d, g, b) : i.indices.push(g, _, d, d, b, g), i.indexCount += 6;
316
+ }
317
+ return i;
318
+ }
319
+ function ht(n, t = {}) {
320
+ const s = G(t.from || 0, 0, 1), e = G(t.to || 1);
321
+ if (e < s)
322
+ throw Error('Value of "from" must be less than the value of "to"!');
323
+ const o = [], l = t.radius || 1, r = t.radiusModifier?.steps || [], i = t.radialSegments || 8, a = t.startCap || !1, u = t.endCap || !1, c = n.closed, f = n.length;
324
+ r.sort((p, m) => p[0] - m[0]);
325
+ const h = t.segmentsPerMeter || 0.1, _ = t.radiusModifier?.type || "none", d = G(
326
+ t.simplificationThreshold || 0,
327
+ 0,
328
+ 1
329
+ ), g = H(
330
+ n,
331
+ _,
332
+ s,
333
+ e,
334
+ l,
335
+ r,
336
+ h,
337
+ d
338
+ );
339
+ o.push(
340
+ X(
341
+ g,
342
+ i,
343
+ c,
344
+ f,
345
+ s,
346
+ t,
347
+ !0
348
+ )
349
+ );
350
+ let b = null;
351
+ const y = t.innerRadius || 0, v = t.thickness || 0;
352
+ return (y > 0 || v > 0) && (v ? b = g.map((p) => ({
353
+ ...p,
354
+ radius: p.radius - v,
355
+ theta: p.theta - x
356
+ })) : b = H(
357
+ n,
358
+ "none",
359
+ s,
360
+ e,
361
+ y,
362
+ [],
363
+ h,
364
+ d
365
+ ).map((p) => ({
366
+ ...p,
367
+ theta: p.theta - x
368
+ })), o.push(
369
+ X(
370
+ b,
371
+ i,
372
+ c,
373
+ f,
374
+ s,
375
+ t,
376
+ !1
377
+ )
378
+ )), a && (!c || s > 0 || e < 1) && (b ? o.push(
379
+ J(
380
+ g[0],
381
+ b[0],
382
+ i,
383
+ !0,
384
+ f,
385
+ s,
386
+ t
387
+ )
388
+ ) : o.push(
389
+ Y(
390
+ g[0],
391
+ i,
392
+ !0,
393
+ f,
394
+ s,
395
+ t
396
+ )
397
+ )), u && (!c || s > 0 || e < 1) && (b ? o.push(
398
+ J(
399
+ g[g.length - 1],
400
+ b[b.length - 1],
401
+ i,
402
+ !1,
403
+ f,
404
+ s,
405
+ t
406
+ )
407
+ ) : o.push(
408
+ Y(
409
+ g[g.length - 1],
410
+ i,
411
+ !1,
412
+ f,
413
+ s,
414
+ t
415
+ )
416
+ )), o;
417
+ }
418
+ function gt(n, t = {}) {
419
+ const s = ht(n, t);
420
+ return ut(s, t.addGroups);
421
+ }
422
+ const $ = -1e3;
423
+ class lt {
424
+ data;
425
+ width;
426
+ height;
427
+ coords = [];
428
+ // vertex coordinates (x, y)
429
+ triangles = [];
430
+ // mesh triangle indices
431
+ nullValue;
432
+ _queue = [];
433
+ _queueIndices = [];
434
+ _errors = [];
435
+ _halfedges = [];
436
+ _candidates = [];
437
+ _invalidPoints;
438
+ _rms = [];
439
+ _pending = [];
440
+ _pendingLen = 0;
441
+ _rmsSum = 0;
442
+ constructor(t, s, e = -1) {
443
+ this.data = t, this.width = s, this.height = this.data.length / s, this.nullValue = e, this._invalidPoints = /* @__PURE__ */ new Set();
444
+ const o = this.width - 1, l = this.height - 1, r = this._addPoint(0, 0), i = this._addPoint(o, 0), a = this._addPoint(0, l), u = this._addPoint(o, l), c = this._addTriangle(u, r, a, -1, -1, -1);
445
+ this._addTriangle(r, u, i, c, -1, -1), this._flush();
446
+ }
447
+ // refine the mesh until its maximum error gets below the given one
448
+ run(t = 1) {
449
+ for (; this.getMaxError() > t; )
450
+ this.refine();
451
+ }
452
+ // Removes triangles where one or more vertices contains a null value (nullValue)
453
+ removeInvalidTriangles() {
454
+ const t = [];
455
+ for (let s = 0; s < this.triangles.length; s += 3) {
456
+ const e = this.triangles[s], o = this.triangles[s + 1], l = this.triangles[s + 2];
457
+ !this._invalidPoints.has(e) && !this._invalidPoints.has(o) && !this._invalidPoints.has(l) && t.push(
458
+ this.triangles[s],
459
+ this.triangles[s + 1],
460
+ this.triangles[s + 2]
461
+ );
462
+ }
463
+ this.triangles = t;
464
+ }
465
+ // refine the mesh with a single point
466
+ refine() {
467
+ this._step(), this._flush();
468
+ }
469
+ // max error of the current mesh
470
+ getMaxError() {
471
+ return this._errors[0];
472
+ }
473
+ // root-mean-square deviation of the current mesh
474
+ getRMSD() {
475
+ return this._rmsSum > 0 ? Math.sqrt(this._rmsSum / (this.width * this.height)) : 0;
476
+ }
477
+ // height value at a given position
478
+ heightAt(t, s) {
479
+ const e = this.data[this.width * s + t];
480
+ return e === this.nullValue ? $ : e;
481
+ }
482
+ // rasterize a triangle, find its max error, and queue it for processing
483
+ _findCandidate(t, s, e, o, l, r, i) {
484
+ const a = Math.min(t, e, l), u = Math.min(s, o, r), c = Math.max(t, e, l), f = Math.max(s, o, r);
485
+ let h = P(e, o, l, r, a, u), _ = P(l, r, t, s, a, u), d = P(t, s, e, o, a, u);
486
+ const g = o - s, b = t - e, y = r - o, v = e - l, p = s - r, m = l - t, A = P(t, s, e, o, l, r), q = this.heightAt(t, s) / A, C = this.heightAt(e, o) / A, z = this.heightAt(l, r) / A;
487
+ let R = 0, M = 0, F = 0, k = 0;
488
+ for (let T = u; T <= f; T++) {
489
+ let w = 0;
490
+ h < 0 && y !== 0 && (w = Math.max(w, Math.floor(-h / y))), _ < 0 && p !== 0 && (w = Math.max(w, Math.floor(-_ / p))), d < 0 && g !== 0 && (w = Math.max(w, Math.floor(-d / g)));
491
+ let E = h + y * w, V = _ + p * w, j = d + g * w, O = !1;
492
+ for (let I = a + w; I <= c; I++) {
493
+ if (E >= 0 && V >= 0 && j >= 0) {
494
+ O = !0;
495
+ const Q = q * E + C * V + z * j, W = this.heightAt(I, T), B = Math.abs(Q - W);
496
+ k += B * B, B > R && (R = B, M = I, F = T);
497
+ } else if (O)
498
+ break;
499
+ E += y, V += p, j += g;
500
+ }
501
+ h += v, _ += m, d += b;
502
+ }
503
+ (M === t && F === s || M === e && F === o || M === l && F === r) && (R = 0), this._candidates[2 * i] = M, this._candidates[2 * i + 1] = F, this._rms[i] = k, this._queuePush(i, R, k);
504
+ }
505
+ // process the next triangle in the queue, splitting it with a new point
506
+ _step() {
507
+ const t = this._queuePop(), s = t * 3 + 0, e = t * 3 + 1, o = t * 3 + 2, l = this.triangles[s], r = this.triangles[e], i = this.triangles[o], a = this.coords[2 * l], u = this.coords[2 * l + 1], c = this.coords[2 * r], f = this.coords[2 * r + 1], h = this.coords[2 * i], _ = this.coords[2 * i + 1], d = this._candidates[2 * t], g = this._candidates[2 * t + 1], b = this._addPoint(d, g);
508
+ if (P(a, u, c, f, d, g) === 0)
509
+ this._handleCollinear(b, s);
510
+ else if (P(c, f, h, _, d, g) === 0)
511
+ this._handleCollinear(b, e);
512
+ else if (P(h, _, a, u, d, g) === 0)
513
+ this._handleCollinear(b, o);
514
+ else {
515
+ const y = this._halfedges[s], v = this._halfedges[e], p = this._halfedges[o], m = this._addTriangle(l, r, b, y, -1, -1, s), A = this._addTriangle(r, i, b, v, -1, m + 1), q = this._addTriangle(i, l, b, p, m + 2, A + 1);
516
+ this._legalize(m), this._legalize(A), this._legalize(q);
517
+ }
518
+ }
519
+ _addPoint(t, s) {
520
+ const e = this.coords.length >> 1;
521
+ return this.coords.push(t, s), this.heightAt(t, s) === $ && this._invalidPoints.add(e), e;
522
+ }
523
+ _addTriangle(t, s, e, o, l, r, i = this.triangles.length) {
524
+ const a = i / 3;
525
+ return this.triangles[i + 0] = t, this.triangles[i + 1] = s, this.triangles[i + 2] = e, this._halfedges[i + 0] = o, this._halfedges[i + 1] = l, this._halfedges[i + 2] = r, o >= 0 && (this._halfedges[o] = i + 0), l >= 0 && (this._halfedges[l] = i + 1), r >= 0 && (this._halfedges[r] = i + 2), this._candidates[2 * a + 0] = 0, this._candidates[2 * a + 1] = 0, this._queueIndices[a] = -1, this._rms[a] = 0, this._pending[this._pendingLen++] = a, i;
526
+ }
527
+ _flush() {
528
+ const t = this.coords;
529
+ for (let s = 0; s < this._pendingLen; s++) {
530
+ const e = this._pending[s], o = 2 * this.triangles[e * 3 + 0], l = 2 * this.triangles[e * 3 + 1], r = 2 * this.triangles[e * 3 + 2];
531
+ this._findCandidate(
532
+ t[o],
533
+ t[o + 1],
534
+ t[l],
535
+ t[l + 1],
536
+ t[r],
537
+ t[r + 1],
538
+ e
539
+ );
540
+ }
541
+ this._pendingLen = 0;
542
+ }
543
+ _legalize(t) {
544
+ const s = this._halfedges[t];
545
+ if (s < 0)
546
+ return;
547
+ const e = t - t % 3, o = s - s % 3, l = e + (t + 1) % 3, r = e + (t + 2) % 3, i = o + (s + 2) % 3, a = o + (s + 1) % 3, u = this.triangles[r], c = this.triangles[t], f = this.triangles[l], h = this.triangles[i], _ = this.coords;
548
+ if (!ct(
549
+ _[2 * u],
550
+ _[2 * u + 1],
551
+ _[2 * c],
552
+ _[2 * c + 1],
553
+ _[2 * f],
554
+ _[2 * f + 1],
555
+ _[2 * h],
556
+ _[2 * h + 1]
557
+ ))
558
+ return;
559
+ const d = this._halfedges[l], g = this._halfedges[r], b = this._halfedges[i], y = this._halfedges[a];
560
+ this._queueRemove(e / 3), this._queueRemove(o / 3);
561
+ const v = this._addTriangle(u, h, f, -1, b, d, e), p = this._addTriangle(h, u, c, v, g, y, o);
562
+ this._legalize(v + 1), this._legalize(p + 2);
563
+ }
564
+ _handleCollinear(t, s) {
565
+ const e = s - s % 3, o = e + (s + 1) % 3, l = e + (s + 2) % 3, r = this.triangles[l], i = this.triangles[s], a = this.triangles[o], u = this._halfedges[o], c = this._halfedges[l], f = this._halfedges[s];
566
+ if (f < 0) {
567
+ const q = this._addTriangle(t, r, i, -1, c, -1, e), C = this._addTriangle(r, t, a, q, -1, u);
568
+ this._legalize(q + 1), this._legalize(C + 2);
569
+ return;
570
+ }
571
+ const h = f - f % 3, _ = h + (f + 2) % 3, d = h + (f + 1) % 3, g = this.triangles[_], b = this._halfedges[_], y = this._halfedges[d];
572
+ this._queueRemove(h / 3);
573
+ const v = this._addTriangle(r, i, t, c, -1, -1, e), p = this._addTriangle(i, g, t, y, -1, v + 1, h), m = this._addTriangle(g, a, t, b, -1, p + 1), A = this._addTriangle(a, r, t, u, v + 2, m + 1);
574
+ this._legalize(v), this._legalize(p), this._legalize(m), this._legalize(A);
575
+ }
576
+ // priority queue methods
577
+ _queuePush(t, s, e) {
578
+ const o = this._queue.length;
579
+ this._queueIndices[t] = o, this._queue.push(t), this._errors.push(s), this._rmsSum += e, this._queueUp(o);
580
+ }
581
+ _queuePop() {
582
+ const t = this._queue.length - 1;
583
+ return this._queueSwap(0, t), this._queueDown(0, t), this._queuePopBack();
584
+ }
585
+ _queuePopBack() {
586
+ const t = this._queue.pop();
587
+ return this._errors.pop(), this._rmsSum -= this._rms[t], this._queueIndices[t] = -1, t;
588
+ }
589
+ _queueRemove(t) {
590
+ const s = this._queueIndices[t];
591
+ if (s < 0) {
592
+ const o = this._pending.indexOf(t);
593
+ if (o !== -1)
594
+ this._pending[o] = this._pending[--this._pendingLen];
595
+ else
596
+ throw new Error("Broken triangulation (something went wrong).");
597
+ return;
598
+ }
599
+ const e = this._queue.length - 1;
600
+ e !== s && (this._queueSwap(s, e), this._queueDown(s, e) || this._queueUp(s)), this._queuePopBack();
601
+ }
602
+ _queueLess(t, s) {
603
+ return this._errors[t] > this._errors[s];
604
+ }
605
+ _queueSwap(t, s) {
606
+ const e = this._queue[t], o = this._queue[s];
607
+ this._queue[t] = o, this._queue[s] = e, this._queueIndices[e] = s, this._queueIndices[o] = t;
608
+ const l = this._errors[t];
609
+ this._errors[t] = this._errors[s], this._errors[s] = l;
610
+ }
611
+ _queueUp(t) {
612
+ let s = t;
613
+ for (; ; ) {
614
+ const e = s - 1 >> 1;
615
+ if (e === s || !this._queueLess(s, e))
616
+ break;
617
+ this._queueSwap(e, s), s = e;
618
+ }
619
+ }
620
+ _queueDown(t, s) {
621
+ let e = t;
622
+ for (; ; ) {
623
+ const o = 2 * e + 1;
624
+ if (o >= s || o < 0)
625
+ break;
626
+ const l = o + 1;
627
+ let r = o;
628
+ if (l < s && this._queueLess(l, o) && (r = l), !this._queueLess(r, e))
629
+ break;
630
+ this._queueSwap(e, r), e = r;
631
+ }
632
+ return e > t;
633
+ }
634
+ }
635
+ function P(n, t, s, e, o, l) {
636
+ return (s - o) * (t - l) - (e - l) * (n - o);
637
+ }
638
+ function ct(n, t, s, e, o, l, r, i) {
639
+ const a = n - r, u = t - i, c = s - r, f = e - i, h = o - r, _ = l - i, d = a * a + u * u, g = c * c + f * f, b = h * h + _ * _;
640
+ return a * (f * b - g * _) - u * (c * b - g * h) + d * (c * _ - f * h) < 0;
641
+ }
642
+ function bt(n, t, s) {
643
+ const e = nt(n), o = new Array(e.length);
644
+ let l = null;
645
+ for (let f = 0; f < e.length; f++)
646
+ l !== null ? o[f] = o[l] + rt(e[l], e[f]) : o[f] = 0, l = f;
647
+ const r = o[o.length - 1], i = new K(), a = new Float32Array(e.length * 2 * 3), u = new Uint32Array((e.length - 1) * 6), c = new Float32Array(e.length * 2 * 2);
648
+ for (let f = 0; f < e.length; f++) {
649
+ const h = f * 6;
650
+ a[h] = e[f][0], a[h + 1] = t, a[h + 2] = e[f][1], a[h + 3] = e[f][0], a[h + 4] = s, a[h + 5] = e[f][1];
651
+ const _ = f * 4;
652
+ c[_] = o[f] / r, c[_ + 1] = 1, c[_ + 2] = o[f] / r, c[_ + 3] = 0;
653
+ const d = f * 2;
654
+ f < e.length - 1 && (u[h] = d, u[h + 1] = d + 1, u[h + 2] = d + 2, u[h + 3] = d + 2, u[h + 4] = d + 1, u[h + 5] = d + 3);
655
+ }
656
+ return i.setAttribute("position", new L(a, 3)), i.setAttribute("uv", new L(c, 2)), i.setIndex(new L(u, 1)), i.computeVertexNormals(), i;
657
+ }
658
+ function vt(n, t, s = 1, e = 1, o = -1, l = 5) {
659
+ const r = t, i = n.length / r;
660
+ console.time("delatin");
661
+ const a = new lt(n, r, o);
662
+ a.run(l), a.removeInvalidTriangles(), console.timeEnd("delatin");
663
+ const u = new Float32Array(a.coords.length * 1.5), c = new Float32Array(a.coords.length);
664
+ for (let h = 0, _ = 0; h < a.coords.length; h += 2)
665
+ c[h] = a.coords[h] / (r - 1), c[h + 1] = 1 - a.coords[h + 1] / (i - 1), _ = h * 1.5, u[_] = a.coords[h] * s, u[_ + 1] = a.heightAt(a.coords[h], a.coords[h + 1]), u[_ + 2] = a.coords[h + 1] * e;
666
+ const f = new Uint32Array(a.triangles);
667
+ return console.log(a.triangles.length / 3), { positions: u, uvs: c, indices: f };
668
+ }
669
+ function pt(n) {
670
+ let t = 0, s, e;
671
+ if (!n || n.length === 0) return t;
672
+ for (s = 0; s < n.length; s++)
673
+ e = n.charCodeAt(s), t = (t << 5) - t + e, t |= 0;
674
+ return t;
675
+ }
676
+ function yt(n) {
677
+ return n.replace(/(^|\s)\S/g, (t) => t.toUpperCase());
678
+ }
679
+ export {
680
+ lt as D,
681
+ bt as a,
682
+ ht as b,
683
+ pt as c,
684
+ gt as d,
685
+ vt as e,
686
+ yt as t
687
+ };
@@ -1,8 +1,4 @@
1
- const s = "casings", e = {
2
- Shoe: 0,
3
- Casing: 1,
4
- Generic: 2
5
- }, a = "completionTools", n = {
1
+ const o = "completionTools", e = {
6
2
  "blank pipe": 0,
7
3
  tube: 1,
8
4
  packer: 2,
@@ -16,8 +12,6 @@ const s = "casings", e = {
16
12
  unknown: 10
17
13
  };
18
14
  export {
19
- a,
20
- e as b,
21
- s as c,
22
- n as d
15
+ e as a,
16
+ o as c
23
17
  };