@wandelbots/wandelbots-js-react-components 6.4.0-pr.revamp.667.5d2eede → 6.4.0-pr.revamp.667.d7cab79

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 (56) hide show
  1. package/README.md +56 -5
  2. package/dist/3d.cjs +1 -1
  3. package/dist/3d.d.ts +1 -0
  4. package/dist/3d.js +16 -15
  5. package/dist/CurrentPoseBar/index.cjs +1 -1
  6. package/dist/CurrentPoseBar/index.js +1 -1
  7. package/dist/RobotControlPanel/index.cjs +1 -1
  8. package/dist/RobotControlPanel/index.js +1 -1
  9. package/dist/RobotHeader/index.js +1 -1
  10. package/dist/SafetyBar/index.js +1 -1
  11. package/dist/chunks/{CurrentPoseBar-zTZi68tY.js → CurrentPoseBar-DENCilvf.js} +1 -1
  12. package/dist/chunks/{CurrentPoseBar-CyHUWmjM.cjs → CurrentPoseBar-DrXTcV-I.cjs} +1 -1
  13. package/dist/chunks/{RobotControlPanel-BXtBHEe9.cjs → RobotControlPanel-DTE8-v2j.cjs} +1 -1
  14. package/dist/chunks/{RobotControlPanel-BiLexAWI.js → RobotControlPanel-E-hUzMIL.js} +1 -1
  15. package/dist/chunks/{RobotHeader-DDmDkUoV.js → RobotHeader-BvIzk8Fw.js} +1 -1
  16. package/dist/chunks/{SafetyBar-RkN0I1Cb.js → SafetyBar-eYzCHOFD.js} +1 -1
  17. package/dist/chunks/{converters-DAr6IQbG.js → converters-D9KpJ2HD.js} +2 -2
  18. package/dist/chunks/loadRobotSession-DlRzFjYE.cjs +3 -0
  19. package/dist/chunks/loadRobotSession-kKQ96rWu.js +4721 -0
  20. package/dist/chunks/robotModelSource-Bv1Z_miZ.cjs +1 -0
  21. package/dist/chunks/robotModelSource-CKuBOeQ-.js +1295 -0
  22. package/dist/chunks/useEveryFrame-B8t_yz-G.js +155 -0
  23. package/dist/chunks/useEveryFrame-CHxg25f4.cjs +1 -0
  24. package/dist/components/robotControl/poseText.d.ts +21 -5
  25. package/dist/components/robots/LinearAxis.d.ts +12 -11
  26. package/dist/components/robots/Robot.d.ts +26 -9
  27. package/dist/components/robots/robotModelSource.d.ts +38 -0
  28. package/dist/core.cjs +1 -1
  29. package/dist/core.d.ts +10 -0
  30. package/dist/core.js +58 -39
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.js +86 -66
  33. package/dist/lib/ConnectedMotionGroup.d.ts +5 -1
  34. package/dist/lib/controllerStateSource.d.ts +6 -4
  35. package/dist/lib/motionGroupModelResources.d.ts +1 -0
  36. package/dist/lib/nats/natsControllerStateSource.d.ts +27 -0
  37. package/dist/lib/robotSession/RobotActivation.d.ts +48 -0
  38. package/dist/lib/robotSession/RobotDescription.d.ts +84 -0
  39. package/dist/lib/robotSession/RobotLiveState.d.ts +56 -0
  40. package/dist/lib/robotSession/RobotLoadProgress.d.ts +72 -0
  41. package/dist/lib/robotSession/RobotSafety.d.ts +59 -0
  42. package/dist/lib/robotSession/RobotSession.d.ts +78 -0
  43. package/dist/lib/robotSession/RobotTargetPose.d.ts +78 -0
  44. package/dist/lib/robotSession/loadRobotResources.d.ts +46 -0
  45. package/dist/lib/robotSession/loadRobotSession.d.ts +81 -0
  46. package/dist/lib/robotSession/robotPose.d.ts +28 -0
  47. package/dist/nats.cjs +1 -0
  48. package/dist/nats.d.ts +4 -0
  49. package/dist/nats.js +131 -0
  50. package/package.json +11 -1
  51. package/dist/chunks/Robot-B3vKEVXP.cjs +0 -1
  52. package/dist/chunks/Robot-DXhaz1tq.js +0 -1272
  53. package/dist/chunks/TrajectoryExecutionStore-CKfEoKo8.cjs +0 -3
  54. package/dist/chunks/TrajectoryExecutionStore-DYVukgCz.js +0 -3613
  55. package/dist/chunks/useEveryFrame-G_-ma1nC.js +0 -142
  56. package/dist/chunks/useEveryFrame-dmPPTKtT.cjs +0 -1
@@ -0,0 +1,1295 @@
1
+ import { jsx as s, jsxs as T, Fragment as ft } from "react/jsx-runtime";
2
+ import * as R from "three";
3
+ import { Matrix4 as M, Vector3 as G, Quaternion as k } from "three";
4
+ import { ConvexGeometry as q, RoundedBoxGeometry as mt } from "three-stdlib";
5
+ import { Line as F, Environment as ht, Lightformer as x, useGLTF as dt } from "@react-three/drei";
6
+ import gt, { useMemo as L, forwardRef as H, useRef as v, useImperativeHandle as B, useEffect as P, useState as V, useCallback as A, Suspense as X } from "react";
7
+ import { d as yt, v as wt, o as Rt } from "./converters-D9KpJ2HD.js";
8
+ import { JointTypeEnum as I } from "@wandelbots/nova-js/v2";
9
+ import { e as E } from "./externalizeComponent-_w2d1_pz.js";
10
+ import { c as _t, b as Y, a as j, p as Mt } from "./Pose3-pocKPrHN.js";
11
+ import { ErrorBoundary as Z } from "react-error-boundary";
12
+ import { useThree as K } from "@react-three/fiber";
13
+ function bt(e) {
14
+ switch (e.shape_type) {
15
+ case "convex_hull":
16
+ return new q(
17
+ e.vertices.map(
18
+ (t) => new R.Vector3(
19
+ t[0] / 1e3,
20
+ t[1] / 1e3,
21
+ t[2] / 1e3
22
+ )
23
+ )
24
+ );
25
+ case "box":
26
+ return new R.BoxGeometry(
27
+ e.size_x / 1e3,
28
+ e.size_y / 1e3,
29
+ e.size_z / 1e3
30
+ );
31
+ case "sphere":
32
+ return new R.SphereGeometry(e.radius / 1e3);
33
+ case "capsule":
34
+ return new R.CapsuleGeometry(
35
+ e.radius / 1e3,
36
+ e.cylinder_height / 1e3
37
+ );
38
+ case "cylinder":
39
+ return new R.CylinderGeometry(
40
+ e.radius / 1e3,
41
+ e.radius / 1e3,
42
+ e.height / 1e3
43
+ );
44
+ case "rectangle":
45
+ return new R.BoxGeometry(e.size_x / 1e3, e.size_y / 1e3, 0);
46
+ default:
47
+ return console.warn(`${e.shape_type} is not supported`), new R.BufferGeometry();
48
+ }
49
+ }
50
+ function vt({
51
+ name: e,
52
+ collider: n,
53
+ children: t
54
+ }) {
55
+ var c, l;
56
+ const r = ((c = n.pose) == null ? void 0 : c.position) ?? [0, 0, 0], i = ((l = n.pose) == null ? void 0 : l.orientation) ?? [0, 0, 0];
57
+ return n.margin && console.warn(`${e} margin is not supported`), /* @__PURE__ */ s(
58
+ "mesh",
59
+ {
60
+ name: e,
61
+ position: new R.Vector3(
62
+ r[0],
63
+ r[1],
64
+ r[2]
65
+ ).divideScalar(1e3),
66
+ rotation: new R.Euler(i[0], i[1], i[2], "XYZ"),
67
+ geometry: bt(n.shape),
68
+ children: t
69
+ }
70
+ );
71
+ }
72
+ function Tt({
73
+ name: e,
74
+ colliders: n,
75
+ meshChildrenProvider: t,
76
+ ...r
77
+ }) {
78
+ return /* @__PURE__ */ s("group", { name: e, ...r, children: Object.entries(n).map(([i, c]) => /* @__PURE__ */ s(
79
+ vt,
80
+ {
81
+ name: i,
82
+ collider: c,
83
+ children: t(i, c)
84
+ },
85
+ i
86
+ )) });
87
+ }
88
+ function ae({
89
+ scene: e,
90
+ meshChildrenProvider: n
91
+ }) {
92
+ const t = e.colliders;
93
+ return /* @__PURE__ */ s("group", { children: t && /* @__PURE__ */ s(
94
+ Tt,
95
+ {
96
+ meshChildrenProvider: n,
97
+ colliders: t
98
+ }
99
+ ) });
100
+ }
101
+ function St(e) {
102
+ const n = (e == null ? void 0 : e.position) ?? [], t = (e == null ? void 0 : e.orientation) ?? [], r = new G(
103
+ t[0] ?? 0,
104
+ t[1] ?? 0,
105
+ t[2] ?? 0
106
+ ), i = r.length(), c = i > 0 ? new k().setFromAxisAngle(r.normalize(), i) : new k();
107
+ return new M().compose(
108
+ new G(
109
+ n[0] ?? 0,
110
+ n[1] ?? 0,
111
+ n[2] ?? 0
112
+ ).divideScalar(1e3),
113
+ c,
114
+ new G(1, 1, 1)
115
+ );
116
+ }
117
+ function Gt(e, n = null, t = []) {
118
+ const r = St(n);
119
+ return e.map((i, c) => {
120
+ const l = r.clone(), o = (i.reverse_rotation_direction ? -1 : 1) * (t[c] ?? 0), a = i.type === "PRISMATIC_JOINT", p = (i.theta ?? 0) + (a ? 0 : o), f = (i.d ?? 0) + (a ? o : 0);
121
+ return r.multiply(new M().makeRotationZ(p)).multiply(
122
+ new M().makeTranslation((i.a ?? 0) / 1e3, 0, f / 1e3)
123
+ ).multiply(new M().makeRotationX(i.alpha ?? 0)), l;
124
+ });
125
+ }
126
+ const J = "#ff4b4b", U = "#2fa8ff", Lt = "#8a8d9e", Ot = 96, xt = 0.15, Pt = new R.Vector3(0, 1, 0), At = 0.2, Et = 2;
127
+ function kt(e) {
128
+ const { lower_limit: n, upper_limit: t } = e ?? {};
129
+ return typeof n != "number" || typeof t != "number" || !Number.isFinite(n) || !Number.isFinite(t) || !(n < t) ? null : { lower_limit: n, upper_limit: t };
130
+ }
131
+ function D({
132
+ base: e,
133
+ direction: n,
134
+ size: t,
135
+ color: r,
136
+ opacity: i
137
+ }) {
138
+ const c = new R.Quaternion().setFromUnitVectors(
139
+ Pt,
140
+ n.clone().normalize()
141
+ ), l = e.clone().addScaledVector(n.clone().normalize(), t / 2);
142
+ return /* @__PURE__ */ T("mesh", { position: l, quaternion: c, renderOrder: 10, children: [
143
+ /* @__PURE__ */ s("coneGeometry", { args: [t * 0.35, t, 16] }),
144
+ /* @__PURE__ */ s(
145
+ "meshBasicMaterial",
146
+ {
147
+ color: r,
148
+ depthTest: !1,
149
+ transparent: !0,
150
+ opacity: i
151
+ }
152
+ )
153
+ ] });
154
+ }
155
+ function $({
156
+ points: e,
157
+ color: n,
158
+ width: t,
159
+ opacity: r
160
+ }) {
161
+ return /* @__PURE__ */ s(
162
+ F,
163
+ {
164
+ points: e,
165
+ color: n,
166
+ lineWidth: t,
167
+ depthTest: !1,
168
+ transparent: !0,
169
+ opacity: r,
170
+ renderOrder: 10
171
+ }
172
+ );
173
+ }
174
+ function W(e, n) {
175
+ const t = [...e];
176
+ let r = n;
177
+ for (; t.length > 1; ) {
178
+ const i = t[t.length - 1], c = t[t.length - 2], l = i.distanceTo(c);
179
+ if (l > r)
180
+ return t[t.length - 1] = i.clone().lerp(c, r / l), t;
181
+ r -= l, t.pop();
182
+ }
183
+ return t;
184
+ }
185
+ function It(e, n, t, r) {
186
+ const i = t * e, c = t * n, l = Math.abs(c - i), o = Math.max(
187
+ 2,
188
+ Math.ceil(l / (2 * Math.PI) * Ot)
189
+ );
190
+ return Array.from({ length: o + 1 }, (a, p) => {
191
+ const f = i + (c - i) * p / o, u = l * p / o / (2 * Math.PI), w = r * (1 + xt * u);
192
+ return new R.Vector3(
193
+ Math.cos(f) * w,
194
+ Math.sin(f) * w,
195
+ 0
196
+ );
197
+ });
198
+ }
199
+ function Ct(e, n, t, r) {
200
+ const i = e.theta ?? 0, c = e.d ?? 0, l = e.type === "PRISMATIC_JOINT", o = e.reverse_rotation_direction ? -1 : 1, { lower_limit: a, upper_limit: p } = n;
201
+ return L(() => {
202
+ const f = new R.Matrix4().makeRotationZ(i).multiply(
203
+ new R.Matrix4().makeTranslation(0, 0, l ? c / 1e3 : 0)
204
+ ), u = (b, S, O) => new R.Vector3(b, S, O).applyMatrix4(f), w = new R.Vector3().applyMatrix4(f), g = u(0, 0, t), h = (l ? [
205
+ u(t * 0.25, 0, o * a / 1e3),
206
+ u(t * 0.25, 0, o * p / 1e3)
207
+ ] : It(a, p, o, t * 0.6)).map((b) => l ? b : b.applyMatrix4(f)), m = u(l ? t * 0.25 : t * 0.6, 0, 0), _ = h.slice(1).reduce((b, S, O) => b + S.distanceTo(h[O]), 0), d = Math.min(r, _ / 3), y = W(
208
+ W(h, d).reverse(),
209
+ d
210
+ ).reverse();
211
+ return {
212
+ axisPoints: [w, g],
213
+ axisTip: g,
214
+ origin: w,
215
+ restPoints: [w, m],
216
+ range: h,
217
+ limitPoints: y,
218
+ rangeStart: y[0],
219
+ rangeEnd: y[y.length - 1]
220
+ };
221
+ }, [i, c, l, o, t, a, p, r]);
222
+ }
223
+ function Ft({
224
+ frame: e,
225
+ dh: n,
226
+ limit: t,
227
+ size: r,
228
+ emphasis: i
229
+ }) {
230
+ const c = i === "highlighted" ? Et : 1, l = i === "dimmed" ? At : 1, o = r * 0.2 * (i === "highlighted" ? 1.4 : 1), a = 2 * c, {
231
+ axisPoints: p,
232
+ axisTip: f,
233
+ origin: u,
234
+ restPoints: w,
235
+ range: g,
236
+ limitPoints: h,
237
+ rangeStart: m,
238
+ rangeEnd: _
239
+ } = Ct(n, t, r, o), { position: d, quaternion: y } = L(() => {
240
+ const b = new R.Vector3(), S = new R.Quaternion();
241
+ return e.decompose(b, S, new R.Vector3()), { position: b, quaternion: S };
242
+ }, [e]);
243
+ return /* @__PURE__ */ T("group", { position: d, quaternion: y, children: [
244
+ /* @__PURE__ */ s(
245
+ $,
246
+ {
247
+ points: p,
248
+ color: U,
249
+ width: a,
250
+ opacity: l
251
+ }
252
+ ),
253
+ /* @__PURE__ */ s(
254
+ D,
255
+ {
256
+ base: f,
257
+ direction: f.clone().sub(u),
258
+ size: o,
259
+ color: U,
260
+ opacity: l
261
+ }
262
+ ),
263
+ /* @__PURE__ */ s(
264
+ $,
265
+ {
266
+ points: w,
267
+ color: Lt,
268
+ width: 1.5 * c,
269
+ opacity: l
270
+ }
271
+ ),
272
+ /* @__PURE__ */ s(
273
+ $,
274
+ {
275
+ points: h,
276
+ color: J,
277
+ width: a,
278
+ opacity: l
279
+ }
280
+ ),
281
+ /* @__PURE__ */ s(
282
+ D,
283
+ {
284
+ base: m,
285
+ direction: g[0].clone().sub(m),
286
+ size: m.distanceTo(g[0]),
287
+ color: J,
288
+ opacity: l
289
+ }
290
+ ),
291
+ /* @__PURE__ */ s(
292
+ D,
293
+ {
294
+ base: _,
295
+ direction: g[g.length - 1].clone().sub(_),
296
+ size: _.distanceTo(g[g.length - 1]),
297
+ color: J,
298
+ opacity: l
299
+ }
300
+ )
301
+ ] });
302
+ }
303
+ function ce({
304
+ dhParameters: e,
305
+ chainOffset: n = null,
306
+ limits: t,
307
+ jointPositions: r,
308
+ size: i = 0.15,
309
+ highlightedJoint: c = null
310
+ }) {
311
+ const l = L(
312
+ () => Gt(e, n, r),
313
+ [e, n, r]
314
+ );
315
+ return /* @__PURE__ */ s("group", { children: l.map((o, a) => {
316
+ const p = kt(t[a]);
317
+ return p ? /* @__PURE__ */ s(
318
+ Ft,
319
+ {
320
+ frame: o,
321
+ dh: e[a],
322
+ limit: p,
323
+ size: i,
324
+ emphasis: c === null ? "normal" : c === a ? "highlighted" : "dimmed"
325
+ },
326
+ a
327
+ ) : null;
328
+ }) });
329
+ }
330
+ function le() {
331
+ return /* @__PURE__ */ s(ht, { frames: 1, children: /* @__PURE__ */ s(Nt, {}) });
332
+ }
333
+ const Vt = [2, 0, 2, 0, 2, 0, 2, 0];
334
+ function Nt({ positions: e = Vt }) {
335
+ return /* @__PURE__ */ T(ft, { children: [
336
+ /* @__PURE__ */ s(
337
+ x,
338
+ {
339
+ intensity: 5,
340
+ "rotation-x": Math.PI / 2,
341
+ position: [0, 5, -9],
342
+ scale: [10, 10, 1]
343
+ }
344
+ ),
345
+ /* @__PURE__ */ s("group", { rotation: [0, 0.5, 0], children: /* @__PURE__ */ s("group", { children: e.map((n, t) => /* @__PURE__ */ s(
346
+ x,
347
+ {
348
+ form: "circle",
349
+ intensity: 5,
350
+ rotation: [Math.PI / 2, 0, 0],
351
+ position: [n, 4, t * 4],
352
+ scale: [3, 1, 1]
353
+ },
354
+ t
355
+ )) }) }),
356
+ /* @__PURE__ */ s(
357
+ x,
358
+ {
359
+ intensity: 40,
360
+ "rotation-y": Math.PI / 2,
361
+ position: [-5, 1, -1],
362
+ scale: [20, 0.1, 1]
363
+ }
364
+ ),
365
+ /* @__PURE__ */ s(
366
+ x,
367
+ {
368
+ intensity: 20,
369
+ "rotation-y": -Math.PI,
370
+ position: [-5, -2, -1],
371
+ scale: [20, 0.1, 1]
372
+ }
373
+ ),
374
+ /* @__PURE__ */ s(
375
+ x,
376
+ {
377
+ "rotation-y": Math.PI / 2,
378
+ position: [-5, -1, -1],
379
+ scale: [20, 0.5, 1],
380
+ intensity: 5
381
+ }
382
+ ),
383
+ /* @__PURE__ */ s(
384
+ x,
385
+ {
386
+ "rotation-y": -Math.PI / 2,
387
+ position: [10, 1, 0],
388
+ scale: [20, 1, 1],
389
+ intensity: 10
390
+ }
391
+ ),
392
+ /* @__PURE__ */ s(
393
+ x,
394
+ {
395
+ form: "ring",
396
+ color: "white",
397
+ intensity: 5,
398
+ scale: 10,
399
+ position: [-15, 4, -18],
400
+ target: [0, 0, 0]
401
+ }
402
+ )
403
+ ] });
404
+ }
405
+ const Q = {
406
+ attach: "material",
407
+ color: "#009f4d",
408
+ opacity: 0.2,
409
+ depthTest: !1,
410
+ depthWrite: !1,
411
+ transparent: !0,
412
+ polygonOffset: !0
413
+ };
414
+ function ue({
415
+ safetyZones: e,
416
+ dhParameters: n,
417
+ ...t
418
+ }) {
419
+ const r = L(
420
+ () => yt(n ?? []),
421
+ [n]
422
+ ), i = (l, o) => {
423
+ var w, g;
424
+ if (!((w = o == null ? void 0 : o.pose) != null && w.position) || !((g = o == null ? void 0 : o.pose) != null && g.orientation))
425
+ return null;
426
+ const a = new R.Vector3(
427
+ o.pose.position[0] / 1e3,
428
+ o.pose.position[1] / 1e3,
429
+ o.pose.position[2] / 1e3
430
+ ), p = new R.Vector3(
431
+ o.pose.orientation[0],
432
+ o.pose.orientation[1],
433
+ o.pose.orientation[2]
434
+ );
435
+ let f;
436
+ const u = o.shape.shape_type === "plane" ? { ...Q, side: R.DoubleSide } : { ...Q, side: R.FrontSide };
437
+ switch (o.shape.shape_type) {
438
+ /**
439
+ * Plane shape, uses DH parameters to calculate the size of the plane (reach distance of a robot)
440
+ */
441
+ case "plane":
442
+ f = /* @__PURE__ */ s("planeGeometry", { args: [r, r] });
443
+ break;
444
+ /**
445
+ * Sphere shape
446
+ */
447
+ case "sphere": {
448
+ const h = (o == null ? void 0 : o.shape).radius / 1e3;
449
+ f = /* @__PURE__ */ s("sphereGeometry", { args: [h] });
450
+ break;
451
+ }
452
+ /**
453
+ * Capsule shape
454
+ */
455
+ case "capsule": {
456
+ const h = (o == null ? void 0 : o.shape).radius / 1e3, m = (o == null ? void 0 : o.shape).cylinder_height / 1e3;
457
+ f = /* @__PURE__ */ s("capsuleGeometry", { args: [h, m] });
458
+ break;
459
+ }
460
+ /**
461
+ * Convex hull, checks at first if the vertices are coplanar - if yes, adds a small offset for
462
+ * renderer to be able to visualize the convex hull.
463
+ */
464
+ case "convex_hull": {
465
+ const h = (o == null ? void 0 : o.shape).vertices.map(
466
+ (_) => new R.Vector3(_[0] / 1e3, _[1] / 1e3, _[2] / 1e3)
467
+ ), m = wt(h);
468
+ if (m.isCoplanar && m.normal) {
469
+ const d = new R.Vector3().addVectors(
470
+ h[0],
471
+ m.normal.multiplyScalar(1e-4)
472
+ );
473
+ h.push(d);
474
+ }
475
+ try {
476
+ f = /* @__PURE__ */ s(
477
+ "primitive",
478
+ {
479
+ object: new q(h),
480
+ attach: "geometry"
481
+ }
482
+ );
483
+ } catch (_) {
484
+ return console.log("Error creating ConvexGeometry:", _), null;
485
+ }
486
+ break;
487
+ }
488
+ /**
489
+ * Convex hull around four spheres. Sphere center points in x/y-plane,
490
+ * offset by either combination "+/- sizeX" or "+/- sizeY".
491
+ * Alternative description: Rectangle in x/y-plane with a 3D padding (source: nova-api docs)
492
+ *
493
+ * Basically a rounded box with a rectangular cross-section.
494
+ */
495
+ case "rectangular_capsule": {
496
+ const h = o.shape, m = h.radius / 1e3, _ = h.sphere_center_distance_x / 1e3, d = h.sphere_center_distance_y / 1e3, y = m * 2;
497
+ f = /* @__PURE__ */ s(
498
+ "primitive",
499
+ {
500
+ object: new mt(_, d, y, 2, m),
501
+ attach: "geometry"
502
+ }
503
+ );
504
+ break;
505
+ }
506
+ default:
507
+ console.warn(
508
+ "Unsupported safety zone shape type:",
509
+ o.shape.shape_type
510
+ ), f = null;
511
+ }
512
+ return /* @__PURE__ */ T(
513
+ "mesh",
514
+ {
515
+ renderOrder: l,
516
+ position: a,
517
+ quaternion: Rt(p),
518
+ children: [
519
+ f,
520
+ /* @__PURE__ */ s("meshStandardMaterial", { ...u, polygonOffsetFactor: -l })
521
+ ]
522
+ },
523
+ `safety-zone-${o.shape.shape_type}-${l}`
524
+ );
525
+ }, c = L(() => Object.values(e ?? {}).map(
526
+ (l, o) => i(o, l)
527
+ ), [e, r]);
528
+ return /* @__PURE__ */ s("group", { ...t, children: c });
529
+ }
530
+ function pe({
531
+ trajectory: e,
532
+ ...n
533
+ }) {
534
+ const t = (e == null ? void 0 : e.map((r) => {
535
+ if (r.position && r.position.length >= 3) {
536
+ const [i, c, l] = r.position;
537
+ if (Number.isFinite(i) && Number.isFinite(c) && Number.isFinite(l))
538
+ return new R.Vector3(i / 1e3, l / 1e3, -c / 1e3);
539
+ }
540
+ return null;
541
+ }).filter((r) => r !== null)) || [];
542
+ return /* @__PURE__ */ s("group", { ...n, children: t.length > 0 && /* @__PURE__ */ s(
543
+ F,
544
+ {
545
+ points: t,
546
+ lineWidth: 3,
547
+ polygonOffset: !0,
548
+ polygonOffsetFactor: 10,
549
+ polygonOffsetUnits: 10
550
+ }
551
+ ) });
552
+ }
553
+ const C = /* @__PURE__ */ new Map();
554
+ async function N(e, n) {
555
+ const t = n || "";
556
+ if (!t)
557
+ throw new Error(
558
+ `Cannot download the model "${e}": no NOVA instance. Give defaultGetModel the URL of the instance or a NOVA client, or give the component its instanceUrl or getModel.`
559
+ );
560
+ const r = `${Jt(t)} ${e}`, i = C.get(r);
561
+ if (i) return i;
562
+ const c = (async () => {
563
+ const l = _t(t);
564
+ try {
565
+ const o = await l.api.motionGroupModels.getMotionGroupGlbModel(
566
+ e,
567
+ { responseType: "blob" }
568
+ );
569
+ return URL.createObjectURL(o);
570
+ } catch (o) {
571
+ throw console.error("Failed to fetch model:", o), o;
572
+ }
573
+ })();
574
+ return C.set(r, c), c.catch(() => {
575
+ C.get(r) === c && C.delete(r);
576
+ }), c;
577
+ }
578
+ function Jt(e) {
579
+ return typeof e == "string" ? e : e.config.instanceUrl;
580
+ }
581
+ function z(e) {
582
+ function n(t) {
583
+ return t.children.length === 0 ? [t] : [t, ...t.children.flatMap((r) => n(r))];
584
+ }
585
+ return n(e).filter((t) => et(t));
586
+ }
587
+ function tt(e) {
588
+ return e.name.endsWith("_FLG");
589
+ }
590
+ function et(e) {
591
+ return /_J[0-9]+$/.test(e.name);
592
+ }
593
+ function Dt(e, n) {
594
+ let t;
595
+ function r(i) {
596
+ if (tt(i)) {
597
+ if (t)
598
+ throw Error(
599
+ `Found multiple flange groups in robot model ${n}; first ${t.name} then ${i.name}. Only one _FLG group is allowed.`
600
+ );
601
+ t = i;
602
+ }
603
+ et(i), i.children.map(r);
604
+ }
605
+ if (r(e.scene), !t)
606
+ throw Error(
607
+ `No flange group found in robot model ${n}. Flange must be identified with a name ending in _FLG.`
608
+ );
609
+ return { gltf: e };
610
+ }
611
+ const nt = H(function({
612
+ rapidlyChangingMotionState: n,
613
+ dhParameters: t,
614
+ chainOffsetPosition: r,
615
+ chainOffsetQuaternion: i,
616
+ onTranslationChanged: c,
617
+ children: l
618
+ }, o) {
619
+ const a = v(null), p = v([]), f = v(
620
+ n.joint_position.filter(
621
+ (d) => d !== void 0
622
+ )
623
+ ), { invalidate: u } = K(), w = v(n);
624
+ w.current = n;
625
+ function g(d) {
626
+ a.current = d, d && h();
627
+ }
628
+ function h() {
629
+ a.current && (p.current = z(a.current), m(), u());
630
+ }
631
+ B(o, () => ({ recollectJoints: h }));
632
+ function m() {
633
+ const d = f.current;
634
+ if (c)
635
+ c(p.current, d);
636
+ else
637
+ for (const [y, b] of p.current.entries()) {
638
+ const O = t[y].reverse_rotation_direction ? -1 : 1;
639
+ b.position.y = O * (d[y] || 0) / 1e3;
640
+ }
641
+ }
642
+ function _(d) {
643
+ f.current = d.joint_position.filter(
644
+ (y) => y !== void 0
645
+ ), m(), u();
646
+ }
647
+ return Y(() => {
648
+ _(w.current);
649
+ }), /* @__PURE__ */ s(
650
+ "group",
651
+ {
652
+ ref: g,
653
+ position: r,
654
+ quaternion: i,
655
+ children: l
656
+ }
657
+ );
658
+ });
659
+ function ot({
660
+ rapidlyChangingMotionState: e,
661
+ dhParameters: n,
662
+ ...t
663
+ }) {
664
+ const r = new M(), i = v(null), c = v(null);
665
+ function l(p) {
666
+ const f = new M();
667
+ for (let h = 0; h < n.length; h++) {
668
+ const m = n[h], _ = p[h] ?? 0, d = new M().makeRotationY(m.theta).multiply(
669
+ new M().makeTranslation(
670
+ m.a / 1e3,
671
+ (m.d + _ * (m.reverse_rotation_direction ? -1 : 1)) / 1e3,
672
+ 0
673
+ )
674
+ ).multiply(new M().makeRotationX(m.alpha));
675
+ f.multiply(d);
676
+ }
677
+ const u = new G(), w = new k(), g = new G();
678
+ return f.decompose(u, w, g), u;
679
+ }
680
+ const o = l(
681
+ e.joint_position
682
+ );
683
+ function a(p, f) {
684
+ r.identity();
685
+ let u = new G();
686
+ for (let m = 0; m < n.length; m++) {
687
+ const _ = f[m] ?? 0, d = n[m], y = new M().makeRotationY(d.theta).multiply(
688
+ new M().makeTranslation(
689
+ d.a / 1e3,
690
+ (d.d + _ * (d.reverse_rotation_direction ? -1 : 1)) / 1e3,
691
+ 0
692
+ )
693
+ ).multiply(new M().makeRotationX(d.alpha));
694
+ r.multiply(y);
695
+ }
696
+ const w = new G(), g = new k(), h = new G();
697
+ if (r.decompose(w, g, h), u = w, i.current && i.current.position.set(
698
+ u.x,
699
+ u.y,
700
+ u.z
701
+ ), c.current) {
702
+ const m = c.current.geometry;
703
+ m != null && m.setPositions && m.setPositions([
704
+ 0,
705
+ 0,
706
+ 0,
707
+ u.x,
708
+ u.y,
709
+ u.z
710
+ ]);
711
+ }
712
+ }
713
+ return /* @__PURE__ */ s(
714
+ nt,
715
+ {
716
+ rapidlyChangingMotionState: e,
717
+ dhParameters: n,
718
+ onTranslationChanged: a,
719
+ children: /* @__PURE__ */ T("group", { ...t, name: "Scene", children: [
720
+ /* @__PURE__ */ T("mesh", { name: "Base", position: [0, 0, 0], children: [
721
+ /* @__PURE__ */ s("sphereGeometry", { args: [0.02, 32, 32] }),
722
+ /* @__PURE__ */ s("meshStandardMaterial", { color: "green", depthTest: !0 })
723
+ ] }),
724
+ /* @__PURE__ */ s(
725
+ F,
726
+ {
727
+ ref: c,
728
+ points: [new G(0, 0, 0), o],
729
+ color: "White",
730
+ lineWidth: 5
731
+ }
732
+ ),
733
+ /* @__PURE__ */ T("mesh", { ref: i, name: "TCP", position: o, children: [
734
+ /* @__PURE__ */ s("sphereGeometry", { args: [0.025, 32, 32] }),
735
+ /* @__PURE__ */ s("meshStandardMaterial", { color: "red", depthTest: !0 })
736
+ ] })
737
+ ] })
738
+ }
739
+ );
740
+ }
741
+ const $t = console.warn;
742
+ function rt() {
743
+ return P(() => {
744
+ console.warn = (e) => {
745
+ e !== "Cannot call the manual advancement of rafz whilst frameLoop is not set as demand" && $t(e);
746
+ };
747
+ }, []), null;
748
+ }
749
+ function jt(e) {
750
+ return e.type === "Mesh";
751
+ }
752
+ function Ut({
753
+ url: e,
754
+ flangeRef: n,
755
+ postModelRender: t,
756
+ ...r
757
+ }) {
758
+ const i = dt(e), l = Dt(i, "robot.glb").gltf;
759
+ P(() => {
760
+ t == null || t();
761
+ }, [e, t]);
762
+ function o(a) {
763
+ try {
764
+ return jt(a) ? a.geometry ? /* @__PURE__ */ s(
765
+ "mesh",
766
+ {
767
+ name: a.name,
768
+ geometry: a.geometry,
769
+ material: a.material,
770
+ position: a.position,
771
+ rotation: a.rotation
772
+ },
773
+ a.uuid
774
+ ) : /* @__PURE__ */ s(
775
+ "group",
776
+ {
777
+ name: a.name,
778
+ position: a.position,
779
+ rotation: a.rotation
780
+ },
781
+ a.uuid
782
+ ) : /* @__PURE__ */ s(
783
+ "group",
784
+ {
785
+ name: a.name,
786
+ position: a.position,
787
+ rotation: a.rotation,
788
+ ref: tt(a) ? n : void 0,
789
+ children: a.children.map(o)
790
+ },
791
+ a.uuid
792
+ );
793
+ } catch (p) {
794
+ return console.warn("Error rendering node", a.name, p), null;
795
+ }
796
+ }
797
+ return /* @__PURE__ */ s("group", { ...r, dispose: null, children: o(l.scene) });
798
+ }
799
+ function it({
800
+ modelURL: e,
801
+ flangeRef: n,
802
+ postModelRender: t,
803
+ ...r
804
+ }) {
805
+ const [i, c] = V(null);
806
+ return P(() => {
807
+ let l = !1;
808
+ return (async () => {
809
+ try {
810
+ const a = typeof e == "string" ? e : await e;
811
+ l || c((p) => p === a ? p : a);
812
+ } catch (a) {
813
+ console.error("Failed to resolve model URL:", a);
814
+ }
815
+ })(), () => {
816
+ l = !0;
817
+ };
818
+ }, [e]), i ? /* @__PURE__ */ s(
819
+ Ut,
820
+ {
821
+ url: i,
822
+ flangeRef: n,
823
+ postModelRender: t,
824
+ ...r
825
+ }
826
+ ) : null;
827
+ }
828
+ const st = (e, n) => {
829
+ e.userData.isGhost || (e.traverse((t) => {
830
+ if (t instanceof R.Mesh) {
831
+ t.material instanceof R.Material && (t.material.colorWrite = !1);
832
+ const r = t.clone(), i = t.clone();
833
+ r.material = new R.MeshStandardMaterial({
834
+ depthTest: !0,
835
+ depthWrite: !0,
836
+ colorWrite: !1,
837
+ polygonOffset: !0,
838
+ polygonOffsetFactor: -1,
839
+ side: R.DoubleSide
840
+ }), r.userData.isGhost = !0, i.material = new R.MeshStandardMaterial({
841
+ color: n,
842
+ opacity: 0.3,
843
+ depthTest: !0,
844
+ depthWrite: !1,
845
+ transparent: !0,
846
+ polygonOffset: !0,
847
+ polygonOffsetFactor: -2,
848
+ side: R.DoubleSide
849
+ }), i.userData.isGhost = !0, t.parent && (t.parent.add(r), t.parent.add(i));
850
+ }
851
+ }), e.userData.isGhost = !0);
852
+ }, at = (e) => {
853
+ if (!e.userData.isGhost) return;
854
+ const n = [];
855
+ e.traverse((t) => {
856
+ var r;
857
+ t instanceof R.Mesh && ((r = t.userData) != null && r.isGhost ? n.push(t) : t.material instanceof R.Material && (t.material.colorWrite = !0));
858
+ }), n.forEach((t) => {
859
+ t.parent && t.parent.remove(t);
860
+ }), e.userData.isGhost = !1;
861
+ }, ct = E(
862
+ ({
863
+ rapidlyChangingMotionState: e,
864
+ modelFromController: n,
865
+ dhParameters: t,
866
+ chainOffsetPosition: r,
867
+ chainOffsetQuaternion: i,
868
+ getModel: c = N,
869
+ flangeRef: l,
870
+ postModelRender: o,
871
+ transparentColor: a,
872
+ instanceUrl: p,
873
+ ...f
874
+ }) => {
875
+ const [u, w] = V(null), g = v(null), h = A((y) => {
876
+ w(y);
877
+ }, []), m = A(() => {
878
+ var y;
879
+ (y = g.current) == null || y.recollectJoints(), o == null || o();
880
+ }, [o]);
881
+ P(() => {
882
+ u && (a ? st(u, a) : at(u));
883
+ }, [u, a]);
884
+ const _ = L(() => {
885
+ const y = c(n, p);
886
+ if (!y) {
887
+ const b = new Blob([], { type: "model/gltf-binary" }), S = new File([b], `${n}.glb`, {
888
+ type: "model/gltf-binary"
889
+ });
890
+ return Promise.resolve(URL.createObjectURL(S));
891
+ }
892
+ return y;
893
+ }, [n, p, c]), d = /* @__PURE__ */ s(
894
+ ot,
895
+ {
896
+ rapidlyChangingMotionState: e,
897
+ dhParameters: t,
898
+ ...f
899
+ }
900
+ );
901
+ return /* @__PURE__ */ T(
902
+ Z,
903
+ {
904
+ fallback: d,
905
+ onError: (y) => {
906
+ console.warn(y);
907
+ },
908
+ children: [
909
+ /* @__PURE__ */ s(X, { fallback: d, children: /* @__PURE__ */ s("group", { ref: h, children: /* @__PURE__ */ s(
910
+ nt,
911
+ {
912
+ ref: g,
913
+ rapidlyChangingMotionState: e,
914
+ dhParameters: t,
915
+ chainOffsetPosition: r,
916
+ chainOffsetQuaternion: i,
917
+ children: /* @__PURE__ */ s(
918
+ it,
919
+ {
920
+ modelURL: _,
921
+ postModelRender: m,
922
+ flangeRef: l,
923
+ ...f
924
+ }
925
+ )
926
+ }
927
+ ) }) }),
928
+ /* @__PURE__ */ s(rt, {})
929
+ ]
930
+ }
931
+ );
932
+ }
933
+ ), Wt = E(
934
+ ({ rapidlyChangingMotionState: e, ...n }) => {
935
+ const t = j(
936
+ e
937
+ );
938
+ return /* @__PURE__ */ s(
939
+ ct,
940
+ {
941
+ rapidlyChangingMotionState: t,
942
+ ...n
943
+ }
944
+ );
945
+ }
946
+ );
947
+ function fe({
948
+ motionGroup: e,
949
+ connectedMotionGroup: n,
950
+ getModel: t,
951
+ flangeRef: r,
952
+ transparentColor: i,
953
+ postModelRender: c,
954
+ ...l
955
+ }) {
956
+ const o = e ?? n, a = o == null ? void 0 : o.nova, p = A(
957
+ (g) => N(g, a),
958
+ [a]
959
+ ), f = t ?? p;
960
+ if (!(o != null && o.dhParameters))
961
+ return null;
962
+ const u = o.modelFromController || "";
963
+ return u ? /* @__PURE__ */ s(
964
+ Wt,
965
+ {
966
+ rapidlyChangingMotionState: o.rapidlyChangingMotionState,
967
+ modelFromController: u,
968
+ dhParameters: o.dhParameters,
969
+ getModel: f,
970
+ flangeRef: r,
971
+ transparentColor: i,
972
+ postModelRender: c,
973
+ chainOffsetPosition: o.mountingPosition,
974
+ chainOffsetQuaternion: o.mountingQuaternion,
975
+ ...l
976
+ }
977
+ ) : /* @__PURE__ */ s(
978
+ ot,
979
+ {
980
+ rapidlyChangingMotionState: o.rapidlyChangingMotionState,
981
+ dhParameters: o.dhParameters,
982
+ chainOffsetPosition: o.mountingPosition,
983
+ chainOffsetQuaternion: o.mountingQuaternion,
984
+ ...l
985
+ }
986
+ );
987
+ }
988
+ const lt = H(
989
+ function({
990
+ rapidlyChangingMotionState: n,
991
+ dhParameters: t,
992
+ chainOffsetPosition: r,
993
+ chainOffsetQuaternion: i,
994
+ onRotationChanged: c,
995
+ children: l
996
+ }, o) {
997
+ const a = v(null), p = v([]), f = v(
998
+ n.joint_position.filter(
999
+ (d) => d !== void 0
1000
+ )
1001
+ ), { invalidate: u } = K(), w = v(n);
1002
+ w.current = n;
1003
+ function g(d) {
1004
+ a.current = d, d && h();
1005
+ }
1006
+ function h() {
1007
+ a.current && (p.current = z(a.current), m(), u());
1008
+ }
1009
+ B(o, () => ({ recollectJoints: h }));
1010
+ function m() {
1011
+ const d = f.current;
1012
+ if (c)
1013
+ c(p.current, d);
1014
+ else
1015
+ for (const [y, b] of p.current.entries()) {
1016
+ const S = t[y], O = S.theta || 0, pt = S.reverse_rotation_direction ? -1 : 1;
1017
+ b.rotation.y = pt * (d[y] || 0) + O;
1018
+ }
1019
+ }
1020
+ function _(d) {
1021
+ f.current = d.joint_position.filter(
1022
+ (y) => y !== void 0
1023
+ ), m(), u();
1024
+ }
1025
+ return Y(() => {
1026
+ _(w.current);
1027
+ }), P(() => {
1028
+ _(n);
1029
+ }, [n]), /* @__PURE__ */ s(
1030
+ "group",
1031
+ {
1032
+ ref: g,
1033
+ position: r,
1034
+ quaternion: i,
1035
+ children: l
1036
+ }
1037
+ );
1038
+ }
1039
+ ), Qt = "line", qt = "mesh";
1040
+ function Ht({
1041
+ rapidlyChangingMotionState: e,
1042
+ dhParameters: n,
1043
+ ...t
1044
+ }) {
1045
+ const r = new M(), i = v([]), c = v([]);
1046
+ gt.useEffect(() => {
1047
+ i.current = new Array(n.length).fill(null), c.current = new Array(n.length).fill(null);
1048
+ }, [n.length]);
1049
+ function l(p, f) {
1050
+ const u = new G(), w = new k(), g = new G();
1051
+ r.decompose(u, w, g);
1052
+ const h = u.clone(), m = new M().makeRotationY(
1053
+ p.theta + f * (p.reverse_rotation_direction ? -1 : 1)
1054
+ ).multiply(new M().makeTranslation(0, p.d / 1e3, 0)).multiply(new M().makeTranslation(p.a / 1e3, 0, 0)).multiply(new M().makeRotationX(p.alpha));
1055
+ return r.multiply(m), r.decompose(u, w, g), { a: h, b: u };
1056
+ }
1057
+ function o(p, f, u, w) {
1058
+ if (!n)
1059
+ return;
1060
+ const g = n[p];
1061
+ if (!g)
1062
+ return;
1063
+ const { a: h, b: m } = l(g, w);
1064
+ f.geometry.setPositions([h.toArray(), m.toArray()].flat()), u.position.set(m.x, m.y, m.z);
1065
+ }
1066
+ function a(p, f) {
1067
+ r.identity();
1068
+ for (let u = 0; u < Math.min(p.length, f.length); u++) {
1069
+ const w = i.current[u], g = c.current[u];
1070
+ w && g && o(u, w, g, f[u]);
1071
+ }
1072
+ }
1073
+ return /* @__PURE__ */ s(
1074
+ lt,
1075
+ {
1076
+ rapidlyChangingMotionState: e,
1077
+ dhParameters: n,
1078
+ onRotationChanged: a,
1079
+ children: /* @__PURE__ */ T("group", { ...t, name: "Scene", children: [
1080
+ /* @__PURE__ */ T("mesh", { children: [
1081
+ /* @__PURE__ */ s("sphereGeometry", { args: [0.01, 32, 32] }),
1082
+ /* @__PURE__ */ s("meshStandardMaterial", { color: "black", depthTest: !0 })
1083
+ ] }),
1084
+ n == null ? void 0 : n.map((p, f) => {
1085
+ const { a: u, b: w } = l(
1086
+ p,
1087
+ e.joint_position[f] ?? 0
1088
+ ), g = `dhrobot_J0${f}`;
1089
+ return /* @__PURE__ */ T("group", { name: g, children: [
1090
+ /* @__PURE__ */ s(
1091
+ F,
1092
+ {
1093
+ ref: (h) => {
1094
+ i.current[f] = h;
1095
+ },
1096
+ name: Qt,
1097
+ points: [u, w],
1098
+ color: "white",
1099
+ lineWidth: 5
1100
+ }
1101
+ ),
1102
+ /* @__PURE__ */ T(
1103
+ "mesh",
1104
+ {
1105
+ ref: (h) => {
1106
+ c.current[f] = h;
1107
+ },
1108
+ name: qt,
1109
+ position: w,
1110
+ children: [
1111
+ /* @__PURE__ */ s("sphereGeometry", { args: [0.01, 32, 32] }),
1112
+ /* @__PURE__ */ s("meshStandardMaterial", { color: "black", depthTest: !0 })
1113
+ ]
1114
+ },
1115
+ `mesh_${f}`
1116
+ )
1117
+ ] }, g);
1118
+ })
1119
+ ] })
1120
+ }
1121
+ );
1122
+ }
1123
+ const ut = E(
1124
+ ({
1125
+ rapidlyChangingMotionState: e,
1126
+ modelFromController: n,
1127
+ dhParameters: t,
1128
+ chainOffsetPosition: r,
1129
+ chainOffsetQuaternion: i,
1130
+ getModel: c = N,
1131
+ flangeRef: l,
1132
+ postModelRender: o,
1133
+ transparentColor: a,
1134
+ instanceUrl: p,
1135
+ ...f
1136
+ }) => {
1137
+ const [u, w] = V(null), g = v(null), h = A((y) => {
1138
+ w(y);
1139
+ }, []), m = A(() => {
1140
+ var y;
1141
+ (y = g.current) == null || y.recollectJoints(), o == null || o();
1142
+ }, [o]);
1143
+ P(() => {
1144
+ u && (a ? st(u, a) : at(u));
1145
+ }, [u, a]);
1146
+ const _ = L(() => {
1147
+ const y = c(n, p);
1148
+ if (!y)
1149
+ throw new Error(
1150
+ `No model found for robot "${n}". Ensure the model is available or provide a custom getModel function.`
1151
+ );
1152
+ return y;
1153
+ }, [n, p, c]), d = /* @__PURE__ */ s(
1154
+ Ht,
1155
+ {
1156
+ rapidlyChangingMotionState: e,
1157
+ dhParameters: t,
1158
+ ...f
1159
+ }
1160
+ );
1161
+ return /* @__PURE__ */ T(
1162
+ Z,
1163
+ {
1164
+ fallback: d,
1165
+ onError: (y) => {
1166
+ console.warn(y);
1167
+ },
1168
+ children: [
1169
+ /* @__PURE__ */ s(X, { fallback: d, children: /* @__PURE__ */ s("group", { ref: h, children: /* @__PURE__ */ s(
1170
+ lt,
1171
+ {
1172
+ ref: g,
1173
+ rapidlyChangingMotionState: e,
1174
+ dhParameters: t,
1175
+ chainOffsetPosition: r,
1176
+ chainOffsetQuaternion: i,
1177
+ children: /* @__PURE__ */ s(
1178
+ it,
1179
+ {
1180
+ modelURL: _,
1181
+ postModelRender: m,
1182
+ flangeRef: l,
1183
+ ...f
1184
+ }
1185
+ )
1186
+ }
1187
+ ) }) }),
1188
+ /* @__PURE__ */ s(rt, {})
1189
+ ]
1190
+ }
1191
+ );
1192
+ }
1193
+ ), Bt = E(
1194
+ ({ rapidlyChangingMotionState: e, ...n }) => {
1195
+ const t = j(
1196
+ e
1197
+ );
1198
+ return /* @__PURE__ */ s(
1199
+ ut,
1200
+ {
1201
+ rapidlyChangingMotionState: t,
1202
+ ...n
1203
+ }
1204
+ );
1205
+ }
1206
+ ), Xt = E((e) => {
1207
+ const { inverseSolver: n, dhParameters: t, ...r } = e, [i, c] = V(
1208
+ I.RevoluteJoint
1209
+ );
1210
+ P(() => {
1211
+ t.length && c(t[0].type ?? I.RevoluteJoint);
1212
+ }, [t]);
1213
+ const l = L(() => n === null && i === I.RevoluteJoint, [n, i]), o = L(() => n === null && i === I.PrismaticJoint, [n, i]);
1214
+ return L(() => !!n, [n]) || l ? /* @__PURE__ */ s(ut, { dhParameters: t, ...r }) : o ? /* @__PURE__ */ s(ct, { dhParameters: t, ...r }) : null;
1215
+ }), me = E((e) => {
1216
+ const n = j(
1217
+ e.rapidlyChangingMotionState
1218
+ );
1219
+ return /* @__PURE__ */ s(
1220
+ Xt,
1221
+ {
1222
+ ...e,
1223
+ rapidlyChangingMotionState: n
1224
+ }
1225
+ );
1226
+ });
1227
+ function he({
1228
+ motionGroup: e,
1229
+ connectedMotionGroup: n,
1230
+ getModel: t,
1231
+ flangeRef: r,
1232
+ transparentColor: i,
1233
+ postModelRender: c,
1234
+ ...l
1235
+ }) {
1236
+ const o = e ?? n, a = o == null ? void 0 : o.nova, p = A(
1237
+ (f) => N(f, a),
1238
+ [a]
1239
+ );
1240
+ return o != null && o.dhParameters ? /* @__PURE__ */ s(
1241
+ Bt,
1242
+ {
1243
+ rapidlyChangingMotionState: o.rapidlyChangingMotionState,
1244
+ modelFromController: o.modelFromController || "",
1245
+ dhParameters: o.dhParameters,
1246
+ getModel: t ?? p,
1247
+ flangeRef: r,
1248
+ transparentColor: i,
1249
+ postModelRender: c,
1250
+ chainOffsetPosition: o.mountingPosition,
1251
+ chainOffsetQuaternion: o.mountingQuaternion,
1252
+ ...l
1253
+ }
1254
+ ) : null;
1255
+ }
1256
+ function de(e) {
1257
+ var i, c, l, o, a, p;
1258
+ const { description: n, state: t } = e, r = n.mounting;
1259
+ return {
1260
+ nova: e.nova,
1261
+ modelFromController: n.motionGroupModel,
1262
+ dhParameters: n.dhParameters,
1263
+ rapidlyChangingMotionState: t.rapidlyChangingMotionState,
1264
+ mountingPosition: [
1265
+ (((i = r == null ? void 0 : r.position) == null ? void 0 : i[0]) ?? 0) / 1e3,
1266
+ (((c = r == null ? void 0 : r.position) == null ? void 0 : c[1]) ?? 0) / 1e3,
1267
+ (((l = r == null ? void 0 : r.position) == null ? void 0 : l[2]) ?? 0) / 1e3
1268
+ ],
1269
+ mountingQuaternion: Mt(
1270
+ [
1271
+ ((o = r == null ? void 0 : r.orientation) == null ? void 0 : o[0]) ?? 0,
1272
+ ((a = r == null ? void 0 : r.orientation) == null ? void 0 : a[1]) ?? 0,
1273
+ ((p = r == null ? void 0 : r.orientation) == null ? void 0 : p[2]) ?? 0
1274
+ ],
1275
+ "ROTATION_VECTOR"
1276
+ )
1277
+ };
1278
+ }
1279
+ export {
1280
+ ae as C,
1281
+ ce as J,
1282
+ fe as L,
1283
+ me as M,
1284
+ le as P,
1285
+ he as R,
1286
+ ue as S,
1287
+ pe as T,
1288
+ Xt as a,
1289
+ Wt as b,
1290
+ ct as c,
1291
+ Bt as d,
1292
+ ut as e,
1293
+ N as f,
1294
+ de as r
1295
+ };