react-three-nurbs 0.1.0 → 0.3.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.
Files changed (3) hide show
  1. package/README.md +68 -0
  2. package/dist/index.js +2988 -560
  3. package/package.json +18 -16
package/dist/index.js CHANGED
@@ -1,9 +1,11 @@
1
- import Ne, { useMemo as Me, useState as pr, useEffect as mr, isValidElement as Ye, Children as br } from "react";
2
- import { Vector3 as hr, BufferGeometry as yr, Float32BufferAttribute as Ie, MeshPhongMaterial as gr, DoubleSide as Er, Color as _r, Mesh as Rr } from "three";
3
- import ue from "verb-nurbs";
4
- import { Line as Sr } from "@react-three/drei";
5
- import { useThree as Cr } from "@react-three/fiber";
6
- var ge = { exports: {} }, ee = {};
1
+ var un = Object.defineProperty;
2
+ var fn = (t, n, e) => n in t ? un(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
+ var ct = (t, n, e) => fn(t, typeof n != "symbol" ? n + "" : n, e);
4
+ import Se, { useMemo as V, isValidElement as gt, forwardRef as ie, Children as ht, useRef as et, useCallback as it, useState as hn } from "react";
5
+ import { Vector3 as I, BufferGeometry as pt, Float32BufferAttribute as J, DoubleSide as wt, Plane as dn, Raycaster as gn, Vector2 as pn } from "three";
6
+ import { Line as xt } from "@react-three/drei";
7
+ import { useThree as vn } from "@react-three/fiber";
8
+ var ee = { exports: {} }, jt = {};
7
9
  /**
8
10
  * @license React
9
11
  * react-jsx-runtime.production.min.js
@@ -13,21 +15,21 @@ var ge = { exports: {} }, ee = {};
13
15
  * This source code is licensed under the MIT license found in the
14
16
  * LICENSE file in the root directory of this source tree.
15
17
  */
16
- var We;
17
- function Tr() {
18
- if (We) return ee;
19
- We = 1;
20
- var T = Ne, x = Symbol.for("react.element"), y = Symbol.for("react.fragment"), c = Object.prototype.hasOwnProperty, k = T.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, F = { key: !0, ref: !0, __self: !0, __source: !0 };
21
- function _(g, f, E) {
22
- var p, m = {}, R = null, D = null;
23
- E !== void 0 && (R = "" + E), f.key !== void 0 && (R = "" + f.key), f.ref !== void 0 && (D = f.ref);
24
- for (p in f) c.call(f, p) && !F.hasOwnProperty(p) && (m[p] = f[p]);
25
- if (g && g.defaultProps) for (p in f = g.defaultProps, f) m[p] === void 0 && (m[p] = f[p]);
26
- return { $$typeof: x, type: g, key: R, ref: D, props: m, _owner: k.current };
27
- }
28
- return ee.Fragment = y, ee.jsx = _, ee.jsxs = _, ee;
29
- }
30
- var re = {};
18
+ var Pe;
19
+ function mn() {
20
+ if (Pe) return jt;
21
+ Pe = 1;
22
+ var t = Se, n = Symbol.for("react.element"), e = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, s = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, o = { key: !0, ref: !0, __self: !0, __source: !0 };
23
+ function i(l, u, a) {
24
+ var g, f = {}, c = null, h = null;
25
+ a !== void 0 && (c = "" + a), u.key !== void 0 && (c = "" + u.key), u.ref !== void 0 && (h = u.ref);
26
+ for (g in u) r.call(u, g) && !o.hasOwnProperty(g) && (f[g] = u[g]);
27
+ if (l && l.defaultProps) for (g in u = l.defaultProps, u) f[g] === void 0 && (f[g] = u[g]);
28
+ return { $$typeof: n, type: l, key: c, ref: h, props: f, _owner: s.current };
29
+ }
30
+ return jt.Fragment = e, jt.jsx = i, jt.jsxs = i, jt;
31
+ }
32
+ var Rt = {};
31
33
  /**
32
34
  * @license React
33
35
  * react-jsx-runtime.development.js
@@ -37,91 +39,91 @@ var re = {};
37
39
  * This source code is licensed under the MIT license found in the
38
40
  * LICENSE file in the root directory of this source tree.
39
41
  */
40
- var $e;
41
- function wr() {
42
- return $e || ($e = 1, process.env.NODE_ENV !== "production" && function() {
43
- var T = Ne, x = Symbol.for("react.element"), y = Symbol.for("react.portal"), c = Symbol.for("react.fragment"), k = Symbol.for("react.strict_mode"), F = Symbol.for("react.profiler"), _ = Symbol.for("react.provider"), g = Symbol.for("react.context"), f = Symbol.for("react.forward_ref"), E = Symbol.for("react.suspense"), p = Symbol.for("react.suspense_list"), m = Symbol.for("react.memo"), R = Symbol.for("react.lazy"), D = Symbol.for("react.offscreen"), S = Symbol.iterator, b = "@@iterator";
44
- function v(e) {
45
- if (e === null || typeof e != "object")
42
+ var Ce;
43
+ function yn() {
44
+ return Ce || (Ce = 1, process.env.NODE_ENV !== "production" && function() {
45
+ var t = Se, n = Symbol.for("react.element"), e = Symbol.for("react.portal"), r = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), i = Symbol.for("react.provider"), l = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), a = Symbol.for("react.suspense"), g = Symbol.for("react.suspense_list"), f = Symbol.for("react.memo"), c = Symbol.for("react.lazy"), h = Symbol.for("react.offscreen"), p = Symbol.iterator, y = "@@iterator";
46
+ function d(v) {
47
+ if (v === null || typeof v != "object")
46
48
  return null;
47
- var r = S && e[S] || e[b];
48
- return typeof r == "function" ? r : null;
49
+ var C = p && v[p] || v[y];
50
+ return typeof C == "function" ? C : null;
49
51
  }
50
- var C = T.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
51
- function s(e) {
52
+ var m = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
53
+ function w(v) {
52
54
  {
53
- for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
54
- t[n - 1] = arguments[n];
55
- W("error", e, t);
55
+ for (var C = arguments.length, A = new Array(C > 1 ? C - 1 : 0), F = 1; F < C; F++)
56
+ A[F - 1] = arguments[F];
57
+ x("error", v, A);
56
58
  }
57
59
  }
58
- function W(e, r, t) {
60
+ function x(v, C, A) {
59
61
  {
60
- var n = C.ReactDebugCurrentFrame, i = n.getStackAddendum();
61
- i !== "" && (r += "%s", t = t.concat([i]));
62
- var u = t.map(function(o) {
63
- return String(o);
62
+ var F = m.ReactDebugCurrentFrame, K = F.getStackAddendum();
63
+ K !== "" && (C += "%s", A = A.concat([K]));
64
+ var L = A.map(function($) {
65
+ return String($);
64
66
  });
65
- u.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, u);
67
+ L.unshift("Warning: " + C), Function.prototype.apply.call(console[v], console, L);
66
68
  }
67
69
  }
68
- var H = !1, U = !1, ce = !1, fe = !1, w = !1, l;
69
- l = Symbol.for("react.module.reference");
70
- function $(e) {
71
- return !!(typeof e == "string" || typeof e == "function" || e === c || e === F || w || e === k || e === E || e === p || fe || e === D || H || U || ce || typeof e == "object" && e !== null && (e.$$typeof === R || e.$$typeof === m || e.$$typeof === _ || e.$$typeof === g || e.$$typeof === f || // This needs to include all possible module reference object
70
+ var _ = !1, b = !1, P = !1, M = !1, S = !1, U;
71
+ U = Symbol.for("react.module.reference");
72
+ function j(v) {
73
+ return !!(typeof v == "string" || typeof v == "function" || v === r || v === o || S || v === s || v === a || v === g || M || v === h || _ || b || P || typeof v == "object" && v !== null && (v.$$typeof === c || v.$$typeof === f || v.$$typeof === i || v.$$typeof === l || v.$$typeof === u || // This needs to include all possible module reference object
72
74
  // types supported by any Flight configuration anywhere since
73
75
  // we don't know which Flight build this will end up being used
74
76
  // with.
75
- e.$$typeof === l || e.getModuleId !== void 0));
77
+ v.$$typeof === U || v.getModuleId !== void 0));
76
78
  }
77
- function N(e, r, t) {
78
- var n = e.displayName;
79
- if (n)
80
- return n;
81
- var i = r.displayName || r.name || "";
82
- return i !== "" ? t + "(" + i + ")" : t;
79
+ function k(v, C, A) {
80
+ var F = v.displayName;
81
+ if (F)
82
+ return F;
83
+ var K = C.displayName || C.name || "";
84
+ return K !== "" ? A + "(" + K + ")" : A;
83
85
  }
84
- function B(e) {
85
- return e.displayName || "Context";
86
+ function E(v) {
87
+ return v.displayName || "Context";
86
88
  }
87
- function j(e) {
88
- if (e == null)
89
+ function T(v) {
90
+ if (v == null)
89
91
  return null;
90
- if (typeof e.tag == "number" && s("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
91
- return e.displayName || e.name || null;
92
- if (typeof e == "string")
93
- return e;
94
- switch (e) {
95
- case c:
92
+ if (typeof v.tag == "number" && w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof v == "function")
93
+ return v.displayName || v.name || null;
94
+ if (typeof v == "string")
95
+ return v;
96
+ switch (v) {
97
+ case r:
96
98
  return "Fragment";
97
- case y:
99
+ case e:
98
100
  return "Portal";
99
- case F:
101
+ case o:
100
102
  return "Profiler";
101
- case k:
103
+ case s:
102
104
  return "StrictMode";
103
- case E:
105
+ case a:
104
106
  return "Suspense";
105
- case p:
107
+ case g:
106
108
  return "SuspenseList";
107
109
  }
108
- if (typeof e == "object")
109
- switch (e.$$typeof) {
110
- case g:
111
- var r = e;
112
- return B(r) + ".Consumer";
113
- case _:
114
- var t = e;
115
- return B(t._context) + ".Provider";
110
+ if (typeof v == "object")
111
+ switch (v.$$typeof) {
112
+ case l:
113
+ var C = v;
114
+ return E(C) + ".Consumer";
115
+ case i:
116
+ var A = v;
117
+ return E(A._context) + ".Provider";
118
+ case u:
119
+ return k(v, v.render, "ForwardRef");
116
120
  case f:
117
- return N(e, e.render, "ForwardRef");
118
- case m:
119
- var n = e.displayName || null;
120
- return n !== null ? n : j(e.type) || "Memo";
121
- case R: {
122
- var i = e, u = i._payload, o = i._init;
121
+ var F = v.displayName || null;
122
+ return F !== null ? F : T(v.type) || "Memo";
123
+ case c: {
124
+ var K = v, L = K._payload, $ = K._init;
123
125
  try {
124
- return j(o(u));
126
+ return T($(L));
125
127
  } catch {
126
128
  return null;
127
129
  }
@@ -129,693 +131,3119 @@ function wr() {
129
131
  }
130
132
  return null;
131
133
  }
132
- var M = Object.assign, z = 0, Z, Y, L, I, te, ne, q;
133
- function J() {
134
+ var D = Object.assign, R = 0, W, G, Q, X, nt, lt, At;
135
+ function St() {
134
136
  }
135
- J.__reactDisabledLog = !0;
136
- function Le() {
137
+ St.__reactDisabledLog = !0;
138
+ function N() {
137
139
  {
138
- if (z === 0) {
139
- Z = console.log, Y = console.info, L = console.warn, I = console.error, te = console.group, ne = console.groupCollapsed, q = console.groupEnd;
140
- var e = {
140
+ if (R === 0) {
141
+ W = console.log, G = console.info, Q = console.warn, X = console.error, nt = console.group, lt = console.groupCollapsed, At = console.groupEnd;
142
+ var v = {
141
143
  configurable: !0,
142
144
  enumerable: !0,
143
- value: J,
145
+ value: St,
144
146
  writable: !0
145
147
  };
146
148
  Object.defineProperties(console, {
147
- info: e,
148
- log: e,
149
- warn: e,
150
- error: e,
151
- group: e,
152
- groupCollapsed: e,
153
- groupEnd: e
149
+ info: v,
150
+ log: v,
151
+ warn: v,
152
+ error: v,
153
+ group: v,
154
+ groupCollapsed: v,
155
+ groupEnd: v
154
156
  });
155
157
  }
156
- z++;
158
+ R++;
157
159
  }
158
160
  }
159
- function Ke() {
161
+ function _t() {
160
162
  {
161
- if (z--, z === 0) {
162
- var e = {
163
+ if (R--, R === 0) {
164
+ var v = {
163
165
  configurable: !0,
164
166
  enumerable: !0,
165
167
  writable: !0
166
168
  };
167
169
  Object.defineProperties(console, {
168
- log: M({}, e, {
169
- value: Z
170
+ log: D({}, v, {
171
+ value: W
170
172
  }),
171
- info: M({}, e, {
172
- value: Y
173
+ info: D({}, v, {
174
+ value: G
173
175
  }),
174
- warn: M({}, e, {
175
- value: L
176
+ warn: D({}, v, {
177
+ value: Q
176
178
  }),
177
- error: M({}, e, {
178
- value: I
179
+ error: D({}, v, {
180
+ value: X
179
181
  }),
180
- group: M({}, e, {
181
- value: te
182
+ group: D({}, v, {
183
+ value: nt
182
184
  }),
183
- groupCollapsed: M({}, e, {
184
- value: ne
185
+ groupCollapsed: D({}, v, {
186
+ value: lt
185
187
  }),
186
- groupEnd: M({}, e, {
187
- value: q
188
+ groupEnd: D({}, v, {
189
+ value: At
188
190
  })
189
191
  });
190
192
  }
191
- z < 0 && s("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
193
+ R < 0 && w("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
192
194
  }
193
195
  }
194
- var le = C.ReactCurrentDispatcher, ve;
195
- function ae(e, r, t) {
196
+ var Bt = m.ReactCurrentDispatcher, Zt;
197
+ function It(v, C, A) {
196
198
  {
197
- if (ve === void 0)
199
+ if (Zt === void 0)
198
200
  try {
199
201
  throw Error();
200
- } catch (i) {
201
- var n = i.stack.trim().match(/\n( *(at )?)/);
202
- ve = n && n[1] || "";
202
+ } catch (K) {
203
+ var F = K.stack.trim().match(/\n( *(at )?)/);
204
+ Zt = F && F[1] || "";
203
205
  }
204
206
  return `
205
- ` + ve + e;
207
+ ` + Zt + v;
206
208
  }
207
209
  }
208
- var de = !1, oe;
210
+ var Yt = !1, Ot;
209
211
  {
210
- var Be = typeof WeakMap == "function" ? WeakMap : Map;
211
- oe = new Be();
212
+ var Ve = typeof WeakMap == "function" ? WeakMap : Map;
213
+ Ot = new Ve();
212
214
  }
213
- function Ee(e, r) {
214
- if (!e || de)
215
+ function le(v, C) {
216
+ if (!v || Yt)
215
217
  return "";
216
218
  {
217
- var t = oe.get(e);
218
- if (t !== void 0)
219
- return t;
219
+ var A = Ot.get(v);
220
+ if (A !== void 0)
221
+ return A;
220
222
  }
221
- var n;
222
- de = !0;
223
- var i = Error.prepareStackTrace;
223
+ var F;
224
+ Yt = !0;
225
+ var K = Error.prepareStackTrace;
224
226
  Error.prepareStackTrace = void 0;
225
- var u;
226
- u = le.current, le.current = null, Le();
227
+ var L;
228
+ L = Bt.current, Bt.current = null, N();
227
229
  try {
228
- if (r) {
229
- var o = function() {
230
+ if (C) {
231
+ var $ = function() {
230
232
  throw Error();
231
233
  };
232
- if (Object.defineProperty(o.prototype, "props", {
234
+ if (Object.defineProperty($.prototype, "props", {
233
235
  set: function() {
234
236
  throw Error();
235
237
  }
236
238
  }), typeof Reflect == "object" && Reflect.construct) {
237
239
  try {
238
- Reflect.construct(o, []);
239
- } catch (P) {
240
- n = P;
240
+ Reflect.construct($, []);
241
+ } catch (rt) {
242
+ F = rt;
241
243
  }
242
- Reflect.construct(e, [], o);
244
+ Reflect.construct(v, [], $);
243
245
  } else {
244
246
  try {
245
- o.call();
246
- } catch (P) {
247
- n = P;
247
+ $.call();
248
+ } catch (rt) {
249
+ F = rt;
248
250
  }
249
- e.call(o.prototype);
251
+ v.call($.prototype);
250
252
  }
251
253
  } else {
252
254
  try {
253
255
  throw Error();
254
- } catch (P) {
255
- n = P;
256
+ } catch (rt) {
257
+ F = rt;
256
258
  }
257
- e();
258
- }
259
- } catch (P) {
260
- if (P && n && typeof P.stack == "string") {
261
- for (var a = P.stack.split(`
262
- `), O = n.stack.split(`
263
- `), d = a.length - 1, h = O.length - 1; d >= 1 && h >= 0 && a[d] !== O[h]; )
264
- h--;
265
- for (; d >= 1 && h >= 0; d--, h--)
266
- if (a[d] !== O[h]) {
267
- if (d !== 1 || h !== 1)
259
+ v();
260
+ }
261
+ } catch (rt) {
262
+ if (rt && F && typeof rt.stack == "string") {
263
+ for (var O = rt.stack.split(`
264
+ `), tt = F.stack.split(`
265
+ `), Z = O.length - 1, Y = tt.length - 1; Z >= 1 && Y >= 0 && O[Z] !== tt[Y]; )
266
+ Y--;
267
+ for (; Z >= 1 && Y >= 0; Z--, Y--)
268
+ if (O[Z] !== tt[Y]) {
269
+ if (Z !== 1 || Y !== 1)
268
270
  do
269
- if (d--, h--, h < 0 || a[d] !== O[h]) {
270
- var A = `
271
- ` + a[d].replace(" at new ", " at ");
272
- return e.displayName && A.includes("<anonymous>") && (A = A.replace("<anonymous>", e.displayName)), typeof e == "function" && oe.set(e, A), A;
271
+ if (Z--, Y--, Y < 0 || O[Z] !== tt[Y]) {
272
+ var ot = `
273
+ ` + O[Z].replace(" at new ", " at ");
274
+ return v.displayName && ot.includes("<anonymous>") && (ot = ot.replace("<anonymous>", v.displayName)), typeof v == "function" && Ot.set(v, ot), ot;
273
275
  }
274
- while (d >= 1 && h >= 0);
276
+ while (Z >= 1 && Y >= 0);
275
277
  break;
276
278
  }
277
279
  }
278
280
  } finally {
279
- de = !1, le.current = u, Ke(), Error.prepareStackTrace = i;
281
+ Yt = !1, Bt.current = L, _t(), Error.prepareStackTrace = K;
280
282
  }
281
- var X = e ? e.displayName || e.name : "", G = X ? ae(X) : "";
282
- return typeof e == "function" && oe.set(e, G), G;
283
+ var Pt = v ? v.displayName || v.name : "", mt = Pt ? It(Pt) : "";
284
+ return typeof v == "function" && Ot.set(v, mt), mt;
283
285
  }
284
- function qe(e, r, t) {
285
- return Ee(e, !1);
286
+ function $e(v, C, A) {
287
+ return le(v, !1);
286
288
  }
287
- function Ue(e) {
288
- var r = e.prototype;
289
- return !!(r && r.isReactComponent);
289
+ function Ne(v) {
290
+ var C = v.prototype;
291
+ return !!(C && C.isReactComponent);
290
292
  }
291
- function ie(e, r, t) {
292
- if (e == null)
293
+ function Vt(v, C, A) {
294
+ if (v == null)
293
295
  return "";
294
- if (typeof e == "function")
295
- return Ee(e, Ue(e));
296
- if (typeof e == "string")
297
- return ae(e);
298
- switch (e) {
299
- case E:
300
- return ae("Suspense");
301
- case p:
302
- return ae("SuspenseList");
303
- }
304
- if (typeof e == "object")
305
- switch (e.$$typeof) {
296
+ if (typeof v == "function")
297
+ return le(v, Ne(v));
298
+ if (typeof v == "string")
299
+ return It(v);
300
+ switch (v) {
301
+ case a:
302
+ return It("Suspense");
303
+ case g:
304
+ return It("SuspenseList");
305
+ }
306
+ if (typeof v == "object")
307
+ switch (v.$$typeof) {
308
+ case u:
309
+ return $e(v.render);
306
310
  case f:
307
- return qe(e.render);
308
- case m:
309
- return ie(e.type, r, t);
310
- case R: {
311
- var n = e, i = n._payload, u = n._init;
311
+ return Vt(v.type, C, A);
312
+ case c: {
313
+ var F = v, K = F._payload, L = F._init;
312
314
  try {
313
- return ie(u(i), r, t);
315
+ return Vt(L(K), C, A);
314
316
  } catch {
315
317
  }
316
318
  }
317
319
  }
318
320
  return "";
319
321
  }
320
- var Q = Object.prototype.hasOwnProperty, _e = {}, Re = C.ReactDebugCurrentFrame;
321
- function se(e) {
322
- if (e) {
323
- var r = e._owner, t = ie(e.type, e._source, r ? r.type : null);
324
- Re.setExtraStackFrame(t);
322
+ var Et = Object.prototype.hasOwnProperty, ae = {}, ue = m.ReactDebugCurrentFrame;
323
+ function $t(v) {
324
+ if (v) {
325
+ var C = v._owner, A = Vt(v.type, v._source, C ? C.type : null);
326
+ ue.setExtraStackFrame(A);
325
327
  } else
326
- Re.setExtraStackFrame(null);
328
+ ue.setExtraStackFrame(null);
327
329
  }
328
- function ze(e, r, t, n, i) {
330
+ function Ke(v, C, A, F, K) {
329
331
  {
330
- var u = Function.call.bind(Q);
331
- for (var o in e)
332
- if (u(e, o)) {
333
- var a = void 0;
332
+ var L = Function.call.bind(Et);
333
+ for (var $ in v)
334
+ if (L(v, $)) {
335
+ var O = void 0;
334
336
  try {
335
- if (typeof e[o] != "function") {
336
- var O = Error((n || "React class") + ": " + t + " type `" + o + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[o] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
337
- throw O.name = "Invariant Violation", O;
337
+ if (typeof v[$] != "function") {
338
+ var tt = Error((F || "React class") + ": " + A + " type `" + $ + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof v[$] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
339
+ throw tt.name = "Invariant Violation", tt;
338
340
  }
339
- a = e[o](r, o, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
340
- } catch (d) {
341
- a = d;
341
+ O = v[$](C, $, F, A, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
342
+ } catch (Z) {
343
+ O = Z;
342
344
  }
343
- a && !(a instanceof Error) && (se(i), s("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, o, typeof a), se(null)), a instanceof Error && !(a.message in _e) && (_e[a.message] = !0, se(i), s("Failed %s type: %s", t, a.message), se(null));
345
+ O && !(O instanceof Error) && ($t(K), w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", F || "React class", A, $, typeof O), $t(null)), O instanceof Error && !(O.message in ae) && (ae[O.message] = !0, $t(K), w("Failed %s type: %s", A, O.message), $t(null));
344
346
  }
345
347
  }
346
348
  }
347
- var Ge = Array.isArray;
348
- function pe(e) {
349
- return Ge(e);
349
+ var We = Array.isArray;
350
+ function Jt(v) {
351
+ return We(v);
350
352
  }
351
- function Je(e) {
353
+ function Le(v) {
352
354
  {
353
- var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
354
- return t;
355
+ var C = typeof Symbol == "function" && Symbol.toStringTag, A = C && v[Symbol.toStringTag] || v.constructor.name || "Object";
356
+ return A;
355
357
  }
356
358
  }
357
- function Ve(e) {
359
+ function qe(v) {
358
360
  try {
359
- return Se(e), !1;
361
+ return fe(v), !1;
360
362
  } catch {
361
363
  return !0;
362
364
  }
363
365
  }
364
- function Se(e) {
365
- return "" + e;
366
+ function fe(v) {
367
+ return "" + v;
366
368
  }
367
- function Ce(e) {
368
- if (Ve(e))
369
- return s("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Je(e)), Se(e);
369
+ function he(v) {
370
+ if (qe(v))
371
+ return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Le(v)), fe(v);
370
372
  }
371
- var Te = C.ReactCurrentOwner, Xe = {
373
+ var de = m.ReactCurrentOwner, ze = {
372
374
  key: !0,
373
375
  ref: !0,
374
376
  __self: !0,
375
377
  __source: !0
376
- }, we, je;
377
- function He(e) {
378
- if (Q.call(e, "ref")) {
379
- var r = Object.getOwnPropertyDescriptor(e, "ref").get;
380
- if (r && r.isReactWarning)
378
+ }, ge, pe;
379
+ function Be(v) {
380
+ if (Et.call(v, "ref")) {
381
+ var C = Object.getOwnPropertyDescriptor(v, "ref").get;
382
+ if (C && C.isReactWarning)
381
383
  return !1;
382
384
  }
383
- return e.ref !== void 0;
385
+ return v.ref !== void 0;
384
386
  }
385
- function Ze(e) {
386
- if (Q.call(e, "key")) {
387
- var r = Object.getOwnPropertyDescriptor(e, "key").get;
388
- if (r && r.isReactWarning)
387
+ function Ze(v) {
388
+ if (Et.call(v, "key")) {
389
+ var C = Object.getOwnPropertyDescriptor(v, "key").get;
390
+ if (C && C.isReactWarning)
389
391
  return !1;
390
392
  }
391
- return e.key !== void 0;
393
+ return v.key !== void 0;
392
394
  }
393
- function Qe(e, r) {
394
- typeof e.ref == "string" && Te.current;
395
+ function Ye(v, C) {
396
+ typeof v.ref == "string" && de.current;
395
397
  }
396
- function er(e, r) {
398
+ function Je(v, C) {
397
399
  {
398
- var t = function() {
399
- we || (we = !0, s("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
400
+ var A = function() {
401
+ ge || (ge = !0, w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", C));
400
402
  };
401
- t.isReactWarning = !0, Object.defineProperty(e, "key", {
402
- get: t,
403
+ A.isReactWarning = !0, Object.defineProperty(v, "key", {
404
+ get: A,
403
405
  configurable: !0
404
406
  });
405
407
  }
406
408
  }
407
- function rr(e, r) {
409
+ function Ge(v, C) {
408
410
  {
409
- var t = function() {
410
- je || (je = !0, s("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
411
+ var A = function() {
412
+ pe || (pe = !0, w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", C));
411
413
  };
412
- t.isReactWarning = !0, Object.defineProperty(e, "ref", {
413
- get: t,
414
+ A.isReactWarning = !0, Object.defineProperty(v, "ref", {
415
+ get: A,
414
416
  configurable: !0
415
417
  });
416
418
  }
417
419
  }
418
- var tr = function(e, r, t, n, i, u, o) {
419
- var a = {
420
+ var He = function(v, C, A, F, K, L, $) {
421
+ var O = {
420
422
  // This tag allows us to uniquely identify this as a React Element
421
- $$typeof: x,
423
+ $$typeof: n,
422
424
  // Built-in properties that belong on the element
423
- type: e,
424
- key: r,
425
- ref: t,
426
- props: o,
425
+ type: v,
426
+ key: C,
427
+ ref: A,
428
+ props: $,
427
429
  // Record the component responsible for creating this element.
428
- _owner: u
430
+ _owner: L
429
431
  };
430
- return a._store = {}, Object.defineProperty(a._store, "validated", {
432
+ return O._store = {}, Object.defineProperty(O._store, "validated", {
431
433
  configurable: !1,
432
434
  enumerable: !1,
433
435
  writable: !0,
434
436
  value: !1
435
- }), Object.defineProperty(a, "_self", {
437
+ }), Object.defineProperty(O, "_self", {
436
438
  configurable: !1,
437
439
  enumerable: !1,
438
440
  writable: !1,
439
- value: n
440
- }), Object.defineProperty(a, "_source", {
441
+ value: F
442
+ }), Object.defineProperty(O, "_source", {
441
443
  configurable: !1,
442
444
  enumerable: !1,
443
445
  writable: !1,
444
- value: i
445
- }), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
446
+ value: K
447
+ }), Object.freeze && (Object.freeze(O.props), Object.freeze(O)), O;
446
448
  };
447
- function nr(e, r, t, n, i) {
449
+ function Xe(v, C, A, F, K) {
448
450
  {
449
- var u, o = {}, a = null, O = null;
450
- t !== void 0 && (Ce(t), a = "" + t), Ze(r) && (Ce(r.key), a = "" + r.key), He(r) && (O = r.ref, Qe(r, i));
451
- for (u in r)
452
- Q.call(r, u) && !Xe.hasOwnProperty(u) && (o[u] = r[u]);
453
- if (e && e.defaultProps) {
454
- var d = e.defaultProps;
455
- for (u in d)
456
- o[u] === void 0 && (o[u] = d[u]);
457
- }
458
- if (a || O) {
459
- var h = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
460
- a && er(o, h), O && rr(o, h);
461
- }
462
- return tr(e, a, O, i, n, Te.current, o);
463
- }
464
- }
465
- var me = C.ReactCurrentOwner, Oe = C.ReactDebugCurrentFrame;
466
- function V(e) {
467
- if (e) {
468
- var r = e._owner, t = ie(e.type, e._source, r ? r.type : null);
469
- Oe.setExtraStackFrame(t);
451
+ var L, $ = {}, O = null, tt = null;
452
+ A !== void 0 && (he(A), O = "" + A), Ze(C) && (he(C.key), O = "" + C.key), Be(C) && (tt = C.ref, Ye(C, K));
453
+ for (L in C)
454
+ Et.call(C, L) && !ze.hasOwnProperty(L) && ($[L] = C[L]);
455
+ if (v && v.defaultProps) {
456
+ var Z = v.defaultProps;
457
+ for (L in Z)
458
+ $[L] === void 0 && ($[L] = Z[L]);
459
+ }
460
+ if (O || tt) {
461
+ var Y = typeof v == "function" ? v.displayName || v.name || "Unknown" : v;
462
+ O && Je($, Y), tt && Ge($, Y);
463
+ }
464
+ return He(v, O, tt, K, F, de.current, $);
465
+ }
466
+ }
467
+ var Gt = m.ReactCurrentOwner, ve = m.ReactDebugCurrentFrame;
468
+ function bt(v) {
469
+ if (v) {
470
+ var C = v._owner, A = Vt(v.type, v._source, C ? C.type : null);
471
+ ve.setExtraStackFrame(A);
470
472
  } else
471
- Oe.setExtraStackFrame(null);
473
+ ve.setExtraStackFrame(null);
472
474
  }
473
- var be;
474
- be = !1;
475
- function he(e) {
476
- return typeof e == "object" && e !== null && e.$$typeof === x;
475
+ var Ht;
476
+ Ht = !1;
477
+ function Xt(v) {
478
+ return typeof v == "object" && v !== null && v.$$typeof === n;
477
479
  }
478
- function Pe() {
480
+ function me() {
479
481
  {
480
- if (me.current) {
481
- var e = j(me.current.type);
482
- if (e)
482
+ if (Gt.current) {
483
+ var v = T(Gt.current.type);
484
+ if (v)
483
485
  return `
484
486
 
485
- Check the render method of \`` + e + "`.";
487
+ Check the render method of \`` + v + "`.";
486
488
  }
487
489
  return "";
488
490
  }
489
491
  }
490
- function ar(e) {
492
+ function Qe(v) {
491
493
  return "";
492
494
  }
493
- var xe = {};
494
- function or(e) {
495
+ var ye = {};
496
+ function tn(v) {
495
497
  {
496
- var r = Pe();
497
- if (!r) {
498
- var t = typeof e == "string" ? e : e.displayName || e.name;
499
- t && (r = `
498
+ var C = me();
499
+ if (!C) {
500
+ var A = typeof v == "string" ? v : v.displayName || v.name;
501
+ A && (C = `
500
502
 
501
- Check the top-level render call using <` + t + ">.");
503
+ Check the top-level render call using <` + A + ">.");
502
504
  }
503
- return r;
505
+ return C;
504
506
  }
505
507
  }
506
- function ke(e, r) {
508
+ function we(v, C) {
507
509
  {
508
- if (!e._store || e._store.validated || e.key != null)
510
+ if (!v._store || v._store.validated || v.key != null)
509
511
  return;
510
- e._store.validated = !0;
511
- var t = or(r);
512
- if (xe[t])
512
+ v._store.validated = !0;
513
+ var A = tn(C);
514
+ if (ye[A])
513
515
  return;
514
- xe[t] = !0;
515
- var n = "";
516
- e && e._owner && e._owner !== me.current && (n = " It was passed a child from " + j(e._owner.type) + "."), V(e), s('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), V(null);
516
+ ye[A] = !0;
517
+ var F = "";
518
+ v && v._owner && v._owner !== Gt.current && (F = " It was passed a child from " + T(v._owner.type) + "."), bt(v), w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', A, F), bt(null);
517
519
  }
518
520
  }
519
- function Ae(e, r) {
521
+ function xe(v, C) {
520
522
  {
521
- if (typeof e != "object")
523
+ if (typeof v != "object")
522
524
  return;
523
- if (pe(e))
524
- for (var t = 0; t < e.length; t++) {
525
- var n = e[t];
526
- he(n) && ke(n, r);
525
+ if (Jt(v))
526
+ for (var A = 0; A < v.length; A++) {
527
+ var F = v[A];
528
+ Xt(F) && we(F, C);
527
529
  }
528
- else if (he(e))
529
- e._store && (e._store.validated = !0);
530
- else if (e) {
531
- var i = v(e);
532
- if (typeof i == "function" && i !== e.entries)
533
- for (var u = i.call(e), o; !(o = u.next()).done; )
534
- he(o.value) && ke(o.value, r);
530
+ else if (Xt(v))
531
+ v._store && (v._store.validated = !0);
532
+ else if (v) {
533
+ var K = d(v);
534
+ if (typeof K == "function" && K !== v.entries)
535
+ for (var L = K.call(v), $; !($ = L.next()).done; )
536
+ Xt($.value) && we($.value, C);
535
537
  }
536
538
  }
537
539
  }
538
- function ir(e) {
540
+ function en(v) {
539
541
  {
540
- var r = e.type;
541
- if (r == null || typeof r == "string")
542
+ var C = v.type;
543
+ if (C == null || typeof C == "string")
542
544
  return;
543
- var t;
544
- if (typeof r == "function")
545
- t = r.propTypes;
546
- else if (typeof r == "object" && (r.$$typeof === f || // Note: Memo only checks outer props here.
545
+ var A;
546
+ if (typeof C == "function")
547
+ A = C.propTypes;
548
+ else if (typeof C == "object" && (C.$$typeof === u || // Note: Memo only checks outer props here.
547
549
  // Inner props are checked in the reconciler.
548
- r.$$typeof === m))
549
- t = r.propTypes;
550
+ C.$$typeof === f))
551
+ A = C.propTypes;
550
552
  else
551
553
  return;
552
- if (t) {
553
- var n = j(r);
554
- ze(t, e.props, "prop", n, e);
555
- } else if (r.PropTypes !== void 0 && !be) {
556
- be = !0;
557
- var i = j(r);
558
- s("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", i || "Unknown");
554
+ if (A) {
555
+ var F = T(C);
556
+ Ke(A, v.props, "prop", F, v);
557
+ } else if (C.PropTypes !== void 0 && !Ht) {
558
+ Ht = !0;
559
+ var K = T(C);
560
+ w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", K || "Unknown");
559
561
  }
560
- typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && s("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
562
+ typeof C.getDefaultProps == "function" && !C.getDefaultProps.isReactClassApproved && w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
561
563
  }
562
564
  }
563
- function sr(e) {
565
+ function nn(v) {
564
566
  {
565
- for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
566
- var n = r[t];
567
- if (n !== "children" && n !== "key") {
568
- V(e), s("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), V(null);
567
+ for (var C = Object.keys(v.props), A = 0; A < C.length; A++) {
568
+ var F = C[A];
569
+ if (F !== "children" && F !== "key") {
570
+ bt(v), w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", F), bt(null);
569
571
  break;
570
572
  }
571
573
  }
572
- e.ref !== null && (V(e), s("Invalid attribute `ref` supplied to `React.Fragment`."), V(null));
574
+ v.ref !== null && (bt(v), w("Invalid attribute `ref` supplied to `React.Fragment`."), bt(null));
573
575
  }
574
576
  }
575
- var Fe = {};
576
- function De(e, r, t, n, i, u) {
577
+ var _e = {};
578
+ function be(v, C, A, F, K, L) {
577
579
  {
578
- var o = $(e);
579
- if (!o) {
580
- var a = "";
581
- (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (a += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
582
- var O = ar();
583
- O ? a += O : a += Pe();
584
- var d;
585
- e === null ? d = "null" : pe(e) ? d = "array" : e !== void 0 && e.$$typeof === x ? (d = "<" + (j(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : d = typeof e, s("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", d, a);
586
- }
587
- var h = nr(e, r, t, i, u);
588
- if (h == null)
589
- return h;
590
- if (o) {
591
- var A = r.children;
592
- if (A !== void 0)
593
- if (n)
594
- if (pe(A)) {
595
- for (var X = 0; X < A.length; X++)
596
- Ae(A[X], e);
597
- Object.freeze && Object.freeze(A);
580
+ var $ = j(v);
581
+ if (!$) {
582
+ var O = "";
583
+ (v === void 0 || typeof v == "object" && v !== null && Object.keys(v).length === 0) && (O += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
584
+ var tt = Qe();
585
+ tt ? O += tt : O += me();
586
+ var Z;
587
+ v === null ? Z = "null" : Jt(v) ? Z = "array" : v !== void 0 && v.$$typeof === n ? (Z = "<" + (T(v.type) || "Unknown") + " />", O = " Did you accidentally export a JSX literal instead of a component?") : Z = typeof v, w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", Z, O);
588
+ }
589
+ var Y = Xe(v, C, A, K, L);
590
+ if (Y == null)
591
+ return Y;
592
+ if ($) {
593
+ var ot = C.children;
594
+ if (ot !== void 0)
595
+ if (F)
596
+ if (Jt(ot)) {
597
+ for (var Pt = 0; Pt < ot.length; Pt++)
598
+ xe(ot[Pt], v);
599
+ Object.freeze && Object.freeze(ot);
598
600
  } else
599
- s("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
601
+ w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
600
602
  else
601
- Ae(A, e);
602
- }
603
- if (Q.call(r, "key")) {
604
- var G = j(e), P = Object.keys(r).filter(function(dr) {
605
- return dr !== "key";
606
- }), ye = P.length > 0 ? "{key: someKey, " + P.join(": ..., ") + ": ...}" : "{key: someKey}";
607
- if (!Fe[G + ye]) {
608
- var vr = P.length > 0 ? "{" + P.join(": ..., ") + ": ...}" : "{}";
609
- s(`A props object containing a "key" prop is being spread into JSX:
603
+ xe(ot, v);
604
+ }
605
+ if (Et.call(C, "key")) {
606
+ var mt = T(v), rt = Object.keys(C).filter(function(an) {
607
+ return an !== "key";
608
+ }), Qt = rt.length > 0 ? "{key: someKey, " + rt.join(": ..., ") + ": ...}" : "{key: someKey}";
609
+ if (!_e[mt + Qt]) {
610
+ var ln = rt.length > 0 ? "{" + rt.join(": ..., ") + ": ...}" : "{}";
611
+ w(`A props object containing a "key" prop is being spread into JSX:
610
612
  let props = %s;
611
613
  <%s {...props} />
612
614
  React keys must be passed directly to JSX without using spread:
613
615
  let props = %s;
614
- <%s key={someKey} {...props} />`, ye, G, vr, G), Fe[G + ye] = !0;
616
+ <%s key={someKey} {...props} />`, Qt, mt, ln, mt), _e[mt + Qt] = !0;
615
617
  }
616
618
  }
617
- return e === c ? sr(h) : ir(h), h;
619
+ return v === r ? nn(Y) : en(Y), Y;
618
620
  }
619
621
  }
620
- function ur(e, r, t) {
621
- return De(e, r, t, !0);
622
+ function rn(v, C, A) {
623
+ return be(v, C, A, !0);
622
624
  }
623
- function cr(e, r, t) {
624
- return De(e, r, t, !1);
625
+ function on(v, C, A) {
626
+ return be(v, C, A, !1);
627
+ }
628
+ var sn = on, cn = rn;
629
+ Rt.Fragment = r, Rt.jsx = sn, Rt.jsxs = cn;
630
+ }()), Rt;
631
+ }
632
+ process.env.NODE_ENV === "production" ? ee.exports = mn() : ee.exports = yn();
633
+ var q = ee.exports;
634
+ function ft(t, n, e, r) {
635
+ if (e >= r[t + 1]) return t;
636
+ if (e <= r[n]) return n;
637
+ let s = n, o = t + 1, i = s + o >> 1;
638
+ for (; e < r[i] || e >= r[i + 1]; )
639
+ e < r[i] ? o = i : s = i, i = s + o >> 1;
640
+ return i;
641
+ }
642
+ function Ct(t, n, e, r) {
643
+ const s = new Array(e + 1), o = new Array(e + 1), i = new Array(e + 1);
644
+ s[0] = 1;
645
+ for (let l = 1; l <= e; l++) {
646
+ o[l] = n - r[t + 1 - l], i[l] = r[t + l] - n;
647
+ let u = 0;
648
+ for (let a = 0; a < l; a++) {
649
+ const g = s[a] / (i[a + 1] + o[l - a]);
650
+ s[a] = u + i[a + 1] * g, u = o[l - a] * g;
625
651
  }
626
- var fr = cr, lr = ur;
627
- re.Fragment = c, re.jsx = fr, re.jsxs = lr;
628
- }()), re;
652
+ s[l] = u;
653
+ }
654
+ return s;
655
+ }
656
+ function ne(t, n, e, r, s) {
657
+ const o = Array.from(
658
+ { length: e + 1 },
659
+ () => new Array(e + 1).fill(0)
660
+ ), i = new Array(e + 1), l = new Array(e + 1);
661
+ o[0][0] = 1;
662
+ for (let f = 1; f <= e; f++) {
663
+ i[f] = n - s[t + 1 - f], l[f] = s[t + f] - n;
664
+ let c = 0;
665
+ for (let h = 0; h < f; h++) {
666
+ o[f][h] = l[h + 1] + i[f - h];
667
+ const p = o[h][f - 1] / o[f][h];
668
+ o[h][f] = c + l[h + 1] * p, c = i[f - h] * p;
669
+ }
670
+ o[f][f] = c;
671
+ }
672
+ const u = Array.from(
673
+ { length: r + 1 },
674
+ () => new Array(e + 1).fill(0)
675
+ );
676
+ for (let f = 0; f <= e; f++)
677
+ u[0][f] = o[f][e];
678
+ const a = [new Array(e + 1).fill(0), new Array(e + 1).fill(0)];
679
+ for (let f = 0; f <= e; f++) {
680
+ let c = 0, h = 1;
681
+ a[0][0] = 1;
682
+ for (let p = 1; p <= r; p++) {
683
+ let y = 0;
684
+ const d = f - p, m = e - p;
685
+ f >= p && (a[h][0] = a[c][0] / o[m + 1][d], y = a[h][0] * o[d][m]);
686
+ const w = d >= -1 ? 1 : -d, x = f - 1 <= m ? p - 1 : e - f;
687
+ for (let b = w; b <= x; b++)
688
+ a[h][b] = (a[c][b] - a[c][b - 1]) / o[m + 1][d + b], y += a[h][b] * o[d + b][m];
689
+ f <= m && (a[h][p] = -a[c][p - 1] / o[m + 1][f], y += a[h][p] * o[f][m]), u[p][f] = y;
690
+ const _ = c;
691
+ c = h, h = _;
692
+ }
693
+ }
694
+ let g = e;
695
+ for (let f = 1; f <= r; f++) {
696
+ for (let c = 0; c <= e; c++)
697
+ u[f][c] *= g;
698
+ g *= e - f;
699
+ }
700
+ return u;
701
+ }
702
+ function Ee(t, n, e) {
703
+ const { degree: r, knots: s, controlPoints: o, weights: i } = t, l = o.length - 1, u = o[0].length;
704
+ let a = -1, g = 0;
705
+ for (let d = 0; d < s.length; d++)
706
+ s[d] <= n && (a = d), Math.abs(s[d] - n) < 1e-14 && g++;
707
+ if (e + g > r && (e = r - g), e <= 0) return { ...t };
708
+ const f = new Array(s.length + e);
709
+ for (let d = 0; d <= a; d++) f[d] = s[d];
710
+ for (let d = 1; d <= e; d++) f[a + d] = n;
711
+ for (let d = a + 1; d < s.length; d++) f[d + e] = s[d];
712
+ const c = new Array(r + 1), h = new Array(l + e + 1), p = new Array(l + e + 1);
713
+ for (let d = 0; d <= a - r; d++)
714
+ h[d] = [...o[d]], p[d] = i[d];
715
+ for (let d = a - g; d <= l; d++)
716
+ h[d + e] = [...o[d]], p[d + e] = i[d];
717
+ for (let d = 0; d <= r - g; d++) {
718
+ const m = a - r + 1 + d;
719
+ c[d] = o[m].map((w) => w * i[m]), c[d].push(i[m]);
720
+ }
721
+ let y = 0;
722
+ for (let d = 1; d <= e; d++) {
723
+ y = a - r + d;
724
+ for (let x = 0; x <= r - d - g; x++) {
725
+ const _ = (n - s[y + x]) / (s[x + a + 1] - s[y + x]), b = new Array(u + 1);
726
+ for (let P = 0; P <= u; P++)
727
+ b[P] = _ * c[x + 1][P] + (1 - _) * c[x][P];
728
+ c[x] = b;
729
+ }
730
+ const m = c[0][u];
731
+ h[y] = c[0].slice(0, u).map((x) => m !== 0 ? x / m : x), p[y] = m;
732
+ const w = c[r - d - g][u];
733
+ h[a + e - d - g] = c[r - d - g].slice(0, u).map((x) => w !== 0 ? x / w : x), p[a + e - d - g] = w;
734
+ }
735
+ for (let d = y + 1; d < a - g; d++) {
736
+ const m = c[d - y][u];
737
+ h[d] = c[d - y].slice(0, u).map((w) => m !== 0 ? w / m : w), p[d] = m;
738
+ }
739
+ return {
740
+ degree: r,
741
+ knots: f,
742
+ controlPoints: h,
743
+ weights: p
744
+ };
745
+ }
746
+ function Lt(t, n) {
747
+ const e = [...n].sort((s, o) => s - o);
748
+ let r = t;
749
+ for (const s of e)
750
+ r = Ee(r, s, 1);
751
+ return r;
752
+ }
753
+ function wn(t, n, e) {
754
+ const { degreeU: r, degreeV: s, knotsU: o, knotsV: i, controlPoints: l, weights: u } = t, a = l.length, g = l[0].length;
755
+ if (e) {
756
+ const f = [];
757
+ for (let c = 0; c < a; c++) {
758
+ const h = {
759
+ degree: s,
760
+ knots: [...i],
761
+ controlPoints: l[c].map((y) => [...y]),
762
+ weights: [...u[c]]
763
+ }, p = Lt(h, n);
764
+ f.push({ cp: p.controlPoints, w: p.weights, knots: p.knots });
765
+ }
766
+ return {
767
+ degreeU: r,
768
+ degreeV: s,
769
+ knotsU: [...o],
770
+ knotsV: f[0].knots,
771
+ controlPoints: f.map((c) => c.cp),
772
+ weights: f.map((c) => c.w)
773
+ };
774
+ } else {
775
+ const f = [], c = [], h = [];
776
+ for (let m = 0; m < g; m++) {
777
+ const w = {
778
+ degree: r,
779
+ knots: [...o],
780
+ controlPoints: Array.from({ length: a }, (_, b) => [...l[b][m]]),
781
+ weights: Array.from({ length: a }, (_, b) => u[b][m])
782
+ }, x = Lt(w, n);
783
+ m === 0 && f.push(...x.knots), c.push(x.controlPoints.map((_) => [_])), h.push(x.weights);
784
+ }
785
+ const p = c[0].length, y = [], d = [];
786
+ for (let m = 0; m < p; m++) {
787
+ y[m] = [], d[m] = [];
788
+ for (let w = 0; w < g; w++)
789
+ y[m][w] = c[w][m][0], d[m][w] = h[w][m];
790
+ }
791
+ return {
792
+ degreeU: r,
793
+ degreeV: s,
794
+ knotsU: f,
795
+ knotsV: [...i],
796
+ controlPoints: y,
797
+ weights: d
798
+ };
799
+ }
800
+ }
801
+ function je(t, n) {
802
+ if (n <= t.degree) return { ...t };
803
+ const e = n - t.degree;
804
+ let r = t;
805
+ for (let s = 0; s < e; s++)
806
+ r = xn(r);
807
+ return r;
808
+ }
809
+ function xn(t) {
810
+ const { degree: n, knots: e, controlPoints: r, weights: s } = t, o = r.length - 1, i = r[0].length, l = n + 1, u = r.map((d, m) => {
811
+ const w = s[m];
812
+ return [...d.map((x) => x * w), w];
813
+ }), a = [];
814
+ let g = 0;
815
+ for (; g < e.length; ) {
816
+ const d = e[g];
817
+ let m = 0;
818
+ for (; g < e.length && Math.abs(e[g] - d) < 1e-14; )
819
+ m++, g++;
820
+ a.push({ value: d, mult: m });
821
+ }
822
+ const f = [];
823
+ for (const d of a)
824
+ for (let m = 0; m < d.mult + 1; m++)
825
+ f.push(d.value);
826
+ const c = f.length - l - 2, h = new Array(c + 1);
827
+ for (let d = 0; d <= c; d++) {
828
+ const m = d <= 0 ? 0 : d > o ? 1 : d / l, w = Math.max(0, Math.min(o, d - 1)), x = Math.max(0, Math.min(o, d));
829
+ h[d] = new Array(i + 1);
830
+ for (let _ = 0; _ <= i; _++)
831
+ h[d][_] = m * u[w][_] + (1 - m) * u[x][_];
832
+ }
833
+ const p = h.map((d) => {
834
+ const m = d[i];
835
+ return d.slice(0, i).map((w) => m !== 0 ? w / m : w);
836
+ }), y = h.map((d) => d[i]);
837
+ return {
838
+ degree: l,
839
+ knots: f,
840
+ controlPoints: p,
841
+ weights: y
842
+ };
843
+ }
844
+ function Re(t) {
845
+ if (t.length === 0) return [];
846
+ if (t.length === 1) return [{ ...t[0] }];
847
+ const n = Math.max(...t.map((s) => s.degree));
848
+ let e = t.map(
849
+ (s) => s.degree < n ? je(s, n) : { ...s }
850
+ );
851
+ const r = /* @__PURE__ */ new Set();
852
+ for (const s of e)
853
+ for (let o = n + 1; o < s.knots.length - n - 1; o++)
854
+ r.add(s.knots[o]);
855
+ return e = e.map((s) => {
856
+ const o = [];
857
+ for (const i of r)
858
+ s.knots.some((u) => Math.abs(u - i) < 1e-14) || o.push(i);
859
+ return o.length > 0 ? Lt(s, o) : s;
860
+ }), e;
861
+ }
862
+ function Te(t, n) {
863
+ const e = t.length - 1, r = t[0].length, s = Math.min(n, e), o = new Array(e + 1);
864
+ o[0] = 0;
865
+ const i = new Array(e);
866
+ let l = 0;
867
+ for (let c = 1; c <= e; c++) {
868
+ let h = 0;
869
+ for (let p = 0; p < r; p++)
870
+ h += (t[c][p] - t[c - 1][p]) ** 2;
871
+ i[c - 1] = Math.sqrt(h), l += i[c - 1];
872
+ }
873
+ l === 0 && (l = 1);
874
+ for (let c = 1; c <= e; c++)
875
+ o[c] = o[c - 1] + i[c - 1] / l;
876
+ o[e] = 1;
877
+ const u = e + s + 1, a = new Array(u + 1);
878
+ for (let c = 0; c <= s; c++) a[c] = 0;
879
+ for (let c = u - s; c <= u; c++) a[c] = 1;
880
+ for (let c = 1; c <= e - s; c++) {
881
+ let h = 0;
882
+ for (let p = c; p <= c + s - 1; p++)
883
+ h += o[p];
884
+ a[c + s] = h / s;
885
+ }
886
+ const g = Array.from({ length: e + 1 }, () => new Array(e + 1).fill(0));
887
+ for (let c = 0; c <= e; c++) {
888
+ const h = ft(e, s, o[c], a), p = Ct(h, o[c], s, a);
889
+ for (let y = 0; y <= s; y++)
890
+ g[c][h - s + y] = p[y];
891
+ }
892
+ const f = new Array(e + 1);
893
+ for (let c = 0; c <= e; c++) f[c] = new Array(r);
894
+ for (let c = 0; c < r; c++) {
895
+ const h = t.map((y) => y[c]), p = bn(g, h);
896
+ for (let y = 0; y <= e; y++)
897
+ f[y][c] = p[y];
898
+ }
899
+ return {
900
+ degree: s,
901
+ knots: a,
902
+ controlPoints: f,
903
+ weights: new Array(e + 1).fill(1)
904
+ };
905
+ }
906
+ function _n(t, n) {
907
+ if (t.length < 2) throw new Error("Lofting requires at least 2 curves");
908
+ const e = Re(t), r = e[0].degree, s = e[0].knots, o = e[0].controlPoints.length, i = e.length, l = Math.min(n, i - 1), u = [];
909
+ for (let p = 0; p < o; p++) {
910
+ const y = [];
911
+ for (let d = 0; d < i; d++)
912
+ y.push(e[d].controlPoints[p]);
913
+ u.push(y);
914
+ }
915
+ const a = u.map(
916
+ (p) => Te(p, l)
917
+ ), g = a[0].knots, f = a[0].controlPoints.length, c = [], h = [];
918
+ for (let p = 0; p < o; p++) {
919
+ c[p] = [], h[p] = [];
920
+ for (let y = 0; y < f; y++)
921
+ c[p][y] = a[p].controlPoints[y], h[p][y] = 1;
922
+ }
923
+ return {
924
+ degreeU: r,
925
+ degreeV: l,
926
+ knotsU: s,
927
+ knotsV: g,
928
+ controlPoints: c,
929
+ weights: h
930
+ };
931
+ }
932
+ function bn(t, n) {
933
+ const e = n.length, r = t.map((o, i) => [...o, n[i]]);
934
+ for (let o = 0; o < e; o++) {
935
+ let i = o, l = Math.abs(r[o][o]);
936
+ for (let a = o + 1; a < e; a++)
937
+ Math.abs(r[a][o]) > l && (l = Math.abs(r[a][o]), i = a);
938
+ i !== o && ([r[o], r[i]] = [r[i], r[o]]);
939
+ const u = r[o][o];
940
+ if (!(Math.abs(u) < 1e-14))
941
+ for (let a = o + 1; a < e; a++) {
942
+ const g = r[a][o] / u;
943
+ for (let f = o; f <= e; f++)
944
+ r[a][f] -= g * r[o][f];
945
+ }
946
+ }
947
+ const s = new Array(e).fill(0);
948
+ for (let o = e - 1; o >= 0; o--) {
949
+ let i = r[o][e];
950
+ for (let l = o + 1; l < e; l++)
951
+ i -= r[o][l] * s[l];
952
+ s[o] = Math.abs(r[o][o]) > 1e-14 ? i / r[o][o] : 0;
953
+ }
954
+ return s;
629
955
  }
630
- process.env.NODE_ENV === "production" ? ge.exports = Tr() : ge.exports = wr();
631
- var K = ge.exports;
632
- const jr = ({
633
- points: T,
634
- degree: x = 3,
635
- weights: y,
636
- knots: c,
637
- curveResolution: k = 50,
638
- color: F = "black",
639
- segments: _,
640
- dashed: g = !1,
641
- vertexColors: f,
642
- ...E
956
+ let B = class dt {
957
+ constructor(n) {
958
+ ct(this, "_degree");
959
+ ct(this, "_knots");
960
+ ct(this, "_controlPoints");
961
+ ct(this, "_weights");
962
+ this._degree = n.degree, this._knots = n.knots, this._controlPoints = n.controlPoints, this._weights = n.weights;
963
+ }
964
+ // --- Construction ---
965
+ static byKnotsControlPointsWeights(n, e, r, s) {
966
+ return new dt({ degree: n, knots: e, controlPoints: r, weights: s });
967
+ }
968
+ static byPoints(n, e) {
969
+ const r = Te(n, e);
970
+ return new dt(r);
971
+ }
972
+ // --- Evaluation ---
973
+ /**
974
+ * Evaluate curve point at parameter t (Algorithm A4.1).
975
+ * Rational curve: C(t) = Σ R_i(t) * P_i where R_i = N_i*w_i / Σ N_j*w_j
976
+ */
977
+ point(n) {
978
+ const e = this._controlPoints.length - 1, r = ft(e, this._degree, n, this._knots), s = Ct(r, n, this._degree, this._knots), o = this._controlPoints[0].length, i = new Array(o).fill(0);
979
+ let l = 0;
980
+ for (let u = 0; u <= this._degree; u++) {
981
+ const a = r - this._degree + u, g = this._weights[a], f = s[u] * g;
982
+ l += f;
983
+ for (let c = 0; c < o; c++)
984
+ i[c] += f * this._controlPoints[a][c];
985
+ }
986
+ if (l !== 0)
987
+ for (let u = 0; u < o; u++)
988
+ i[u] /= l;
989
+ return i;
990
+ }
991
+ /**
992
+ * Compute derivatives of the rational curve at parameter t.
993
+ * Uses Algorithm A4.2 + Eq. 4.20 from The NURBS Book.
994
+ *
995
+ * Returns: derivatives[k] = kth derivative vector
996
+ */
997
+ derivatives(n, e) {
998
+ const r = this._controlPoints.length - 1, s = this._controlPoints[0].length, o = Math.min(e, this._degree), i = ft(r, this._degree, n, this._knots), l = ne(i, n, this._degree, o, this._knots), u = [], a = [];
999
+ for (let f = 0; f <= o; f++) {
1000
+ const c = new Array(s).fill(0);
1001
+ let h = 0;
1002
+ for (let p = 0; p <= this._degree; p++) {
1003
+ const y = i - this._degree + p, d = this._weights[y];
1004
+ for (let m = 0; m < s; m++)
1005
+ c[m] += l[f][p] * d * this._controlPoints[y][m];
1006
+ h += l[f][p] * d;
1007
+ }
1008
+ u.push(c), a.push(h);
1009
+ }
1010
+ const g = [];
1011
+ for (let f = 0; f <= o; f++) {
1012
+ const c = [...u[f]];
1013
+ for (let h = 1; h <= f; h++) {
1014
+ const p = Pn(f, h);
1015
+ for (let y = 0; y < s; y++)
1016
+ c[y] -= p * a[h] * g[f - h][y];
1017
+ }
1018
+ for (let h = 0; h < s; h++)
1019
+ c[h] /= a[0];
1020
+ g.push(c);
1021
+ }
1022
+ for (let f = o + 1; f <= e; f++)
1023
+ g.push(new Array(s).fill(0));
1024
+ return g;
1025
+ }
1026
+ /**
1027
+ * Compute tangent vector (first derivative, NOT normalized) at parameter t.
1028
+ */
1029
+ tangent(n) {
1030
+ return this.derivatives(n, 1)[1];
1031
+ }
1032
+ /**
1033
+ * Compute arc length using Gauss-Legendre quadrature.
1034
+ */
1035
+ length() {
1036
+ return this.lengthBetween(this._knots[this._degree], this._knots[this._knots.length - this._degree - 1]);
1037
+ }
1038
+ lengthBetween(n, e) {
1039
+ const r = [-0.9061798459, -0.5384693101, 0, 0.5384693101, 0.9061798459], s = [0.2369268851, 0.4786286705, 0.5688888889, 0.4786286705, 0.2369268851], o = Math.max(this._controlPoints.length * 2, 8);
1040
+ let i = 0;
1041
+ for (let l = 0; l < o; l++) {
1042
+ const u = n + (e - n) * l / o, a = n + (e - n) * (l + 1) / o, g = (a - u) / 2, f = (u + a) / 2;
1043
+ let c = 0;
1044
+ for (let h = 0; h < r.length; h++) {
1045
+ const p = f + g * r[h], y = this.tangent(p), d = Math.sqrt(y.reduce((m, w) => m + w * w, 0));
1046
+ c += s[h] * d;
1047
+ }
1048
+ i += g * c;
1049
+ }
1050
+ return i;
1051
+ }
1052
+ /**
1053
+ * Find the parameter of the closest point on the curve to a given point.
1054
+ * Implements Algorithm A6.1 from "The NURBS Book" (Piegl & Tiller), Section 6.1.
1055
+ *
1056
+ * Phase 1: Initial guess via control polygon (Greville abscissa of closest control point)
1057
+ * + refinement by sampling within the support of that basis function.
1058
+ * Phase 2: Newton iteration with four convergence criteria:
1059
+ * (1) Point coincidence: ||C(t) - P|| < eps1
1060
+ * (2) Zero cosine: |C'(t) · (C(t) - P)| / (|C'(t)| · |C(t) - P|) < eps2
1061
+ * (3) Parameter correction: |Δt| · |C'(t)| < eps1
1062
+ * (4) Domain bounds
1063
+ */
1064
+ closestParam(n) {
1065
+ const e = n.length, r = 1e-8, s = 1e-6, o = this._knots[this._degree], i = this._knots[this._knots.length - this._degree - 1], l = this._controlPoints.length - 1;
1066
+ let u = o, a = 1 / 0;
1067
+ for (let m = 0; m <= l; m++) {
1068
+ let w = 0;
1069
+ for (let x = 0; x < e; x++)
1070
+ w += (this._controlPoints[m][x] - n[x]) ** 2;
1071
+ if (w < a) {
1072
+ a = w;
1073
+ let x = 0;
1074
+ for (let _ = 1; _ <= this._degree; _++)
1075
+ x += this._knots[m + _];
1076
+ x /= this._degree, u = Math.max(o, Math.min(i, x));
1077
+ }
1078
+ }
1079
+ const g = 0.2 * (i - o), f = Math.max(o, u - g), c = Math.min(i, u + g), h = 20;
1080
+ for (let m = 0; m <= h; m++) {
1081
+ const w = f + (c - f) * m / h, x = this.point(w);
1082
+ let _ = 0;
1083
+ for (let b = 0; b < e; b++) _ += (x[b] - n[b]) ** 2;
1084
+ _ < a && (a = _, u = w);
1085
+ }
1086
+ const p = Math.max(l * 4, 20);
1087
+ for (let m = 0; m <= p; m++) {
1088
+ const w = o + (i - o) * m / p, x = this.point(w);
1089
+ let _ = 0;
1090
+ for (let b = 0; b < e; b++) _ += (x[b] - n[b]) ** 2;
1091
+ _ < a && (a = _, u = w);
1092
+ }
1093
+ let y = u;
1094
+ const d = Math.min(2, this._degree);
1095
+ for (let m = 0; m < 50; m++) {
1096
+ const w = this.derivatives(y, d), x = w[0], _ = w[1], b = x.map((D, R) => D - n[R]);
1097
+ let P = 0;
1098
+ for (let D = 0; D < e; D++) P += b[D] ** 2;
1099
+ if (Math.sqrt(P) < r) break;
1100
+ let M = 0, S = 0;
1101
+ for (let D = 0; D < e; D++)
1102
+ M += _[D] * b[D], S += _[D] ** 2;
1103
+ S = Math.sqrt(S);
1104
+ const U = Math.sqrt(P);
1105
+ if (S > 0 && U > 0 && Math.abs(M) / (S * U) < s)
1106
+ break;
1107
+ let j = M, k = S * S;
1108
+ if (d >= 2) {
1109
+ const D = w[2];
1110
+ for (let R = 0; R < e; R++)
1111
+ k += D[R] * b[R];
1112
+ }
1113
+ if (Math.abs(k) < 1e-14) break;
1114
+ const E = -j / k;
1115
+ if (Math.abs(E) * S < r) break;
1116
+ const T = Math.max(o, Math.min(i, y + E));
1117
+ if (Math.abs(T - y) < 1e-14) break;
1118
+ y = T;
1119
+ }
1120
+ return y;
1121
+ }
1122
+ closestPoint(n) {
1123
+ return this.point(this.closestParam(n));
1124
+ }
1125
+ /**
1126
+ * Split curve at parameter t by inserting knot until multiplicity = degree.
1127
+ * Returns two NurbsCurve objects.
1128
+ */
1129
+ split(n) {
1130
+ let e = 0;
1131
+ for (const i of this._knots)
1132
+ Math.abs(i - n) < 1e-10 && e++;
1133
+ const r = this._degree - e;
1134
+ if (r <= 0)
1135
+ return this._splitAtFullMult(n);
1136
+ let s = this.asData();
1137
+ for (let i = 0; i < r; i++)
1138
+ s = Ee(s, n, 1);
1139
+ return new dt(s)._splitAtFullMult(n);
1140
+ }
1141
+ _splitAtFullMult(n) {
1142
+ let e = -1;
1143
+ for (let g = 0; g < this._knots.length; g++)
1144
+ if (Math.abs(this._knots[g] - n) < 1e-10) {
1145
+ e = g;
1146
+ break;
1147
+ }
1148
+ if (e === -1) return [this.clone()];
1149
+ const r = this._degree, s = this._knots.slice(0, e + 1);
1150
+ for (let g = 0; g < r + 1; g++) s.push(n);
1151
+ const o = this._controlPoints.slice(0, e - r + 1), i = this._weights.slice(0, e - r + 1), l = [];
1152
+ for (let g = 0; g < r + 1; g++) l.push(n);
1153
+ l.push(...this._knots.slice(e + 1));
1154
+ const u = this._controlPoints.slice(e - r), a = this._weights.slice(e - r);
1155
+ return [
1156
+ new dt({ degree: r, knots: s, controlPoints: o, weights: i }),
1157
+ new dt({ degree: r, knots: l, controlPoints: u, weights: a })
1158
+ ];
1159
+ }
1160
+ reverse() {
1161
+ const n = this._knots[this._knots.length - 1], e = this._knots[0];
1162
+ return new dt({
1163
+ degree: this._degree,
1164
+ knots: this._knots.map((r) => n + e - r).reverse(),
1165
+ controlPoints: [...this._controlPoints].reverse(),
1166
+ weights: [...this._weights].reverse()
1167
+ });
1168
+ }
1169
+ clone() {
1170
+ return new dt({
1171
+ degree: this._degree,
1172
+ knots: [...this._knots],
1173
+ controlPoints: this._controlPoints.map((n) => [...n]),
1174
+ weights: [...this._weights]
1175
+ });
1176
+ }
1177
+ // --- Accessors ---
1178
+ degree() {
1179
+ return this._degree;
1180
+ }
1181
+ knots() {
1182
+ return this._knots;
1183
+ }
1184
+ controlPoints() {
1185
+ return this._controlPoints;
1186
+ }
1187
+ weights() {
1188
+ return this._weights;
1189
+ }
1190
+ asData() {
1191
+ return {
1192
+ degree: this._degree,
1193
+ knots: [...this._knots],
1194
+ controlPoints: this._controlPoints.map((n) => [...n]),
1195
+ weights: [...this._weights]
1196
+ };
1197
+ }
1198
+ };
1199
+ function Pn(t, n) {
1200
+ if (n < 0 || n > t) return 0;
1201
+ if (n === 0 || n === t) return 1;
1202
+ let e = 1;
1203
+ for (let r = 0; r < n; r++)
1204
+ e = e * (t - r) / (r + 1);
1205
+ return Math.round(e);
1206
+ }
1207
+ let ut = class Wt {
1208
+ // [u][v]
1209
+ constructor(n) {
1210
+ ct(this, "_degreeU");
1211
+ ct(this, "_degreeV");
1212
+ ct(this, "_knotsU");
1213
+ ct(this, "_knotsV");
1214
+ ct(this, "_controlPoints");
1215
+ // [u][v][xyz]
1216
+ ct(this, "_weights");
1217
+ this._degreeU = n.degreeU, this._degreeV = n.degreeV, this._knotsU = n.knotsU, this._knotsV = n.knotsV, this._controlPoints = n.controlPoints, this._weights = n.weights;
1218
+ }
1219
+ // --- Construction ---
1220
+ static byKnotsControlPointsWeights(n, e, r, s, o, i) {
1221
+ return new Wt({ degreeU: n, degreeV: e, knotsU: r, knotsV: s, controlPoints: o, weights: i });
1222
+ }
1223
+ static byLoftingCurves(n, e) {
1224
+ return new Wt(_n(n.map((r) => r.asData()), e));
1225
+ }
1226
+ static byCorners(n, e, r, s) {
1227
+ return new Wt({
1228
+ degreeU: 1,
1229
+ degreeV: 1,
1230
+ knotsU: [0, 0, 1, 1],
1231
+ knotsV: [0, 0, 1, 1],
1232
+ controlPoints: [[n, s], [e, r]],
1233
+ weights: [[1, 1], [1, 1]]
1234
+ });
1235
+ }
1236
+ // --- Evaluation ---
1237
+ /**
1238
+ * Evaluate surface point at (u, v) — Algorithm A4.3 (rational tensor product).
1239
+ */
1240
+ point(n, e) {
1241
+ const r = this._controlPoints.length - 1, s = this._controlPoints[0].length - 1, o = this._controlPoints[0][0].length, i = ft(r, this._degreeU, n, this._knotsU), l = ft(s, this._degreeV, e, this._knotsV), u = Ct(i, n, this._degreeU, this._knotsU), a = Ct(l, e, this._degreeV, this._knotsV), g = new Array(o).fill(0);
1242
+ let f = 0;
1243
+ for (let c = 0; c <= this._degreeU; c++) {
1244
+ const h = i - this._degreeU + c;
1245
+ for (let p = 0; p <= this._degreeV; p++) {
1246
+ const y = l - this._degreeV + p, d = this._weights[h][y], m = u[c] * a[p] * d;
1247
+ f += m;
1248
+ for (let w = 0; w < o; w++)
1249
+ g[w] += m * this._controlPoints[h][y][w];
1250
+ }
1251
+ }
1252
+ if (f !== 0)
1253
+ for (let c = 0; c < o; c++)
1254
+ g[c] /= f;
1255
+ return g;
1256
+ }
1257
+ /**
1258
+ * Compute surface normal at (u, v) as cross product of partial derivatives.
1259
+ */
1260
+ normal(n, e) {
1261
+ const r = this.derivatives(n, e, 1), s = r[1][0], o = r[0][1];
1262
+ return [
1263
+ s[1] * o[2] - s[2] * o[1],
1264
+ s[2] * o[0] - s[0] * o[2],
1265
+ s[0] * o[1] - s[1] * o[0]
1266
+ ];
1267
+ }
1268
+ /**
1269
+ * Compute partial derivatives of the rational surface at (u, v).
1270
+ * Returns ders[k][l] = mixed partial derivative ∂^(k+l)S / ∂u^k ∂v^l.
1271
+ * Algorithm A4.4 adapted for rational surfaces (Eq. 4.20 generalized).
1272
+ */
1273
+ derivatives(n, e, r) {
1274
+ const s = this._controlPoints.length - 1, o = this._controlPoints[0].length - 1, i = this._controlPoints[0][0].length, l = Math.min(r, this._degreeU), u = Math.min(r, this._degreeV), a = ft(s, this._degreeU, n, this._knotsU), g = ft(o, this._degreeV, e, this._knotsV), f = ne(a, n, this._degreeU, l, this._knotsU), c = ne(g, e, this._degreeV, u, this._knotsV), h = [], p = [];
1275
+ for (let d = 0; d <= l; d++) {
1276
+ h[d] = [], p[d] = [];
1277
+ for (let m = 0; m <= u; m++) {
1278
+ const w = new Array(i).fill(0);
1279
+ let x = 0;
1280
+ for (let _ = 0; _ <= this._degreeU; _++) {
1281
+ const b = a - this._degreeU + _;
1282
+ for (let P = 0; P <= this._degreeV; P++) {
1283
+ const M = g - this._degreeV + P, S = this._weights[b][M], U = f[d][_] * c[m][P] * S;
1284
+ for (let j = 0; j < i; j++)
1285
+ w[j] += U * this._controlPoints[b][M][j];
1286
+ x += U;
1287
+ }
1288
+ }
1289
+ h[d][m] = w, p[d][m] = x;
1290
+ }
1291
+ }
1292
+ const y = [];
1293
+ for (let d = 0; d <= r; d++) {
1294
+ y[d] = [];
1295
+ for (let m = 0; m <= r; m++) {
1296
+ if (d > l || m > u) {
1297
+ y[d][m] = new Array(i).fill(0);
1298
+ continue;
1299
+ }
1300
+ const w = [...h[d][m]];
1301
+ for (let x = 1; x <= m; x++) {
1302
+ const _ = ke(m, x);
1303
+ for (let b = 0; b < i; b++)
1304
+ w[b] -= _ * p[0][x] * y[d][m - x][b];
1305
+ }
1306
+ for (let x = 1; x <= d; x++) {
1307
+ const _ = ke(d, x);
1308
+ for (let b = 0; b < i; b++)
1309
+ w[b] -= _ * p[x][0] * y[d - x][m][b];
1310
+ }
1311
+ for (let x = 0; x < i; x++)
1312
+ w[x] /= p[0][0];
1313
+ y[d][m] = w;
1314
+ }
1315
+ }
1316
+ return y;
1317
+ }
1318
+ /**
1319
+ * Find closest UV parameters to a 3D point.
1320
+ * Implements the surface point projection from "The NURBS Book" Section 6.1.
1321
+ *
1322
+ * Phase 1: Initial guess via closest control point (Greville abscissa)
1323
+ * + grid refinement near the best candidate.
1324
+ * Phase 2: Newton iteration with four convergence criteria:
1325
+ * (1) Point coincidence: ||S(u,v) - P|| < eps1
1326
+ * (2) Zero cosine (U): |S_u · (S - P)| / (|S_u| · |S - P|) < eps2
1327
+ * (2) Zero cosine (V): |S_v · (S - P)| / (|S_v| · |S - P|) < eps2
1328
+ * (3) Parameter correction: |Δu·S_u + Δv·S_v| < eps1
1329
+ * (4) Domain bounds
1330
+ */
1331
+ closestParam(n) {
1332
+ const e = n.length, r = this._controlPoints.length - 1, s = this._controlPoints[0].length - 1, o = this._knotsU[this._degreeU], i = this._knotsU[r + 1], l = this._knotsV[this._degreeV], u = this._knotsV[s + 1], a = 1e-8, g = 1e-6;
1333
+ let f = (o + i) / 2, c = (l + u) / 2, h = 1 / 0;
1334
+ for (let m = 0; m <= r; m++) {
1335
+ let w = 0;
1336
+ for (let x = 1; x <= this._degreeU; x++) w += this._knotsU[m + x];
1337
+ w /= this._degreeU;
1338
+ for (let x = 0; x <= s; x++) {
1339
+ let _ = 0;
1340
+ for (let b = 0; b < e; b++)
1341
+ _ += (this._controlPoints[m][x][b] - n[b]) ** 2;
1342
+ if (_ < h) {
1343
+ h = _, f = Math.max(o, Math.min(i, w));
1344
+ let b = 0;
1345
+ for (let P = 1; P <= this._degreeV; P++) b += this._knotsV[x + P];
1346
+ b /= this._degreeV, c = Math.max(l, Math.min(u, b));
1347
+ }
1348
+ }
1349
+ }
1350
+ const p = 20;
1351
+ for (let m = 0; m <= p; m++)
1352
+ for (let w = 0; w <= p; w++) {
1353
+ const x = o + (i - o) * m / p, _ = l + (u - l) * w / p, b = this.point(x, _);
1354
+ let P = 0;
1355
+ for (let M = 0; M < e; M++) P += (b[M] - n[M]) ** 2;
1356
+ P < h && (h = P, f = x, c = _);
1357
+ }
1358
+ let y = f, d = c;
1359
+ for (let m = 0; m < 50; m++) {
1360
+ const w = this.derivatives(y, d, 1), x = w[0][0], _ = w[1][0], b = w[0][1], P = x.map((N, _t) => N - n[_t]);
1361
+ let M = 0;
1362
+ for (let N = 0; N < e; N++) M += P[N] ** 2;
1363
+ const S = Math.sqrt(M);
1364
+ if (S < a) break;
1365
+ let U = 0, j = 0, k = 0, E = 0;
1366
+ for (let N = 0; N < e; N++)
1367
+ U += _[N] * P[N], j += b[N] * P[N], k += _[N] ** 2, E += b[N] ** 2;
1368
+ k = Math.sqrt(k), E = Math.sqrt(E);
1369
+ const T = k > 0 && S > 0 ? Math.abs(U) / (k * S) : 0, D = E > 0 && S > 0 ? Math.abs(j) / (E * S) : 0;
1370
+ if (T < g && D < g) break;
1371
+ let R = 0, W = 0, G = 0;
1372
+ for (let N = 0; N < e; N++)
1373
+ R += _[N] * _[N], W += _[N] * b[N], G += b[N] * b[N];
1374
+ const Q = R * G - W * W;
1375
+ if (Math.abs(Q) < 1e-14) break;
1376
+ const X = -(G * U - W * j) / Q, nt = -(R * j - W * U) / Q;
1377
+ let lt = 0;
1378
+ for (let N = 0; N < e; N++) {
1379
+ const _t = X * _[N] + nt * b[N];
1380
+ lt += _t * _t;
1381
+ }
1382
+ if (Math.sqrt(lt) < a) break;
1383
+ const At = Math.max(o, Math.min(i, y + X)), St = Math.max(l, Math.min(u, d + nt));
1384
+ if (Math.abs(At - y) + Math.abs(St - d) < 1e-14) break;
1385
+ y = At, d = St;
1386
+ }
1387
+ return [y, d];
1388
+ }
1389
+ /**
1390
+ * Extract an iso-parametric curve from the surface.
1391
+ * If useV=false: fix u=param, extract curve in V direction.
1392
+ * If useV=true: fix v=param, extract curve in U direction.
1393
+ */
1394
+ /**
1395
+ * Extract an iso-parametric curve from the surface.
1396
+ * If useV=true: fix v=param, extract curve in U direction.
1397
+ * If useV=false: fix u=param, extract curve in V direction.
1398
+ *
1399
+ * Works in homogeneous coordinates: for each row/column, blend the
1400
+ * homogeneous control points (w*P, w) using basis functions, then
1401
+ * store the result as the new curve's control points and weights.
1402
+ */
1403
+ isocurve(n, e) {
1404
+ if (e) {
1405
+ const r = this._controlPoints.length - 1, s = this._controlPoints[0].length - 1, o = this._controlPoints[0][0].length, i = ft(s, this._degreeV, n, this._knotsV), l = Ct(i, n, this._degreeV, this._knotsV), u = [], a = [];
1406
+ for (let g = 0; g <= r; g++) {
1407
+ const f = new Array(o).fill(0);
1408
+ let c = 0;
1409
+ for (let h = 0; h <= this._degreeV; h++) {
1410
+ const p = i - this._degreeV + h, y = this._weights[g][p];
1411
+ for (let d = 0; d < o; d++)
1412
+ f[d] += l[h] * y * this._controlPoints[g][p][d];
1413
+ c += l[h] * y;
1414
+ }
1415
+ u.push(c !== 0 ? f.map((h) => h / c) : f), a.push(c);
1416
+ }
1417
+ return B.byKnotsControlPointsWeights(this._degreeU, [...this._knotsU], u, a);
1418
+ } else {
1419
+ const r = this._controlPoints.length - 1, s = this._controlPoints[0].length - 1, o = this._controlPoints[0][0].length, i = ft(r, this._degreeU, n, this._knotsU), l = Ct(i, n, this._degreeU, this._knotsU), u = [], a = [];
1420
+ for (let g = 0; g <= s; g++) {
1421
+ const f = new Array(o).fill(0);
1422
+ let c = 0;
1423
+ for (let h = 0; h <= this._degreeU; h++) {
1424
+ const p = i - this._degreeU + h, y = this._weights[p][g];
1425
+ for (let d = 0; d < o; d++)
1426
+ f[d] += l[h] * y * this._controlPoints[p][g][d];
1427
+ c += l[h] * y;
1428
+ }
1429
+ u.push(c !== 0 ? f.map((h) => h / c) : f), a.push(c);
1430
+ }
1431
+ return B.byKnotsControlPointsWeights(this._degreeV, [...this._knotsV], u, a);
1432
+ }
1433
+ }
1434
+ // --- Accessors ---
1435
+ degreeU() {
1436
+ return this._degreeU;
1437
+ }
1438
+ degreeV() {
1439
+ return this._degreeV;
1440
+ }
1441
+ knotsU() {
1442
+ return this._knotsU;
1443
+ }
1444
+ knotsV() {
1445
+ return this._knotsV;
1446
+ }
1447
+ controlPoints() {
1448
+ return this._controlPoints;
1449
+ }
1450
+ weights() {
1451
+ return this._weights;
1452
+ }
1453
+ asData() {
1454
+ return {
1455
+ degreeU: this._degreeU,
1456
+ degreeV: this._degreeV,
1457
+ knotsU: [...this._knotsU],
1458
+ knotsV: [...this._knotsV],
1459
+ controlPoints: this._controlPoints.map((n) => n.map((e) => [...e])),
1460
+ weights: this._weights.map((n) => [...n])
1461
+ };
1462
+ }
1463
+ };
1464
+ function ke(t, n) {
1465
+ if (n < 0 || n > t) return 0;
1466
+ if (n === 0 || n === t) return 1;
1467
+ let e = 1;
1468
+ for (let r = 0; r < n; r++)
1469
+ e = e * (t - r) / (r + 1);
1470
+ return Math.round(e);
1471
+ }
1472
+ function at(t, n) {
1473
+ return t.map((e, r) => e + n[r]);
1474
+ }
1475
+ function qt(t, n) {
1476
+ return t.map((e, r) => e - n[r]);
1477
+ }
1478
+ function st(t, n) {
1479
+ return t.map((e) => e * n);
1480
+ }
1481
+ function ce(t, n) {
1482
+ return t.reduce((e, r, s) => e + r * n[s], 0);
1483
+ }
1484
+ function Cn(t, n) {
1485
+ return [
1486
+ t[1] * n[2] - t[2] * n[1],
1487
+ t[2] * n[0] - t[0] * n[2],
1488
+ t[0] * n[1] - t[1] * n[0]
1489
+ ];
1490
+ }
1491
+ function re(t) {
1492
+ const n = Math.sqrt(ce(t, t));
1493
+ return n > 0 ? st(t, 1 / n) : t;
1494
+ }
1495
+ function kn(t) {
1496
+ return Math.sqrt(ce(t, t));
1497
+ }
1498
+ function zt(t, n, e, r, s, o) {
1499
+ const i = re(n), l = re(e);
1500
+ let u = o - s;
1501
+ u < 0 && (u += 2 * Math.PI);
1502
+ let a;
1503
+ u <= Math.PI / 2 ? a = 1 : u <= Math.PI ? a = 2 : u <= 3 * Math.PI / 2 ? a = 3 : a = 4;
1504
+ const g = u / a, f = Math.cos(g / 2);
1505
+ let c = at(t, at(st(i, r * Math.cos(s)), st(l, r * Math.sin(s)))), h = at(st(i, -Math.sin(s)), st(l, Math.cos(s)));
1506
+ const p = [c], y = [1];
1507
+ let d = s;
1508
+ for (let w = 0; w < a; w++) {
1509
+ d += g;
1510
+ const x = at(t, at(st(i, r * Math.cos(d)), st(l, r * Math.sin(d)))), _ = at(st(i, -Math.sin(d)), st(l, Math.cos(d))), b = qt(x, c), P = h[0] * _[1] - h[1] * _[0];
1511
+ let M;
1512
+ if (Math.abs(P) > 1e-14)
1513
+ M = (b[0] * _[1] - b[1] * _[0]) / P;
1514
+ else {
1515
+ const U = h[0] * _[2] - h[2] * _[0];
1516
+ Math.abs(U) > 1e-14 ? M = (b[0] * _[2] - b[2] * _[0]) / U : M = (b[1] * _[2] - b[2] * _[1]) / (h[1] * _[2] - h[2] * _[1]);
1517
+ }
1518
+ const S = at(c, st(h, M));
1519
+ p.push(S, x), y.push(f, 1), c = x, h = _;
1520
+ }
1521
+ const m = [];
1522
+ m.push(0, 0, 0);
1523
+ for (let w = 1; w < a; w++) {
1524
+ const x = w / a;
1525
+ m.push(x, x);
1526
+ }
1527
+ return m.push(1, 1, 1), { degree: 2, knots: m, controlPoints: p, weights: y };
1528
+ }
1529
+ function Mn(t, n, e, r) {
1530
+ return zt(t, n, e, r, 0, 2 * Math.PI);
1531
+ }
1532
+ function An(t, n) {
1533
+ const e = t.controlPoints, r = e.map((s) => at(s, n));
1534
+ return {
1535
+ degreeU: t.degree,
1536
+ degreeV: 1,
1537
+ knotsU: [...t.knots],
1538
+ knotsV: [0, 0, 1, 1],
1539
+ controlPoints: e.map((s, o) => [s, r[o]]),
1540
+ weights: t.weights.map((s) => [s, s])
1541
+ };
1542
+ }
1543
+ function Sn(t, n, e, r) {
1544
+ const s = re(e), o = zt(
1545
+ [0, 0, 0],
1546
+ [1, 0, 0],
1547
+ [0, 1, 0],
1548
+ 1,
1549
+ 0,
1550
+ r
1551
+ ), i = o.controlPoints.length, l = [], u = [];
1552
+ for (let f = 0; f < t.controlPoints.length; f++) {
1553
+ const c = t.controlPoints[f], h = t.weights[f], p = qt(c, n), y = ce(p, s), d = at(n, st(s, y)), m = qt(c, d), w = kn(m);
1554
+ if (w < 1e-14) {
1555
+ l[f] = [], u[f] = [];
1556
+ for (let P = 0; P < i; P++)
1557
+ l[f][P] = [...c], u[f][P] = h * o.weights[P];
1558
+ continue;
1559
+ }
1560
+ const x = st(m, 1 / w), _ = Cn(s, x), b = zt(d, x, _, w, 0, r);
1561
+ l[f] = [], u[f] = [];
1562
+ for (let P = 0; P < b.controlPoints.length; P++)
1563
+ l[f][P] = b.controlPoints[P], u[f][P] = h * b.weights[P];
1564
+ }
1565
+ const a = [], g = [];
1566
+ for (let f = 0; f < i; f++) {
1567
+ a[f] = [], g[f] = [];
1568
+ for (let c = 0; c < t.controlPoints.length; c++)
1569
+ a[f][c] = l[c][f], g[f][c] = u[c][f];
1570
+ }
1571
+ return {
1572
+ degreeU: 2,
1573
+ // arc degree
1574
+ degreeV: t.degree,
1575
+ knotsU: o.knots,
1576
+ knotsV: [...t.knots],
1577
+ controlPoints: a,
1578
+ weights: g
1579
+ };
1580
+ }
1581
+ function En(t, n) {
1582
+ const e = t.controlPoints.length, r = n.controlPoints.length, s = n.controlPoints[0], o = [], i = [];
1583
+ for (let l = 0; l < r; l++) {
1584
+ o[l] = [], i[l] = [];
1585
+ const u = qt(n.controlPoints[l], s);
1586
+ for (let a = 0; a < e; a++)
1587
+ o[l][a] = at(t.controlPoints[a], u), i[l][a] = n.weights[l] * t.weights[a];
1588
+ }
1589
+ return {
1590
+ degreeU: n.degree,
1591
+ degreeV: t.degree,
1592
+ knotsU: [...n.knots],
1593
+ knotsV: [...t.knots],
1594
+ controlPoints: o,
1595
+ weights: i
1596
+ };
1597
+ }
1598
+ function jn(t, n, e = 1e-3, r = 40) {
1599
+ const s = r, o = [], i = [];
1600
+ for (let a = 0; a <= s; a++) {
1601
+ o[a] = [], i[a] = [];
1602
+ for (let g = 0; g <= s; g++) {
1603
+ const f = a / s, c = g / s, h = t.point(f, c), p = n.closestParam(h), y = n.point(p[0], p[1]), d = t.normal(f, c), m = Math.sqrt(d[0] ** 2 + d[1] ** 2 + d[2] ** 2), w = [h[0] - y[0], h[1] - y[1], h[2] - y[2]];
1604
+ let _ = Math.sqrt(w[0] ** 2 + w[1] ** 2 + w[2] ** 2);
1605
+ m > 1e-14 && (_ = (w[0] * d[0] + w[1] * d[1] + w[2] * d[2]) / m), o[a][g] = _, i[a][g] = h;
1606
+ }
1607
+ }
1608
+ const l = [];
1609
+ for (let a = 0; a < s; a++)
1610
+ for (let g = 0; g < s; g++) {
1611
+ const f = [
1612
+ { d: o[a][g], pt: i[a][g] },
1613
+ { d: o[a + 1][g], pt: i[a + 1][g] },
1614
+ { d: o[a + 1][g + 1], pt: i[a + 1][g + 1] },
1615
+ { d: o[a][g + 1], pt: i[a][g + 1] }
1616
+ ];
1617
+ for (let c = 0; c < 4; c++) {
1618
+ const h = f[c], p = f[(c + 1) % 4];
1619
+ if (h.d >= 0 != p.d >= 0) {
1620
+ const y = h.d / (h.d - p.d);
1621
+ l.push([
1622
+ h.pt[0] + y * (p.pt[0] - h.pt[0]),
1623
+ h.pt[1] + y * (p.pt[1] - h.pt[1]),
1624
+ h.pt[2] + y * (p.pt[2] - h.pt[2])
1625
+ ]);
1626
+ }
1627
+ }
1628
+ }
1629
+ return l.length < 2 ? [] : Rn(l, e * 10).map((a) => ({ points: a }));
1630
+ }
1631
+ function Rn(t, n) {
1632
+ if (t.length === 0) return [];
1633
+ const e = /* @__PURE__ */ new Set(), r = [];
1634
+ for (; e.size < t.length; ) {
1635
+ let s = -1;
1636
+ for (let l = 0; l < t.length; l++)
1637
+ if (!e.has(l)) {
1638
+ s = l;
1639
+ break;
1640
+ }
1641
+ if (s === -1) break;
1642
+ const o = [t[s]];
1643
+ e.add(s);
1644
+ let i = !0;
1645
+ for (; i; ) {
1646
+ i = !1;
1647
+ const l = o[o.length - 1];
1648
+ let u = -1, a = n * n;
1649
+ for (let g = 0; g < t.length; g++) {
1650
+ if (e.has(g)) continue;
1651
+ const f = t[g][0] - l[0], c = t[g][1] - l[1], h = t[g][2] - l[2], p = f * f + c * c + h * h;
1652
+ p < a && (a = p, u = g);
1653
+ }
1654
+ u >= 0 && (o.push(t[u]), e.add(u), i = !0);
1655
+ }
1656
+ o.length >= 2 && r.push(o);
1657
+ }
1658
+ return r;
1659
+ }
1660
+ function H(t, n) {
1661
+ const e = t + n + 1;
1662
+ return Array(e).fill(0).map((r, s) => s < n + 1 ? 0 : s >= e - n - 1 ? 1 : (s - n) / (e - 2 * n - 1));
1663
+ }
1664
+ function Tn(t, n, e) {
1665
+ const r = t.point(n, e);
1666
+ return new I(r[0], r[1], r[2]);
1667
+ }
1668
+ function Dn(t, n, e) {
1669
+ try {
1670
+ const r = t.normal(n, e), s = new I(r[0], r[1], r[2]), o = s.length();
1671
+ return o > 0 ? s.divideScalar(o) : new I(0, 1, 0);
1672
+ } catch {
1673
+ const s = t.point(n, e), o = t.point(Math.min(n + 1e-4, 1), e), i = t.point(n, Math.min(e + 1e-4, 1)), l = new I().subVectors(new I(...o), new I(...s)), u = new I().subVectors(new I(...i), new I(...s)), a = new I().crossVectors(l, u).normalize();
1674
+ return a.length() > 0 ? a : new I(0, 1, 0);
1675
+ }
1676
+ }
1677
+ function ur(t, n = 100) {
1678
+ return Array.from({ length: n }, (e, r) => {
1679
+ const s = r / (n - 1), o = t.point(s);
1680
+ return [o[0], o[1]];
1681
+ });
1682
+ }
1683
+ function Un(t, n = 5, e = 10) {
1684
+ const r = (a) => [a[0], a[1]], s = (a, g, f) => {
1685
+ const c = [g[0] - a[0], g[1] - a[1]], h = [f[0] - g[0], f[1] - g[1]], p = c[0] * h[0] + c[1] * h[1], y = Math.sqrt(c[0] * c[0] + c[1] * c[1]), d = Math.sqrt(h[0] * h[0] + h[1] * h[1]);
1686
+ return y === 0 || d === 0 ? 0 : Math.acos(Math.max(-1, Math.min(1, p / (y * d)))) * (180 / Math.PI);
1687
+ };
1688
+ function o(a, g, f) {
1689
+ const c = r(t.point(a)), h = r(t.point((a + g) / 2)), p = r(t.point(g));
1690
+ if (s(c, h, p) > n && f < e) {
1691
+ const d = o(a, (a + g) / 2, f + 1), m = o((a + g) / 2, g, f + 1);
1692
+ return [...d.slice(0, -1), ...m];
1693
+ } else
1694
+ return [c, p];
1695
+ }
1696
+ const i = [], l = 10;
1697
+ let u = null;
1698
+ for (let a = 0; a < l; a++) {
1699
+ const g = o(a / l, (a + 1) / l, 0);
1700
+ for (const f of g)
1701
+ (!u || f[0] !== u[0] || f[1] !== u[1]) && (i.push(f), u = f);
1702
+ }
1703
+ return i;
1704
+ }
1705
+ function fr(t, n) {
1706
+ try {
1707
+ const e = t.closestParam(n);
1708
+ return [e[0], e[1]];
1709
+ } catch {
1710
+ return null;
1711
+ }
1712
+ }
1713
+ function Fn(t, n, e = 100) {
1714
+ const r = [], s = n.point(0), o = t.closestParam(s);
1715
+ r.push([o[0], o[1]]);
1716
+ for (let i = 1; i <= e; i++) {
1717
+ const l = i / e, u = n.point(l), a = r[r.length - 1], g = In(t, u, a[0], a[1]);
1718
+ r.push(g);
1719
+ }
1720
+ return r;
1721
+ }
1722
+ function In(t, n, e, r) {
1723
+ const s = n.length, o = 1e-8, i = 1e-6;
1724
+ let l = e, u = r;
1725
+ for (let a = 0; a < 20; a++) {
1726
+ const g = t.derivatives(l, u, 1), f = g[0][0], c = g[1][0], h = g[0][1], p = f.map((k, E) => k - n[E]);
1727
+ let y = 0;
1728
+ for (let k = 0; k < s; k++) y += p[k] ** 2;
1729
+ if (Math.sqrt(y) < o) break;
1730
+ let d = 0, m = 0, w = 0, x = 0;
1731
+ for (let k = 0; k < s; k++)
1732
+ d += c[k] * p[k], m += h[k] * p[k], w += c[k] ** 2, x += h[k] ** 2;
1733
+ w = Math.sqrt(w), x = Math.sqrt(x);
1734
+ const _ = Math.sqrt(y);
1735
+ if (w > 0 && x > 0 && _ > 0 && Math.abs(d) / (w * _) < i && Math.abs(m) / (x * _) < i)
1736
+ break;
1737
+ let b = 0, P = 0, M = 0;
1738
+ for (let k = 0; k < s; k++)
1739
+ b += c[k] * c[k], P += c[k] * h[k], M += h[k] * h[k];
1740
+ const S = b * M - P * P;
1741
+ if (Math.abs(S) < 1e-14) break;
1742
+ const U = -(M * d - P * m) / S, j = -(b * m - P * d) / S;
1743
+ l = Math.max(0, Math.min(1, l + U)), u = Math.max(0, Math.min(1, u + j));
1744
+ }
1745
+ return [l, u];
1746
+ }
1747
+ const Mt = ({
1748
+ points: t,
1749
+ degree: n = 3,
1750
+ weights: e,
1751
+ knots: r,
1752
+ resolution: s = 50,
1753
+ color: o = "black",
1754
+ segments: i,
1755
+ dashed: l = !1,
1756
+ vertexColors: u,
1757
+ ...a
643
1758
  }) => {
644
- const p = Me(() => {
645
- if (!c)
646
- return console.error("NurbsCurve requires knots to be provided"), [];
1759
+ const g = V(() => {
647
1760
  try {
648
- const m = Array(T.length).fill(1), R = ue.geom.NurbsCurve.byKnotsControlPointsWeights(
649
- x,
650
- c,
651
- T,
652
- y ?? m
653
- );
654
- return Array.from({ length: k + 1 }, (D, S) => {
655
- const b = S / k, v = R.point(b);
656
- return new hr(v[0], v[1], v[2]);
1761
+ const f = r ?? H(t.length, n), c = Array(t.length).fill(1), h = B.byKnotsControlPointsWeights(
1762
+ n,
1763
+ f,
1764
+ t,
1765
+ e ?? c
1766
+ ), p = s;
1767
+ return Array.from({ length: p + 1 }, (y, d) => {
1768
+ const m = d / p, w = h.point(m);
1769
+ return new I(w[0], w[1], w[2]);
657
1770
  });
658
- } catch (m) {
659
- return console.error("Error creating NURBS curve:", m), [];
1771
+ } catch (f) {
1772
+ return console.error("Error creating NURBS curve:", f), [];
660
1773
  }
661
- }, [T, x, y, c, k]);
662
- return p.length === 0 ? null : /* @__PURE__ */ K.jsx(
663
- Sr,
1774
+ }, [t, n, e, r, s]);
1775
+ return g.length === 0 ? null : /* @__PURE__ */ q.jsx(
1776
+ xt,
664
1777
  {
665
- points: p,
666
- color: F,
667
- segments: _,
668
- dashed: g,
669
- vertexColors: f,
670
- ...E
1778
+ points: g,
1779
+ color: o,
1780
+ segments: i,
1781
+ dashed: l,
1782
+ vertexColors: u,
1783
+ ...a
671
1784
  }
672
1785
  );
1786
+ }, On = /* @__PURE__ */ new Set([
1787
+ "meshBasicMaterial",
1788
+ "meshStandardMaterial",
1789
+ "meshPhongMaterial",
1790
+ "meshLambertMaterial",
1791
+ "meshToonMaterial",
1792
+ "meshNormalMaterial",
1793
+ "meshMatcapMaterial",
1794
+ "meshDepthMaterial",
1795
+ "meshDistanceMaterial",
1796
+ "meshPhysicalMaterial",
1797
+ "pointsMaterial",
1798
+ "lineBasicMaterial",
1799
+ "lineDashedMaterial",
1800
+ "spriteMaterial",
1801
+ "shadowMaterial",
1802
+ "rawShaderMaterial",
1803
+ "shaderMaterial"
1804
+ ]);
1805
+ function vt(t) {
1806
+ return gt(t) ? typeof t.type == "string" ? On.has(t.type) : !!(t.type && t.type.prototype && "isMaterial" in t.type.prototype) : !1;
1807
+ }
1808
+ const De = ie(function({
1809
+ controlPoints: n,
1810
+ weights: e,
1811
+ degreeU: r,
1812
+ degreeV: s,
1813
+ knotsU: o,
1814
+ knotsV: i,
1815
+ resolutionU: l = 20,
1816
+ resolutionV: u = 20,
1817
+ color: a = "#ffffff",
1818
+ wireframe: g = !1,
1819
+ fastNormals: f = !1,
1820
+ children: c,
1821
+ ...h
1822
+ }, p) {
1823
+ const y = V(() => {
1824
+ if (!c) return null;
1825
+ const w = ht.toArray(c);
1826
+ for (const x of w)
1827
+ if (vt(x))
1828
+ return x;
1829
+ return console.warn("NurbsSurface children must be a material component"), null;
1830
+ }, [c]), d = et(null), m = V(() => {
1831
+ if (!n || n.length === 0) return null;
1832
+ try {
1833
+ const w = o ?? H(n.length, r), x = i ?? H(n[0].length, s), _ = ut.byKnotsControlPointsWeights(
1834
+ r,
1835
+ s,
1836
+ w,
1837
+ x,
1838
+ n,
1839
+ e
1840
+ ), b = (l + 1) * (u + 1), P = new Float32Array(b * 3), M = new Float32Array(b * 2);
1841
+ let S = 0, U = 0;
1842
+ for (let R = 0; R <= l; R++)
1843
+ for (let W = 0; W <= u; W++) {
1844
+ const G = R / l, Q = W / u, X = _.point(G, Q);
1845
+ P[S++] = X[0], P[S++] = X[1], P[S++] = X[2], M[U++] = G, M[U++] = Q;
1846
+ }
1847
+ let j = null;
1848
+ if (!f) {
1849
+ j = new Float32Array(b * 3);
1850
+ let R = 0;
1851
+ for (let W = 0; W <= l; W++)
1852
+ for (let G = 0; G <= u; G++) {
1853
+ const Q = W / l, X = G / u;
1854
+ try {
1855
+ const nt = _.normal(Q, X), lt = Math.sqrt(nt[0] ** 2 + nt[1] ** 2 + nt[2] ** 2);
1856
+ lt > 0 ? (j[R++] = nt[0] / lt, j[R++] = nt[1] / lt, j[R++] = nt[2] / lt) : (j[R++] = 0, j[R++] = 1, j[R++] = 0);
1857
+ } catch {
1858
+ j[R++] = 0, j[R++] = 1, j[R++] = 0;
1859
+ }
1860
+ }
1861
+ }
1862
+ const k = l * u * 6, E = new Uint32Array(k);
1863
+ let T = 0;
1864
+ for (let R = 0; R < l; R++)
1865
+ for (let W = 0; W < u; W++) {
1866
+ const G = R * (u + 1) + W, Q = G + 1, X = (R + 1) * (u + 1) + W, nt = X + 1;
1867
+ E[T++] = G, E[T++] = Q, E[T++] = X, E[T++] = Q, E[T++] = nt, E[T++] = X;
1868
+ }
1869
+ const D = d.current ?? new pt();
1870
+ return D.setAttribute("position", new J(P, 3)), j && D.setAttribute("normal", new J(j, 3)), D.setAttribute("uv", new J(M, 2)), D.setIndex(Array.from(E)), j || D.computeVertexNormals(), D.computeBoundingSphere(), d.current = D, D;
1871
+ } catch (w) {
1872
+ return console.error("Error creating NURBS surface:", w), null;
1873
+ }
1874
+ }, [n, e, r, s, o, i, l, u, f]);
1875
+ return !m || c && !y ? null : /* @__PURE__ */ q.jsx("mesh", { ref: p, ...h, geometry: m, children: y || /* @__PURE__ */ q.jsx("meshPhongMaterial", { color: a, wireframe: g, side: wt }) });
1876
+ }), hr = ({
1877
+ degreeV: t = 3,
1878
+ resolutionU: n = 20,
1879
+ resolutionV: e = 20,
1880
+ color: r = "#ff0000",
1881
+ wireframe: s = !1,
1882
+ children: o
1883
+ }) => {
1884
+ const { curveChildren: i, materialChild: l } = V(() => {
1885
+ const g = [];
1886
+ let f = null;
1887
+ return ht.forEach(o, (c) => {
1888
+ gt(c) && c.type === Mt ? g.push(c) : vt(c) && (f = c);
1889
+ }), { curveChildren: g, materialChild: f };
1890
+ }, [o]), u = et(null), a = V(() => {
1891
+ if (i.length < 2)
1892
+ return console.error("LoftedSurface requires at least 2 NurbsCurve children"), null;
1893
+ try {
1894
+ const g = i.map((d) => {
1895
+ const { points: m, degree: w = 3, weights: x, knots: _ } = d.props, b = Array(m.length).fill(1), P = _ ?? H(m.length, w);
1896
+ return B.byKnotsControlPointsWeights(
1897
+ w,
1898
+ P,
1899
+ m,
1900
+ x ?? b
1901
+ );
1902
+ }), f = ut.byLoftingCurves(g, t), c = [], h = [], p = [];
1903
+ for (let d = 0; d <= n; d++)
1904
+ for (let m = 0; m <= e; m++) {
1905
+ const w = d / n, x = m / e, _ = f.point(w, x);
1906
+ c.push(_[0], _[1], _[2]), p.push(w, x);
1907
+ }
1908
+ for (let d = 0; d < n; d++)
1909
+ for (let m = 0; m < e; m++) {
1910
+ const w = d * (e + 1) + m, x = w + 1, _ = (d + 1) * (e + 1) + m, b = _ + 1;
1911
+ h.push(w, x, _), h.push(x, b, _);
1912
+ }
1913
+ const y = u.current ?? new pt();
1914
+ return y.setAttribute("position", new J(c, 3)), y.setAttribute("uv", new J(p, 2)), y.setIndex(h), y.computeVertexNormals(), y.computeBoundingSphere(), u.current = y, y;
1915
+ } catch (g) {
1916
+ return console.error("Error creating lofted surface:", g), null;
1917
+ }
1918
+ }, [i, t, n, e]);
1919
+ return a ? /* @__PURE__ */ q.jsx("mesh", { geometry: a, children: l || /* @__PURE__ */ q.jsx("meshStandardMaterial", { color: r, wireframe: s, side: wt }) }) : null;
673
1920
  };
674
- function Fr({
675
- controlPoints: T,
676
- weights: x,
677
- degreeU: y,
678
- degreeV: c,
679
- color: k = "#ffffff",
680
- wireframe: F = !1,
681
- children: _,
682
- ...g
1921
+ function Vn(t, n, e = 2) {
1922
+ const r = n && n.length, s = r ? n[0] * e : t.length;
1923
+ let o = Ue(t, 0, s, e, !0);
1924
+ const i = [];
1925
+ if (!o || o.next === o.prev) return i;
1926
+ let l, u, a;
1927
+ if (r && (o = Ln(t, n, o, e)), t.length > 80 * e) {
1928
+ l = t[0], u = t[1];
1929
+ let g = l, f = u;
1930
+ for (let c = e; c < s; c += e) {
1931
+ const h = t[c], p = t[c + 1];
1932
+ h < l && (l = h), p < u && (u = p), h > g && (g = h), p > f && (f = p);
1933
+ }
1934
+ a = Math.max(g - l, f - u), a = a !== 0 ? 32767 / a : 0;
1935
+ }
1936
+ return Dt(o, i, e, l, u, a, 0), i;
1937
+ }
1938
+ function Ue(t, n, e, r, s) {
1939
+ let o;
1940
+ if (s === tr(t, n, e, r) > 0)
1941
+ for (let i = n; i < e; i += r) o = Me(i / r | 0, t[i], t[i + 1], o);
1942
+ else
1943
+ for (let i = e - r; i >= n; i -= r) o = Me(i / r | 0, t[i], t[i + 1], o);
1944
+ return o && kt(o, o.next) && (Ft(o), o = o.next), o;
1945
+ }
1946
+ function yt(t, n) {
1947
+ if (!t) return t;
1948
+ n || (n = t);
1949
+ let e = t, r;
1950
+ do
1951
+ if (r = !1, !e.steiner && (kt(e, e.next) || z(e.prev, e, e.next) === 0)) {
1952
+ if (Ft(e), e = n = e.prev, e === e.next) break;
1953
+ r = !0;
1954
+ } else
1955
+ e = e.next;
1956
+ while (r || e !== n);
1957
+ return n;
1958
+ }
1959
+ function Dt(t, n, e, r, s, o, i) {
1960
+ if (!t) return;
1961
+ !i && o && Yn(t, r, s, o);
1962
+ let l = t;
1963
+ for (; t.prev !== t.next; ) {
1964
+ const u = t.prev, a = t.next;
1965
+ if (o ? Nn(t, r, s, o) : $n(t)) {
1966
+ n.push(u.i, t.i, a.i), Ft(t), t = a.next, l = a.next;
1967
+ continue;
1968
+ }
1969
+ if (t = a, t === l) {
1970
+ i ? i === 1 ? (t = Kn(yt(t), n), Dt(t, n, e, r, s, o, 2)) : i === 2 && Wn(t, n, e, r, s, o) : Dt(yt(t), n, e, r, s, o, 1);
1971
+ break;
1972
+ }
1973
+ }
1974
+ }
1975
+ function $n(t) {
1976
+ const n = t.prev, e = t, r = t.next;
1977
+ if (z(n, e, r) >= 0) return !1;
1978
+ const s = n.x, o = e.x, i = r.x, l = n.y, u = e.y, a = r.y, g = Math.min(s, o, i), f = Math.min(l, u, a), c = Math.max(s, o, i), h = Math.max(l, u, a);
1979
+ let p = r.next;
1980
+ for (; p !== n; ) {
1981
+ if (p.x >= g && p.x <= c && p.y >= f && p.y <= h && Tt(s, l, o, u, i, a, p.x, p.y) && z(p.prev, p, p.next) >= 0) return !1;
1982
+ p = p.next;
1983
+ }
1984
+ return !0;
1985
+ }
1986
+ function Nn(t, n, e, r) {
1987
+ const s = t.prev, o = t, i = t.next;
1988
+ if (z(s, o, i) >= 0) return !1;
1989
+ const l = s.x, u = o.x, a = i.x, g = s.y, f = o.y, c = i.y, h = Math.min(l, u, a), p = Math.min(g, f, c), y = Math.max(l, u, a), d = Math.max(g, f, c), m = oe(h, p, n, e, r), w = oe(y, d, n, e, r);
1990
+ let x = t.prevZ, _ = t.nextZ;
1991
+ for (; x && x.z >= m && _ && _.z <= w; ) {
1992
+ if (x.x >= h && x.x <= y && x.y >= p && x.y <= d && x !== s && x !== i && Tt(l, g, u, f, a, c, x.x, x.y) && z(x.prev, x, x.next) >= 0 || (x = x.prevZ, _.x >= h && _.x <= y && _.y >= p && _.y <= d && _ !== s && _ !== i && Tt(l, g, u, f, a, c, _.x, _.y) && z(_.prev, _, _.next) >= 0)) return !1;
1993
+ _ = _.nextZ;
1994
+ }
1995
+ for (; x && x.z >= m; ) {
1996
+ if (x.x >= h && x.x <= y && x.y >= p && x.y <= d && x !== s && x !== i && Tt(l, g, u, f, a, c, x.x, x.y) && z(x.prev, x, x.next) >= 0) return !1;
1997
+ x = x.prevZ;
1998
+ }
1999
+ for (; _ && _.z <= w; ) {
2000
+ if (_.x >= h && _.x <= y && _.y >= p && _.y <= d && _ !== s && _ !== i && Tt(l, g, u, f, a, c, _.x, _.y) && z(_.prev, _, _.next) >= 0) return !1;
2001
+ _ = _.nextZ;
2002
+ }
2003
+ return !0;
2004
+ }
2005
+ function Kn(t, n) {
2006
+ let e = t;
2007
+ do {
2008
+ const r = e.prev, s = e.next.next;
2009
+ !kt(r, s) && Ie(r, e, e.next, s) && Ut(r, s) && Ut(s, r) && (n.push(r.i, e.i, s.i), Ft(e), Ft(e.next), e = t = s), e = e.next;
2010
+ } while (e !== t);
2011
+ return yt(e);
2012
+ }
2013
+ function Wn(t, n, e, r, s, o) {
2014
+ let i = t;
2015
+ do {
2016
+ let l = i.next.next;
2017
+ for (; l !== i.prev; ) {
2018
+ if (i.i !== l.i && Hn(i, l)) {
2019
+ let u = Oe(i, l);
2020
+ i = yt(i, i.next), u = yt(u, u.next), Dt(i, n, e, r, s, o, 0), Dt(u, n, e, r, s, o, 0);
2021
+ return;
2022
+ }
2023
+ l = l.next;
2024
+ }
2025
+ i = i.next;
2026
+ } while (i !== t);
2027
+ }
2028
+ function Ln(t, n, e, r) {
2029
+ const s = [];
2030
+ for (let o = 0, i = n.length; o < i; o++) {
2031
+ const l = n[o] * r, u = o < i - 1 ? n[o + 1] * r : t.length, a = Ue(t, l, u, r, !1);
2032
+ a === a.next && (a.steiner = !0), s.push(Gn(a));
2033
+ }
2034
+ s.sort(qn);
2035
+ for (let o = 0; o < s.length; o++)
2036
+ e = zn(s[o], e);
2037
+ return e;
2038
+ }
2039
+ function qn(t, n) {
2040
+ let e = t.x - n.x;
2041
+ if (e === 0 && (e = t.y - n.y, e === 0)) {
2042
+ const r = (t.next.y - t.y) / (t.next.x - t.x), s = (n.next.y - n.y) / (n.next.x - n.x);
2043
+ e = r - s;
2044
+ }
2045
+ return e;
2046
+ }
2047
+ function zn(t, n) {
2048
+ const e = Bn(t, n);
2049
+ if (!e)
2050
+ return n;
2051
+ const r = Oe(e, t);
2052
+ return yt(r, r.next), yt(e, e.next);
2053
+ }
2054
+ function Bn(t, n) {
2055
+ let e = n;
2056
+ const r = t.x, s = t.y;
2057
+ let o = -1 / 0, i;
2058
+ if (kt(t, e)) return e;
2059
+ do {
2060
+ if (kt(t, e.next)) return e.next;
2061
+ if (s <= e.y && s >= e.next.y && e.next.y !== e.y) {
2062
+ const f = e.x + (s - e.y) * (e.next.x - e.x) / (e.next.y - e.y);
2063
+ if (f <= r && f > o && (o = f, i = e.x < e.next.x ? e : e.next, f === r))
2064
+ return i;
2065
+ }
2066
+ e = e.next;
2067
+ } while (e !== n);
2068
+ if (!i) return null;
2069
+ const l = i, u = i.x, a = i.y;
2070
+ let g = 1 / 0;
2071
+ e = i;
2072
+ do {
2073
+ if (r >= e.x && e.x >= u && r !== e.x && Fe(s < a ? r : o, s, u, a, s < a ? o : r, s, e.x, e.y)) {
2074
+ const f = Math.abs(s - e.y) / (r - e.x);
2075
+ Ut(e, t) && (f < g || f === g && (e.x > i.x || e.x === i.x && Zn(i, e))) && (i = e, g = f);
2076
+ }
2077
+ e = e.next;
2078
+ } while (e !== l);
2079
+ return i;
2080
+ }
2081
+ function Zn(t, n) {
2082
+ return z(t.prev, t, n.prev) < 0 && z(n.next, t, t.next) < 0;
2083
+ }
2084
+ function Yn(t, n, e, r) {
2085
+ let s = t;
2086
+ do
2087
+ s.z === 0 && (s.z = oe(s.x, s.y, n, e, r)), s.prevZ = s.prev, s.nextZ = s.next, s = s.next;
2088
+ while (s !== t);
2089
+ s.prevZ.nextZ = null, s.prevZ = null, Jn(s);
2090
+ }
2091
+ function Jn(t) {
2092
+ let n, e = 1;
2093
+ do {
2094
+ let r = t, s;
2095
+ t = null;
2096
+ let o = null;
2097
+ for (n = 0; r; ) {
2098
+ n++;
2099
+ let i = r, l = 0;
2100
+ for (let a = 0; a < e && (l++, i = i.nextZ, !!i); a++)
2101
+ ;
2102
+ let u = e;
2103
+ for (; l > 0 || u > 0 && i; )
2104
+ l !== 0 && (u === 0 || !i || r.z <= i.z) ? (s = r, r = r.nextZ, l--) : (s = i, i = i.nextZ, u--), o ? o.nextZ = s : t = s, s.prevZ = o, o = s;
2105
+ r = i;
2106
+ }
2107
+ o.nextZ = null, e *= 2;
2108
+ } while (n > 1);
2109
+ return t;
2110
+ }
2111
+ function oe(t, n, e, r, s) {
2112
+ return t = (t - e) * s | 0, n = (n - r) * s | 0, t = (t | t << 8) & 16711935, t = (t | t << 4) & 252645135, t = (t | t << 2) & 858993459, t = (t | t << 1) & 1431655765, n = (n | n << 8) & 16711935, n = (n | n << 4) & 252645135, n = (n | n << 2) & 858993459, n = (n | n << 1) & 1431655765, t | n << 1;
2113
+ }
2114
+ function Gn(t) {
2115
+ let n = t, e = t;
2116
+ do
2117
+ (n.x < e.x || n.x === e.x && n.y < e.y) && (e = n), n = n.next;
2118
+ while (n !== t);
2119
+ return e;
2120
+ }
2121
+ function Fe(t, n, e, r, s, o, i, l) {
2122
+ return (s - i) * (n - l) >= (t - i) * (o - l) && (t - i) * (r - l) >= (e - i) * (n - l) && (e - i) * (o - l) >= (s - i) * (r - l);
2123
+ }
2124
+ function Tt(t, n, e, r, s, o, i, l) {
2125
+ return !(t === i && n === l) && Fe(t, n, e, r, s, o, i, l);
2126
+ }
2127
+ function Hn(t, n) {
2128
+ return t.next.i !== n.i && t.prev.i !== n.i && !Xn(t, n) && // doesn't intersect other edges
2129
+ (Ut(t, n) && Ut(n, t) && Qn(t, n) && // locally visible
2130
+ (z(t.prev, t, n.prev) || z(t, n.prev, n)) || // does not create opposite-facing sectors
2131
+ kt(t, n) && z(t.prev, t, t.next) > 0 && z(n.prev, n, n.next) > 0);
2132
+ }
2133
+ function z(t, n, e) {
2134
+ return (n.y - t.y) * (e.x - n.x) - (n.x - t.x) * (e.y - n.y);
2135
+ }
2136
+ function kt(t, n) {
2137
+ return t.x === n.x && t.y === n.y;
2138
+ }
2139
+ function Ie(t, n, e, r) {
2140
+ const s = Kt(z(t, n, e)), o = Kt(z(t, n, r)), i = Kt(z(e, r, t)), l = Kt(z(e, r, n));
2141
+ return !!(s !== o && i !== l || s === 0 && Nt(t, e, n) || o === 0 && Nt(t, r, n) || i === 0 && Nt(e, t, r) || l === 0 && Nt(e, n, r));
2142
+ }
2143
+ function Nt(t, n, e) {
2144
+ return n.x <= Math.max(t.x, e.x) && n.x >= Math.min(t.x, e.x) && n.y <= Math.max(t.y, e.y) && n.y >= Math.min(t.y, e.y);
2145
+ }
2146
+ function Kt(t) {
2147
+ return t > 0 ? 1 : t < 0 ? -1 : 0;
2148
+ }
2149
+ function Xn(t, n) {
2150
+ let e = t;
2151
+ do {
2152
+ if (e.i !== t.i && e.next.i !== t.i && e.i !== n.i && e.next.i !== n.i && Ie(e, e.next, t, n)) return !0;
2153
+ e = e.next;
2154
+ } while (e !== t);
2155
+ return !1;
2156
+ }
2157
+ function Ut(t, n) {
2158
+ return z(t.prev, t, t.next) < 0 ? z(t, n, t.next) >= 0 && z(t, t.prev, n) >= 0 : z(t, n, t.prev) < 0 || z(t, t.next, n) < 0;
2159
+ }
2160
+ function Qn(t, n) {
2161
+ let e = t, r = !1;
2162
+ const s = (t.x + n.x) / 2, o = (t.y + n.y) / 2;
2163
+ do
2164
+ e.y > o != e.next.y > o && e.next.y !== e.y && s < (e.next.x - e.x) * (o - e.y) / (e.next.y - e.y) + e.x && (r = !r), e = e.next;
2165
+ while (e !== t);
2166
+ return r;
2167
+ }
2168
+ function Oe(t, n) {
2169
+ const e = se(t.i, t.x, t.y), r = se(n.i, n.x, n.y), s = t.next, o = n.prev;
2170
+ return t.next = n, n.prev = t, e.next = s, s.prev = e, r.next = e, e.prev = r, o.next = r, r.prev = o, r;
2171
+ }
2172
+ function Me(t, n, e, r) {
2173
+ const s = se(t, n, e);
2174
+ return r ? (s.next = r.next, s.prev = r, r.next.prev = s, r.next = s) : (s.prev = s, s.next = s), s;
2175
+ }
2176
+ function Ft(t) {
2177
+ t.next.prev = t.prev, t.prev.next = t.next, t.prevZ && (t.prevZ.nextZ = t.nextZ), t.nextZ && (t.nextZ.prevZ = t.prevZ);
2178
+ }
2179
+ function se(t, n, e) {
2180
+ return {
2181
+ i: t,
2182
+ // vertex index in coordinates array
2183
+ x: n,
2184
+ y: e,
2185
+ // vertex coordinates
2186
+ prev: null,
2187
+ // previous and next vertex nodes in a polygon ring
2188
+ next: null,
2189
+ z: 0,
2190
+ // z-order curve value
2191
+ prevZ: null,
2192
+ // previous and next nodes in z-order
2193
+ nextZ: null,
2194
+ steiner: !1
2195
+ // indicates whether this is a steiner point
2196
+ };
2197
+ }
2198
+ function tr(t, n, e, r) {
2199
+ let s = 0;
2200
+ for (let o = n, i = e - r; o < e; o += r)
2201
+ s += (t[i] - t[o]) * (t[o + 1] + t[i + 1]), i = o;
2202
+ return s;
2203
+ }
2204
+ function dr({
2205
+ color: t = "#ffffff",
2206
+ trimCurveResolution: n = 200,
2207
+ adaptiveMaxAngleDeg: e = 5,
2208
+ adaptiveMaxDepth: r = 10,
2209
+ wireframe: s = !1,
2210
+ world: o = !1,
2211
+ children: i,
2212
+ ...l
683
2213
  }) {
684
- const { scene: f } = Cr(), [E, p] = pr(null);
685
- return mr(() => {
686
- const m = T.length + y + 1, R = T[0].length + c + 1, D = Array(m).fill(0).map((w, l) => l < y + 1 ? 0 : l >= m - y - 1 ? 1 : (l - y) / (m - 2 * y - 1)), S = Array(R).fill(0).map((w, l) => l < c + 1 ? 0 : l >= R - c - 1 ? 1 : (l - c) / (R - 2 * c - 1)), b = ue.geom.NurbsSurface.byKnotsControlPointsWeights(
687
- y,
688
- c,
689
- D,
690
- S,
691
- T,
692
- x
693
- ), v = new yr(), C = [], s = [], W = [], H = 20, U = 20, ce = 1 / H, fe = 1 / U;
694
- for (let w = 0; w <= H; w++)
695
- for (let l = 0; l <= U; l++) {
696
- const $ = w * ce, N = l * fe, B = b.point($, N), j = 1e-4, M = b.point($ + j, N), z = b.point($, N + j), Z = b.point($, N), Y = M.map((q, J) => (q - Z[J]) / j), L = z.map((q, J) => (q - Z[J]) / j), I = [
697
- Y[1] * L[2] - Y[2] * L[1],
698
- Y[2] * L[0] - Y[0] * L[2],
699
- Y[0] * L[1] - Y[1] * L[0]
700
- ], te = Math.sqrt(
701
- I[0] * I[0] + I[1] * I[1] + I[2] * I[2]
702
- ), ne = I.map((q) => q / te);
703
- C.push(...B), s.push(...ne);
704
- }
705
- for (let w = 0; w < H; w++)
706
- for (let l = 0; l < U; l++) {
707
- const $ = w * (U + 1) + l, N = $ + 1, B = (w + 1) * (U + 1) + l, j = B + 1;
708
- W.push($, N, B), W.push(N, j, B);
709
- }
710
- if (v.setAttribute("position", new Ie(C, 3)), v.setAttribute("normal", new Ie(s, 3)), v.setIndex(W), p(v), !_) {
711
- const w = new gr({
712
- color: new _r(k),
713
- side: Er,
714
- wireframe: F
715
- }), l = new Rr(v, w);
716
- return f.add(l), () => {
717
- f.remove(l), v.dispose(), w.dispose();
718
- };
2214
+ const { surfaceChild: u, curveChildren: a, materialChild: g } = V(() => {
2215
+ const h = ht.toArray(i);
2216
+ let p = null;
2217
+ const y = [];
2218
+ let d = null;
2219
+ for (const m of h)
2220
+ gt(m) && (m.type === De || m.type === "NurbsSurface" ? p = m : m.type === Mt || m.type === "NurbsCurve" ? y.push(m) : vt(m) && (d = m));
2221
+ return { surfaceChild: p, curveChildren: y, materialChild: d };
2222
+ }, [i]), f = et(null), c = V(() => {
2223
+ if (!u || a.length === 0)
2224
+ return u || console.warn("TrimmedSurface requires a NurbsSurface child"), a.length === 0 && console.warn("TrimmedSurface requires at least one NurbsCurve"), null;
2225
+ try {
2226
+ const h = u.props, p = H(h.controlPoints.length, h.degreeU), y = H(h.controlPoints[0].length, h.degreeV), d = ut.byKnotsControlPointsWeights(
2227
+ h.degreeU,
2228
+ h.degreeV,
2229
+ p,
2230
+ y,
2231
+ h.controlPoints,
2232
+ h.weights
2233
+ ), w = a.map((E) => {
2234
+ const T = E.props, D = T.knots ?? H(T.points.length, T.degree ?? 2), R = B.byKnotsControlPointsWeights(
2235
+ T.degree ?? 2,
2236
+ D,
2237
+ T.points,
2238
+ T.weights ?? Array(T.points.length).fill(1)
2239
+ );
2240
+ if (o) {
2241
+ const W = Fn(
2242
+ d,
2243
+ R,
2244
+ n
2245
+ );
2246
+ if (W.length > 1) {
2247
+ const G = H(W.length, T.degree ?? 2);
2248
+ return B.byKnotsControlPointsWeights(
2249
+ T.degree ?? 2,
2250
+ G,
2251
+ W.map(([Q, X]) => [Q, X, 0]),
2252
+ Array(W.length).fill(1)
2253
+ );
2254
+ }
2255
+ return null;
2256
+ }
2257
+ return R;
2258
+ }).filter((E) => E !== null).map(
2259
+ (E) => Un(E, e, r)
2260
+ ), x = [], _ = [];
2261
+ let b = 0;
2262
+ w.forEach((E, T) => {
2263
+ T > 0 && _.push(b), E.forEach(([D, R]) => {
2264
+ x.push(D, R), b++;
2265
+ });
2266
+ });
2267
+ const P = Vn(x, _, 2), M = [], S = [], U = [], j = [];
2268
+ for (let E = 0; E < x.length; E += 2)
2269
+ j.push([x[E], x[E + 1]]);
2270
+ for (const [E, T] of j) {
2271
+ const D = Tn(d, E, T), R = Dn(d, E, T);
2272
+ M.push(D.x, D.y, D.z), S.push(R.x, R.y, R.z), U.push(E, T);
2273
+ }
2274
+ const k = f.current ?? new pt();
2275
+ return k.setAttribute("position", new J(M, 3)), k.setAttribute("normal", new J(S, 3)), k.setAttribute("uv", new J(U, 2)), k.setIndex(Array.from(P)), k.computeBoundingSphere(), f.current = k, k;
2276
+ } catch (h) {
2277
+ return console.error("Error creating trimmed surface:", h), null;
719
2278
  }
720
- return () => {
721
- v.dispose();
722
- };
723
2279
  }, [
724
- T,
725
- x,
726
- y,
727
- c,
728
- k,
729
- F,
730
- f,
731
- _
732
- ]), E && _ ? !Ye(_) || !_.type.toString().includes("Material") ? (console.warn("NurbsSurface children must be a material component"), null) : /* @__PURE__ */ K.jsxs("mesh", { ...g, children: [
733
- /* @__PURE__ */ K.jsx("primitive", { object: E, attach: "geometry" }),
734
- _
735
- ] }) : null;
736
- }
737
- const Dr = ({
738
- degreeV: T = 3,
739
- knotsV: x,
740
- resolutionU: y = 20,
741
- resolutionV: c = 20,
742
- color: k = "#ff0000",
743
- wireframe: F = !1,
744
- children: _
2280
+ u,
2281
+ a,
2282
+ n,
2283
+ e,
2284
+ r,
2285
+ o
2286
+ ]);
2287
+ return !c || !g ? (!g && u && a.length > 0 && console.warn("TrimmedSurface requires a material as a direct child"), null) : /* @__PURE__ */ q.jsx("mesh", { ...l, geometry: c, children: g });
2288
+ }
2289
+ const gr = ({
2290
+ center: t = [0, 0, 0],
2291
+ axis: n = [1, 0, 0],
2292
+ angle: e = 2 * Math.PI,
2293
+ resolutionU: r = 20,
2294
+ resolutionV: s = 20,
2295
+ color: o = "#ff0000",
2296
+ wireframe: i = !1,
2297
+ children: l,
2298
+ ...u
745
2299
  }) => {
746
- const g = Me(() => {
747
- const f = br.toArray(_).filter(
748
- (E) => Ye(E) && E.type === jr
749
- );
750
- if (f.length < 2)
751
- return console.error("LoftedSurface requires at least 2 NurbsCurve children"), null;
2300
+ const { profileChild: a, materialChild: g } = V(() => {
2301
+ let h = null, p = null;
2302
+ const y = ht.toArray(l);
2303
+ for (const d of y)
2304
+ gt(d) && (d.type === Mt ? h = d : vt(d) && (p = d));
2305
+ return { profileChild: h, materialChild: p };
2306
+ }, [l]), f = et(null), c = V(() => {
2307
+ if (!a)
2308
+ return console.error("RevolvedSurface requires a NurbsCurve child"), null;
752
2309
  try {
753
- const E = f.map((S) => {
754
- const { points: b, degree: v = 3, weights: C, knots: s } = S.props, W = Array(b.length).fill(1);
755
- return ue.geom.NurbsCurve.byKnotsControlPointsWeights(
756
- v,
757
- s,
2310
+ const { points: h, degree: p = 3, weights: y, knots: d } = a.props, m = Array(h.length).fill(1);
2311
+ if (!h || h.length < 2) return null;
2312
+ const w = Math.sqrt(n[0] ** 2 + n[1] ** 2 + n[2] ** 2);
2313
+ if (w === 0) return null;
2314
+ const x = [
2315
+ n[0] / w,
2316
+ n[1] / w,
2317
+ n[2] / w
2318
+ ], _ = d ?? H(h.length, p), b = B.byKnotsControlPointsWeights(
2319
+ p,
2320
+ _,
2321
+ h,
2322
+ y ?? m
2323
+ ), P = new ut(
2324
+ Sn(b.asData(), t, x, e)
2325
+ ), M = [], S = [], U = [];
2326
+ for (let k = 0; k <= r; k++)
2327
+ for (let E = 0; E <= s; E++) {
2328
+ const T = k / r, D = E / s, R = P.point(T, D);
2329
+ M.push(R[0], R[1], R[2]), U.push(T, D);
2330
+ }
2331
+ for (let k = 0; k < r; k++)
2332
+ for (let E = 0; E < s; E++) {
2333
+ const T = k * (s + 1) + E, D = T + 1, R = (k + 1) * (s + 1) + E, W = R + 1;
2334
+ S.push(T, D, R), S.push(D, W, R);
2335
+ }
2336
+ const j = f.current ?? new pt();
2337
+ return j.setAttribute("position", new J(M, 3)), j.setAttribute("uv", new J(U, 2)), j.setIndex(S), j.computeVertexNormals(), j.computeBoundingSphere(), f.current = j, j;
2338
+ } catch (h) {
2339
+ return console.error("Error creating revolved surface:", h), null;
2340
+ }
2341
+ }, [a, t, n, e, r, s]);
2342
+ return c ? /* @__PURE__ */ q.jsx("mesh", { ...u, geometry: c, children: g || /* @__PURE__ */ q.jsx("meshStandardMaterial", { color: o, wireframe: i, side: wt }) }) : null;
2343
+ }, pr = ({
2344
+ direction: t,
2345
+ resolutionU: n = 20,
2346
+ resolutionV: e = 20,
2347
+ color: r = "#ff0000",
2348
+ wireframe: s = !1,
2349
+ children: o,
2350
+ ...i
2351
+ }) => {
2352
+ const { profileChild: l, materialChild: u } = V(() => {
2353
+ let f = null, c = null;
2354
+ const h = ht.toArray(o);
2355
+ for (const p of h)
2356
+ gt(p) && (p.type === Mt ? f = p : vt(p) && (c = p));
2357
+ return { profileChild: f, materialChild: c };
2358
+ }, [o]), a = et(null), g = V(() => {
2359
+ if (!l)
2360
+ return console.error("ExtrudedSurface requires a NurbsCurve child"), null;
2361
+ try {
2362
+ const { points: f, degree: c = 3, weights: h, knots: p } = l.props, y = Array(f.length).fill(1), d = p ?? H(f.length, c), m = B.byKnotsControlPointsWeights(
2363
+ c,
2364
+ d,
2365
+ f,
2366
+ h ?? y
2367
+ ), w = new ut(
2368
+ An(m.asData(), t)
2369
+ ), x = [], _ = [], b = [];
2370
+ for (let M = 0; M <= n; M++)
2371
+ for (let S = 0; S <= e; S++) {
2372
+ const U = M / n, j = S / e, k = w.point(U, j);
2373
+ x.push(k[0], k[1], k[2]), b.push(U, j);
2374
+ }
2375
+ for (let M = 0; M < n; M++)
2376
+ for (let S = 0; S < e; S++) {
2377
+ const U = M * (e + 1) + S, j = U + 1, k = (M + 1) * (e + 1) + S, E = k + 1;
2378
+ _.push(U, j, k), _.push(j, E, k);
2379
+ }
2380
+ const P = a.current ?? new pt();
2381
+ return P.setAttribute("position", new J(x, 3)), P.setAttribute("uv", new J(b, 2)), P.setIndex(_), P.computeVertexNormals(), P.computeBoundingSphere(), a.current = P, P;
2382
+ } catch (f) {
2383
+ return console.error("Error creating extruded surface:", f), null;
2384
+ }
2385
+ }, [l, t, n, e]);
2386
+ return g ? /* @__PURE__ */ q.jsx("mesh", { ...i, geometry: g, children: u || /* @__PURE__ */ q.jsx("meshStandardMaterial", { color: r, wireframe: s, side: wt }) }) : null;
2387
+ }, vr = ({
2388
+ resolutionU: t = 20,
2389
+ resolutionV: n = 20,
2390
+ color: e = "#ff0000",
2391
+ wireframe: r = !1,
2392
+ children: s,
2393
+ ...o
2394
+ }) => {
2395
+ const { profileChild: i, railChild: l, materialChild: u } = V(() => {
2396
+ const f = [];
2397
+ let c = null;
2398
+ const h = ht.toArray(s);
2399
+ for (const p of h)
2400
+ gt(p) && (p.type === Mt ? f.push(p) : vt(p) && (c = p));
2401
+ return {
2402
+ profileChild: f[0] ?? null,
2403
+ railChild: f[1] ?? null,
2404
+ materialChild: c
2405
+ };
2406
+ }, [s]), a = et(null), g = V(() => {
2407
+ if (!i || !l)
2408
+ return console.error("SweptSurface requires exactly 2 NurbsCurve children (profile and rail)"), null;
2409
+ try {
2410
+ const f = (x) => {
2411
+ const { points: _, degree: b = 3, weights: P, knots: M } = x, S = M ?? H(_.length, b);
2412
+ return B.byKnotsControlPointsWeights(
758
2413
  b,
759
- C ?? W
2414
+ S,
2415
+ _,
2416
+ P ?? Array(_.length).fill(1)
760
2417
  );
761
- }), p = ue.geom.NurbsSurface.byLoftingCurves(
762
- E,
763
- T
764
- ), m = [], R = [], D = [];
765
- for (let S = 0; S <= y; S++)
766
- for (let b = 0; b <= c; b++) {
767
- const v = S / y, C = b / c, s = p.point(v, C);
768
- m.push(s[0], s[1], s[2]), D.push(v, C);
769
- }
770
- for (let S = 0; S < y; S++)
771
- for (let b = 0; b < c; b++) {
772
- const v = S * (c + 1) + b, C = v + 1, s = (S + 1) * (c + 1) + b, W = s + 1;
773
- R.push(v, C, s), R.push(C, W, s);
774
- }
775
- return {
776
- vertices: m,
777
- indices: R,
778
- uvs: D
779
- };
780
- } catch (E) {
781
- return console.error("Error creating lofted surface:", E), null;
782
- }
783
- }, [_, T, x, y, c]);
784
- return g ? /* @__PURE__ */ K.jsxs("mesh", { children: [
785
- /* @__PURE__ */ K.jsxs("bufferGeometry", { children: [
786
- /* @__PURE__ */ K.jsx(
787
- "bufferAttribute",
788
- {
789
- attach: "attributes-position",
790
- count: g.vertices.length / 3,
791
- array: new Float32Array(g.vertices),
792
- itemSize: 3
793
- }
794
- ),
795
- /* @__PURE__ */ K.jsx(
796
- "bufferAttribute",
797
- {
798
- attach: "attributes-uv",
799
- count: g.uvs.length / 2,
800
- array: new Float32Array(g.uvs),
801
- itemSize: 2
802
- }
803
- ),
804
- /* @__PURE__ */ K.jsx(
805
- "bufferAttribute",
2418
+ }, c = f(i.props), h = f(l.props), p = new ut(
2419
+ En(c.asData(), h.asData())
2420
+ ), y = [], d = [], m = [];
2421
+ for (let x = 0; x <= t; x++)
2422
+ for (let _ = 0; _ <= n; _++) {
2423
+ const b = x / t, P = _ / n, M = p.point(b, P);
2424
+ y.push(M[0], M[1], M[2]), m.push(b, P);
2425
+ }
2426
+ for (let x = 0; x < t; x++)
2427
+ for (let _ = 0; _ < n; _++) {
2428
+ const b = x * (n + 1) + _, P = b + 1, M = (x + 1) * (n + 1) + _, S = M + 1;
2429
+ d.push(b, P, M), d.push(P, S, M);
2430
+ }
2431
+ const w = a.current ?? new pt();
2432
+ return w.setAttribute("position", new J(y, 3)), w.setAttribute("uv", new J(m, 2)), w.setIndex(d), w.computeVertexNormals(), w.computeBoundingSphere(), a.current = w, w;
2433
+ } catch (f) {
2434
+ return console.error("Error creating swept surface:", f), null;
2435
+ }
2436
+ }, [i, l, t, n]);
2437
+ return g ? /* @__PURE__ */ q.jsx("mesh", { ...o, geometry: g, children: u || /* @__PURE__ */ q.jsx("meshStandardMaterial", { color: e, wireframe: r, side: wt }) }) : null;
2438
+ };
2439
+ function Ae(t) {
2440
+ const n = t.knotsU ?? H(t.controlPoints.length, t.degreeU), e = t.knotsV ?? H(t.controlPoints[0].length, t.degreeV);
2441
+ return ut.byKnotsControlPointsWeights(
2442
+ t.degreeU,
2443
+ t.degreeV,
2444
+ n,
2445
+ e,
2446
+ t.controlPoints,
2447
+ t.weights
2448
+ );
2449
+ }
2450
+ function er({
2451
+ surface0: t,
2452
+ surface1: n,
2453
+ tolerance: e = 1e-3
2454
+ }) {
2455
+ return { curves: V(() => {
2456
+ if (!t || !n) return [];
2457
+ try {
2458
+ const s = Ae(t), o = Ae(n);
2459
+ return jn(
2460
+ s,
2461
+ o,
2462
+ e
2463
+ ).map((l) => ({
2464
+ points: l.points.map(
2465
+ (u) => new I(u[0], u[1], u[2])
2466
+ )
2467
+ }));
2468
+ } catch (s) {
2469
+ return console.error("useSurfaceIntersection: Error computing intersection:", s), [];
2470
+ }
2471
+ }, [t, n, e]) };
2472
+ }
2473
+ const mr = ({
2474
+ tolerance: t = 1e-3,
2475
+ lineColor: n = "#ff0000",
2476
+ lineWidth: e = 2,
2477
+ children: r
2478
+ }) => {
2479
+ const s = V(() => {
2480
+ const i = [];
2481
+ return ht.forEach(r, (l) => {
2482
+ if (gt(l) && (l.type === De || l.type === "NurbsSurface")) {
2483
+ const u = l.props;
2484
+ i.push({
2485
+ controlPoints: u.controlPoints,
2486
+ weights: u.weights,
2487
+ degreeU: u.degreeU,
2488
+ degreeV: u.degreeV,
2489
+ knotsU: u.knotsU,
2490
+ knotsV: u.knotsV
2491
+ });
2492
+ }
2493
+ }), i;
2494
+ }, [r]), { curves: o } = er({
2495
+ surface0: s[0] ?? null,
2496
+ surface1: s[1] ?? null,
2497
+ tolerance: t
2498
+ });
2499
+ return s.length < 2 ? (console.warn("SurfaceIntersection requires exactly 2 NurbsSurface children"), null) : /* @__PURE__ */ q.jsxs("group", { children: [
2500
+ r,
2501
+ o.map(
2502
+ (i, l) => i.points.length >= 2 ? /* @__PURE__ */ q.jsx(
2503
+ xt,
806
2504
  {
807
- attach: "index",
808
- count: g.indices.length,
809
- array: new Uint32Array(g.indices),
810
- itemSize: 1
811
- }
812
- )
813
- ] }),
814
- /* @__PURE__ */ K.jsx("meshStandardMaterial", { color: k, wireframe: F })
815
- ] }) : null;
2505
+ points: i.points,
2506
+ color: n,
2507
+ lineWidth: e
2508
+ },
2509
+ l
2510
+ ) : null
2511
+ )
2512
+ ] });
2513
+ }, yr = ({
2514
+ throughPoints: t,
2515
+ degree: n = 3,
2516
+ resolution: e = 50,
2517
+ color: r = "black",
2518
+ ...s
2519
+ }) => {
2520
+ const o = V(() => {
2521
+ if (!t || t.length < 2) return [];
2522
+ try {
2523
+ const i = B.byPoints(t, n);
2524
+ return Array.from({ length: e + 1 }, (l, u) => {
2525
+ const a = u / e, g = i.point(a);
2526
+ return new I(g[0], g[1], g[2]);
2527
+ });
2528
+ } catch (i) {
2529
+ return console.error("InterpolatedCurve: Error creating curve:", i), [];
2530
+ }
2531
+ }, [t, n, e]);
2532
+ return o.length === 0 ? null : /* @__PURE__ */ q.jsx(xt, { points: o, color: r, ...s });
816
2533
  };
2534
+ function nr({
2535
+ points: t,
2536
+ degreeU: n = 3,
2537
+ degreeV: e = 3,
2538
+ resolutionU: r = 20,
2539
+ resolutionV: s = 20
2540
+ }) {
2541
+ const o = V(() => {
2542
+ if (!t || t.length < 2) return null;
2543
+ for (const l of t)
2544
+ if (!l || l.length < 2) return null;
2545
+ try {
2546
+ const l = t.map(
2547
+ (u) => B.byPoints(u, Math.min(n, u.length - 1))
2548
+ );
2549
+ return ut.byLoftingCurves(
2550
+ l,
2551
+ Math.min(e, l.length - 1)
2552
+ );
2553
+ } catch (l) {
2554
+ return console.error("useInterpolatedSurface: Error creating surface:", l), null;
2555
+ }
2556
+ }, [t, n, e]), i = V(() => {
2557
+ if (!o) return null;
2558
+ try {
2559
+ const l = (r + 1) * (s + 1), u = new Float32Array(l * 3), a = new Float32Array(l * 3), g = new Float32Array(l * 2);
2560
+ let f = 0, c = 0, h = 0;
2561
+ for (let m = 0; m <= r; m++)
2562
+ for (let w = 0; w <= s; w++) {
2563
+ const x = m / r, _ = w / s, b = o.point(x, _);
2564
+ u[f++] = b[0], u[f++] = b[1], u[f++] = b[2];
2565
+ try {
2566
+ const P = o.normal(x, _), M = Math.sqrt(P[0] ** 2 + P[1] ** 2 + P[2] ** 2);
2567
+ M > 0 ? (a[c++] = P[0] / M, a[c++] = P[1] / M, a[c++] = P[2] / M) : (a[c++] = 0, a[c++] = 1, a[c++] = 0);
2568
+ } catch {
2569
+ a[c++] = 0, a[c++] = 1, a[c++] = 0;
2570
+ }
2571
+ g[h++] = x, g[h++] = _;
2572
+ }
2573
+ const p = r * s * 6, y = new Uint32Array(p);
2574
+ let d = 0;
2575
+ for (let m = 0; m < r; m++)
2576
+ for (let w = 0; w < s; w++) {
2577
+ const x = m * (s + 1) + w, _ = x + 1, b = (m + 1) * (s + 1) + w, P = b + 1;
2578
+ y[d++] = x, y[d++] = _, y[d++] = b, y[d++] = _, y[d++] = P, y[d++] = b;
2579
+ }
2580
+ return { vertices: u, normals: a, uvs: g, indices: y };
2581
+ } catch (l) {
2582
+ return console.error("useInterpolatedSurface: Error generating geometry:", l), null;
2583
+ }
2584
+ }, [o, r, s]);
2585
+ return { surface: o, geometry: i };
2586
+ }
2587
+ const wr = ie(
2588
+ function({
2589
+ points: n,
2590
+ degreeU: e = 3,
2591
+ degreeV: r = 3,
2592
+ resolutionU: s = 20,
2593
+ resolutionV: o = 20,
2594
+ color: i = "#ffffff",
2595
+ wireframe: l = !1,
2596
+ children: u,
2597
+ ...a
2598
+ }, g) {
2599
+ const f = V(() => {
2600
+ if (!u) return null;
2601
+ const y = ht.toArray(u);
2602
+ for (const d of y)
2603
+ if (vt(d)) return d;
2604
+ return null;
2605
+ }, [u]), { geometry: c } = nr({
2606
+ points: n,
2607
+ degreeU: e,
2608
+ degreeV: r,
2609
+ resolutionU: s,
2610
+ resolutionV: o
2611
+ }), h = et(null), p = V(() => {
2612
+ if (!c) return null;
2613
+ const y = h.current ?? new pt();
2614
+ return y.setAttribute("position", new J(c.vertices, 3)), y.setAttribute("normal", new J(c.normals, 3)), y.setAttribute("uv", new J(c.uvs, 2)), y.setIndex(Array.from(c.indices)), y.computeBoundingSphere(), h.current = y, y;
2615
+ }, [c]);
2616
+ return p ? /* @__PURE__ */ q.jsx("mesh", { ref: g, ...a, geometry: p, children: f || /* @__PURE__ */ q.jsx("meshPhongMaterial", { color: i, wireframe: l, side: wt }) }) : null;
2617
+ }
2618
+ ), xr = ({
2619
+ center: t = [0, 0, 0],
2620
+ radius: n = 1,
2621
+ xaxis: e = [1, 0, 0],
2622
+ yaxis: r = [0, 1, 0],
2623
+ resolution: s = 64,
2624
+ color: o = "black",
2625
+ ...i
2626
+ }) => {
2627
+ const l = V(() => {
2628
+ try {
2629
+ const u = new B(Mn(t, e, r, n));
2630
+ return Array.from({ length: s + 1 }, (a, g) => {
2631
+ const f = g / s, c = u.point(f);
2632
+ return new I(c[0], c[1], c[2]);
2633
+ });
2634
+ } catch (u) {
2635
+ return console.error("NurbsCircle: Error creating circle:", u), [];
2636
+ }
2637
+ }, [t, e, r, n, s]);
2638
+ return l.length === 0 ? null : /* @__PURE__ */ q.jsx(xt, { points: l, color: o, ...i });
2639
+ }, _r = ({
2640
+ center: t = [0, 0, 0],
2641
+ radius: n = 1,
2642
+ xaxis: e = [1, 0, 0],
2643
+ yaxis: r = [0, 1, 0],
2644
+ startAngle: s = 0,
2645
+ endAngle: o = Math.PI / 2,
2646
+ resolution: i = 50,
2647
+ color: l = "black",
2648
+ ...u
2649
+ }) => {
2650
+ const a = V(() => {
2651
+ try {
2652
+ const g = new B(zt(t, e, r, n, s, o));
2653
+ return Array.from({ length: i + 1 }, (f, c) => {
2654
+ const h = c / i, p = g.point(h);
2655
+ return new I(p[0], p[1], p[2]);
2656
+ });
2657
+ } catch (g) {
2658
+ return console.error("NurbsArc: Error creating arc:", g), [];
2659
+ }
2660
+ }, [t, e, r, n, s, o, i]);
2661
+ return a.length === 0 ? null : /* @__PURE__ */ q.jsx(xt, { points: a, color: l, ...u });
2662
+ }, br = ({
2663
+ surface: t,
2664
+ countU: n = 10,
2665
+ countV: e = 10,
2666
+ color: r = "#666666",
2667
+ lineWidth: s = 1,
2668
+ resolution: o = 50
2669
+ }) => {
2670
+ const i = V(() => {
2671
+ if (!t) return [];
2672
+ const l = [];
2673
+ for (let u = 0; u <= n; u++) {
2674
+ const a = u / n;
2675
+ try {
2676
+ const g = t.isocurve(a, !1), f = Array.from({ length: o + 1 }, (c, h) => {
2677
+ const p = h / o, y = g.point(p);
2678
+ return new I(y[0], y[1], y[2]);
2679
+ });
2680
+ l.push({ points: f, key: `u-${u}` });
2681
+ } catch {
2682
+ }
2683
+ }
2684
+ for (let u = 0; u <= e; u++) {
2685
+ const a = u / e;
2686
+ try {
2687
+ const g = t.isocurve(a, !0), f = Array.from({ length: o + 1 }, (c, h) => {
2688
+ const p = h / o, y = g.point(p);
2689
+ return new I(y[0], y[1], y[2]);
2690
+ });
2691
+ l.push({ points: f, key: `v-${u}` });
2692
+ } catch {
2693
+ }
2694
+ }
2695
+ return l;
2696
+ }, [t, n, e, o]);
2697
+ return /* @__PURE__ */ q.jsx("group", { children: i.map((l) => /* @__PURE__ */ q.jsx(
2698
+ xt,
2699
+ {
2700
+ points: l.points,
2701
+ color: r,
2702
+ lineWidth: s
2703
+ },
2704
+ l.key
2705
+ )) });
2706
+ };
2707
+ function rr(t, n, e, r, s, o) {
2708
+ const i = t.point(0), l = t.point(1), u = n.point(0), a = n.point(1), g = (s + 1) * (o + 1), f = new Float32Array(g * 3), c = new Float32Array(g * 2);
2709
+ let h = 0, p = 0;
2710
+ for (let x = 0; x <= s; x++)
2711
+ for (let _ = 0; _ <= o; _++) {
2712
+ const b = x / s, P = _ / o, M = t.point(b), S = n.point(b), U = e.point(P), j = r.point(P);
2713
+ for (let k = 0; k < 3; k++) {
2714
+ const E = (1 - P) * M[k] + P * S[k], T = (1 - b) * U[k] + b * j[k], D = (1 - b) * (1 - P) * i[k] + b * (1 - P) * l[k] + (1 - b) * P * u[k] + b * P * a[k];
2715
+ f[h++] = E + T - D;
2716
+ }
2717
+ c[p++] = b, c[p++] = P;
2718
+ }
2719
+ const y = s * o * 6, d = new Uint32Array(y);
2720
+ let m = 0;
2721
+ for (let x = 0; x < s; x++)
2722
+ for (let _ = 0; _ < o; _++) {
2723
+ const b = x * (o + 1) + _, P = b + 1, M = (x + 1) * (o + 1) + _, S = M + 1;
2724
+ d[m++] = b, d[m++] = P, d[m++] = M, d[m++] = P, d[m++] = S, d[m++] = M;
2725
+ }
2726
+ const w = new pt();
2727
+ return w.setAttribute("position", new J(f, 3)), w.setAttribute("uv", new J(c, 2)), w.setIndex(Array.from(d)), w.computeVertexNormals(), w.computeBoundingSphere(), w;
2728
+ }
2729
+ const Pr = ie(function({
2730
+ resolutionU: n = 20,
2731
+ resolutionV: e = 20,
2732
+ color: r = "#ff0000",
2733
+ wireframe: s = !1,
2734
+ children: o,
2735
+ ...i
2736
+ }, l) {
2737
+ const { curveChildren: u, materialChild: a } = V(() => {
2738
+ const c = [];
2739
+ let h = null;
2740
+ const p = ht.toArray(o);
2741
+ for (const y of p)
2742
+ gt(y) && y.type === Mt ? c.push(y) : vt(y) && (h = y);
2743
+ return { curveChildren: c, materialChild: h };
2744
+ }, [o]), g = et(null), f = V(() => {
2745
+ if (u.length !== 4)
2746
+ return console.error("CoonsPatch requires exactly 4 NurbsCurve children (bottom, top, left, right)"), null;
2747
+ try {
2748
+ const c = u.map((p) => {
2749
+ const { points: y, degree: d = 3, weights: m, knots: w } = p.props, x = w ?? H(y.length, d);
2750
+ return B.byKnotsControlPointsWeights(
2751
+ d,
2752
+ x,
2753
+ y,
2754
+ m ?? Array(y.length).fill(1)
2755
+ );
2756
+ }), h = rr(
2757
+ c[0],
2758
+ c[1],
2759
+ c[2],
2760
+ c[3],
2761
+ n,
2762
+ e
2763
+ );
2764
+ return g.current && g.current !== h && g.current.dispose(), g.current = h, h;
2765
+ } catch (c) {
2766
+ return console.error("Error creating Coons patch:", c), null;
2767
+ }
2768
+ }, [u, n, e]);
2769
+ return f ? /* @__PURE__ */ q.jsx("mesh", { ref: l, ...i, geometry: f, children: a || /* @__PURE__ */ q.jsx("meshPhongMaterial", { color: r, wireframe: s, side: wt }) }) : null;
2770
+ }), Cr = ({
2771
+ sourcePoints: t,
2772
+ sourceDegree: n = 3,
2773
+ sourceKnots: e,
2774
+ sourceWeights: r,
2775
+ sourceCurve: s,
2776
+ distance: o,
2777
+ planeNormal: i = [0, 0, 1],
2778
+ samples: l = 50,
2779
+ degree: u = 3,
2780
+ resolution: a = 50,
2781
+ color: g = "black",
2782
+ ...f
2783
+ }) => {
2784
+ const c = V(() => {
2785
+ try {
2786
+ let h = s ?? null;
2787
+ if (!h && t && t.length >= 2) {
2788
+ const m = e ?? H(t.length, n);
2789
+ h = B.byKnotsControlPointsWeights(
2790
+ n,
2791
+ m,
2792
+ t,
2793
+ r ?? Array(t.length).fill(1)
2794
+ );
2795
+ }
2796
+ if (!h || o === 0) return [];
2797
+ const p = new I(...i).normalize(), y = [];
2798
+ for (let m = 0; m <= l; m++) {
2799
+ const w = m / l, x = h.point(w), _ = h.tangent(w), b = new I(_[0], _[1], _[2]).normalize(), P = new I().crossVectors(b, p).normalize();
2800
+ y.push([
2801
+ x[0] + P.x * o,
2802
+ x[1] + P.y * o,
2803
+ x[2] + P.z * o
2804
+ ]);
2805
+ }
2806
+ const d = B.byPoints(
2807
+ y,
2808
+ Math.min(u, y.length - 1)
2809
+ );
2810
+ return Array.from({ length: a + 1 }, (m, w) => {
2811
+ const x = w / a, _ = d.point(x);
2812
+ return new I(_[0], _[1], _[2]);
2813
+ });
2814
+ } catch (h) {
2815
+ return console.error("OffsetCurve: Error creating offset:", h), [];
2816
+ }
2817
+ }, [t, n, e, r, s, o, i, l, u, a]);
2818
+ return c.length === 0 ? null : /* @__PURE__ */ q.jsx(xt, { points: c, color: g, ...f });
2819
+ };
2820
+ function kr({
2821
+ points: t,
2822
+ degree: n = 3,
2823
+ weights: e,
2824
+ knots: r,
2825
+ resolution: s = 50
2826
+ }) {
2827
+ const o = V(() => {
2828
+ if (!t || t.length < 2) return null;
2829
+ try {
2830
+ const f = r ?? H(t.length, n), c = e ?? Array(t.length).fill(1);
2831
+ return B.byKnotsControlPointsWeights(
2832
+ n,
2833
+ f,
2834
+ t,
2835
+ c
2836
+ );
2837
+ } catch (f) {
2838
+ return console.error("useNurbsCurve: Error creating curve:", f), null;
2839
+ }
2840
+ }, [t, n, e, r]), i = V(() => o ? Array.from({ length: s + 1 }, (f, c) => {
2841
+ const h = c / s, p = o.point(h);
2842
+ return new I(p[0], p[1], p[2]);
2843
+ }) : [], [o, s]), l = it(
2844
+ (f) => {
2845
+ if (!o) return null;
2846
+ const c = o.point(f);
2847
+ return new I(c[0], c[1], c[2]);
2848
+ },
2849
+ [o]
2850
+ ), u = it(
2851
+ (f) => {
2852
+ if (!o) return null;
2853
+ try {
2854
+ const c = o.tangent(f);
2855
+ return new I(c[0], c[1], c[2]).normalize();
2856
+ } catch {
2857
+ return null;
2858
+ }
2859
+ },
2860
+ [o]
2861
+ ), a = it(() => {
2862
+ if (!o) return 0;
2863
+ try {
2864
+ return o.length();
2865
+ } catch {
2866
+ return 0;
2867
+ }
2868
+ }, [o]), g = it(
2869
+ (f) => {
2870
+ if (!o) return null;
2871
+ try {
2872
+ return o.closestParam([f.x, f.y, f.z]);
2873
+ } catch {
2874
+ return null;
2875
+ }
2876
+ },
2877
+ [o]
2878
+ );
2879
+ return {
2880
+ curve: o,
2881
+ points: i,
2882
+ point: l,
2883
+ tangent: u,
2884
+ length: a,
2885
+ closestParam: g
2886
+ };
2887
+ }
2888
+ function Mr({
2889
+ controlPoints: t,
2890
+ weights: n,
2891
+ degreeU: e,
2892
+ degreeV: r,
2893
+ knotsU: s,
2894
+ knotsV: o,
2895
+ resolutionU: i = 20,
2896
+ resolutionV: l = 20
2897
+ }) {
2898
+ const u = V(() => {
2899
+ if (!t || t.length === 0) return null;
2900
+ try {
2901
+ const h = s ?? H(t.length, e), p = o ?? H(t[0].length, r);
2902
+ return ut.byKnotsControlPointsWeights(
2903
+ e,
2904
+ r,
2905
+ h,
2906
+ p,
2907
+ t,
2908
+ n
2909
+ );
2910
+ } catch (h) {
2911
+ return console.error("useNurbsSurface: Error creating surface:", h), null;
2912
+ }
2913
+ }, [t, n, e, r, s, o]), a = V(() => {
2914
+ if (!u) return null;
2915
+ try {
2916
+ const h = (i + 1) * (l + 1), p = new Float32Array(h * 3), y = new Float32Array(h * 3), d = new Float32Array(h * 2);
2917
+ let m = 0, w = 0, x = 0;
2918
+ for (let M = 0; M <= i; M++)
2919
+ for (let S = 0; S <= l; S++) {
2920
+ const U = M / i, j = S / l, k = u.point(U, j);
2921
+ p[m++] = k[0], p[m++] = k[1], p[m++] = k[2];
2922
+ try {
2923
+ const E = u.normal(U, j), T = Math.sqrt(E[0] ** 2 + E[1] ** 2 + E[2] ** 2);
2924
+ T > 0 ? (y[w++] = E[0] / T, y[w++] = E[1] / T, y[w++] = E[2] / T) : (y[w++] = 0, y[w++] = 1, y[w++] = 0);
2925
+ } catch {
2926
+ y[w++] = 0, y[w++] = 1, y[w++] = 0;
2927
+ }
2928
+ d[x++] = U, d[x++] = j;
2929
+ }
2930
+ const _ = i * l * 6, b = new Uint32Array(_);
2931
+ let P = 0;
2932
+ for (let M = 0; M < i; M++)
2933
+ for (let S = 0; S < l; S++) {
2934
+ const U = M * (l + 1) + S, j = U + 1, k = (M + 1) * (l + 1) + S, E = k + 1;
2935
+ b[P++] = U, b[P++] = j, b[P++] = k, b[P++] = j, b[P++] = E, b[P++] = k;
2936
+ }
2937
+ return { vertices: p, normals: y, uvs: d, indices: b };
2938
+ } catch (h) {
2939
+ return console.error("useNurbsSurface: Error generating geometry:", h), null;
2940
+ }
2941
+ }, [u, i, l]), g = it(
2942
+ (h, p) => {
2943
+ if (!u) return null;
2944
+ const y = u.point(h, p);
2945
+ return new I(y[0], y[1], y[2]);
2946
+ },
2947
+ [u]
2948
+ ), f = it(
2949
+ (h, p) => {
2950
+ if (!u) return null;
2951
+ try {
2952
+ const y = u.normal(h, p);
2953
+ return new I(y[0], y[1], y[2]).normalize();
2954
+ } catch {
2955
+ return null;
2956
+ }
2957
+ },
2958
+ [u]
2959
+ ), c = it(
2960
+ (h) => {
2961
+ if (!u) return null;
2962
+ try {
2963
+ const p = u.closestParam([h.x, h.y, h.z]);
2964
+ return [p[0], p[1]];
2965
+ } catch {
2966
+ return null;
2967
+ }
2968
+ },
2969
+ [u]
2970
+ );
2971
+ return { surface: u, geometry: a, point: g, normal: f, closestParam: c };
2972
+ }
2973
+ function te(t) {
2974
+ return Array.isArray(t[0]) && Array.isArray(t[0][0]);
2975
+ }
2976
+ function or(t, n) {
2977
+ switch (t) {
2978
+ case "xy":
2979
+ return new I(0, 0, 1);
2980
+ case "xz":
2981
+ return new I(0, 1, 0);
2982
+ case "yz":
2983
+ return new I(1, 0, 0);
2984
+ case "screen":
2985
+ default:
2986
+ return n.clone().negate();
2987
+ }
2988
+ }
2989
+ function Ar({
2990
+ controlPoints: t,
2991
+ onControlPointChange: n,
2992
+ dragPlane: e = "screen"
2993
+ }) {
2994
+ const { camera: r } = vn(), [s, o] = hn(null), i = et(null), l = et(new dn()), u = et(new gn()), a = et(t), g = et(n), f = et(null), c = et(null);
2995
+ a.current = t, g.current = n;
2996
+ const h = it(
2997
+ (m, w) => {
2998
+ m.stopPropagation(), i.current = w, o(w);
2999
+ const x = m.point.clone(), _ = new I();
3000
+ r.getWorldDirection(_);
3001
+ const b = or(e, _);
3002
+ l.current.setFromNormalAndCoplanarPoint(b, x);
3003
+ },
3004
+ [r, e]
3005
+ ), p = it(
3006
+ (m) => {
3007
+ if (!i.current) return;
3008
+ m.stopPropagation();
3009
+ const x = m.ray ?? u.current.ray;
3010
+ if (m.ray === void 0) {
3011
+ const b = new pn(m.pointer.x, m.pointer.y);
3012
+ u.current.setFromCamera(b, r);
3013
+ }
3014
+ const _ = new I();
3015
+ x.intersectPlane(l.current, _) && (c.current = [_.x, _.y, _.z], f.current === null && (f.current = requestAnimationFrame(() => {
3016
+ f.current = null;
3017
+ const b = c.current, P = i.current;
3018
+ if (!b || !P) return;
3019
+ const M = a.current;
3020
+ if (te(M)) {
3021
+ const S = M.map((U) => U.map((j) => [...j]));
3022
+ S[P[0]][P[1]] = b, g.current(S, P);
3023
+ } else {
3024
+ const S = M.map((U) => [...U]);
3025
+ S[P[0]] = b, g.current(S, P);
3026
+ }
3027
+ })));
3028
+ },
3029
+ [r]
3030
+ ), y = it(() => {
3031
+ f.current !== null && (cancelAnimationFrame(f.current), f.current = null);
3032
+ const m = c.current, w = i.current;
3033
+ if (m && w) {
3034
+ const x = a.current;
3035
+ if (te(x)) {
3036
+ const _ = x.map((b) => b.map((P) => [...P]));
3037
+ _[w[0]][w[1]] = m, g.current(_, w);
3038
+ } else {
3039
+ const _ = x.map((b) => [...b]);
3040
+ _[w[0]] = m, g.current(_, w);
3041
+ }
3042
+ }
3043
+ c.current = null, i.current = null, o(null);
3044
+ }, []);
3045
+ return {
3046
+ handles: V(() => {
3047
+ const m = [];
3048
+ if (te(t))
3049
+ for (let w = 0; w < t.length; w++)
3050
+ for (let x = 0; x < t[w].length; x++) {
3051
+ const _ = t[w][x], b = [w, x];
3052
+ m.push({
3053
+ position: [_[0], _[1], _[2] ?? 0],
3054
+ index: b,
3055
+ bind: {
3056
+ onPointerDown: (P) => h(P, b)
3057
+ }
3058
+ });
3059
+ }
3060
+ else
3061
+ for (let w = 0; w < t.length; w++) {
3062
+ const x = t[w], _ = [w];
3063
+ m.push({
3064
+ position: [x[0], x[1], x[2] ?? 0],
3065
+ index: _,
3066
+ bind: {
3067
+ onPointerDown: (b) => h(b, _)
3068
+ }
3069
+ });
3070
+ }
3071
+ return m;
3072
+ }, [t, h]),
3073
+ isDragging: s !== null,
3074
+ activeIndex: s,
3075
+ dragBind: {
3076
+ onPointerMove: p,
3077
+ onPointerUp: y
3078
+ }
3079
+ };
3080
+ }
3081
+ function Sr({
3082
+ throughPoints: t,
3083
+ degree: n = 3,
3084
+ resolution: e = 50
3085
+ }) {
3086
+ const r = V(() => {
3087
+ if (!t || t.length < 2) return null;
3088
+ try {
3089
+ return B.byPoints(t, n);
3090
+ } catch (l) {
3091
+ return console.error("useInterpolatedCurve: Error creating curve:", l), null;
3092
+ }
3093
+ }, [t, n]), s = V(() => r ? Array.from({ length: e + 1 }, (l, u) => {
3094
+ const a = u / e, g = r.point(a);
3095
+ return new I(g[0], g[1], g[2]);
3096
+ }) : [], [r, e]), o = it(
3097
+ (l) => {
3098
+ if (!r) return null;
3099
+ const u = r.point(l);
3100
+ return new I(u[0], u[1], u[2]);
3101
+ },
3102
+ [r]
3103
+ ), i = it(
3104
+ (l) => {
3105
+ if (!r) return null;
3106
+ try {
3107
+ const u = r.tangent(l);
3108
+ return new I(u[0], u[1], u[2]).normalize();
3109
+ } catch {
3110
+ return null;
3111
+ }
3112
+ },
3113
+ [r]
3114
+ );
3115
+ return { curve: r, points: s, point: o, tangent: i };
3116
+ }
3117
+ function Er({
3118
+ curve: t,
3119
+ distance: n,
3120
+ planeNormal: e = [0, 0, 1],
3121
+ samples: r = 50,
3122
+ degree: s = 3,
3123
+ resolution: o = 50
3124
+ }) {
3125
+ const i = V(() => {
3126
+ if (!t || n === 0) return null;
3127
+ try {
3128
+ const u = new I(...e).normalize(), a = [];
3129
+ for (let g = 0; g <= r; g++) {
3130
+ const f = g / r, c = t.point(f), h = t.tangent(f), p = new I(h[0], h[1], h[2]).normalize(), y = new I().crossVectors(p, u).normalize();
3131
+ a.push([
3132
+ c[0] + y.x * n,
3133
+ c[1] + y.y * n,
3134
+ c[2] + y.z * n
3135
+ ]);
3136
+ }
3137
+ return B.byPoints(
3138
+ a,
3139
+ Math.min(s, a.length - 1)
3140
+ );
3141
+ } catch (u) {
3142
+ return console.error("useOffsetCurve: Error creating offset curve:", u), null;
3143
+ }
3144
+ }, [t, n, e, r, s]), l = V(() => i ? Array.from({ length: o + 1 }, (u, a) => {
3145
+ const g = a / o, f = i.point(g);
3146
+ return new I(f[0], f[1], f[2]);
3147
+ }) : [], [i, o]);
3148
+ return { curve: i, points: l };
3149
+ }
3150
+ function jr(t, n, e) {
3151
+ if (!t || t.length === 0)
3152
+ return "controlPoints must be a non-empty 3D array";
3153
+ const r = t[0].length;
3154
+ for (let s = 1; s < t.length; s++)
3155
+ if (t[s].length !== r)
3156
+ return `controlPoints row ${s} has length ${t[s].length}, expected ${r}`;
3157
+ if (t.length < n + 1)
3158
+ return `controlPoints has ${t.length} rows but degreeU=${n} requires at least ${n + 1}`;
3159
+ if (r < e + 1)
3160
+ return `controlPoints has ${r} columns but degreeV=${e} requires at least ${e + 1}`;
3161
+ for (let s = 0; s < t.length; s++)
3162
+ for (let o = 0; o < t[s].length; o++)
3163
+ if (!Array.isArray(t[s][o]) || t[s][o].length < 2)
3164
+ return `controlPoints[${s}][${o}] must be an array of at least 2 numbers`;
3165
+ return null;
3166
+ }
3167
+ function Rr(t, n, e, r = "knots") {
3168
+ const s = n + e + 1;
3169
+ if (t.length !== s)
3170
+ return `${r} has length ${t.length}, expected ${s} (numControlPoints=${n}, degree=${e})`;
3171
+ for (let o = 1; o < t.length; o++)
3172
+ if (t[o] < t[o - 1])
3173
+ return `${r} must be non-decreasing, but ${r}[${o}]=${t[o]} < ${r}[${o - 1}]=${t[o - 1]}`;
3174
+ return null;
3175
+ }
3176
+ function Tr(t, n) {
3177
+ if (!t || t.length === 0)
3178
+ return "weights must be a non-empty 2D array";
3179
+ if (t.length !== n.length)
3180
+ return `weights has ${t.length} rows, expected ${n.length} to match controlPoints`;
3181
+ for (let e = 0; e < t.length; e++)
3182
+ if (t[e].length !== n[e].length)
3183
+ return `weights[${e}] has length ${t[e].length}, expected ${n[e].length}`;
3184
+ return null;
3185
+ }
3186
+ function Dr(t, n) {
3187
+ return t.length !== n ? `weights has length ${t.length}, expected ${n}` : null;
3188
+ }
3189
+ function Ur(t, n, e = "degree") {
3190
+ return t < 1 ? `${e} must be >= 1, got ${t}` : t >= n ? `${e}=${t} must be < numControlPoints=${n}` : null;
3191
+ }
3192
+ function Fr(t, n) {
3193
+ const e = Lt(t.asData(), n);
3194
+ return new B(e);
3195
+ }
3196
+ function Ir(t, n, e) {
3197
+ const r = wn(t.asData(), n, e);
3198
+ return new ut(r);
3199
+ }
3200
+ function Or(t, n) {
3201
+ const e = je(t.asData(), n);
3202
+ return new B(e);
3203
+ }
3204
+ function Vr(t) {
3205
+ const n = t.map((r) => r.asData());
3206
+ return Re(n).map((r) => new B(r));
3207
+ }
817
3208
  export {
818
- Dr as LoftedSurface,
819
- jr as NurbsCurve,
820
- Fr as NurbsSurface
3209
+ Pr as CoonsPatch,
3210
+ pr as ExtrudedSurface,
3211
+ yr as InterpolatedCurve,
3212
+ wr as InterpolatedSurface,
3213
+ br as IsoCurves,
3214
+ hr as LoftedSurface,
3215
+ _r as NurbsArc,
3216
+ xr as NurbsCircle,
3217
+ Mt as NurbsCurve,
3218
+ De as NurbsSurface,
3219
+ Cr as OffsetCurve,
3220
+ gr as RevolvedSurface,
3221
+ mr as SurfaceIntersection,
3222
+ vr as SweptSurface,
3223
+ dr as TrimmedSurface,
3224
+ Un as adaptiveSampleNurbsCurve2D,
3225
+ rr as computeCoonsPatch,
3226
+ Dn as computeNormal,
3227
+ Or as curveElevateDegree,
3228
+ Fr as curveKnotRefine,
3229
+ H as generateUniformKnots,
3230
+ vt as isMaterialElement,
3231
+ Fn as projectCurveOntoSurface,
3232
+ Tn as projectPointToSurface,
3233
+ fr as projectPointToSurfaceUV,
3234
+ ur as sampleNurbsCurve2D,
3235
+ Ir as surfaceKnotRefine,
3236
+ Vr as unifyCurveKnots,
3237
+ Ar as useControlPointDrag,
3238
+ Sr as useInterpolatedCurve,
3239
+ nr as useInterpolatedSurface,
3240
+ kr as useNurbsCurve,
3241
+ Mr as useNurbsSurface,
3242
+ Er as useOffsetCurve,
3243
+ er as useSurfaceIntersection,
3244
+ jr as validateControlPoints,
3245
+ Ur as validateDegree,
3246
+ Rr as validateKnots,
3247
+ Dr as validateWeights1D,
3248
+ Tr as validateWeights2D
821
3249
  };