@margoengine/splines 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +175 -2
- package/dist/closest.d.ts +36 -0
- package/dist/closest.js +101 -0
- package/dist/fit.d.ts +29 -0
- package/dist/fit.js +175 -0
- package/dist/frames.d.ts +48 -0
- package/dist/frames.js +113 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +86 -0
- package/dist/kinds.d.ts +27 -0
- package/dist/kinds.js +76 -0
- package/dist/knots.d.ts +81 -0
- package/dist/knots.js +196 -0
- package/dist/mesh.d.ts +72 -0
- package/dist/mesh.js +106 -0
- package/dist/offset.d.ts +33 -0
- package/dist/offset.js +176 -0
- package/dist/polynomial-we3se7Ae.js +40 -0
- package/dist/polynomial.d.ts +6 -0
- package/dist/query.d.ts +50 -0
- package/dist/query.js +394 -0
- package/package.json +76 -4
package/dist/query.js
ADDED
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./polynomial-we3se7Ae.js";
|
|
2
|
+
//#region src/query.ts
|
|
3
|
+
var a = (e, t) => e[0] * t[0] + e[1] * t[1] + e[2] * t[2], o = (e, t) => new Float64Array([
|
|
4
|
+
e[0] - t[0],
|
|
5
|
+
e[1] - t[1],
|
|
6
|
+
e[2] - t[2]
|
|
7
|
+
]), s = (e) => Math.max(0, Math.min(1, e)), c = (e, t = 1e-12) => e.sort((e, t) => e - t).filter((e, n, r) => !n || e - r[n - 1] > t), l = (e) => [
|
|
8
|
+
e[0],
|
|
9
|
+
3 * (e[1] - e[0]),
|
|
10
|
+
3 * (e[2] - 2 * e[1] + e[0]),
|
|
11
|
+
e[3] - 3 * e[2] + 3 * e[1] - e[0]
|
|
12
|
+
], u = (e, t) => ((e[3] * t + e[2]) * t + e[1]) * t + e[0];
|
|
13
|
+
function d(e, t, n) {
|
|
14
|
+
let r = Math.max(Math.abs(e), Math.abs(t), Math.abs(n));
|
|
15
|
+
if (!r) return [];
|
|
16
|
+
if (e /= r, t /= r, n /= r, Math.abs(e) <= 2 ** -52 * 8) return t ? [-n / t] : [];
|
|
17
|
+
let i = t * t - 4 * e * n;
|
|
18
|
+
if (i < 0) return [];
|
|
19
|
+
let a = -.5 * (t + (t < 0 ? -1 : 1) * Math.sqrt(i));
|
|
20
|
+
return a ? c([a / e, n / a]) : [-t / (2 * e)];
|
|
21
|
+
}
|
|
22
|
+
function f(e) {
|
|
23
|
+
let t = l(e), n = Math.max(...t.map(Math.abs));
|
|
24
|
+
if (!n) return {
|
|
25
|
+
roots: [],
|
|
26
|
+
constant: !0
|
|
27
|
+
};
|
|
28
|
+
let r = t.map((e) => e / n), i = c([
|
|
29
|
+
0,
|
|
30
|
+
...d(3 * r[3], 2 * r[2], r[1]).filter((e) => e > 0 && e < 1),
|
|
31
|
+
1
|
|
32
|
+
]), a = i.filter((e) => Math.abs(u(r, e)) <= 64 * 2 ** -52);
|
|
33
|
+
for (let e = 1; e < i.length; e++) {
|
|
34
|
+
let t = i[e - 1], n = i[e], o = u(r, t);
|
|
35
|
+
if (!(o * u(r, n) >= 0)) {
|
|
36
|
+
for (let e = 0; e < 64; e++) {
|
|
37
|
+
let e = (t + n) / 2, i = u(r, e);
|
|
38
|
+
if (i === 0) {
|
|
39
|
+
t = n = e;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
o * i < 0 ? n = e : (t = e, o = i);
|
|
43
|
+
}
|
|
44
|
+
a.push((t + n) / 2);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
roots: c(a),
|
|
49
|
+
constant: !1
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function p(e) {
|
|
53
|
+
let t = e.tolerance ?? 1e-7, n = e.parameterTolerance ?? 1e-7, r = e.maxWork ?? 2e5;
|
|
54
|
+
if (!Number.isFinite(t) || t <= 0 || !Number.isFinite(n) || n <= 0 || n >= 1 || !Number.isSafeInteger(r) || r < 1) throw RangeError("Invalid curve query options; pass positive tolerances and a positive integer maxWork.");
|
|
55
|
+
return {
|
|
56
|
+
tolerance: t,
|
|
57
|
+
parameterTolerance: n,
|
|
58
|
+
maxWork: r
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function m(e, t) {
|
|
62
|
+
return e.points.sort((e, t) => e.t - t.t || (e.otherT ?? 0) - (t.otherT ?? 0)), e.points = e.points.filter((e, n, r) => !r.slice(0, n).some((n) => Math.abs(n.t - e.t) <= t && Math.abs((n.otherT ?? 0) - (e.otherT ?? 0)) <= t)), e.overlaps.sort((e, t) => e.t0 - t.t0), e.points = e.points.filter((n) => !e.overlaps.some((e) => n.t >= e.t0 - t && n.t <= e.t1 + t && (n.otherT === void 0 || e.otherT0 === void 0 || n.otherT >= Math.min(e.otherT0, e.otherT1) - t && n.otherT <= Math.max(e.otherT0, e.otherT1) + t))), e;
|
|
63
|
+
}
|
|
64
|
+
function h(t) {
|
|
65
|
+
let r = [
|
|
66
|
+
[],
|
|
67
|
+
[],
|
|
68
|
+
[]
|
|
69
|
+
], i = e(t);
|
|
70
|
+
for (let e = 0; e < i; e++) {
|
|
71
|
+
let a = n(t, e);
|
|
72
|
+
for (let t = 0; t < 3; t++) {
|
|
73
|
+
let n = l([
|
|
74
|
+
a[t],
|
|
75
|
+
a[t + 3],
|
|
76
|
+
a[t + 6],
|
|
77
|
+
a[t + 9]
|
|
78
|
+
]);
|
|
79
|
+
r[t].push(...d(3 * n[3], 2 * n[2], n[1]).filter((e) => e > 0 && e < 1).map((t) => (e + t) / i)), e && r[t].push(e / i);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
let [a, o, s] = r.map((e) => c(e));
|
|
83
|
+
return {
|
|
84
|
+
x: a,
|
|
85
|
+
y: o,
|
|
86
|
+
z: s,
|
|
87
|
+
values: c([
|
|
88
|
+
...a,
|
|
89
|
+
...o,
|
|
90
|
+
...s
|
|
91
|
+
])
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function g(e) {
|
|
95
|
+
let t = new Float64Array([
|
|
96
|
+
Infinity,
|
|
97
|
+
Infinity,
|
|
98
|
+
Infinity
|
|
99
|
+
]), n = new Float64Array([
|
|
100
|
+
-Infinity,
|
|
101
|
+
-Infinity,
|
|
102
|
+
-Infinity
|
|
103
|
+
]);
|
|
104
|
+
for (let r of [
|
|
105
|
+
0,
|
|
106
|
+
1,
|
|
107
|
+
...h(e).values
|
|
108
|
+
]) {
|
|
109
|
+
let i = e.at(r);
|
|
110
|
+
for (let e = 0; e < 3; e++) t[e] = Math.min(t[e], i[e]), n[e] = Math.max(n[e], i[e]);
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
min: t,
|
|
114
|
+
max: n
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function _(r, o, s = 0, c = {}) {
|
|
118
|
+
i(o);
|
|
119
|
+
let l = Math.hypot(o[0], o[1], o[2]);
|
|
120
|
+
if (!l || !Number.isFinite(s)) throw RangeError("Invalid plane; pass a nonzero normal and finite constant.");
|
|
121
|
+
let { parameterTolerance: u } = p(c), d = e(r), h = {
|
|
122
|
+
points: [],
|
|
123
|
+
overlaps: []
|
|
124
|
+
};
|
|
125
|
+
for (let e = 0; e < d; e++) {
|
|
126
|
+
let i = n(r, e), c = f([
|
|
127
|
+
0,
|
|
128
|
+
1,
|
|
129
|
+
2,
|
|
130
|
+
3
|
|
131
|
+
].map((e) => (a(i.subarray(e * 3, e * 3 + 3), o) + s) / l));
|
|
132
|
+
if (c.constant) h.overlaps.push({
|
|
133
|
+
t0: e / d,
|
|
134
|
+
t1: (e + 1) / d
|
|
135
|
+
});
|
|
136
|
+
else for (let n of c.roots) h.points.push({
|
|
137
|
+
t: (e + n) / d,
|
|
138
|
+
point: t(i, n, 0)
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return m(h, u);
|
|
142
|
+
}
|
|
143
|
+
function v(s, h, g, _ = {}) {
|
|
144
|
+
i(h), i(g);
|
|
145
|
+
let v = Math.hypot(g[0], g[1], g[2]);
|
|
146
|
+
if (!v) throw RangeError("Invalid ray; pass a nonzero direction.");
|
|
147
|
+
let { tolerance: y, parameterTolerance: b } = p(_), x = Float64Array.from(g, (e) => e / v), S = 0;
|
|
148
|
+
for (let e = 1; e < 3; e++) Math.abs(x[e]) < Math.abs(x[S]) && (S = e);
|
|
149
|
+
let C = /* @__PURE__ */ new Float64Array(3);
|
|
150
|
+
C[S] = 1;
|
|
151
|
+
let w = r(x, C), T = r(x, w), E = e(s), D = {
|
|
152
|
+
points: [],
|
|
153
|
+
overlaps: []
|
|
154
|
+
};
|
|
155
|
+
for (let e = 0; e < E; e++) {
|
|
156
|
+
let i = n(s, e), p = [
|
|
157
|
+
0,
|
|
158
|
+
1,
|
|
159
|
+
2,
|
|
160
|
+
3
|
|
161
|
+
].map((e) => o(i.subarray(e * 3, e * 3 + 3), h)), m = p.map((e) => a(e, w)), g = p.map((e) => a(e, T)), _ = p.map((e) => a(e, x)), b = f(Math.max(...m.map(Math.abs)) >= Math.max(...g.map(Math.abs)) ? m : g);
|
|
162
|
+
if (b.constant) {
|
|
163
|
+
let t = l(_), n = c([
|
|
164
|
+
0,
|
|
165
|
+
...f(_).roots,
|
|
166
|
+
...d(3 * t[3], 2 * t[2], t[1]).filter((e) => e > 0 && e < 1),
|
|
167
|
+
1
|
|
168
|
+
]);
|
|
169
|
+
for (let r = 1; r < n.length; r++) u(t, (n[r - 1] + n[r]) / 2) >= 0 && D.overlaps.push({
|
|
170
|
+
t0: (e + n[r - 1]) / E,
|
|
171
|
+
t1: (e + n[r]) / E,
|
|
172
|
+
otherT0: u(t, n[r - 1]) / v,
|
|
173
|
+
otherT1: u(t, n[r]) / v
|
|
174
|
+
});
|
|
175
|
+
} else for (let n of b.roots) {
|
|
176
|
+
let s = t(i, n, 0), c = o(s, h), l = a(c, x);
|
|
177
|
+
l >= -y && Math.hypot(...r(c, x)) <= y && D.points.push({
|
|
178
|
+
t: (e + n) / E,
|
|
179
|
+
otherT: Math.max(0, l / v),
|
|
180
|
+
point: s
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return m(D, b);
|
|
185
|
+
}
|
|
186
|
+
function y(e) {
|
|
187
|
+
let t = e.p, n = /* @__PURE__ */ new Float64Array(12), r = /* @__PURE__ */ new Float64Array(12), i = t.slice();
|
|
188
|
+
for (let e = 0; e < 4; e++) {
|
|
189
|
+
n.set(i.subarray(0, 3), e * 3), r.set(i.subarray((3 - e) * 3, (4 - e) * 3), (3 - e) * 3);
|
|
190
|
+
for (let t = 0; t < 3 - e; t++) for (let e = 0; e < 3; e++) i[t * 3 + e] = (i[t * 3 + e] + i[(t + 1) * 3 + e]) / 2;
|
|
191
|
+
}
|
|
192
|
+
let a = (e.t0 + e.t1) / 2;
|
|
193
|
+
return [{
|
|
194
|
+
p: n,
|
|
195
|
+
t0: e.t0,
|
|
196
|
+
t1: a
|
|
197
|
+
}, {
|
|
198
|
+
p: r,
|
|
199
|
+
t0: a,
|
|
200
|
+
t1: e.t1
|
|
201
|
+
}];
|
|
202
|
+
}
|
|
203
|
+
function b(e) {
|
|
204
|
+
return {
|
|
205
|
+
min: new Float64Array([
|
|
206
|
+
0,
|
|
207
|
+
1,
|
|
208
|
+
2
|
|
209
|
+
].map((t) => Math.min(e[t], e[t + 3], e[t + 6], e[t + 9]))),
|
|
210
|
+
max: new Float64Array([
|
|
211
|
+
0,
|
|
212
|
+
1,
|
|
213
|
+
2
|
|
214
|
+
].map((t) => Math.max(e[t], e[t + 3], e[t + 6], e[t + 9])))
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
var x = (e) => Math.hypot(...o(e.max, e.min));
|
|
218
|
+
function S(e, n, r) {
|
|
219
|
+
let i = t(e, n, 0), a = t(e, r, 0), o = t(e, n, 1), s = t(e, r, 1), c = /* @__PURE__ */ new Float64Array(12);
|
|
220
|
+
c.set(i), c.set(a, 9);
|
|
221
|
+
for (let e = 0; e < 3; e++) c[e + 3] = i[e] + o[e] * (r - n) / 3, c[e + 6] = a[e] - s[e] * (r - n) / 3;
|
|
222
|
+
return c;
|
|
223
|
+
}
|
|
224
|
+
function C(e, n, r) {
|
|
225
|
+
let i = (e, n) => {
|
|
226
|
+
let i = b(e), a = 0;
|
|
227
|
+
for (let e = 1; e < 3; e++) i.max[e] - i.min[e] > i.max[a] - i.min[a] && (a = e);
|
|
228
|
+
return f([
|
|
229
|
+
0,
|
|
230
|
+
1,
|
|
231
|
+
2,
|
|
232
|
+
3
|
|
233
|
+
].map((t) => e[t * 3 + a] - n[a])).roots.filter((i) => Math.hypot(...o(t(e, i, 0), n)) <= r);
|
|
234
|
+
}, a = [];
|
|
235
|
+
for (let r of [0, 1]) for (let o of i(n, t(e, r, 0))) a.push([r, o]);
|
|
236
|
+
for (let r of [0, 1]) for (let o of i(e, t(n, r, 0))) a.push([o, r]);
|
|
237
|
+
for (let [t, i] of a) for (let [o, s] of a) if (o > t + 1e-12 && Math.abs(s - i) > 1e-12) {
|
|
238
|
+
let a = S(e, t, o), c = S(n, i, s);
|
|
239
|
+
if (a.every((e, t) => Math.abs(e - c[t]) <= r)) return {
|
|
240
|
+
t0: t,
|
|
241
|
+
t1: o,
|
|
242
|
+
otherT0: i,
|
|
243
|
+
otherT1: s
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function w(e, n, i) {
|
|
248
|
+
let s = [
|
|
249
|
+
0,
|
|
250
|
+
1,
|
|
251
|
+
2,
|
|
252
|
+
3
|
|
253
|
+
].map((t) => e.subarray(t * 3, t * 3 + 3)), p = s[0], m = /* @__PURE__ */ new Float64Array(3), h = 0;
|
|
254
|
+
for (let e of [...s, ...[
|
|
255
|
+
0,
|
|
256
|
+
1,
|
|
257
|
+
2,
|
|
258
|
+
3
|
|
259
|
+
].map((e) => n.subarray(e * 3, e * 3 + 3))]) {
|
|
260
|
+
let t = o(e, p), n = Math.hypot(...t);
|
|
261
|
+
n > h && (m = t, h = n);
|
|
262
|
+
}
|
|
263
|
+
if (!h) return;
|
|
264
|
+
let g = m.map((e) => e / h);
|
|
265
|
+
if ([...s, ...[
|
|
266
|
+
0,
|
|
267
|
+
1,
|
|
268
|
+
2,
|
|
269
|
+
3
|
|
270
|
+
].map((e) => n.subarray(e * 3, e * 3 + 3))].some((e) => Math.hypot(...r(o(e, p), g)) > i)) return;
|
|
271
|
+
let _ = (e) => [
|
|
272
|
+
0,
|
|
273
|
+
1,
|
|
274
|
+
2,
|
|
275
|
+
3
|
|
276
|
+
].map((t) => a(o(e.subarray(t * 3, t * 3 + 3), p), g)), v = _(e), y = _(n), b = l(v), x = l(y), S = (e) => c([
|
|
277
|
+
0,
|
|
278
|
+
...d(3 * e[3], 2 * e[2], e[1]).filter((e) => e > 0 && e < 1),
|
|
279
|
+
1
|
|
280
|
+
]), C = S(b), w = S(x), T = {
|
|
281
|
+
points: [],
|
|
282
|
+
overlaps: []
|
|
283
|
+
}, E = (e, t, n, r) => {
|
|
284
|
+
let a = f(e.map((e) => e - t));
|
|
285
|
+
return a.constant ? n : a.roots.find((e) => e >= n - 1e-10 && e <= r + 1e-10) ?? (Math.abs(u(l(e), n) - t) <= i ? n : r);
|
|
286
|
+
};
|
|
287
|
+
for (let n = 1; n < C.length; n++) for (let r = 1; r < w.length; r++) {
|
|
288
|
+
let a = u(b, C[n - 1]), o = u(b, C[n]), s = u(x, w[r - 1]), c = u(x, w[r]), l = Math.max(Math.min(a, o), Math.min(s, c)), d = Math.min(Math.max(a, o), Math.max(s, c));
|
|
289
|
+
if (d < l - i) continue;
|
|
290
|
+
let f = E(v, l, C[n - 1], C[n]), p = E(v, d, C[n - 1], C[n]), m = E(y, l, w[r - 1], w[r]), h = E(y, d, w[r - 1], w[r]);
|
|
291
|
+
f > p && ([f, p] = [p, f], [m, h] = [h, m]), Math.abs(d - l) <= i ? T.points.push({
|
|
292
|
+
t: f,
|
|
293
|
+
otherT: m,
|
|
294
|
+
point: t(e, f, 0)
|
|
295
|
+
}) : T.overlaps.push({
|
|
296
|
+
t0: f,
|
|
297
|
+
t1: p,
|
|
298
|
+
otherT0: m,
|
|
299
|
+
otherT1: h
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
return T;
|
|
303
|
+
}
|
|
304
|
+
function T(e, n, r, i) {
|
|
305
|
+
for (let c = 0; c < 50; c++) {
|
|
306
|
+
let c = o(t(e, r, 0), t(n, i, 0)), l = t(e, r, 1), u = t(n, i, 1), d = a(l, l), f = a(u, u), p = a(l, u), m = a(c, l), h = a(c, u), g = d * f - p * p;
|
|
307
|
+
if (g <= 2 ** -52 * d * f) break;
|
|
308
|
+
let _ = s(r + (p * h - f * m) / g), v = s(i + (d * h - p * m) / g);
|
|
309
|
+
if (Math.abs(_ - r) + Math.abs(v - i) < 1e-14) {
|
|
310
|
+
r = _, i = v;
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
r = _, i = v;
|
|
314
|
+
}
|
|
315
|
+
return [
|
|
316
|
+
r,
|
|
317
|
+
i,
|
|
318
|
+
Math.hypot(...o(t(e, r, 0), t(n, i, 0)))
|
|
319
|
+
];
|
|
320
|
+
}
|
|
321
|
+
function E(r, i, a = {}) {
|
|
322
|
+
let { tolerance: o, parameterTolerance: s, maxWork: c } = p(a), l = e(r), u = e(i), d = {
|
|
323
|
+
points: [],
|
|
324
|
+
overlaps: []
|
|
325
|
+
}, f = 0, h = Array.from({ length: l }, (e, t) => n(r, t)), g = Array.from({ length: u }, (e, t) => n(i, t));
|
|
326
|
+
for (let e = 0; e < l; e++) for (let n = 0; n < u; n++) {
|
|
327
|
+
let r = h[e], i = g[n], a = Math.max(1, ...r.map(Math.abs), ...i.map(Math.abs)) * 2 ** -52 * 16, s = (e) => r.every((t, n) => Math.abs(t - i[e ? (3 - Math.floor(n / 3)) * 3 + n % 3 : n]) <= a);
|
|
328
|
+
if (s(!1) || s(!0)) {
|
|
329
|
+
let t = !s(!1);
|
|
330
|
+
d.overlaps.push({
|
|
331
|
+
t0: e / l,
|
|
332
|
+
t1: (e + 1) / l,
|
|
333
|
+
otherT0: (n + +!!t) / u,
|
|
334
|
+
otherT1: (n + +!t) / u
|
|
335
|
+
});
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
let p = w(r, i, a);
|
|
339
|
+
if (p) {
|
|
340
|
+
d.points.push(...p.points.map((t) => ({
|
|
341
|
+
t: (e + t.t) / l,
|
|
342
|
+
otherT: (n + t.otherT) / u,
|
|
343
|
+
point: t.point
|
|
344
|
+
}))), d.overlaps.push(...p.overlaps.map((t) => ({
|
|
345
|
+
t0: (e + t.t0) / l,
|
|
346
|
+
t1: (e + t.t1) / l,
|
|
347
|
+
otherT0: (n + t.otherT0) / u,
|
|
348
|
+
otherT1: (n + t.otherT1) / u
|
|
349
|
+
})));
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
let m = C(r, i, a * 4);
|
|
353
|
+
if (m) {
|
|
354
|
+
d.overlaps.push({
|
|
355
|
+
t0: (e + m.t0) / l,
|
|
356
|
+
t1: (e + m.t1) / l,
|
|
357
|
+
otherT0: (n + m.otherT0) / u,
|
|
358
|
+
otherT1: (n + m.otherT1) / u
|
|
359
|
+
});
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
let _ = [[{
|
|
363
|
+
p: r,
|
|
364
|
+
t0: 0,
|
|
365
|
+
t1: 1
|
|
366
|
+
}, {
|
|
367
|
+
p: i,
|
|
368
|
+
t0: 0,
|
|
369
|
+
t1: 1
|
|
370
|
+
}]];
|
|
371
|
+
for (; _.length;) {
|
|
372
|
+
if (++f > c) throw Object.assign(/* @__PURE__ */ RangeError("Curve intersection work limit reached; raise maxWork or split the input curves."), { code: "limit" });
|
|
373
|
+
let [s, p] = _.pop(), m = b(s.p), h = b(p.p);
|
|
374
|
+
if ([
|
|
375
|
+
0,
|
|
376
|
+
1,
|
|
377
|
+
2
|
|
378
|
+
].some((e) => m.max[e] + a < h.min[e] || h.max[e] + a < m.min[e])) continue;
|
|
379
|
+
let g = x(m), v = x(h);
|
|
380
|
+
if (Math.max(g, v) <= o || Math.max(s.t1 - s.t0, p.t1 - p.t0) <= 1e-12) {
|
|
381
|
+
let [a, c, f] = T(r, i, (s.t0 + s.t1) / 2, (p.t0 + p.t1) / 2);
|
|
382
|
+
f <= o && d.points.push({
|
|
383
|
+
t: (e + a) / l,
|
|
384
|
+
otherT: (n + c) / u,
|
|
385
|
+
point: t(r, a, 0)
|
|
386
|
+
});
|
|
387
|
+
} else if (g >= v) for (let e of y(s)) _.push([e, p]);
|
|
388
|
+
else for (let e of y(p)) _.push([s, e]);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return m(d, s);
|
|
392
|
+
}
|
|
393
|
+
//#endregion
|
|
394
|
+
export { _ as intersectSplinePlane, v as intersectSplineRay, E as intersectSplines, g as splineBounds, h as splineExtrema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,78 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@margoengine/splines",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "3D Catmull-Rom, Bezier, Hermite, B-spline and Kochanek-Bartels curves with arc-length lookup, closest point, stable frames and knot editing.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"margoengine",
|
|
7
|
+
"webgpu",
|
|
8
|
+
"3d",
|
|
9
|
+
"splines"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://margoengine.com",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/scottcampbelldata/margoengine/issues"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/scottcampbelldata/margoengine.git",
|
|
18
|
+
"directory": "packages/splines"
|
|
19
|
+
},
|
|
20
|
+
"license": "Apache-2.0",
|
|
21
|
+
"author": "Scott Campbell",
|
|
22
|
+
"type": "module",
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./closest": {
|
|
30
|
+
"types": "./dist/closest.d.ts",
|
|
31
|
+
"import": "./dist/closest.js"
|
|
32
|
+
},
|
|
33
|
+
"./frames": {
|
|
34
|
+
"types": "./dist/frames.d.ts",
|
|
35
|
+
"import": "./dist/frames.js"
|
|
36
|
+
},
|
|
37
|
+
"./knots": {
|
|
38
|
+
"types": "./dist/knots.d.ts",
|
|
39
|
+
"import": "./dist/knots.js"
|
|
40
|
+
},
|
|
41
|
+
"./mesh": {
|
|
42
|
+
"types": "./dist/mesh.d.ts",
|
|
43
|
+
"import": "./dist/mesh.js"
|
|
44
|
+
},
|
|
45
|
+
"./fit": {
|
|
46
|
+
"types": "./dist/fit.d.ts",
|
|
47
|
+
"import": "./dist/fit.js"
|
|
48
|
+
},
|
|
49
|
+
"./kinds": {
|
|
50
|
+
"types": "./dist/kinds.d.ts",
|
|
51
|
+
"import": "./dist/kinds.js"
|
|
52
|
+
},
|
|
53
|
+
"./query": {
|
|
54
|
+
"types": "./dist/query.d.ts",
|
|
55
|
+
"import": "./dist/query.js"
|
|
56
|
+
},
|
|
57
|
+
"./offset": {
|
|
58
|
+
"types": "./dist/offset.d.ts",
|
|
59
|
+
"import": "./dist/offset.js"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"files": [
|
|
63
|
+
"dist",
|
|
64
|
+
"LICENSE",
|
|
65
|
+
"NOTICE"
|
|
66
|
+
],
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public"
|
|
69
|
+
},
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"@margoengine/core": "^1.0.0"
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"build": "node ../../scripts/build-optional.js splines",
|
|
75
|
+
"test": "npm run build && node --test test/*.test.js",
|
|
76
|
+
"prepack": "npm run build"
|
|
77
|
+
}
|
|
78
|
+
}
|