@wandelbots/wandelbots-js-react-components 4.7.2-pr.feat-RB-3348-remove-v1-usage.553.1cbc99f → 4.7.2-pr.v4.554.f8a153d

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