@wandelbots/wandelbots-js-react-components 6.4.0-pr.revamp.667.bd2ec84 → 6.4.0-pr.revamp.667.ca77f09

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 (154) hide show
  1. package/README.md +172 -40
  2. package/dist/3d.cjs +1 -1
  3. package/dist/3d.d.ts +3 -4
  4. package/dist/3d.js +35 -38
  5. package/dist/CurrentPose/index.cjs +1 -1
  6. package/dist/CurrentPose/index.js +2 -2
  7. package/dist/CurrentPoseBar/index.cjs +1 -1
  8. package/dist/CurrentPoseBar/index.js +1 -1
  9. package/dist/JoggingButtons/index.cjs +1 -1
  10. package/dist/JoggingButtons/index.js +1 -1
  11. package/dist/JoggingGizmo/index.cjs +1 -1
  12. package/dist/JoggingGizmo/index.js +2 -2
  13. package/dist/JoggingJointSlider/index.cjs +1 -1
  14. package/dist/JoggingJointSlider/index.js +1 -1
  15. package/dist/RobotControl/index.cjs +1 -1
  16. package/dist/RobotControl/index.js +2 -2
  17. package/dist/RobotControlPanel/index.cjs +1 -1
  18. package/dist/RobotControlPanel/index.d.ts +1 -1
  19. package/dist/RobotControlPanel/index.js +1 -1
  20. package/dist/RobotHeader/index.cjs +1 -1
  21. package/dist/RobotHeader/index.d.ts +3 -5
  22. package/dist/RobotHeader/index.js +6 -7
  23. package/dist/RobotScene/index.cjs +1 -1
  24. package/dist/RobotScene/index.js +3 -3
  25. package/dist/RobotView/index.cjs +1 -1
  26. package/dist/RobotView/index.js +2 -2
  27. package/dist/SafetyBar/IndicatorWithExplanation.d.ts +12 -1
  28. package/dist/SafetyBar/SafetyBar.d.ts +15 -1
  29. package/dist/SafetyBar/index.cjs +1 -1
  30. package/dist/SafetyBar/index.d.ts +0 -1
  31. package/dist/SafetyBar/index.js +3 -4
  32. package/dist/SafetyBar/robotSafetyOf.d.ts +1 -0
  33. package/dist/chunks/{ConnectedMotionGroup-BifrgwV1.js → ConnectedMotionGroup-DNYakgxy.js} +6 -5
  34. package/dist/chunks/ConnectedMotionGroup-IRTsTxwB.cjs +3 -0
  35. package/dist/chunks/{CurrentPose-CMqO8oqX.cjs → CurrentPose-CAq9e9JY.cjs} +1 -1
  36. package/dist/chunks/{CurrentPose-CdD2ZB7B.js → CurrentPose-CgdINEh2.js} +3 -3
  37. package/dist/chunks/{CurrentPoseBar-CX1xFBtm.js → CurrentPoseBar--HkZBGnN.js} +11 -11
  38. package/dist/chunks/{CurrentPoseBar-BTBAwIO4.cjs → CurrentPoseBar-DoOUfRRs.cjs} +1 -1
  39. package/dist/chunks/{JoggingButtons-aijK-3g6.js → JoggingButtons-BNOnpcTH.js} +1 -1
  40. package/dist/chunks/{JoggingButtons-BOHl7hVq.cjs → JoggingButtons-Boaym2hQ.cjs} +1 -1
  41. package/dist/chunks/{JoggingGizmo-CoKYUtXq.cjs → JoggingGizmo-CNFjpWDv.cjs} +1 -1
  42. package/dist/chunks/{JoggingGizmo-DHvrJouR.js → JoggingGizmo-RDiEVQes.js} +1 -1
  43. package/dist/chunks/{JoggingGizmoOrientation-CIvIAIeO.js → JoggingGizmoOrientation-Dzzz2gEz.js} +1 -1
  44. package/dist/chunks/{JoggingGizmoOrientation-DVcagPRJ.cjs → JoggingGizmoOrientation-laUrgY0N.cjs} +1 -1
  45. package/dist/chunks/{JoggingJointSlider-DQtt4-pa.js → JoggingJointSlider-BY-Tof8G.js} +1 -1
  46. package/dist/chunks/{JoggingJointSlider-CTFYKzsU.cjs → JoggingJointSlider-Dm3vILd3.cjs} +1 -1
  47. package/dist/chunks/{JoggingRefusedError-BIkUM6-g.js → JoggingRefusedError-C4D8_YR_.js} +5 -3
  48. package/dist/chunks/JoggingRefusedError-DqyrfUcc.cjs +1 -0
  49. package/dist/chunks/Pose3-BfBNPRDM.cjs +1 -0
  50. package/dist/chunks/{Pose3-B_fLR-Wv.js → Pose3-DWxfC6Dj.js} +1 -2
  51. package/dist/chunks/{Robot-C-IWfxP9.js → Robot-B-VAYuAr.js} +5 -5
  52. package/dist/chunks/{Robot-Cfhjv9Z8.cjs → Robot-DRf8T9Zf.cjs} +1 -1
  53. package/dist/chunks/RobotActivation-CRVxXvlx.cjs +1 -0
  54. package/dist/chunks/RobotActivation-oR-8Y0iq.js +143 -0
  55. package/dist/chunks/RobotControl-Dbe50ZKM.cjs +1 -0
  56. package/dist/chunks/RobotControl-Ms1F7fFe.js +332 -0
  57. package/dist/chunks/RobotControlPanel-B7NxoHsO.cjs +1 -0
  58. package/dist/chunks/RobotControlPanel-CkQlkq8x.js +1029 -0
  59. package/dist/chunks/RobotHeader-CjOaf9s6.cjs +1 -0
  60. package/dist/chunks/RobotHeader-LSuRTDFB.js +395 -0
  61. package/dist/chunks/RobotScene-Au6zpHH1.cjs +1 -0
  62. package/dist/chunks/RobotScene-C6XEgaVR.js +1284 -0
  63. package/dist/chunks/RobotSessionProvider-CoF_tX0O.cjs +1 -0
  64. package/dist/chunks/RobotSessionProvider-DuHi-dtw.js +30 -0
  65. package/dist/chunks/{RobotView-BGYlAWj-.cjs → RobotView-Cg6JfGiY.cjs} +1 -1
  66. package/dist/chunks/{RobotView-D-v8jCM7.js → RobotView-CrAxNkyG.js} +3 -3
  67. package/dist/chunks/{robotSafetyOf-DuKKma1_.js → SafetyBar-C85BAKsL.js} +244 -215
  68. package/dist/chunks/SafetyBar-D2l81Omq.cjs +1 -0
  69. package/dist/chunks/externalizeComponent-CA_sHzyH.cjs +2 -0
  70. package/dist/chunks/{externalizeComponent-4juwPKL5.js → externalizeComponent-CChY_1bN.js} +34 -8
  71. package/dist/chunks/{useSmoothedMotionState-BSSV8aZN.js → hooks-BWoeBWLV.js} +43 -87
  72. package/dist/chunks/hooks-BXe2bNMo.cjs +1 -0
  73. package/dist/chunks/loadRobotSession-BzY9H3F8.cjs +1 -0
  74. package/dist/chunks/{loadRobotSession-GHHtv5dv.js → loadRobotSession-Ts2MumBB.js} +1065 -679
  75. package/dist/chunks/poseText-BxG4Caa-.js +48 -0
  76. package/dist/chunks/poseText-CwplkbDM.cjs +1 -0
  77. package/dist/chunks/useSmoothedMotionState-CCXmMZ0S.cjs +1 -0
  78. package/dist/chunks/useSmoothedMotionState-CELh-YJa.js +50 -0
  79. package/dist/components/VelocitySlider.d.ts +14 -1
  80. package/dist/components/connectionWarning/ConnectionWarning.d.ts +18 -4
  81. package/dist/components/connectionWarning/connectionWarningOf.d.ts +1 -11
  82. package/dist/components/jogging/JoggingCartesianAxisControl.d.ts +7 -1
  83. package/dist/components/jogging/JoggingCartesianTab.d.ts +6 -0
  84. package/dist/components/jogging/JoggingJointTab.d.ts +5 -0
  85. package/dist/components/jogging/JoggingJointValueControl.d.ts +7 -1
  86. package/dist/components/jogging/JoggingPanel.d.ts +11 -0
  87. package/dist/components/jogging/JoggingRefusedError.d.ts +8 -3
  88. package/dist/components/jogging/JoggingStore.d.ts +206 -17
  89. package/dist/components/jogging/joggingColors.d.ts +6 -0
  90. package/dist/components/robotControl/CartesianJogTab.d.ts +14 -3
  91. package/dist/components/robotControl/JogArea.d.ts +6 -3
  92. package/dist/components/robotControl/JogDisabledReason.d.ts +15 -0
  93. package/dist/components/robotControl/JointJogTab.d.ts +10 -2
  94. package/dist/components/robotControl/MoveToTab.d.ts +24 -3
  95. package/dist/components/robotControl/PoseField.d.ts +3 -1
  96. package/dist/components/robotControl/RobotControl.d.ts +3 -0
  97. package/dist/components/robotControl/RobotControlPanel.d.ts +91 -22
  98. package/dist/components/robotControl/VelocityRow.d.ts +8 -2
  99. package/dist/components/robotControl/atPose.d.ts +6 -0
  100. package/dist/components/robotControl/poseText.d.ts +13 -1
  101. package/dist/components/robotControl/units.d.ts +10 -2
  102. package/dist/components/robotControl/useRobotControlProps.d.ts +7 -4
  103. package/dist/components/robotControl/velocityText.d.ts +18 -0
  104. package/dist/components/robotHeader/ActivationSwitch.d.ts +13 -2
  105. package/dist/components/robotHeader/RobotHeader.d.ts +25 -4
  106. package/dist/components/robotHeader/robotActivationOf.d.ts +1 -8
  107. package/dist/components/robotScene/RobotScene.d.ts +7 -1
  108. package/dist/components/robots/MotionGroupVisualizer.d.ts +6 -4
  109. package/dist/components/robots/SupportedLinearAxis.d.ts +6 -4
  110. package/dist/components/robots/SupportedRobot.d.ts +7 -5
  111. package/dist/components/robots/useFrameSmoothedMotionState.d.ts +25 -0
  112. package/dist/components/utils/useSmoothedMotionState.d.ts +11 -2
  113. package/dist/core.cjs +1 -1
  114. package/dist/core.d.ts +8 -10
  115. package/dist/core.js +60 -69
  116. package/dist/index.cjs +1 -1
  117. package/dist/index.js +100 -113
  118. package/dist/lib/ConnectedMotionGroup.d.ts +11 -0
  119. package/dist/lib/ControllerStateStream.d.ts +9 -9
  120. package/dist/lib/JoggerConnection.d.ts +48 -13
  121. package/dist/lib/MotionStreamConnection.d.ts +3 -2
  122. package/dist/lib/TrajectoryExecutionStore.d.ts +58 -20
  123. package/dist/lib/controllerStateSource.d.ts +6 -5
  124. package/dist/lib/robotSession/RobotActivation.d.ts +52 -21
  125. package/dist/lib/robotSession/RobotSession.d.ts +27 -8
  126. package/dist/lib/robotSession/RobotTargetPose.d.ts +4 -2
  127. package/dist/lib/robotSession/loadRobotSession.d.ts +1 -1
  128. package/dist/lib/robotSession/robotPose.d.ts +0 -6
  129. package/dist/session.cjs +1 -1
  130. package/dist/session.d.ts +6 -6
  131. package/dist/session.js +30 -38
  132. package/package.json +22 -1
  133. package/dist/chunks/ConnectedMotionGroup-CybwJHkh.cjs +0 -3
  134. package/dist/chunks/JoggingRefusedError-BuCGsVsa.cjs +0 -1
  135. package/dist/chunks/Pose3-Ch4xVeXV.cjs +0 -1
  136. package/dist/chunks/RobotActivation-Bb0oNSBN.cjs +0 -1
  137. package/dist/chunks/RobotActivation-C0rrwpQZ.js +0 -115
  138. package/dist/chunks/RobotControl-Cv6Sr1Ni.js +0 -289
  139. package/dist/chunks/RobotControl-DFnOYMAa.cjs +0 -1
  140. package/dist/chunks/RobotControlPanel-B1_9g9D-.js +0 -850
  141. package/dist/chunks/RobotControlPanel-BpTpRBgy.cjs +0 -1
  142. package/dist/chunks/RobotScene-0ZJzXL50.cjs +0 -1
  143. package/dist/chunks/RobotScene-DpFeFpnx.js +0 -1255
  144. package/dist/chunks/RobotSessionProvider--AekyPqD.cjs +0 -1
  145. package/dist/chunks/RobotSessionProvider-TVaKGzqa.js +0 -25
  146. package/dist/chunks/externalizeComponent-Br_U-QAr.cjs +0 -2
  147. package/dist/chunks/loadRobotSession-DYbeNnTI.cjs +0 -1
  148. package/dist/chunks/poseText-BXUaQWnK.cjs +0 -1
  149. package/dist/chunks/poseText-pg4cxE8R.js +0 -41
  150. package/dist/chunks/robotActivationOf-B4oV10Za.cjs +0 -1
  151. package/dist/chunks/robotActivationOf-EzcT9g07.js +0 -368
  152. package/dist/chunks/robotSafetyOf-Dxm6s7Pp.cjs +0 -1
  153. package/dist/chunks/useSmoothedMotionState-B9WO73k0.cjs +0 -1
  154. package/dist/components/robotHeader/robotSafetyOf.d.ts +0 -11
@@ -1,1255 +0,0 @@
1
- import { jsx as s, jsxs as b, Fragment as k } from "react/jsx-runtime";
2
- import { observer as yt } from "mobx-react-lite";
3
- import { a as gt } from "./RobotSessionProvider-TVaKGzqa.js";
4
- import { useTheme as wt } from "@mui/material/styles";
5
- import Rt, { useMemo as x, useRef as _, useEffect as A, forwardRef as Q, useImperativeHandle as X, useState as Y, useCallback as C, Suspense as Z } from "react";
6
- import { Environment as vt, Lightformer as I, PivotControls as St, Line as K, useGLTF as _t } from "@react-three/drei";
7
- import * as v from "three";
8
- import { Euler as bt, Vector3 as M, Quaternion as j, Matrix4 as T } from "three";
9
- import { RoundedBoxGeometry as Tt, ConvexGeometry as Ot } from "three-stdlib";
10
- import { JointTypeEnum as G } from "@wandelbots/nova-js/v2";
11
- import { e as E } from "./externalizeComponent-4juwPKL5.js";
12
- import { V as Mt, b as z, a as q } from "./useSmoothedMotionState-BSSV8aZN.js";
13
- import { ErrorBoundary as tt } from "react-error-boundary";
14
- import { useThree as J, useFrame as xt } from "@react-three/fiber";
15
- import { g as At, j as Gt, r as It } from "./PoseTransformer-CmuoS76S.js";
16
- import { P as Lt, p as N } from "./Pose3-B_fLR-Wv.js";
17
- import { autorun as Et, computed as Vt } from "mobx";
18
- function jt() {
19
- return /* @__PURE__ */ s(vt, { frames: 1, children: /* @__PURE__ */ s(Pt, {}) });
20
- }
21
- const Ct = [2, 0, 2, 0, 2, 0, 2, 0];
22
- function Pt({ positions: t = Ct }) {
23
- return /* @__PURE__ */ b(k, { children: [
24
- /* @__PURE__ */ s(
25
- I,
26
- {
27
- intensity: 5,
28
- "rotation-x": Math.PI / 2,
29
- position: [0, 5, -9],
30
- scale: [10, 10, 1]
31
- }
32
- ),
33
- /* @__PURE__ */ s("group", { rotation: [0, 0.5, 0], children: /* @__PURE__ */ s("group", { children: t.map((e, n) => /* @__PURE__ */ s(
34
- I,
35
- {
36
- form: "circle",
37
- intensity: 5,
38
- rotation: [Math.PI / 2, 0, 0],
39
- position: [e, 4, n * 4],
40
- scale: [3, 1, 1]
41
- },
42
- n
43
- )) }) }),
44
- /* @__PURE__ */ s(
45
- I,
46
- {
47
- intensity: 40,
48
- "rotation-y": Math.PI / 2,
49
- position: [-5, 1, -1],
50
- scale: [20, 0.1, 1]
51
- }
52
- ),
53
- /* @__PURE__ */ s(
54
- I,
55
- {
56
- intensity: 20,
57
- "rotation-y": -Math.PI,
58
- position: [-5, -2, -1],
59
- scale: [20, 0.1, 1]
60
- }
61
- ),
62
- /* @__PURE__ */ s(
63
- I,
64
- {
65
- "rotation-y": Math.PI / 2,
66
- position: [-5, -1, -1],
67
- scale: [20, 0.5, 1],
68
- intensity: 5
69
- }
70
- ),
71
- /* @__PURE__ */ s(
72
- I,
73
- {
74
- "rotation-y": -Math.PI / 2,
75
- position: [10, 1, 0],
76
- scale: [20, 1, 1],
77
- intensity: 10
78
- }
79
- ),
80
- /* @__PURE__ */ s(
81
- I,
82
- {
83
- form: "ring",
84
- color: "white",
85
- intensity: 5,
86
- scale: 10,
87
- position: [-15, 4, -18],
88
- target: [0, 0, 0]
89
- }
90
- )
91
- ] });
92
- }
93
- function kt(t) {
94
- const e = t.length(), n = new v.Quaternion();
95
- if (e > 1e-6) {
96
- const o = t.clone().normalize();
97
- n.setFromAxisAngle(o, e);
98
- }
99
- return n;
100
- }
101
- function qt(t) {
102
- if (!t || t.length === 0)
103
- return 5;
104
- const o = t.reduce((a, c) => a + Math.abs(c.a ?? 0) / 1e3 + Math.abs(c.d ?? 0) / 1e3, 0) * 2;
105
- return !Number.isFinite(o) || o <= 0 ? 5 : o;
106
- }
107
- function Jt(t) {
108
- if (t.length < 3)
109
- return console.log("Not enough vertices to define a plane"), { isCoplanar: !1 };
110
- const e = new v.Vector3(t[0].x, t[0].y, t[0].z), n = new v.Vector3(t[1].x, t[1].y, t[1].z), o = new v.Vector3(t[2].x, t[2].y, t[2].z), a = new v.Vector3().subVectors(n, e), c = new v.Vector3().subVectors(o, e), u = new v.Vector3().crossVectors(a, c).normalize();
111
- for (let i = 3; i < t.length; i++) {
112
- const y = new v.Vector3(t[i].x, t[i].y, t[i].z), p = new v.Vector3().subVectors(y, e), h = u.dot(p);
113
- if (Math.abs(h) > 1e-6)
114
- return console.log("Vertices are not on the same plane"), { isCoplanar: !1 };
115
- }
116
- return { isCoplanar: !0, normal: u };
117
- }
118
- const $ = {
119
- attach: "material",
120
- color: "#009f4d",
121
- opacity: 0.2,
122
- depthTest: !1,
123
- depthWrite: !1,
124
- transparent: !0,
125
- polygonOffset: !0
126
- };
127
- function Nt({
128
- safetyZones: t,
129
- dhParameters: e,
130
- ...n
131
- }) {
132
- const o = x(
133
- () => qt(e ?? []),
134
- [e]
135
- ), a = (u, i) => {
136
- var d, g;
137
- if (!((d = i == null ? void 0 : i.pose) != null && d.position) || !((g = i == null ? void 0 : i.pose) != null && g.orientation))
138
- return null;
139
- const y = new v.Vector3(
140
- i.pose.position[0] / 1e3,
141
- i.pose.position[1] / 1e3,
142
- i.pose.position[2] / 1e3
143
- ), p = new v.Vector3(
144
- i.pose.orientation[0],
145
- i.pose.orientation[1],
146
- i.pose.orientation[2]
147
- );
148
- let h;
149
- const r = i.shape.shape_type === "plane" ? { ...$, side: v.DoubleSide } : { ...$, side: v.FrontSide };
150
- switch (i.shape.shape_type) {
151
- /**
152
- * Plane shape, uses DH parameters to calculate the size of the plane (reach distance of a robot)
153
- */
154
- case "plane":
155
- h = /* @__PURE__ */ s("planeGeometry", { args: [o, o] });
156
- break;
157
- /**
158
- * Sphere shape
159
- */
160
- case "sphere": {
161
- const f = (i == null ? void 0 : i.shape).radius / 1e3;
162
- h = /* @__PURE__ */ s("sphereGeometry", { args: [f] });
163
- break;
164
- }
165
- /**
166
- * Capsule shape
167
- */
168
- case "capsule": {
169
- const f = (i == null ? void 0 : i.shape).radius / 1e3, l = (i == null ? void 0 : i.shape).cylinder_height / 1e3;
170
- h = /* @__PURE__ */ s("capsuleGeometry", { args: [f, l] });
171
- break;
172
- }
173
- /**
174
- * Convex hull, checks at first if the vertices are coplanar - if yes, adds a small offset for
175
- * renderer to be able to visualize the convex hull.
176
- */
177
- case "convex_hull": {
178
- const f = (i == null ? void 0 : i.shape).vertices.map(
179
- (w) => new v.Vector3(w[0] / 1e3, w[1] / 1e3, w[2] / 1e3)
180
- ), l = Jt(f);
181
- if (l.isCoplanar && l.normal) {
182
- const m = new v.Vector3().addVectors(
183
- f[0],
184
- l.normal.multiplyScalar(1e-4)
185
- );
186
- f.push(m);
187
- }
188
- try {
189
- h = /* @__PURE__ */ s(
190
- "primitive",
191
- {
192
- object: new Ot(f),
193
- attach: "geometry"
194
- }
195
- );
196
- } catch (w) {
197
- return console.log("Error creating ConvexGeometry:", w), null;
198
- }
199
- break;
200
- }
201
- /**
202
- * Convex hull around four spheres. Sphere center points in x/y-plane,
203
- * offset by either combination "+/- sizeX" or "+/- sizeY".
204
- * Alternative description: Rectangle in x/y-plane with a 3D padding (source: nova-api docs)
205
- *
206
- * Basically a rounded box with a rectangular cross-section.
207
- */
208
- case "rectangular_capsule": {
209
- const f = i.shape, l = f.radius / 1e3, w = f.sphere_center_distance_x / 1e3, m = f.sphere_center_distance_y / 1e3, R = l * 2;
210
- h = /* @__PURE__ */ s(
211
- "primitive",
212
- {
213
- object: new Tt(w, m, R, 2, l),
214
- attach: "geometry"
215
- }
216
- );
217
- break;
218
- }
219
- default:
220
- console.warn(
221
- "Unsupported safety zone shape type:",
222
- i.shape.shape_type
223
- ), h = null;
224
- }
225
- return /* @__PURE__ */ b(
226
- "mesh",
227
- {
228
- renderOrder: u,
229
- position: y,
230
- quaternion: kt(p),
231
- children: [
232
- h,
233
- /* @__PURE__ */ s("meshStandardMaterial", { ...r, polygonOffsetFactor: -u })
234
- ]
235
- },
236
- `safety-zone-${i.shape.shape_type}-${u}`
237
- );
238
- }, c = x(() => Object.values(t ?? {}).map(
239
- (u, i) => a(i, u)
240
- ), [t, o]);
241
- return /* @__PURE__ */ s("group", { ...n, children: c });
242
- }
243
- const Ft = ["#ff2060", "#20df80", "#2080ff"], Dt = [
244
- "#6A6A6A",
245
- "#9B9B9B",
246
- "#727272"
247
- ], $t = "#BBBBBB", Ut = 0.5;
248
- function U(t) {
249
- if (!t) return [0, 0, 0, 0, 0, 0, 1];
250
- const { position: e, quaternion: n } = Lt.fromPose(t);
251
- return [
252
- e.x / 1e3,
253
- e.y / 1e3,
254
- e.z / 1e3,
255
- n.x,
256
- n.y,
257
- n.z,
258
- n.w
259
- ];
260
- }
261
- function Bt({
262
- base: t,
263
- tcpOffset: e,
264
- rapidlyChangingMotionState: n,
265
- orientation: o,
266
- rotate: a = !1
267
- }) {
268
- const c = _(null), u = _(null), i = J((p) => p.invalidate), y = o === "tool";
269
- return A(() => {
270
- const p = new Mt(
271
- U(n.flange_pose),
272
- { tension: 120, friction: 20, threshold: 1e-3 }
273
- );
274
- return u.current = p, () => {
275
- p.destroy(), u.current = null;
276
- };
277
- }, []), A(
278
- () => Et(() => {
279
- var h;
280
- const p = n.flange_pose;
281
- p && ((h = u.current) == null || h.setTarget(U(p)), i());
282
- }),
283
- [n, i]
284
- ), xt((p, h) => {
285
- const r = u.current, d = c.current;
286
- if (!r || !d) return;
287
- const g = r.update(h), [f = 0, l = 0, w = 0, m = 0, R = 0, S = 0, O = 1] = r.getCurrentValues();
288
- d.position.set(f, l, w), d.quaternion.set(m, R, S, O), g || i();
289
- }), /* @__PURE__ */ b(k, { children: [
290
- /* @__PURE__ */ s(B, { transform: t, children: /* @__PURE__ */ s(H, { active: !y, rotate: !1 }) }),
291
- /* @__PURE__ */ s("group", { ref: c, children: /* @__PURE__ */ s(B, { transform: e, children: /* @__PURE__ */ s(H, { active: y, rotate: a }) }) })
292
- ] });
293
- }
294
- function B({
295
- transform: t,
296
- children: e
297
- }) {
298
- const n = t == null ? void 0 : t.position;
299
- return /* @__PURE__ */ s(
300
- "group",
301
- {
302
- position: [
303
- ((n == null ? void 0 : n[0]) ?? 0) / 1e3,
304
- ((n == null ? void 0 : n[1]) ?? 0) / 1e3,
305
- ((n == null ? void 0 : n[2]) ?? 0) / 1e3
306
- ],
307
- quaternion: N(
308
- (t == null ? void 0 : t.orientation) ?? [0, 0, 0],
309
- (t == null ? void 0 : t.orientation_type) ?? "ROTATION_VECTOR"
310
- ),
311
- children: e
312
- }
313
- );
314
- }
315
- function H({ active: t, rotate: e }) {
316
- return /* @__PURE__ */ s(
317
- St,
318
- {
319
- depthTest: !1,
320
- scale: 0.12,
321
- disableRotations: !e,
322
- disableSliders: !0,
323
- disableScaling: !0,
324
- autoTransform: !1,
325
- opacity: t ? 1 : Ut,
326
- axisColors: t ? Ft : Dt,
327
- hoveredColor: t ? void 0 : $t
328
- }
329
- );
330
- }
331
- const et = new bt(Math.PI / 2, 0, 0), Ht = console.warn;
332
- function nt() {
333
- return A(() => {
334
- console.warn = (t) => {
335
- t !== "Cannot call the manual advancement of rafz whilst frameLoop is not set as demand" && Ht(t);
336
- };
337
- }, []), null;
338
- }
339
- const Wt = new M(0, 1, 0), ot = /_J([0-9]+)$/, Qt = "_FLG", P = "_REST", L = /* @__PURE__ */ new Map();
340
- async function F(t, e, n) {
341
- const o = e || "";
342
- if (!o)
343
- throw new Error(
344
- `Cannot download the model "${t}": no NOVA instance. Give defaultGetModel the URL of the instance or a NOVA client, or give the component its instanceUrl or getModel.`
345
- );
346
- const a = `${Xt(o)} ${t} ${n ?? ""}`, c = L.get(a);
347
- if (c) return c;
348
- const u = (async () => {
349
- const i = At(o);
350
- try {
351
- const y = n ? await Gt(
352
- i,
353
- t,
354
- n,
355
- "glb"
356
- ) : await i.api.motionGroupModels.getMotionGroupGlbModel(
357
- t,
358
- { responseType: "blob" }
359
- );
360
- return URL.createObjectURL(y);
361
- } catch (y) {
362
- throw console.error("Failed to fetch model:", y), y;
363
- }
364
- })();
365
- return L.set(a, u), u.catch(() => {
366
- L.get(a) === u && L.delete(a);
367
- }), u;
368
- }
369
- async function Ie() {
370
- const t = Array.from(L.values());
371
- L.clear(), await Promise.allSettled(
372
- t.map(async (e) => URL.revokeObjectURL(await e))
373
- );
374
- }
375
- function Xt(t) {
376
- return typeof t == "string" ? t : t.config.instanceUrl;
377
- }
378
- function rt(t) {
379
- function e(n) {
380
- return n.children.length === 0 ? [n] : [n, ...n.children.flatMap((o) => e(o))];
381
- }
382
- return e(t).filter((n) => at(n));
383
- }
384
- function Yt(t, e) {
385
- return t.clone().multiply(new j().setFromAxisAngle(Wt, -e));
386
- }
387
- function Zt(t, e, n) {
388
- const o = D(t);
389
- if (o === null) return null;
390
- const a = e[o];
391
- if (!a || a.type === G.PrismaticJoint) return null;
392
- const c = a.theta ?? 0, u = o === 0 && n ? n.position : t.position, i = o === 0 && n ? n.quaternion : t.quaternion;
393
- return {
394
- position: u,
395
- frame: Yt(i, c),
396
- theta: c
397
- };
398
- }
399
- function Kt(t, e) {
400
- var n;
401
- return D(t) === 0 && ((n = e[0]) == null ? void 0 : n.type) === G.PrismaticJoint;
402
- }
403
- function it(t) {
404
- const e = new j().setFromEuler(et), n = e.clone().invert(), [o = 0, a = 0, c = 0] = (t == null ? void 0 : t.position) ?? [], u = new M(o, a, c).divideScalar(1e3).applyQuaternion(n), [i = 0, y = 0, p = 0] = (t == null ? void 0 : t.orientation) ?? [], h = n.clone().multiply(N([i, y, p], "ROTATION_VECTOR")).multiply(e);
405
- return { position: u, quaternion: h };
406
- }
407
- function zt(t, e) {
408
- const n = D(t);
409
- if (n === null) return null;
410
- const o = e[n];
411
- return !o || o.type !== G.PrismaticJoint ? null : {
412
- position: t.position.clone(),
413
- quaternion: t.quaternion.clone()
414
- };
415
- }
416
- function st(t) {
417
- return t.name.endsWith(Qt);
418
- }
419
- function at(t) {
420
- return ot.test(t.name);
421
- }
422
- function D(t) {
423
- var n;
424
- const e = (n = t.name.match(ot)) == null ? void 0 : n[1];
425
- return e === void 0 ? null : Number.parseInt(e, 10);
426
- }
427
- function te(t, e) {
428
- let n;
429
- function o(a) {
430
- if (st(a)) {
431
- if (n)
432
- throw Error(
433
- `Found multiple flange groups in robot model ${e}; first ${n.name} then ${a.name}. Only one _FLG group is allowed.`
434
- );
435
- n = a;
436
- }
437
- at(a), a.children.map(o);
438
- }
439
- if (o(t.scene), !n)
440
- throw Error(
441
- `No flange group found in robot model ${e}. Flange must be identified with a name ending in _FLG.`
442
- );
443
- return { gltf: t };
444
- }
445
- const ct = Q(function({
446
- rapidlyChangingMotionState: e,
447
- dhParameters: n,
448
- chainOffsetPosition: o,
449
- chainOffsetQuaternion: a,
450
- onTranslationChanged: c,
451
- children: u
452
- }, i) {
453
- const y = _(null), p = _([]), h = _(
454
- e.joint_position.filter(
455
- (m) => m !== void 0
456
- )
457
- ), { invalidate: r } = J(), d = _(e);
458
- d.current = e;
459
- function g(m) {
460
- y.current = m, m && f();
461
- }
462
- function f() {
463
- y.current && (p.current = rt(y.current), l(), r());
464
- }
465
- X(i, () => ({ recollectJoints: f }));
466
- function l() {
467
- const m = h.current;
468
- if (c)
469
- c(p.current, m);
470
- else
471
- for (const [R, S] of p.current.entries()) {
472
- const O = n[R];
473
- if ((O == null ? void 0 : O.type) !== G.PrismaticJoint) continue;
474
- const V = O.reverse_rotation_direction ? -1 : 1;
475
- S.position.y = V * (m[R] || 0) / 1e3;
476
- }
477
- }
478
- function w(m) {
479
- h.current = m.joint_position.filter(
480
- (R) => R !== void 0
481
- ), l(), r();
482
- }
483
- return z(() => {
484
- w(d.current);
485
- }), A(() => {
486
- w(e);
487
- }, [e]), /* @__PURE__ */ s(
488
- "group",
489
- {
490
- ref: g,
491
- position: o,
492
- quaternion: a,
493
- children: u
494
- }
495
- );
496
- });
497
- function ee({
498
- rapidlyChangingMotionState: t,
499
- dhParameters: e,
500
- ...n
501
- }) {
502
- const o = new T(), a = _(null), c = _(null);
503
- function u(p) {
504
- const h = new T();
505
- for (let f = 0; f < e.length; f++) {
506
- const l = e[f], w = p[f] ?? 0, m = new T().makeRotationY(l.theta).multiply(
507
- new T().makeTranslation(
508
- l.a / 1e3,
509
- (l.d + w * (l.reverse_rotation_direction ? -1 : 1)) / 1e3,
510
- 0
511
- )
512
- ).multiply(new T().makeRotationX(l.alpha));
513
- h.multiply(m);
514
- }
515
- const r = new M(), d = new j(), g = new M();
516
- return h.decompose(r, d, g), r;
517
- }
518
- const i = u(
519
- t.joint_position
520
- );
521
- function y(p, h) {
522
- o.identity();
523
- let r = new M();
524
- for (let l = 0; l < e.length; l++) {
525
- const w = h[l] ?? 0, m = e[l], R = new T().makeRotationY(m.theta).multiply(
526
- new T().makeTranslation(
527
- m.a / 1e3,
528
- (m.d + w * (m.reverse_rotation_direction ? -1 : 1)) / 1e3,
529
- 0
530
- )
531
- ).multiply(new T().makeRotationX(m.alpha));
532
- o.multiply(R);
533
- }
534
- const d = new M(), g = new j(), f = new M();
535
- if (o.decompose(d, g, f), r = d, a.current && a.current.position.set(
536
- r.x,
537
- r.y,
538
- r.z
539
- ), c.current) {
540
- const l = c.current.geometry;
541
- l != null && l.setPositions && l.setPositions([
542
- 0,
543
- 0,
544
- 0,
545
- r.x,
546
- r.y,
547
- r.z
548
- ]);
549
- }
550
- }
551
- return /* @__PURE__ */ s(
552
- ct,
553
- {
554
- rapidlyChangingMotionState: t,
555
- dhParameters: e,
556
- onTranslationChanged: y,
557
- children: /* @__PURE__ */ b("group", { ...n, name: "Scene", children: [
558
- /* @__PURE__ */ b("mesh", { name: "Base", position: [0, 0, 0], children: [
559
- /* @__PURE__ */ s("sphereGeometry", { args: [0.02, 32, 32] }),
560
- /* @__PURE__ */ s("meshStandardMaterial", { color: "green", depthTest: !0 })
561
- ] }),
562
- /* @__PURE__ */ s(
563
- K,
564
- {
565
- ref: c,
566
- points: [new M(0, 0, 0), i],
567
- color: "White",
568
- lineWidth: 5
569
- }
570
- ),
571
- /* @__PURE__ */ b("mesh", { ref: a, name: "TCP", position: i, children: [
572
- /* @__PURE__ */ s("sphereGeometry", { args: [0.025, 32, 32] }),
573
- /* @__PURE__ */ s("meshStandardMaterial", { color: "red", depthTest: !0 })
574
- ] })
575
- ] })
576
- }
577
- );
578
- }
579
- function ne(t) {
580
- return t.type === "Mesh";
581
- }
582
- function oe({
583
- url: t,
584
- flangeRef: e,
585
- postModelRender: n,
586
- dhParameters: o = [],
587
- kinematicChainOffset: a,
588
- ...c
589
- }) {
590
- const u = _t(t), y = te(u, "robot.glb").gltf, p = x(
591
- () => it(a),
592
- [a]
593
- );
594
- A(() => {
595
- n == null || n();
596
- }, [t, n]);
597
- function h(r) {
598
- try {
599
- if (ne(r))
600
- return r.geometry ? /* @__PURE__ */ s(
601
- "mesh",
602
- {
603
- name: r.name,
604
- geometry: r.geometry,
605
- material: r.material,
606
- position: r.position,
607
- rotation: r.rotation
608
- },
609
- r.uuid
610
- ) : /* @__PURE__ */ s(
611
- "group",
612
- {
613
- name: r.name,
614
- position: r.position,
615
- rotation: r.rotation
616
- },
617
- r.uuid
618
- );
619
- if (Kt(r, o))
620
- return /* @__PURE__ */ s(
621
- "group",
622
- {
623
- name: `${r.name}${P}`,
624
- position: p.position,
625
- quaternion: p.quaternion,
626
- children: /* @__PURE__ */ s("group", { name: r.name, children: r.children.map(h) })
627
- },
628
- r.uuid
629
- );
630
- const d = zt(r, o);
631
- if (d)
632
- return /* @__PURE__ */ s(
633
- "group",
634
- {
635
- name: `${r.name}${P}`,
636
- position: d.position,
637
- quaternion: d.quaternion,
638
- children: /* @__PURE__ */ s("group", { name: r.name, children: r.children.map(h) })
639
- },
640
- r.uuid
641
- );
642
- const g = Zt(
643
- r,
644
- o,
645
- a ? p : void 0
646
- );
647
- return g ? /* @__PURE__ */ s(
648
- "group",
649
- {
650
- name: `${r.name}${P}`,
651
- position: g.position,
652
- quaternion: g.frame,
653
- children: /* @__PURE__ */ s("group", { name: r.name, rotation: [0, g.theta, 0], children: r.children.map(h) })
654
- },
655
- r.uuid
656
- ) : /* @__PURE__ */ s(
657
- "group",
658
- {
659
- name: r.name,
660
- position: r.position,
661
- rotation: r.rotation,
662
- ref: st(r) ? e : void 0,
663
- children: r.children.map(h)
664
- },
665
- r.uuid
666
- );
667
- } catch (d) {
668
- return console.warn("Error rendering node", r.name, d), null;
669
- }
670
- }
671
- return /* @__PURE__ */ s("group", { ...c, dispose: null, children: h(y.scene) });
672
- }
673
- function lt({
674
- modelURL: t,
675
- flangeRef: e,
676
- postModelRender: n,
677
- dhParameters: o,
678
- kinematicChainOffset: a,
679
- ...c
680
- }) {
681
- const [u, i] = Y(null);
682
- return A(() => {
683
- let y = !1;
684
- return (async () => {
685
- try {
686
- const h = typeof t == "string" ? t : await t;
687
- y || i((r) => r === h ? r : h);
688
- } catch (h) {
689
- console.error("Failed to resolve model URL:", h);
690
- }
691
- })(), () => {
692
- y = !0;
693
- };
694
- }, [t]), u ? /* @__PURE__ */ s(
695
- oe,
696
- {
697
- url: u,
698
- flangeRef: e,
699
- postModelRender: n,
700
- dhParameters: o,
701
- kinematicChainOffset: a,
702
- ...c
703
- }
704
- ) : null;
705
- }
706
- const W = (t, e) => {
707
- const n = [];
708
- t.traverse((o) => {
709
- o instanceof v.Mesh && !o.userData.isGhost && !o.userData.hasGhost && n.push(o);
710
- });
711
- for (const o of n) {
712
- if (!o.parent) continue;
713
- const a = o.clone();
714
- a.visible = !0, a.material = new v.MeshStandardMaterial({
715
- depthTest: !0,
716
- depthWrite: !0,
717
- colorWrite: !1,
718
- polygonOffset: !0,
719
- polygonOffsetFactor: -1,
720
- side: v.DoubleSide
721
- }), a.userData.isGhost = !0;
722
- const c = o.clone();
723
- c.visible = !0, c.material = new v.MeshStandardMaterial({
724
- color: e,
725
- opacity: 0.3,
726
- depthTest: !0,
727
- depthWrite: !1,
728
- transparent: !0,
729
- polygonOffset: !0,
730
- polygonOffsetFactor: -2,
731
- side: v.DoubleSide
732
- }), c.userData.isGhost = !0, o.parent.add(a), o.parent.add(c), o.visible = !1, o.userData.hasGhost = !0;
733
- }
734
- }, re = (t) => {
735
- var n;
736
- const e = [];
737
- t.traverse((o) => {
738
- o instanceof v.Mesh && (o.userData.isGhost ? e.push(o) : o.userData.hasGhost && (o.visible = !0, o.userData.hasGhost = !1));
739
- });
740
- for (const o of e)
741
- (n = o.parent) == null || n.remove(o), o.material instanceof v.Material && o.material.dispose();
742
- };
743
- function ut(t) {
744
- const e = _(null), n = _(t);
745
- n.current = t, A(() => {
746
- const a = e.current;
747
- a && (re(a), t && W(a, t));
748
- }, [t]);
749
- const o = C(() => {
750
- const a = e.current;
751
- a && n.current && W(a, n.current);
752
- }, []);
753
- return { groupRef: e, styleDrawnModel: o };
754
- }
755
- const pt = E(
756
- ({
757
- rapidlyChangingMotionState: t,
758
- modelFromController: e,
759
- dhParameters: n,
760
- serialNumber: o,
761
- kinematicChainOffset: a,
762
- chainOffsetPosition: c,
763
- chainOffsetQuaternion: u,
764
- getModel: i = F,
765
- flangeRef: y,
766
- postModelRender: p,
767
- transparentColor: h,
768
- instanceUrl: r,
769
- ...d
770
- }) => {
771
- const g = _(null), f = ut(h), { styleDrawnModel: l } = f, w = C(() => {
772
- var S;
773
- (S = g.current) == null || S.recollectJoints(), l(), p == null || p();
774
- }, [p, l]), m = x(() => {
775
- const S = i(e, r, o);
776
- if (!S) {
777
- const O = new Blob([], { type: "model/gltf-binary" }), V = new File([O], `${e}.glb`, {
778
- type: "model/gltf-binary"
779
- });
780
- return Promise.resolve(URL.createObjectURL(V));
781
- }
782
- return S;
783
- }, [e, r, o, i]), R = /* @__PURE__ */ s(
784
- ee,
785
- {
786
- rapidlyChangingMotionState: t,
787
- dhParameters: n,
788
- ...d
789
- }
790
- );
791
- return /* @__PURE__ */ b(
792
- tt,
793
- {
794
- fallback: R,
795
- onError: (S) => {
796
- console.warn(S);
797
- },
798
- children: [
799
- /* @__PURE__ */ s(Z, { fallback: R, children: /* @__PURE__ */ s("group", { ref: f.groupRef, children: /* @__PURE__ */ s(
800
- ct,
801
- {
802
- ref: g,
803
- rapidlyChangingMotionState: t,
804
- dhParameters: n,
805
- chainOffsetPosition: c,
806
- chainOffsetQuaternion: u,
807
- children: /* @__PURE__ */ s(
808
- lt,
809
- {
810
- modelURL: m,
811
- postModelRender: w,
812
- flangeRef: y,
813
- dhParameters: n,
814
- kinematicChainOffset: a,
815
- ...d
816
- }
817
- )
818
- }
819
- ) }) }),
820
- /* @__PURE__ */ s(nt, {})
821
- ]
822
- }
823
- );
824
- }
825
- ), Le = E(
826
- ({ rapidlyChangingMotionState: t, ...e }) => {
827
- const n = q(
828
- t
829
- );
830
- return /* @__PURE__ */ s(
831
- pt,
832
- {
833
- rapidlyChangingMotionState: n,
834
- ...e
835
- }
836
- );
837
- }
838
- ), ft = Q(
839
- function({
840
- rapidlyChangingMotionState: e,
841
- dhParameters: n,
842
- chainOffsetPosition: o,
843
- chainOffsetQuaternion: a,
844
- onRotationChanged: c,
845
- children: u
846
- }, i) {
847
- const y = _(null), p = _([]), h = _(
848
- e.joint_position.filter(
849
- (m) => m !== void 0
850
- )
851
- ), { invalidate: r } = J(), d = _(e);
852
- d.current = e;
853
- function g(m) {
854
- y.current = m, m && f();
855
- }
856
- function f() {
857
- y.current && (p.current = rt(y.current), l(), r());
858
- }
859
- X(i, () => ({ recollectJoints: f }));
860
- function l() {
861
- const m = h.current;
862
- if (c)
863
- c(p.current, m);
864
- else
865
- for (const [R, S] of p.current.entries()) {
866
- const O = n[R];
867
- if (!O) continue;
868
- const V = O.theta || 0, dt = O.reverse_rotation_direction ? -1 : 1;
869
- S.rotation.y = dt * (m[R] || 0) + V;
870
- }
871
- }
872
- function w(m) {
873
- h.current = m.joint_position.filter(
874
- (R) => R !== void 0
875
- ), l(), r();
876
- }
877
- return z(() => {
878
- w(d.current);
879
- }), A(() => {
880
- w(e);
881
- }, [e]), /* @__PURE__ */ s(
882
- "group",
883
- {
884
- ref: g,
885
- position: o,
886
- quaternion: a,
887
- children: u
888
- }
889
- );
890
- }
891
- ), ie = "line", se = "mesh";
892
- function ae({
893
- rapidlyChangingMotionState: t,
894
- dhParameters: e,
895
- kinematicChainOffset: n,
896
- ...o
897
- }) {
898
- const a = new T(), c = _([]), u = _([]), i = it(n);
899
- Rt.useEffect(() => {
900
- c.current = new Array(e.length).fill(null), u.current = new Array(e.length).fill(null);
901
- }, [e.length]);
902
- function y(r, d) {
903
- const g = new M(), f = new j(), l = new M();
904
- a.decompose(g, f, l);
905
- const w = g.clone(), m = new T().makeRotationY(
906
- r.theta + d * (r.reverse_rotation_direction ? -1 : 1)
907
- ).multiply(new T().makeTranslation(0, r.d / 1e3, 0)).multiply(new T().makeTranslation(r.a / 1e3, 0, 0)).multiply(new T().makeRotationX(r.alpha));
908
- return a.multiply(m), a.decompose(g, f, l), { a: w, b: g };
909
- }
910
- function p(r, d, g, f) {
911
- if (!e)
912
- return;
913
- const l = e[r];
914
- if (!l)
915
- return;
916
- const { a: w, b: m } = y(l, f);
917
- d.geometry.setPositions([w.toArray(), m.toArray()].flat()), g.position.set(m.x, m.y, m.z);
918
- }
919
- function h(r, d) {
920
- a.identity();
921
- for (let g = 0; g < Math.min(r.length, d.length); g++) {
922
- const f = c.current[g], l = u.current[g];
923
- f && l && p(g, f, l, d[g]);
924
- }
925
- }
926
- return /* @__PURE__ */ s(
927
- ft,
928
- {
929
- rapidlyChangingMotionState: t,
930
- dhParameters: e,
931
- onRotationChanged: h,
932
- children: /* @__PURE__ */ s("group", { ...o, name: "Scene", children: /* @__PURE__ */ b(
933
- "group",
934
- {
935
- position: i.position,
936
- quaternion: i.quaternion,
937
- children: [
938
- /* @__PURE__ */ b("mesh", { children: [
939
- /* @__PURE__ */ s("sphereGeometry", { args: [0.01, 32, 32] }),
940
- /* @__PURE__ */ s("meshStandardMaterial", { color: "black", depthTest: !0 })
941
- ] }),
942
- e == null ? void 0 : e.map((r, d) => {
943
- const { a: g, b: f } = y(
944
- r,
945
- t.joint_position[d] ?? 0
946
- ), l = `dhrobot_J0${d}`;
947
- return /* @__PURE__ */ b("group", { name: l, children: [
948
- /* @__PURE__ */ s(
949
- K,
950
- {
951
- ref: (w) => {
952
- c.current[d] = w;
953
- },
954
- name: ie,
955
- points: [g, f],
956
- color: "white",
957
- lineWidth: 5
958
- }
959
- ),
960
- /* @__PURE__ */ b(
961
- "mesh",
962
- {
963
- ref: (w) => {
964
- u.current[d] = w;
965
- },
966
- name: se,
967
- position: f,
968
- children: [
969
- /* @__PURE__ */ s("sphereGeometry", { args: [0.01, 32, 32] }),
970
- /* @__PURE__ */ s("meshStandardMaterial", { color: "black", depthTest: !0 })
971
- ]
972
- },
973
- `mesh_${d}`
974
- )
975
- ] }, l);
976
- })
977
- ]
978
- }
979
- ) })
980
- }
981
- );
982
- }
983
- const ht = E(
984
- ({
985
- rapidlyChangingMotionState: t,
986
- modelFromController: e,
987
- dhParameters: n,
988
- serialNumber: o,
989
- kinematicChainOffset: a,
990
- chainOffsetPosition: c,
991
- chainOffsetQuaternion: u,
992
- getModel: i = F,
993
- flangeRef: y,
994
- postModelRender: p,
995
- transparentColor: h,
996
- instanceUrl: r,
997
- ...d
998
- }) => {
999
- const g = _(null), f = ut(h), { styleDrawnModel: l } = f, w = C(() => {
1000
- var S;
1001
- (S = g.current) == null || S.recollectJoints(), l(), p == null || p();
1002
- }, [p, l]), m = x(() => {
1003
- const S = i(e, r, o);
1004
- if (!S)
1005
- throw new Error(
1006
- `No model found for robot "${e}". Ensure the model is available or provide a custom getModel function.`
1007
- );
1008
- return S;
1009
- }, [e, r, o, i]), R = /* @__PURE__ */ s(
1010
- ae,
1011
- {
1012
- rapidlyChangingMotionState: t,
1013
- dhParameters: n,
1014
- kinematicChainOffset: a,
1015
- ...d
1016
- }
1017
- );
1018
- return /* @__PURE__ */ b(
1019
- tt,
1020
- {
1021
- fallback: R,
1022
- onError: (S) => {
1023
- console.warn(S);
1024
- },
1025
- children: [
1026
- /* @__PURE__ */ s(Z, { fallback: R, children: /* @__PURE__ */ s("group", { ref: f.groupRef, children: /* @__PURE__ */ s(
1027
- ft,
1028
- {
1029
- ref: g,
1030
- rapidlyChangingMotionState: t,
1031
- dhParameters: n,
1032
- chainOffsetPosition: c,
1033
- chainOffsetQuaternion: u,
1034
- children: /* @__PURE__ */ s(
1035
- lt,
1036
- {
1037
- modelURL: m,
1038
- postModelRender: w,
1039
- flangeRef: y,
1040
- dhParameters: n,
1041
- kinematicChainOffset: a,
1042
- ...d
1043
- }
1044
- )
1045
- }
1046
- ) }) }),
1047
- /* @__PURE__ */ s(nt, {})
1048
- ]
1049
- }
1050
- );
1051
- }
1052
- ), Ee = E(
1053
- ({ rapidlyChangingMotionState: t, ...e }) => {
1054
- const n = q(
1055
- t
1056
- );
1057
- return /* @__PURE__ */ s(
1058
- ht,
1059
- {
1060
- rapidlyChangingMotionState: n,
1061
- ...e
1062
- }
1063
- );
1064
- }
1065
- ), mt = E((t) => {
1066
- const { inverseSolver: e, dhParameters: n, ...o } = t, [a, c] = Y(
1067
- G.RevoluteJoint
1068
- );
1069
- A(() => {
1070
- n.length && c(n[0].type ?? G.RevoluteJoint);
1071
- }, [n]);
1072
- const u = x(() => e === null && a === G.RevoluteJoint, [e, a]), i = x(() => e === null && a === G.PrismaticJoint, [e, a]);
1073
- return x(() => !!e, [e]) || u ? /* @__PURE__ */ s(ht, { dhParameters: n, ...o }) : i ? /* @__PURE__ */ s(pt, { dhParameters: n, ...o }) : null;
1074
- }), ce = E((t) => {
1075
- const e = q(
1076
- t.rapidlyChangingMotionState
1077
- );
1078
- return /* @__PURE__ */ s(
1079
- mt,
1080
- {
1081
- ...t,
1082
- rapidlyChangingMotionState: e
1083
- }
1084
- );
1085
- }), le = [-4, 1, 4], ue = {
1086
- timestamp: "",
1087
- sequence_number: 0,
1088
- motion_group: "",
1089
- controller: "",
1090
- joint_limit_reached: { limit_reached: [] },
1091
- standstill: !0,
1092
- description_revision: 0
1093
- };
1094
- function pe({
1095
- robot: t,
1096
- getModel: e,
1097
- safetyZones: n,
1098
- plannedJoints: o,
1099
- jogAxes: a,
1100
- robotVisible: c = !0,
1101
- robotRef: u,
1102
- onModelDrawn: i,
1103
- lighting: y = !0,
1104
- children: p
1105
- }) {
1106
- const h = wt(), r = t.nova, d = C(
1107
- (w, m, R) => F(w, r, R),
1108
- [r]
1109
- ), g = e ?? d, f = x(
1110
- () => o ? { ...ue, joint_position: o } : null,
1111
- [o]
1112
- );
1113
- if (!t.dhParameters) return null;
1114
- const l = {
1115
- // The model comes from loadModel
1116
- instanceUrl: "",
1117
- getModel: g,
1118
- inverseSolver: t.inverseSolver,
1119
- modelFromController: t.modelFromController ?? "",
1120
- serialNumber: t.serialNumber,
1121
- dhParameters: t.dhParameters,
1122
- kinematicChainOffset: t.kinematicChainOffset
1123
- };
1124
- return /* @__PURE__ */ b(k, { children: [
1125
- n && /* @__PURE__ */ s(
1126
- Nt,
1127
- {
1128
- safetyZones: n,
1129
- dhParameters: t.dhParameters
1130
- }
1131
- ),
1132
- /* @__PURE__ */ s(
1133
- "group",
1134
- {
1135
- ref: u,
1136
- position: t.mountingPosition,
1137
- quaternion: t.mountingQuaternion,
1138
- children: /* @__PURE__ */ b("group", { rotation: et, children: [
1139
- /* @__PURE__ */ s("group", { visible: c, children: /* @__PURE__ */ s(
1140
- ce,
1141
- {
1142
- ...l,
1143
- rapidlyChangingMotionState: t.rapidlyChangingMotionState,
1144
- postModelRender: i
1145
- }
1146
- ) }),
1147
- f && /* @__PURE__ */ s(
1148
- mt,
1149
- {
1150
- ...l,
1151
- rapidlyChangingMotionState: f,
1152
- transparentColor: h.palette.success.main
1153
- }
1154
- ),
1155
- y && /* @__PURE__ */ s(
1156
- "directionalLight",
1157
- {
1158
- position: le,
1159
- castShadow: !0,
1160
- intensity: 1
1161
- }
1162
- )
1163
- ] })
1164
- }
1165
- ),
1166
- a && /* @__PURE__ */ s(Bt, { ...a }),
1167
- y && /* @__PURE__ */ s(jt, {}),
1168
- p
1169
- ] });
1170
- }
1171
- function fe(t) {
1172
- var a, c, u, i, y, p;
1173
- const { description: e, state: n } = t, o = e.mounting;
1174
- return {
1175
- nova: t.nova,
1176
- modelFromController: e.motionGroupModel,
1177
- dhParameters: e.dhParameters,
1178
- inverseSolver: e.inverseSolver,
1179
- serialNumber: e.serialNumber,
1180
- kinematicChainOffset: e.kinematicChainOffset,
1181
- rapidlyChangingMotionState: n.rapidlyChangingMotionState,
1182
- mountingPosition: [
1183
- (((a = o == null ? void 0 : o.position) == null ? void 0 : a[0]) ?? 0) / 1e3,
1184
- (((c = o == null ? void 0 : o.position) == null ? void 0 : c[1]) ?? 0) / 1e3,
1185
- (((u = o == null ? void 0 : o.position) == null ? void 0 : u[2]) ?? 0) / 1e3
1186
- ],
1187
- mountingQuaternion: N(
1188
- [
1189
- ((i = o == null ? void 0 : o.orientation) == null ? void 0 : i[0]) ?? 0,
1190
- ((y = o == null ? void 0 : o.orientation) == null ? void 0 : y[1]) ?? 0,
1191
- ((p = o == null ? void 0 : o.orientation) == null ? void 0 : p[2]) ?? 0
1192
- ],
1193
- "ROTATION_VECTOR"
1194
- )
1195
- };
1196
- }
1197
- function he(t) {
1198
- var u;
1199
- const { description: e, jogging: n } = t, o = x(
1200
- () => Vt(() => {
1201
- const i = t.trajectory.plannedTrajectory;
1202
- return i ? t.state.isAt({
1203
- type: "joint",
1204
- motionGroupId: t.motionGroupId,
1205
- joints: i.endJoints
1206
- }) ? null : i.endJoints : null;
1207
- }),
1208
- [t]
1209
- ).get(), a = n.selectedOrientation === "tool", c = n.selectedTcpId;
1210
- return {
1211
- robot: fe(t),
1212
- safetyZones: e.safetyZones,
1213
- plannedJoints: o,
1214
- jogAxes: {
1215
- base: a ? It(
1216
- n.selectedCoordSystemId,
1217
- n.coordSystems
1218
- ) : n.jogCoordSystem,
1219
- tcpOffset: c ? (u = e.tcpOffsetsById[c]) == null ? void 0 : u.pose : void 0,
1220
- rapidlyChangingMotionState: t.state.rapidlyChangingMotionState,
1221
- orientation: n.selectedOrientation,
1222
- rotate: n.selectedCartesianMotionType === "rotate"
1223
- }
1224
- };
1225
- }
1226
- const Ve = yt(function({
1227
- session: e,
1228
- ...n
1229
- }) {
1230
- const o = gt(e), a = he(o);
1231
- return /* @__PURE__ */ s(pe, { ...a, ...n });
1232
- });
1233
- export {
1234
- ee as D,
1235
- Qt as F,
1236
- ot as J,
1237
- et as M,
1238
- jt as P,
1239
- Ve as R,
1240
- Nt as S,
1241
- P as a,
1242
- Bt as b,
1243
- ce as c,
1244
- mt as d,
1245
- pe as e,
1246
- Le as f,
1247
- pt as g,
1248
- Ee as h,
1249
- ht as i,
1250
- F as j,
1251
- D as k,
1252
- fe as l,
1253
- Ie as r,
1254
- he as u
1255
- };