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