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