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

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