@wandelbots/wandelbots-js-react-components 4.7.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +11 -32
  2. package/dist/3d.cjs.js +1 -1
  3. package/dist/3d.es.js +1 -1
  4. package/dist/MotionGroupVisualizer-C6MgXjCN.cjs +2 -0
  5. package/dist/MotionGroupVisualizer-C6MgXjCN.cjs.map +1 -0
  6. package/dist/MotionGroupVisualizer-Cm-XYEZe.js +1328 -0
  7. package/dist/{MotionGroupVisualizer-DP4K1dVw.cjs.map → MotionGroupVisualizer-Cm-XYEZe.js.map} +1 -1
  8. package/dist/auth0-spa-js.production.esm-CVEdrQ4-.cjs +5 -0
  9. package/dist/auth0-spa-js.production.esm-CVEdrQ4-.cjs.map +1 -0
  10. package/dist/auth0-spa-js.production.esm-Cr9w0sUa.js +4217 -0
  11. package/dist/auth0-spa-js.production.esm-Cr9w0sUa.js.map +1 -0
  12. package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts +1 -1
  13. package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts.map +1 -1
  14. package/dist/components/3d-viewport/SafetyZonesRenderer.d.ts +1 -2
  15. package/dist/components/3d-viewport/SafetyZonesRenderer.d.ts.map +1 -1
  16. package/dist/components/3d-viewport/TrajectoryRenderer.d.ts +2 -2
  17. package/dist/components/3d-viewport/TrajectoryRenderer.d.ts.map +1 -1
  18. package/dist/components/3d-viewport/collider/ColliderCollection.d.ts +1 -1
  19. package/dist/components/3d-viewport/collider/ColliderElement.d.ts +1 -1
  20. package/dist/components/3d-viewport/collider/CollisionSceneRenderer.d.ts +2 -2
  21. package/dist/components/3d-viewport/collider/colliderShapeToBufferGeometry.d.ts +1 -1
  22. package/dist/core.cjs.js +1 -1
  23. package/dist/core.es.js +37 -39
  24. package/dist/core.es.js.map +1 -1
  25. package/dist/index.cjs.js +1 -1
  26. package/dist/index.d.ts +0 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.es.js +51 -55
  29. package/dist/index.es.js.map +1 -1
  30. package/dist/interpolation-GwZidExa.cjs +42 -0
  31. package/dist/interpolation-GwZidExa.cjs.map +1 -0
  32. package/dist/{interpolation-B8AcxfdD.js → interpolation-JdOMWH6y.js} +3635 -3115
  33. package/dist/interpolation-JdOMWH6y.js.map +1 -0
  34. package/dist/lib/ConnectedMotionGroup.d.ts +2 -3
  35. package/dist/lib/ConnectedMotionGroup.d.ts.map +1 -1
  36. package/dist/lib/MotionStreamConnection.d.ts +0 -1
  37. package/dist/lib/MotionStreamConnection.d.ts.map +1 -1
  38. package/dist/themes/createDarkTheme.d.ts.map +1 -1
  39. package/dist/themes/themeTypes.d.ts +0 -4
  40. package/dist/themes/themeTypes.d.ts.map +1 -1
  41. package/dist/{theming-BKpqgTRM.js → theming-B1iO9Lkl.js} +3104 -3062
  42. package/dist/theming-B1iO9Lkl.js.map +1 -0
  43. package/dist/theming-BKsKrdpU.cjs +115 -0
  44. package/dist/theming-BKsKrdpU.cjs.map +1 -0
  45. package/package.json +15 -29
  46. package/src/components/3d-viewport/CoordinateSystemTransform.tsx +29 -18
  47. package/src/components/3d-viewport/SafetyZonesRenderer.tsx +24 -151
  48. package/src/components/3d-viewport/TrajectoryRenderer.tsx +9 -10
  49. package/src/components/3d-viewport/collider/ColliderCollection.tsx +1 -1
  50. package/src/components/3d-viewport/collider/ColliderElement.tsx +1 -1
  51. package/src/components/3d-viewport/collider/CollisionSceneRenderer.tsx +2 -2
  52. package/src/components/3d-viewport/collider/colliderShapeToBufferGeometry.ts +1 -1
  53. package/src/index.ts +0 -1
  54. package/src/lib/ConnectedMotionGroup.ts +0 -5
  55. package/src/lib/MotionStreamConnection.ts +0 -5
  56. package/src/themes/createDarkTheme.ts +1 -22
  57. package/src/themes/themeTypes.ts +0 -5
  58. package/dist/LoadingCover-B3UN1lnU.js +0 -81
  59. package/dist/LoadingCover-B3UN1lnU.js.map +0 -1
  60. package/dist/LoadingCover-DXcsXWDy.cjs +0 -2
  61. package/dist/LoadingCover-DXcsXWDy.cjs.map +0 -1
  62. package/dist/MotionGroupVisualizer-CPEIGXUC.js +0 -1407
  63. package/dist/MotionGroupVisualizer-CPEIGXUC.js.map +0 -1
  64. package/dist/MotionGroupVisualizer-DP4K1dVw.cjs +0 -2
  65. package/dist/WandelscriptEditor-6sAoniLC.cjs +0 -2
  66. package/dist/WandelscriptEditor-6sAoniLC.cjs.map +0 -1
  67. package/dist/WandelscriptEditor-kWC2VyG_.js +0 -140
  68. package/dist/WandelscriptEditor-kWC2VyG_.js.map +0 -1
  69. package/dist/auth0-spa-js.production.esm-DNao6_S5.js +0 -4064
  70. package/dist/auth0-spa-js.production.esm-DNao6_S5.js.map +0 -1
  71. package/dist/auth0-spa-js.production.esm-DaBMfOV8.cjs +0 -5
  72. package/dist/auth0-spa-js.production.esm-DaBMfOV8.cjs.map +0 -1
  73. package/dist/components/wandelscript-editor/WandelscriptEditor.d.ts +0 -16
  74. package/dist/components/wandelscript-editor/WandelscriptEditor.d.ts.map +0 -1
  75. package/dist/components/wandelscript-editor/wandelscript.tmLanguage.d.ts +0 -45
  76. package/dist/components/wandelscript-editor/wandelscript.tmLanguage.d.ts.map +0 -1
  77. package/dist/externalizeComponent-B98tgTPP.cjs +0 -24
  78. package/dist/externalizeComponent-B98tgTPP.cjs.map +0 -1
  79. package/dist/externalizeComponent-BOqKMZMc.js +0 -526
  80. package/dist/externalizeComponent-BOqKMZMc.js.map +0 -1
  81. package/dist/interpolation-B8AcxfdD.js.map +0 -1
  82. package/dist/interpolation-SWzo5zr4.cjs +0 -20
  83. package/dist/interpolation-SWzo5zr4.cjs.map +0 -1
  84. package/dist/theming-BKpqgTRM.js.map +0 -1
  85. package/dist/theming-CatQaIl_.cjs +0 -115
  86. package/dist/theming-CatQaIl_.cjs.map +0 -1
  87. package/dist/wandelscript.cjs.js +0 -2
  88. package/dist/wandelscript.cjs.js.map +0 -1
  89. package/dist/wandelscript.d.ts +0 -2
  90. package/dist/wandelscript.d.ts.map +0 -1
  91. package/dist/wandelscript.es.js +0 -5
  92. package/dist/wandelscript.es.js.map +0 -1
  93. package/src/components/wandelscript-editor/WandelscriptEditor.tsx +0 -142
  94. package/src/components/wandelscript-editor/wandelscript.tmLanguage.ts +0 -62
  95. package/src/wandelscript.ts +0 -2
@@ -0,0 +1,1328 @@
1
+ import { j as e, g as Me, v as _e, o as Te, N as ke, V as re, c as se, h as U, b as X, M as v, J as O } from "./interpolation-JdOMWH6y.js";
2
+ import * as g from "three";
3
+ import { Matrix4 as w, Vector3 as k, Quaternion as J } from "three";
4
+ import { ConvexGeometry as oe, RoundedBoxGeometry as Fe } from "three-stdlib";
5
+ import Ge, { useMemo as V, useRef as R, useEffect as M, useCallback as T, useState as F, Suspense as ie } from "react";
6
+ import { useThree as ae, useFrame as le, Canvas as K } from "@react-three/fiber";
7
+ import { Environment as Le, Lightformer as L, Line as B, useGLTF as Se, Bounds as Z } from "@react-three/drei";
8
+ import { useTheme as Pe, Card as Ae, Box as b, Typography as Q, Divider as z, Button as ee } from "@mui/material";
9
+ import { observer as Ie } from "mobx-react-lite";
10
+ import { useTranslation as De } from "react-i18next";
11
+ import { ErrorBoundary as ce } from "react-error-boundary";
12
+ function Oe(t) {
13
+ switch (t.shape_type) {
14
+ case "convex_hull":
15
+ return new oe(
16
+ t.vertices.map(
17
+ (n) => new g.Vector3(
18
+ n[0] / 1e3,
19
+ n[1] / 1e3,
20
+ n[2] / 1e3
21
+ )
22
+ )
23
+ );
24
+ case "box":
25
+ return new g.BoxGeometry(
26
+ t.size_x / 1e3,
27
+ t.size_y / 1e3,
28
+ t.size_z / 1e3
29
+ );
30
+ case "sphere":
31
+ return new g.SphereGeometry(t.radius / 1e3);
32
+ case "capsule":
33
+ return new g.CapsuleGeometry(
34
+ t.radius / 1e3,
35
+ t.cylinder_height / 1e3
36
+ );
37
+ case "cylinder":
38
+ return new g.CylinderGeometry(
39
+ t.radius / 1e3,
40
+ t.radius / 1e3,
41
+ t.height / 1e3
42
+ );
43
+ case "rectangle":
44
+ return new g.BoxGeometry(t.size_x / 1e3, t.size_y / 1e3, 0);
45
+ default:
46
+ return console.warn(`${t.shape_type} is not supported`), new g.BufferGeometry();
47
+ }
48
+ }
49
+ function Ve({
50
+ name: t,
51
+ collider: s,
52
+ children: n
53
+ }) {
54
+ var u, c;
55
+ const a = ((u = s.pose) == null ? void 0 : u.position) ?? [0, 0, 0], i = ((c = s.pose) == null ? void 0 : c.orientation) ?? [0, 0, 0];
56
+ return s.margin && console.warn(`${t} margin is not supported`), /* @__PURE__ */ e.jsx(
57
+ "mesh",
58
+ {
59
+ name: t,
60
+ position: new g.Vector3(
61
+ a[0],
62
+ a[1],
63
+ a[2]
64
+ ).divideScalar(1e3),
65
+ rotation: new g.Euler(i[0], i[1], i[2], "XYZ"),
66
+ geometry: Oe(s.shape),
67
+ children: n
68
+ }
69
+ );
70
+ }
71
+ function Ue({
72
+ name: t,
73
+ colliders: s,
74
+ meshChildrenProvider: n,
75
+ ...a
76
+ }) {
77
+ return /* @__PURE__ */ e.jsx("group", { name: t, ...a, children: Object.entries(s).map(([i, u]) => /* @__PURE__ */ e.jsx(
78
+ Ve,
79
+ {
80
+ name: i,
81
+ collider: u,
82
+ children: n(i, u)
83
+ },
84
+ i
85
+ )) });
86
+ }
87
+ function it({
88
+ scene: t,
89
+ meshChildrenProvider: s
90
+ }) {
91
+ const n = t.colliders;
92
+ return /* @__PURE__ */ e.jsx("group", { children: n && /* @__PURE__ */ e.jsx(
93
+ Ue,
94
+ {
95
+ meshChildrenProvider: s,
96
+ colliders: n
97
+ }
98
+ ) });
99
+ }
100
+ function te() {
101
+ return /* @__PURE__ */ e.jsx(Le, { children: /* @__PURE__ */ e.jsx(Ce, {}) });
102
+ }
103
+ function Ce({ positions: t = [2, 0, 2, 0, 2, 0, 2, 0] }) {
104
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
105
+ /* @__PURE__ */ e.jsx(
106
+ L,
107
+ {
108
+ intensity: 5,
109
+ "rotation-x": Math.PI / 2,
110
+ position: [0, 5, -9],
111
+ scale: [10, 10, 1]
112
+ }
113
+ ),
114
+ /* @__PURE__ */ e.jsx("group", { rotation: [0, 0.5, 0], children: /* @__PURE__ */ e.jsx("group", { children: t.map((s, n) => /* @__PURE__ */ e.jsx(
115
+ L,
116
+ {
117
+ form: "circle",
118
+ intensity: 5,
119
+ rotation: [Math.PI / 2, 0, 0],
120
+ position: [s, 4, n * 4],
121
+ scale: [3, 1, 1]
122
+ },
123
+ n
124
+ )) }) }),
125
+ /* @__PURE__ */ e.jsx(
126
+ L,
127
+ {
128
+ intensity: 40,
129
+ "rotation-y": Math.PI / 2,
130
+ position: [-5, 1, -1],
131
+ scale: [20, 0.1, 1]
132
+ }
133
+ ),
134
+ /* @__PURE__ */ e.jsx(
135
+ L,
136
+ {
137
+ intensity: 20,
138
+ "rotation-y": -Math.PI,
139
+ position: [-5, -2, -1],
140
+ scale: [20, 0.1, 1]
141
+ }
142
+ ),
143
+ /* @__PURE__ */ e.jsx(
144
+ L,
145
+ {
146
+ "rotation-y": Math.PI / 2,
147
+ position: [-5, -1, -1],
148
+ scale: [20, 0.5, 1],
149
+ intensity: 5
150
+ }
151
+ ),
152
+ /* @__PURE__ */ e.jsx(
153
+ L,
154
+ {
155
+ "rotation-y": -Math.PI / 2,
156
+ position: [10, 1, 0],
157
+ scale: [20, 1, 1],
158
+ intensity: 10
159
+ }
160
+ ),
161
+ /* @__PURE__ */ e.jsx(
162
+ L,
163
+ {
164
+ form: "ring",
165
+ color: "white",
166
+ intensity: 5,
167
+ scale: 10,
168
+ position: [-15, 4, -18],
169
+ target: [0, 0, 0]
170
+ }
171
+ )
172
+ ] });
173
+ }
174
+ function at({
175
+ safetyZones: t,
176
+ dhParameters: s,
177
+ ...n
178
+ }) {
179
+ const a = {
180
+ attach: "material",
181
+ color: "#009f4d",
182
+ opacity: 0.2,
183
+ depthTest: !1,
184
+ depthWrite: !1,
185
+ transparent: !0,
186
+ polygonOffset: !0
187
+ }, i = Me(s ?? []), u = (f, r) => {
188
+ var d, x;
189
+ if (!((d = r == null ? void 0 : r.pose) != null && d.position) || !((x = r == null ? void 0 : r.pose) != null && x.orientation))
190
+ return null;
191
+ const h = new g.Vector3(r.pose.position[0] / 1e3, r.pose.position[1] / 1e3, r.pose.position[2] / 1e3), m = new g.Vector3(r.pose.orientation[0], r.pose.orientation[1], r.pose.orientation[2]);
192
+ let o;
193
+ const l = r.shape.shape_type === "plane" ? { ...a, side: g.DoubleSide } : { ...a, side: g.FrontSide };
194
+ switch (r.shape.shape_type) {
195
+ /**
196
+ * Plane shape, uses DH parameters to calculate the size of the plane (reach distance of a robot)
197
+ */
198
+ case "plane":
199
+ o = /* @__PURE__ */ e.jsx("planeGeometry", { args: [i, i] });
200
+ break;
201
+ /**
202
+ * Sphere shape
203
+ */
204
+ case "sphere": {
205
+ const p = (r == null ? void 0 : r.shape).radius / 1e3;
206
+ o = /* @__PURE__ */ e.jsx("sphereGeometry", { args: [p] });
207
+ break;
208
+ }
209
+ /**
210
+ * Capsule shape
211
+ */
212
+ case "capsule": {
213
+ const p = (r == null ? void 0 : r.shape).radius / 1e3, j = (r == null ? void 0 : r.shape).cylinder_height / 1e3;
214
+ o = /* @__PURE__ */ e.jsx("capsuleGeometry", { args: [p, j] });
215
+ break;
216
+ }
217
+ /**
218
+ * Convex hull, checks at first if the vertices are coplanar - if yes, adds a small offset for
219
+ * renderer to be able to visualize the convex hull.
220
+ */
221
+ case "convex_hull": {
222
+ const p = (r == null ? void 0 : r.shape).vertices.map(
223
+ (y) => new g.Vector3(y[0] / 1e3, y[1] / 1e3, y[2] / 1e3)
224
+ ), j = _e(p);
225
+ if (j.isCoplanar && j.normal) {
226
+ const G = new g.Vector3().addVectors(
227
+ p[0],
228
+ j.normal.multiplyScalar(1e-4)
229
+ );
230
+ p.push(G);
231
+ }
232
+ try {
233
+ o = /* @__PURE__ */ e.jsx("primitive", { object: new oe(p), attach: "geometry" });
234
+ } catch (y) {
235
+ return console.log("Error creating ConvexGeometry:", y), null;
236
+ }
237
+ break;
238
+ }
239
+ /**
240
+ * Convex hull around four spheres. Sphere center points in x/y-plane,
241
+ * offset by either combination "+/- sizeX" or "+/- sizeY".
242
+ * Alternative description: Rectangle in x/y-plane with a 3D padding (source: nova-api docs)
243
+ *
244
+ * Basically a rounded box with a rectangular cross-section.
245
+ */
246
+ case "rectangular_capsule": {
247
+ const p = r.shape, j = p.radius / 1e3, y = p.sphere_center_distance_x / 1e3, G = p.sphere_center_distance_y / 1e3, S = j * 2;
248
+ o = /* @__PURE__ */ e.jsx(
249
+ "primitive",
250
+ {
251
+ object: new Fe(y, G, S, 2, j),
252
+ attach: "geometry"
253
+ }
254
+ );
255
+ break;
256
+ }
257
+ default:
258
+ console.warn("Unsupported safety zone shape type:", r.shape.shape_type), o = null;
259
+ }
260
+ return /* @__PURE__ */ e.jsxs(
261
+ "mesh",
262
+ {
263
+ renderOrder: f,
264
+ position: h,
265
+ quaternion: Te(m),
266
+ children: [
267
+ o,
268
+ /* @__PURE__ */ e.jsx("meshStandardMaterial", { ...l, polygonOffsetFactor: -f })
269
+ ]
270
+ },
271
+ `safety-zone-${r.shape.shape_type}-${f}`
272
+ );
273
+ }, c = V(() => Object.values(t ?? {}).map((f, r) => u(r, f)), [t, i]);
274
+ return /* @__PURE__ */ e.jsx("group", { ...n, children: c });
275
+ }
276
+ function lt({
277
+ trajectory: t,
278
+ ...s
279
+ }) {
280
+ const n = (t == null ? void 0 : t.map((a) => {
281
+ if (a.position && a.position.length >= 3) {
282
+ const [i, u, c] = a.position;
283
+ if (isFinite(i) && isFinite(u) && isFinite(c))
284
+ return new g.Vector3(i / 1e3, c / 1e3, -u / 1e3);
285
+ }
286
+ return null;
287
+ }).filter((a) => a !== null)) || [];
288
+ return /* @__PURE__ */ e.jsx("group", { ...s, children: n.length > 0 && /* @__PURE__ */ e.jsx(
289
+ B,
290
+ {
291
+ points: n,
292
+ lineWidth: 3,
293
+ polygonOffset: !0,
294
+ polygonOffsetFactor: 10,
295
+ polygonOffsetUnits: 10
296
+ }
297
+ ) });
298
+ }
299
+ const E = /* @__PURE__ */ new Map();
300
+ async function C(t, s) {
301
+ if (E.has(t))
302
+ return E.get(t);
303
+ const n = (async () => {
304
+ var c;
305
+ const a = s || "", i = new ke({ instanceUrl: a }), u = i.api.motionGroupModels;
306
+ (c = u.axios) != null && c.interceptors && u.axios.interceptors.request.use((f) => {
307
+ var r;
308
+ return (r = f.url) != null && r.includes("/glb") && (f.responseType = "blob"), f;
309
+ });
310
+ try {
311
+ const f = await i.api.motionGroupModels.getMotionGroupGlbModel(t);
312
+ return URL.createObjectURL(f);
313
+ } catch (f) {
314
+ throw console.error("Failed to fetch model:", f), f;
315
+ }
316
+ })();
317
+ return E.set(t, n), n;
318
+ }
319
+ function ue(t) {
320
+ function s(n) {
321
+ return n.children.length === 0 ? [n] : [n, ...n.children.flatMap((a) => s(a))];
322
+ }
323
+ return s(t).filter((n) => pe(n));
324
+ }
325
+ function de(t) {
326
+ return t.name.endsWith("_FLG");
327
+ }
328
+ function pe(t) {
329
+ return /_J[0-9]+$/.test(t.name);
330
+ }
331
+ function Ee(t, s) {
332
+ let n;
333
+ function a(i) {
334
+ if (de(i)) {
335
+ if (n)
336
+ throw Error(
337
+ `Found multiple flange groups in robot model ${s}; first ${n.name} then ${i.name}. Only one _FLG group is allowed.`
338
+ );
339
+ n = i;
340
+ }
341
+ pe(i), i.children.map(a);
342
+ }
343
+ if (a(t.scene), !n)
344
+ throw Error(
345
+ `No flange group found in robot model ${s}. Flange must be identified with a name ending in _FLG.`
346
+ );
347
+ return { gltf: t };
348
+ }
349
+ function fe({
350
+ rapidlyChangingMotionState: t,
351
+ dhParameters: s,
352
+ onRotationChanged: n,
353
+ children: a
354
+ }) {
355
+ const i = R([]), u = R([]), c = R(null), { invalidate: f } = ae();
356
+ M(() => {
357
+ const o = t.joint_position.filter(
358
+ (l) => l !== void 0
359
+ );
360
+ return c.current = new re(o, {
361
+ tension: 120,
362
+ // Controls spring stiffness - higher values create faster, more responsive motion
363
+ friction: 20,
364
+ // Controls damping - higher values reduce oscillation and create smoother settling
365
+ threshold: 1e-3
366
+ }), () => {
367
+ var l;
368
+ (l = c.current) == null || l.destroy();
369
+ };
370
+ }, []), le((o, l) => {
371
+ if (c.current) {
372
+ const d = c.current.update(l);
373
+ h(), d || f();
374
+ }
375
+ });
376
+ function r(o) {
377
+ o && (u.current = ue(o), h(), f());
378
+ }
379
+ function h() {
380
+ var l;
381
+ const o = ((l = c.current) == null ? void 0 : l.getCurrentValues()) || [];
382
+ if (n)
383
+ n(u.current, o);
384
+ else
385
+ for (const [d, x] of u.current.entries()) {
386
+ const p = s[d], j = p.theta || 0, y = p.reverse_rotation_direction ? -1 : 1;
387
+ x.rotation.y = y * (o[d] || 0) + j;
388
+ }
389
+ }
390
+ const m = T(() => {
391
+ const o = t.joint_position.filter(
392
+ (l) => l !== void 0
393
+ );
394
+ requestAnimationFrame(() => {
395
+ var l;
396
+ i.current = o, (l = c.current) == null || l.setTarget(o);
397
+ });
398
+ }, [t]);
399
+ return M(() => {
400
+ m();
401
+ }, [t, m]), se(() => {
402
+ m();
403
+ }), /* @__PURE__ */ e.jsx("group", { ref: r, children: a });
404
+ }
405
+ const Je = "line", Be = "mesh";
406
+ function We({
407
+ rapidlyChangingMotionState: t,
408
+ dhParameters: s,
409
+ ...n
410
+ }) {
411
+ const a = new w(), i = R([]), u = R([]);
412
+ Ge.useEffect(() => {
413
+ i.current = new Array(s.length).fill(null), u.current = new Array(s.length).fill(null);
414
+ }, [s.length]);
415
+ function c(h, m) {
416
+ const o = new k(), l = new J(), d = new k();
417
+ a.decompose(o, l, d);
418
+ const x = o.clone(), p = new w().makeRotationY(
419
+ h.theta + m * (h.reverse_rotation_direction ? -1 : 1)
420
+ ).multiply(new w().makeTranslation(0, h.d / 1e3, 0)).multiply(new w().makeTranslation(h.a / 1e3, 0, 0)).multiply(new w().makeRotationX(h.alpha));
421
+ return a.multiply(p), a.decompose(o, l, d), { a: x, b: o };
422
+ }
423
+ function f(h, m, o, l) {
424
+ if (!s)
425
+ return;
426
+ const d = s[h];
427
+ if (!d)
428
+ return;
429
+ const { a: x, b: p } = c(d, l);
430
+ m.geometry.setPositions([x.toArray(), p.toArray()].flat()), o.position.set(p.x, p.y, p.z);
431
+ }
432
+ function r(h, m) {
433
+ a.identity();
434
+ for (let o = 0; o < Math.min(h.length, m.length); o++) {
435
+ const l = i.current[o], d = u.current[o];
436
+ l && d && f(o, l, d, m[o]);
437
+ }
438
+ }
439
+ return /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsx(
440
+ fe,
441
+ {
442
+ rapidlyChangingMotionState: t,
443
+ dhParameters: s,
444
+ onRotationChanged: r,
445
+ children: /* @__PURE__ */ e.jsxs("group", { ...n, name: "Scene", children: [
446
+ /* @__PURE__ */ e.jsxs("mesh", { children: [
447
+ /* @__PURE__ */ e.jsx("sphereGeometry", { args: [0.01, 32, 32] }),
448
+ /* @__PURE__ */ e.jsx("meshStandardMaterial", { color: "black", depthTest: !0 })
449
+ ] }),
450
+ s.map((h, m) => {
451
+ const { a: o, b: l } = c(
452
+ h,
453
+ t.joint_position[m] ?? 0
454
+ ), d = `dhrobot_J0${m}`;
455
+ return /* @__PURE__ */ e.jsxs("group", { name: d, children: [
456
+ /* @__PURE__ */ e.jsx(
457
+ B,
458
+ {
459
+ ref: (x) => {
460
+ i.current[m] = x;
461
+ },
462
+ name: Je,
463
+ points: [o, l],
464
+ color: "white",
465
+ lineWidth: 5
466
+ }
467
+ ),
468
+ /* @__PURE__ */ e.jsxs(
469
+ "mesh",
470
+ {
471
+ ref: (x) => {
472
+ u.current[m] = x;
473
+ },
474
+ name: Be,
475
+ position: l,
476
+ children: [
477
+ /* @__PURE__ */ e.jsx("sphereGeometry", { args: [0.01, 32, 32] }),
478
+ /* @__PURE__ */ e.jsx("meshStandardMaterial", { color: "black", depthTest: !0 })
479
+ ]
480
+ },
481
+ "mesh_" + m
482
+ )
483
+ ] }, d);
484
+ })
485
+ ] })
486
+ }
487
+ ) });
488
+ }
489
+ const $e = console.warn;
490
+ function he() {
491
+ return M(() => {
492
+ console.warn = (t) => {
493
+ t !== "Cannot call the manual advancement of rafz whilst frameLoop is not set as demand" && $e(t);
494
+ };
495
+ }, []), /* @__PURE__ */ e.jsx(e.Fragment, {});
496
+ }
497
+ function He(t) {
498
+ return t.type === "Mesh";
499
+ }
500
+ function Ne({
501
+ url: t,
502
+ flangeRef: s,
503
+ postModelRender: n,
504
+ ...a
505
+ }) {
506
+ const i = Se(t);
507
+ let u;
508
+ try {
509
+ u = Ee(i, "robot.glb").gltf;
510
+ } catch (r) {
511
+ throw r;
512
+ }
513
+ const c = T(
514
+ (r) => {
515
+ r && n && n();
516
+ },
517
+ [n]
518
+ );
519
+ function f(r) {
520
+ try {
521
+ return He(r) ? r.geometry ? /* @__PURE__ */ e.jsx(
522
+ "mesh",
523
+ {
524
+ name: r.name,
525
+ geometry: r.geometry,
526
+ material: r.material,
527
+ position: r.position,
528
+ rotation: r.rotation
529
+ },
530
+ r.uuid
531
+ ) : /* @__PURE__ */ e.jsx("group", { name: r.name, position: r.position, rotation: r.rotation }, r.uuid) : /* @__PURE__ */ e.jsx(
532
+ "group",
533
+ {
534
+ name: r.name,
535
+ position: r.position,
536
+ rotation: r.rotation,
537
+ ref: de(r) ? s : void 0,
538
+ children: r.children.map(f)
539
+ },
540
+ r.uuid
541
+ );
542
+ } catch (h) {
543
+ return console.warn("Error rendering node", r.name, h), null;
544
+ }
545
+ }
546
+ return /* @__PURE__ */ e.jsx("group", { ...a, dispose: null, ref: c, children: f(u.scene) });
547
+ }
548
+ function me({
549
+ modelURL: t,
550
+ flangeRef: s,
551
+ postModelRender: n,
552
+ ...a
553
+ }) {
554
+ const [i, u] = F(null);
555
+ return M(() => {
556
+ (async () => {
557
+ try {
558
+ if (typeof t == "string")
559
+ u(t);
560
+ else {
561
+ const f = await t;
562
+ u(f);
563
+ }
564
+ } catch (f) {
565
+ console.error("Failed to resolve model URL:", f);
566
+ }
567
+ })();
568
+ }, [t]), i ? /* @__PURE__ */ e.jsx(
569
+ Ne,
570
+ {
571
+ url: i,
572
+ flangeRef: s,
573
+ postModelRender: n,
574
+ ...a
575
+ }
576
+ ) : null;
577
+ }
578
+ const xe = (t, s) => {
579
+ t.userData.isGhost || (t.traverse((n) => {
580
+ if (n instanceof g.Mesh) {
581
+ n.material instanceof g.Material && (n.material.colorWrite = !1);
582
+ const a = n.clone(), i = n.clone();
583
+ a.material = new g.MeshStandardMaterial({
584
+ depthTest: !0,
585
+ depthWrite: !0,
586
+ colorWrite: !1,
587
+ polygonOffset: !0,
588
+ polygonOffsetFactor: -1,
589
+ side: g.DoubleSide
590
+ }), a.userData.isGhost = !0, i.material = new g.MeshStandardMaterial({
591
+ color: s,
592
+ opacity: 0.3,
593
+ depthTest: !0,
594
+ depthWrite: !1,
595
+ transparent: !0,
596
+ polygonOffset: !0,
597
+ polygonOffsetFactor: -2,
598
+ side: g.DoubleSide
599
+ }), i.userData.isGhost = !0, n.parent && (n.parent.add(a), n.parent.add(i));
600
+ }
601
+ }), t.userData.isGhost = !0);
602
+ }, ye = (t) => {
603
+ if (!t.userData.isGhost) return;
604
+ const s = [];
605
+ t.traverse((n) => {
606
+ var a;
607
+ n instanceof g.Mesh && ((a = n.userData) != null && a.isGhost ? s.push(n) : n.material instanceof g.Material && (n.material.colorWrite = !0));
608
+ }), s.forEach((n) => {
609
+ n.parent && n.parent.remove(n);
610
+ }), t.userData.isGhost = !1;
611
+ }, ge = U(
612
+ ({
613
+ rapidlyChangingMotionState: t,
614
+ modelFromController: s,
615
+ dhParameters: n,
616
+ getModel: a = C,
617
+ flangeRef: i,
618
+ postModelRender: u,
619
+ transparentColor: c,
620
+ instanceUrl: f,
621
+ ...r
622
+ }) => {
623
+ const [h, m] = F(null), o = T((d) => {
624
+ m(d);
625
+ }, []);
626
+ M(() => {
627
+ h && (c ? xe(h, c) : ye(h));
628
+ }, [h, c]);
629
+ const l = /* @__PURE__ */ e.jsx(
630
+ We,
631
+ {
632
+ rapidlyChangingMotionState: t,
633
+ dhParameters: n,
634
+ ...r
635
+ }
636
+ );
637
+ return /* @__PURE__ */ e.jsxs(
638
+ ce,
639
+ {
640
+ fallback: l,
641
+ onError: (d) => {
642
+ console.warn(d);
643
+ },
644
+ children: [
645
+ /* @__PURE__ */ e.jsx(ie, { fallback: l, children: /* @__PURE__ */ e.jsx("group", { ref: o, children: /* @__PURE__ */ e.jsx(
646
+ fe,
647
+ {
648
+ rapidlyChangingMotionState: t,
649
+ dhParameters: n,
650
+ children: /* @__PURE__ */ e.jsx(
651
+ me,
652
+ {
653
+ modelURL: (() => {
654
+ const d = a(s, f);
655
+ if (!d) {
656
+ const x = new Blob([], { type: "model/gltf-binary" }), p = new File([x], `${s}.glb`, { type: "model/gltf-binary" });
657
+ return Promise.resolve(URL.createObjectURL(p));
658
+ }
659
+ return d;
660
+ })(),
661
+ postModelRender: u,
662
+ flangeRef: i,
663
+ ...r
664
+ }
665
+ )
666
+ }
667
+ ) }) }),
668
+ /* @__PURE__ */ e.jsx(he, {})
669
+ ]
670
+ }
671
+ );
672
+ }
673
+ );
674
+ function qe({
675
+ connectedMotionGroup: t,
676
+ getModel: s = C,
677
+ flangeRef: n,
678
+ transparentColor: a,
679
+ postModelRender: i,
680
+ ...u
681
+ }) {
682
+ return t.dhParameters ? /* @__PURE__ */ e.jsx(
683
+ ge,
684
+ {
685
+ rapidlyChangingMotionState: t.rapidlyChangingMotionState,
686
+ modelFromController: t.modelFromController || "",
687
+ dhParameters: t.dhParameters,
688
+ getModel: s,
689
+ flangeRef: n,
690
+ transparentColor: a,
691
+ postModelRender: i,
692
+ ...u
693
+ }
694
+ ) : null;
695
+ }
696
+ const ct = U(
697
+ Ie(
698
+ ({
699
+ robotName: t,
700
+ programState: s,
701
+ safetyState: n,
702
+ operationMode: a,
703
+ driveToHomeEnabled: i = !1,
704
+ onDriveToHomePress: u,
705
+ onDriveToHomeRelease: c,
706
+ connectedMotionGroup: f,
707
+ robotComponent: r = qe,
708
+ customContentComponent: h,
709
+ className: m
710
+ }) => {
711
+ var H;
712
+ const o = Pe(), { t: l } = De(), [d, x] = F(!1), p = R(null), j = R(null), [y, G] = F(!1), [S, Re] = F({ width: 400, height: 600 }), [Xe, ve] = F(0);
713
+ M(() => {
714
+ const D = () => {
715
+ if (j.current) {
716
+ const { offsetWidth: q, offsetHeight: Y } = j.current;
717
+ G(q > Y), Re({ width: q, height: Y });
718
+ }
719
+ };
720
+ D();
721
+ const N = new ResizeObserver(D);
722
+ return j.current && N.observe(j.current), () => {
723
+ N.disconnect();
724
+ };
725
+ }, []);
726
+ const W = T(() => {
727
+ ve((D) => D + 1);
728
+ }, []), P = T(() => {
729
+ !i || !u || (x(!0), u());
730
+ }, [i, u]), A = T(() => {
731
+ !i || !c || (x(!1), c());
732
+ }, [i, c]), $ = T(() => {
733
+ d && c && (x(!1), c());
734
+ }, [d, c]), _ = y ? S.width < 350 : S.height < 200, I = y ? S.height < 310 : S.height < 450;
735
+ return /* @__PURE__ */ e.jsx(
736
+ Ae,
737
+ {
738
+ ref: j,
739
+ className: m,
740
+ sx: {
741
+ width: "100%",
742
+ height: "100%",
743
+ display: "flex",
744
+ flexDirection: y ? "row" : "column",
745
+ position: "relative",
746
+ overflow: "hidden",
747
+ minWidth: { xs: 180, sm: 220, md: 250 },
748
+ minHeight: y ? { xs: 200, sm: 240, md: 260 } : { xs: 150, sm: 180, md: 220 },
749
+ // Allow progressive hiding in portrait mode
750
+ border: `1px solid ${o.palette.divider}`,
751
+ borderRadius: "18px",
752
+ boxShadow: "none",
753
+ backgroundColor: ((H = o.palette.backgroundPaperElevation) == null ? void 0 : H[8]) || "#2A2A3F",
754
+ backgroundImage: "none"
755
+ // Override any gradient from elevation
756
+ },
757
+ children: y ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
758
+ /* @__PURE__ */ e.jsx(
759
+ b,
760
+ {
761
+ sx: {
762
+ flex: "0 0 50%",
763
+ position: "relative",
764
+ height: "100%",
765
+ minHeight: "100%",
766
+ maxHeight: "100%",
767
+ borderRadius: 1,
768
+ m: { xs: 1.5, sm: 2, md: 3 },
769
+ mr: { xs: 0.75, sm: 1, md: 1.5 },
770
+ overflow: "hidden",
771
+ // Prevent content from affecting container size
772
+ display: _ ? "none" : "block"
773
+ },
774
+ children: !_ && /* @__PURE__ */ e.jsxs(
775
+ K,
776
+ {
777
+ orthographic: !0,
778
+ camera: {
779
+ position: [3, 2, 3],
780
+ zoom: 1
781
+ },
782
+ shadows: !0,
783
+ frameloop: "demand",
784
+ style: {
785
+ borderRadius: o.shape.borderRadius,
786
+ width: "100%",
787
+ height: "100%",
788
+ background: "transparent",
789
+ position: "absolute",
790
+ top: 0,
791
+ left: 0
792
+ },
793
+ dpr: [1, 2],
794
+ gl: { alpha: !0, antialias: !0 },
795
+ children: [
796
+ /* @__PURE__ */ e.jsx(te, {}),
797
+ /* @__PURE__ */ e.jsx(Z, { fit: !0, observe: !0, margin: 1, maxDuration: 1, children: /* @__PURE__ */ e.jsx(
798
+ r,
799
+ {
800
+ connectedMotionGroup: f,
801
+ postModelRender: W
802
+ }
803
+ ) })
804
+ ]
805
+ }
806
+ )
807
+ }
808
+ ),
809
+ /* @__PURE__ */ e.jsxs(
810
+ b,
811
+ {
812
+ sx: {
813
+ flex: "1",
814
+ display: "flex",
815
+ flexDirection: "column",
816
+ justifyContent: "flex-start",
817
+ width: _ ? "100%" : "50%"
818
+ },
819
+ children: [
820
+ /* @__PURE__ */ e.jsxs(
821
+ b,
822
+ {
823
+ sx: {
824
+ p: { xs: 1.5, sm: 2, md: 3 },
825
+ pb: { xs: 1, sm: 1.5, md: 2 },
826
+ textAlign: "left"
827
+ },
828
+ children: [
829
+ /* @__PURE__ */ e.jsx(Q, { variant: "h6", component: "h2", sx: { mb: 1 }, children: t }),
830
+ /* @__PURE__ */ e.jsx(
831
+ X,
832
+ {
833
+ programState: s,
834
+ safetyState: n,
835
+ operationMode: a
836
+ }
837
+ )
838
+ ]
839
+ }
840
+ ),
841
+ /* @__PURE__ */ e.jsxs(
842
+ b,
843
+ {
844
+ sx: {
845
+ p: { xs: 1.5, sm: 2, md: 3 },
846
+ pt: 0,
847
+ flex: "1",
848
+ display: "flex",
849
+ flexDirection: "column",
850
+ justifyContent: "space-between"
851
+ },
852
+ children: [
853
+ !I && h && /* @__PURE__ */ e.jsxs(b, { children: [
854
+ /* @__PURE__ */ e.jsx(h, {}),
855
+ /* @__PURE__ */ e.jsx(
856
+ z,
857
+ {
858
+ sx: {
859
+ mt: 1,
860
+ mb: 0,
861
+ borderColor: o.palette.divider,
862
+ opacity: 0.5
863
+ }
864
+ }
865
+ )
866
+ ] }),
867
+ /* @__PURE__ */ e.jsx(
868
+ b,
869
+ {
870
+ sx: {
871
+ mt: !I && h ? "auto" : 0
872
+ },
873
+ children: /* @__PURE__ */ e.jsx(
874
+ b,
875
+ {
876
+ sx: {
877
+ display: "flex",
878
+ justifyContent: "flex-start",
879
+ mt: { xs: 1, sm: 1.5, md: 2 },
880
+ mb: { xs: 0.5, sm: 0.75, md: 1 }
881
+ },
882
+ children: /* @__PURE__ */ e.jsx(
883
+ ee,
884
+ {
885
+ ref: p,
886
+ variant: "contained",
887
+ color: "secondary",
888
+ size: "small",
889
+ disabled: !i,
890
+ onMouseDown: P,
891
+ onMouseUp: A,
892
+ onMouseLeave: $,
893
+ onTouchStart: P,
894
+ onTouchEnd: A,
895
+ sx: {
896
+ textTransform: "none",
897
+ px: 1.5,
898
+ py: 0.5
899
+ },
900
+ children: l("RobotCard.DriveToHome.bt")
901
+ }
902
+ )
903
+ }
904
+ )
905
+ }
906
+ )
907
+ ]
908
+ }
909
+ )
910
+ ]
911
+ }
912
+ )
913
+ ] }) : /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsxs(
914
+ b,
915
+ {
916
+ sx: {
917
+ p: 3,
918
+ height: "100%",
919
+ display: "flex",
920
+ flexDirection: "column"
921
+ },
922
+ children: [
923
+ /* @__PURE__ */ e.jsxs(b, { children: [
924
+ /* @__PURE__ */ e.jsx(Q, { variant: "h6", component: "h2", sx: { mb: 1 }, children: t }),
925
+ /* @__PURE__ */ e.jsx(
926
+ X,
927
+ {
928
+ programState: s,
929
+ safetyState: n,
930
+ operationMode: a
931
+ }
932
+ )
933
+ ] }),
934
+ /* @__PURE__ */ e.jsx(
935
+ b,
936
+ {
937
+ sx: {
938
+ flex: _ ? 0 : 1,
939
+ position: "relative",
940
+ minHeight: _ ? 0 : { xs: 120, sm: 150, md: 200 },
941
+ height: _ ? 0 : "auto",
942
+ borderRadius: 1,
943
+ overflow: "hidden",
944
+ display: _ ? "none" : "block"
945
+ },
946
+ children: !_ && /* @__PURE__ */ e.jsxs(
947
+ K,
948
+ {
949
+ orthographic: !0,
950
+ camera: {
951
+ position: [3, 2, 3],
952
+ zoom: 1
953
+ },
954
+ shadows: !0,
955
+ frameloop: "demand",
956
+ style: {
957
+ borderRadius: o.shape.borderRadius,
958
+ width: "100%",
959
+ height: "100%",
960
+ background: "transparent",
961
+ position: "absolute"
962
+ },
963
+ dpr: [1, 2],
964
+ gl: { alpha: !0, antialias: !0 },
965
+ children: [
966
+ /* @__PURE__ */ e.jsx(te, {}),
967
+ /* @__PURE__ */ e.jsx(Z, { fit: !0, clip: !0, observe: !0, margin: 1, maxDuration: 1, children: /* @__PURE__ */ e.jsx(
968
+ r,
969
+ {
970
+ connectedMotionGroup: f,
971
+ postModelRender: W
972
+ }
973
+ ) })
974
+ ]
975
+ }
976
+ )
977
+ }
978
+ ),
979
+ /* @__PURE__ */ e.jsxs(b, { children: [
980
+ !I && h && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
981
+ /* @__PURE__ */ e.jsx(h, {}),
982
+ /* @__PURE__ */ e.jsx(
983
+ z,
984
+ {
985
+ sx: {
986
+ mt: 1,
987
+ mb: 0,
988
+ borderColor: o.palette.divider,
989
+ opacity: 0.5
990
+ }
991
+ }
992
+ )
993
+ ] }),
994
+ /* @__PURE__ */ e.jsx(
995
+ b,
996
+ {
997
+ sx: {
998
+ display: "flex",
999
+ justifyContent: "flex-start",
1000
+ mt: !I && h ? { xs: 1, sm: 2, md: 5 } : { xs: 0.5, sm: 1, md: 2 },
1001
+ mb: { xs: 0.5, sm: 0.75, md: 1 }
1002
+ },
1003
+ children: /* @__PURE__ */ e.jsx(
1004
+ ee,
1005
+ {
1006
+ ref: p,
1007
+ variant: "contained",
1008
+ color: "secondary",
1009
+ size: "small",
1010
+ disabled: !i,
1011
+ onMouseDown: P,
1012
+ onMouseUp: A,
1013
+ onMouseLeave: $,
1014
+ onTouchStart: P,
1015
+ onTouchEnd: A,
1016
+ sx: {
1017
+ textTransform: "none",
1018
+ px: 1.5,
1019
+ py: 0.5
1020
+ },
1021
+ children: l("RobotCard.DriveToHome.bt")
1022
+ }
1023
+ )
1024
+ }
1025
+ )
1026
+ ] })
1027
+ ]
1028
+ }
1029
+ ) })
1030
+ }
1031
+ );
1032
+ }
1033
+ )
1034
+ ), ut = Array(6).fill(2 * Math.PI);
1035
+ function je({
1036
+ rapidlyChangingMotionState: t,
1037
+ dhParameters: s,
1038
+ onTranslationChanged: n,
1039
+ children: a
1040
+ }) {
1041
+ const i = R([]), u = R([]), c = R(null), { invalidate: f } = ae();
1042
+ M(() => {
1043
+ const o = t.joint_position.filter(
1044
+ (l) => l !== void 0
1045
+ );
1046
+ return c.current = new re(o, {
1047
+ tension: 120,
1048
+ // Controls spring stiffness - higher values create faster, more responsive motion
1049
+ friction: 20,
1050
+ // Controls damping - higher values reduce oscillation and create smoother settling
1051
+ threshold: 1e-3
1052
+ }), () => {
1053
+ var l;
1054
+ (l = c.current) == null || l.destroy();
1055
+ };
1056
+ }, []), le((o, l) => {
1057
+ if (c.current) {
1058
+ const d = c.current.update(l);
1059
+ h(), d || f();
1060
+ }
1061
+ });
1062
+ function r(o) {
1063
+ o && (u.current = ue(o), h(), f());
1064
+ }
1065
+ function h() {
1066
+ var l;
1067
+ const o = ((l = c.current) == null ? void 0 : l.getCurrentValues()) || [];
1068
+ if (n)
1069
+ n(u.current, o);
1070
+ else
1071
+ for (const [d, x] of u.current.entries()) {
1072
+ const j = s[d].reverse_rotation_direction ? -1 : 1;
1073
+ x.position.y = j * (o[d] || 0) / 1e3;
1074
+ }
1075
+ }
1076
+ const m = T(() => {
1077
+ const o = t.joint_position.filter(
1078
+ (l) => l !== void 0
1079
+ );
1080
+ requestAnimationFrame(() => {
1081
+ var l;
1082
+ i.current = o, (l = c.current) == null || l.setTarget(o);
1083
+ });
1084
+ }, [t]);
1085
+ return M(() => {
1086
+ m();
1087
+ }, [t, m]), se(() => {
1088
+ m();
1089
+ }), /* @__PURE__ */ e.jsx("group", { ref: r, children: a });
1090
+ }
1091
+ function we({
1092
+ rapidlyChangingMotionState: t,
1093
+ dhParameters: s,
1094
+ ...n
1095
+ }) {
1096
+ const a = new w(), i = R(null), u = R(null);
1097
+ function c(h) {
1098
+ const m = new w();
1099
+ for (let x = 0; x < s.length; x++) {
1100
+ const p = s[x], j = h[x] ?? 0, y = new w().makeRotationY(p.theta).multiply(
1101
+ new w().makeTranslation(
1102
+ p.a / 1e3,
1103
+ (p.d + j * (p.reverse_rotation_direction ? -1 : 1)) / 1e3,
1104
+ 0
1105
+ )
1106
+ ).multiply(new w().makeRotationX(p.alpha));
1107
+ m.multiply(y);
1108
+ }
1109
+ const o = new k(), l = new J(), d = new k();
1110
+ return m.decompose(o, l, d), o;
1111
+ }
1112
+ const f = c(t.joint_position);
1113
+ function r(h, m) {
1114
+ a.identity();
1115
+ let o = new k();
1116
+ for (let p = 0; p < s.length; p++) {
1117
+ const j = m[p] ?? 0, y = s[p], G = new w().makeRotationY(y.theta).multiply(
1118
+ new w().makeTranslation(
1119
+ y.a / 1e3,
1120
+ (y.d + j * (y.reverse_rotation_direction ? -1 : 1)) / 1e3,
1121
+ 0
1122
+ )
1123
+ ).multiply(new w().makeRotationX(y.alpha));
1124
+ a.multiply(G);
1125
+ }
1126
+ const l = new k(), d = new J(), x = new k();
1127
+ if (a.decompose(l, d, x), o = l, i.current && i.current.position.set(o.x, o.y, o.z), u.current) {
1128
+ const p = u.current.geometry;
1129
+ p && p.setPositions && p.setPositions([0, 0, 0, o.x, o.y, o.z]);
1130
+ }
1131
+ }
1132
+ return /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsx(
1133
+ je,
1134
+ {
1135
+ rapidlyChangingMotionState: t,
1136
+ dhParameters: s,
1137
+ onTranslationChanged: r,
1138
+ children: /* @__PURE__ */ e.jsxs("group", { ...n, name: "Scene", children: [
1139
+ /* @__PURE__ */ e.jsxs("mesh", { name: "Base", position: [0, 0, 0], children: [
1140
+ /* @__PURE__ */ e.jsx("sphereGeometry", { args: [0.02, 32, 32] }),
1141
+ /* @__PURE__ */ e.jsx("meshStandardMaterial", { color: "green", depthTest: !0 })
1142
+ ] }),
1143
+ /* @__PURE__ */ e.jsx(
1144
+ B,
1145
+ {
1146
+ ref: u,
1147
+ points: [new k(0, 0, 0), f],
1148
+ color: "White",
1149
+ lineWidth: 5
1150
+ }
1151
+ ),
1152
+ /* @__PURE__ */ e.jsxs("mesh", { ref: i, name: "TCP", position: f, children: [
1153
+ /* @__PURE__ */ e.jsx("sphereGeometry", { args: [0.025, 32, 32] }),
1154
+ /* @__PURE__ */ e.jsx("meshStandardMaterial", { color: "red", depthTest: !0 })
1155
+ ] })
1156
+ ] })
1157
+ }
1158
+ ) });
1159
+ }
1160
+ const be = U(
1161
+ ({
1162
+ rapidlyChangingMotionState: t,
1163
+ modelFromController: s,
1164
+ dhParameters: n,
1165
+ getModel: a = C,
1166
+ flangeRef: i,
1167
+ postModelRender: u,
1168
+ transparentColor: c,
1169
+ instanceUrl: f,
1170
+ ...r
1171
+ }) => {
1172
+ const [h, m] = F(null), o = T((d) => {
1173
+ m(d);
1174
+ }, []);
1175
+ M(() => {
1176
+ h && (c ? xe(h, c) : ye(h));
1177
+ }, [h, c]);
1178
+ const l = /* @__PURE__ */ e.jsx(
1179
+ we,
1180
+ {
1181
+ rapidlyChangingMotionState: t,
1182
+ dhParameters: n,
1183
+ ...r
1184
+ }
1185
+ );
1186
+ return /* @__PURE__ */ e.jsxs(
1187
+ ce,
1188
+ {
1189
+ fallback: l,
1190
+ onError: (d) => {
1191
+ console.warn(d);
1192
+ },
1193
+ children: [
1194
+ /* @__PURE__ */ e.jsx(ie, { fallback: l, children: /* @__PURE__ */ e.jsx("group", { ref: o, children: /* @__PURE__ */ e.jsx(
1195
+ je,
1196
+ {
1197
+ rapidlyChangingMotionState: t,
1198
+ dhParameters: n,
1199
+ children: /* @__PURE__ */ e.jsx(
1200
+ me,
1201
+ {
1202
+ modelURL: (() => {
1203
+ const d = a(s, f);
1204
+ if (!d) {
1205
+ const x = new Blob([], { type: "model/gltf-binary" }), p = new File([x], `${s}.glb`, { type: "model/gltf-binary" });
1206
+ return Promise.resolve(URL.createObjectURL(p));
1207
+ }
1208
+ return d;
1209
+ })(),
1210
+ postModelRender: u,
1211
+ flangeRef: i,
1212
+ ...r
1213
+ }
1214
+ )
1215
+ }
1216
+ ) }) }),
1217
+ /* @__PURE__ */ e.jsx(he, {})
1218
+ ]
1219
+ }
1220
+ );
1221
+ }
1222
+ );
1223
+ function dt({
1224
+ connectedMotionGroup: t,
1225
+ getModel: s = C,
1226
+ flangeRef: n,
1227
+ transparentColor: a,
1228
+ postModelRender: i,
1229
+ ...u
1230
+ }) {
1231
+ if (!t.dhParameters)
1232
+ return null;
1233
+ const c = t.modelFromController || "";
1234
+ return c && s(c) ? /* @__PURE__ */ e.jsx(
1235
+ be,
1236
+ {
1237
+ rapidlyChangingMotionState: t.rapidlyChangingMotionState,
1238
+ modelFromController: c,
1239
+ dhParameters: t.dhParameters,
1240
+ getModel: s,
1241
+ flangeRef: n,
1242
+ transparentColor: a,
1243
+ postModelRender: i,
1244
+ ...u
1245
+ }
1246
+ ) : /* @__PURE__ */ e.jsx(
1247
+ we,
1248
+ {
1249
+ rapidlyChangingMotionState: t.rapidlyChangingMotionState,
1250
+ dhParameters: t.dhParameters,
1251
+ ...u
1252
+ }
1253
+ );
1254
+ }
1255
+ const ne = {
1256
+ [v.Abb]: [0, 0, 0, 0, Math.PI / 2, 0, 0],
1257
+ [v.Fanuc]: [0, 0, 0, 0, -Math.PI / 2, 0, 0],
1258
+ [v.Yaskawa]: [0, 0, 0, 0, -Math.PI / 2, 0, 0],
1259
+ [v.Kuka]: [
1260
+ 0,
1261
+ -Math.PI / 2,
1262
+ Math.PI / 2,
1263
+ 0,
1264
+ Math.PI / 2,
1265
+ 0,
1266
+ 0
1267
+ ],
1268
+ [v.Universalrobots]: [
1269
+ 0,
1270
+ -Math.PI / 2,
1271
+ -Math.PI / 2,
1272
+ -Math.PI / 2,
1273
+ Math.PI / 2,
1274
+ -Math.PI / 2,
1275
+ 0
1276
+ ]
1277
+ };
1278
+ function Ye(t) {
1279
+ const [s] = t.split("_");
1280
+ switch (s) {
1281
+ case "ABB":
1282
+ return v.Abb;
1283
+ case "FANUC":
1284
+ return v.Fanuc;
1285
+ case "YASKAWA":
1286
+ return v.Yaskawa;
1287
+ case "KUKA":
1288
+ return v.Kuka;
1289
+ case "UniversalRobots":
1290
+ return v.Universalrobots;
1291
+ default:
1292
+ return null;
1293
+ }
1294
+ }
1295
+ function pt(t, s) {
1296
+ const n = Ye(t);
1297
+ return n && n in ne ? ne[n] : s || null;
1298
+ }
1299
+ const ft = U((t) => {
1300
+ const {
1301
+ inverseSolver: s,
1302
+ dhParameters: n,
1303
+ ...a
1304
+ } = t, [i, u] = F(O.RevoluteJoint);
1305
+ M(() => {
1306
+ n.length && u(n[0].type ?? O.RevoluteJoint);
1307
+ }, [n]);
1308
+ const c = V(() => s === null && i === O.RevoluteJoint, [s, i]), f = V(() => s === null && i === O.PrismaticJoint, [s, i]);
1309
+ return V(() => !!s, [s]) || c ? /* @__PURE__ */ e.jsx(ge, { dhParameters: n, ...a }) : f ? /* @__PURE__ */ e.jsx(be, { dhParameters: n, ...a }) : /* @__PURE__ */ e.jsx(e.Fragment, {});
1310
+ });
1311
+ export {
1312
+ it as C,
1313
+ dt as L,
1314
+ ne as M,
1315
+ te as P,
1316
+ ct as R,
1317
+ at as S,
1318
+ lt as T,
1319
+ ut as a,
1320
+ qe as b,
1321
+ be as c,
1322
+ C as d,
1323
+ Ye as e,
1324
+ ge as f,
1325
+ pt as g,
1326
+ ft as h
1327
+ };
1328
+ //# sourceMappingURL=MotionGroupVisualizer-Cm-XYEZe.js.map