@wandelbots/wandelbots-js-react-components 4.5.0 → 4.6.0-pr.feat-RB-3079-sphere-zone-renderer.543.0a0dd0b

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