@wandelbots/wandelbots-js-react-components 4.6.0 → 4.7.0-pr.fix-RB-3347-safety-zone-alignment.547.29f3542

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