@wandelbots/wandelbots-js-react-components 6.3.0 → 6.4.0-pr.chore-playground-tool-steps.664.4537d63

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 (191) hide show
  1. package/README.md +323 -120
  2. package/dist/3d.cjs +1 -1
  3. package/dist/3d.d.ts +5 -3
  4. package/dist/3d.js +24 -23
  5. package/dist/CurrentPoseBar/index.cjs +1 -0
  6. package/dist/CurrentPoseBar/index.d.ts +2 -0
  7. package/dist/CurrentPoseBar/index.js +5 -0
  8. package/dist/JoggingButtons/index.cjs +1 -0
  9. package/dist/JoggingButtons/index.d.ts +3 -0
  10. package/dist/JoggingButtons/index.js +5 -0
  11. package/dist/JoggingGizmo/index.cjs +1 -0
  12. package/dist/JoggingGizmo/index.d.ts +4 -0
  13. package/dist/JoggingGizmo/index.js +7 -0
  14. package/dist/JoggingJointSlider/index.cjs +1 -0
  15. package/dist/JoggingJointSlider/index.d.ts +2 -0
  16. package/dist/JoggingJointSlider/index.js +5 -0
  17. package/dist/RobotControlPanel/index.cjs +1 -0
  18. package/dist/RobotControlPanel/index.d.ts +2 -0
  19. package/dist/RobotControlPanel/index.js +5 -0
  20. package/dist/RobotHeader/index.cjs +1 -0
  21. package/dist/RobotHeader/index.d.ts +4 -0
  22. package/dist/RobotHeader/index.js +5 -0
  23. package/dist/SafetyBar/index.cjs +1 -1
  24. package/dist/SafetyBar/index.js +1 -1
  25. package/dist/chunks/CurrentPoseBar-CyHUWmjM.cjs +1 -0
  26. package/dist/chunks/CurrentPoseBar-zTZi68tY.js +505 -0
  27. package/dist/chunks/JoggingButtons-CXaozFVz.js +108 -0
  28. package/dist/chunks/JoggingButtons-CbL-5LMK.cjs +1 -0
  29. package/dist/chunks/JoggingGizmo-DGbFLWgT.cjs +1 -0
  30. package/dist/chunks/JoggingGizmo-SuS9MmL7.js +810 -0
  31. package/dist/chunks/JoggingGizmoOrientation-dzned4f4.cjs +1 -0
  32. package/dist/chunks/JoggingGizmoOrientation-x_crT_64.js +14 -0
  33. package/dist/chunks/JoggingJointSlider-CZ-k6XCa.js +406 -0
  34. package/dist/chunks/JoggingJointSlider-R3_A9Ppj.cjs +1 -0
  35. package/dist/chunks/Robot-D0ZqUCn3.cjs +1 -0
  36. package/dist/chunks/Robot-UoykZeYH.js +1272 -0
  37. package/dist/chunks/RobotControlPanel-BnMfmO41.js +822 -0
  38. package/dist/chunks/RobotControlPanel-BuDGcxPR.cjs +1 -0
  39. package/dist/chunks/RobotHeader-BZci9ahT.js +244 -0
  40. package/dist/chunks/RobotHeader-CqK0700U.cjs +1 -0
  41. package/dist/chunks/SafetyBar-Bbg-o8h9.cjs +1 -0
  42. package/dist/chunks/{SafetyBar-Cy9DiXp9.js → SafetyBar-Cuak4ffd.js} +11 -10
  43. package/dist/chunks/SmallSelect-BdD9uLKK.js +52 -0
  44. package/dist/chunks/SmallSelect-Dcsd7_6_.cjs +1 -0
  45. package/dist/chunks/TrajectoryExecutionStore-DPqfDcfn.js +3398 -0
  46. package/dist/chunks/TrajectoryExecutionStore-DV6mLEx9.cjs +3 -0
  47. package/dist/chunks/converters-C8I_A_tA.cjs +1 -0
  48. package/dist/chunks/converters-DpNB_WNQ.js +39 -0
  49. package/dist/chunks/externalizeComponent-BdxGBLIv.cjs +2 -0
  50. package/dist/chunks/externalizeComponent-_w2d1_pz.js +283 -0
  51. package/dist/chunks/holdSafety-BtoZ5We3.cjs +1 -0
  52. package/dist/chunks/holdSafety-Di1GZAWg.js +37 -0
  53. package/dist/chunks/joggingColors-CuT5u0H8.js +135 -0
  54. package/dist/chunks/joggingColors-ZDc_2UCp.cjs +1 -0
  55. package/dist/chunks/useEveryFrame-G_-ma1nC.js +142 -0
  56. package/dist/chunks/useEveryFrame-dmPPTKtT.cjs +1 -0
  57. package/dist/chunks/useSmoothedMotionState-COMJRcOt.js +214 -0
  58. package/dist/chunks/useSmoothedMotionState-Con0E5Bx.cjs +1 -0
  59. package/dist/components/AppHeader.d.ts +1 -1
  60. package/dist/components/currentPoseBar/CurrentPoseBar.d.ts +48 -0
  61. package/dist/components/currentPoseBar/OrientationFormatPopover.d.ts +19 -0
  62. package/dist/components/currentPoseBar/StreamStatus.d.ts +10 -0
  63. package/dist/components/currentPoseBar/orientation.d.ts +34 -0
  64. package/dist/components/currentPoseBar/poseValues.d.ts +15 -0
  65. package/dist/components/jogging/JoggingButtons.d.ts +16 -0
  66. package/dist/components/jogging/JoggingCartesianAxisControl.d.ts +1 -1
  67. package/dist/components/jogging/JoggingJointTab.d.ts +1 -1
  68. package/dist/components/jogging/JoggingPanel.d.ts +6 -3
  69. package/dist/components/jogging/JoggingStore.d.ts +96 -19
  70. package/dist/components/jogging/gizmo/JoggingGizmo.d.ts +43 -0
  71. package/dist/components/jogging/gizmo/JoggingGizmoOrientation.d.ts +26 -0
  72. package/dist/components/jogging/gizmo/RotationHandles.d.ts +7 -0
  73. package/dist/components/jogging/gizmo/RotationScene.d.ts +6 -0
  74. package/dist/components/jogging/gizmo/TranslationHandles.d.ts +6 -0
  75. package/dist/components/jogging/gizmo/TranslationScene.d.ts +6 -0
  76. package/dist/components/jogging/gizmo/arcGrabAreas.d.ts +58 -0
  77. package/dist/components/jogging/gizmo/arcs.d.ts +54 -0
  78. package/dist/components/jogging/gizmo/arrows.d.ts +63 -0
  79. package/dist/components/jogging/gizmo/gizmoShared.d.ts +125 -0
  80. package/dist/components/jogging/gizmo/gizmoView.d.ts +42 -0
  81. package/dist/components/jogging/gizmo/useGizmoTurn.d.ts +11 -0
  82. package/dist/components/jogging/holdSafety.d.ts +44 -0
  83. package/dist/components/jogging/jogError.d.ts +9 -0
  84. package/dist/components/jogging/jogHandle.d.ts +23 -0
  85. package/dist/components/jogging/joggingColors.d.ts +24 -0
  86. package/dist/components/jogging/joggingVelocity.d.ts +21 -0
  87. package/dist/components/jogging/joint/JoggingJointSlider.d.ts +52 -0
  88. package/dist/components/jogging/joint/JointSliderTrack.d.ts +27 -0
  89. package/dist/components/jogging/joint/jointJog.d.ts +55 -0
  90. package/dist/components/jogging/joint/useJointJogHold.d.ts +48 -0
  91. package/dist/components/jogging/useHold.d.ts +38 -0
  92. package/dist/components/jogging/useJogControls.d.ts +45 -0
  93. package/dist/components/robotControl/CartesianJogTab.d.ts +21 -0
  94. package/dist/components/robotControl/HoldToMoveButton.d.ts +25 -0
  95. package/dist/components/robotControl/JogArea.d.ts +22 -0
  96. package/dist/components/robotControl/JogModeToggle.d.ts +8 -0
  97. package/dist/components/robotControl/JointJogTab.d.ts +11 -0
  98. package/dist/components/robotControl/MoveToTab.d.ts +18 -0
  99. package/dist/components/robotControl/PanelSelect.d.ts +13 -0
  100. package/dist/components/robotControl/PoseField.d.ts +21 -0
  101. package/dist/components/robotControl/RobotControlPanel.d.ts +212 -0
  102. package/dist/components/robotControl/Section.d.ts +5 -0
  103. package/dist/components/robotControl/SmallSelect.d.ts +15 -0
  104. package/dist/components/robotControl/VelocityRow.d.ts +14 -0
  105. package/dist/components/robotControl/atPose.d.ts +8 -0
  106. package/dist/components/robotControl/poseText.d.ts +15 -0
  107. package/dist/components/robotControl/units.d.ts +16 -0
  108. package/dist/components/robotControl/useCopyText.d.ts +12 -0
  109. package/dist/components/robotControl/useEveryFrame.d.ts +6 -0
  110. package/dist/components/robotHeader/ActivationSwitch.d.ts +7 -0
  111. package/dist/components/robotHeader/AppNavigation.d.ts +15 -0
  112. package/dist/components/robotHeader/RobotHeader.d.ts +42 -0
  113. package/dist/components/robots/GenericRobot.d.ts +2 -1
  114. package/dist/components/robots/LinearAxis.d.ts +1 -1
  115. package/dist/components/robots/LinearAxisAnimator.d.ts +11 -2
  116. package/dist/components/robots/Robot.d.ts +1 -1
  117. package/dist/components/robots/robotModelLogic.d.ts +11 -9
  118. package/dist/components/utils/hooks.d.ts +1 -6
  119. package/dist/core.cjs +1 -1
  120. package/dist/core.d.ts +13 -18
  121. package/dist/core.js +37 -51
  122. package/dist/index.cjs +1 -1
  123. package/dist/index.js +58 -71
  124. package/dist/lib/ConnectedMotionGroup.d.ts +5 -7
  125. package/dist/lib/JoggerConnection.d.ts +137 -27
  126. package/dist/lib/MotionStreamConnection.d.ts +15 -6
  127. package/dist/lib/Pose3.d.ts +22 -0
  128. package/dist/lib/PoseTransformer.d.ts +25 -0
  129. package/dist/lib/TrajectoryExecutionStore.d.ts +129 -0
  130. package/dist/lib/connectionLogger.d.ts +9 -0
  131. package/dist/lib/incrementalCartesianMotion.d.ts +40 -0
  132. package/dist/lib/motionStateUpdate.d.ts +27 -0
  133. package/dist/lib/novaConnection.d.ts +23 -0
  134. package/dist/lib/planErrorTranslation.d.ts +8 -0
  135. package/dist/lib/rotation.d.ts +12 -0
  136. package/package.json +31 -66
  137. package/dist/Setup.d.ts +0 -11
  138. package/dist/chunks/MotionGroupVisualizer-DshWR1wY.js +0 -1653
  139. package/dist/chunks/MotionGroupVisualizer-eD7yFEcF.cjs +0 -1
  140. package/dist/chunks/SafetyBar-DPrv_OQA.cjs +0 -1
  141. package/dist/chunks/externalizeComponent-EDymnaGR.js +0 -268
  142. package/dist/chunks/externalizeComponent-OO4jcrz5.cjs +0 -2
  143. package/dist/chunks/theming-DfSy4-Ic.cjs +0 -4
  144. package/dist/chunks/theming-mF9Rt8SS.js +0 -5542
  145. package/dist/chunks/useSmoothedMotionState-DyDgSVYX.js +0 -478
  146. package/dist/chunks/useSmoothedMotionState-VYxEIyfr.cjs +0 -1
  147. package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts +0 -11
  148. package/dist/components/AdornedTextField.d.ts +0 -7
  149. package/dist/components/CopyableText.d.ts +0 -6
  150. package/dist/components/CycleTimer/CycleTimer.d.ts +0 -3
  151. package/dist/components/CycleTimer/DefaultVariant.d.ts +0 -9
  152. package/dist/components/CycleTimer/SmallVariant.d.ts +0 -10
  153. package/dist/components/CycleTimer/index.d.ts +0 -27
  154. package/dist/components/CycleTimer/types.d.ts +0 -49
  155. package/dist/components/CycleTimer/useAnimations.d.ts +0 -14
  156. package/dist/components/CycleTimer/useTimerLogic.d.ts +0 -24
  157. package/dist/components/CycleTimer/utils.d.ts +0 -21
  158. package/dist/components/CycleTimer.d.ts +0 -3
  159. package/dist/components/DataGrid.d.ts +0 -66
  160. package/dist/components/LogPanel.d.ts +0 -38
  161. package/dist/components/LogStore.d.ts +0 -12
  162. package/dist/components/LogViewer.d.ts +0 -46
  163. package/dist/components/ProgramControl.d.ts +0 -55
  164. package/dist/components/ProgramStateIndicator.d.ts +0 -26
  165. package/dist/components/RobotCard.d.ts +0 -98
  166. package/dist/components/RobotListItem.d.ts +0 -34
  167. package/dist/components/RobotSetupReadinessIndicator.d.ts +0 -37
  168. package/dist/components/SelectableFab.d.ts +0 -7
  169. package/dist/components/TabBar.d.ts +0 -45
  170. package/dist/components/ThemeSelect.d.ts +0 -6
  171. package/dist/components/Timer/Timer.d.ts +0 -3
  172. package/dist/components/Timer/TimerDefaultVariant.d.ts +0 -9
  173. package/dist/components/Timer/TimerSmallVariant.d.ts +0 -10
  174. package/dist/components/Timer/index.d.ts +0 -19
  175. package/dist/components/Timer/types.d.ts +0 -35
  176. package/dist/components/Timer/useTimerAnimations.d.ts +0 -10
  177. package/dist/components/Timer/useTimerLogic.d.ts +0 -19
  178. package/dist/components/Timer/utils.d.ts +0 -17
  179. package/dist/components/Timer.d.ts +0 -3
  180. package/dist/components/TransparentOverlay.d.ts +0 -4
  181. package/dist/components/jogging/JoggingFreedriveTab.d.ts +0 -1
  182. package/dist/components/jogging/PoseCartesianValues.d.ts +0 -9
  183. package/dist/components/jogging/PoseJointValues.d.ts +0 -8
  184. package/dist/components/robots/AxisConfig.d.ts +0 -2
  185. package/dist/components/robots/manufacturerHomePositions.d.ts +0 -20
  186. package/dist/icons/DropdownArrowIcon.d.ts +0 -2
  187. package/dist/icons/index.d.ts +0 -12
  188. package/dist/lib/novaCompat.d.ts +0 -16
  189. package/dist/themes/createDarkTheme.d.ts +0 -7
  190. package/dist/themes/themeTypes.d.ts +0 -40
  191. package/dist/themes/theming.d.ts +0 -24
@@ -0,0 +1,1272 @@
1
+ import { jsx as s, jsxs as T, Fragment as ft } from "react/jsx-runtime";
2
+ import * as R from "three";
3
+ import { Matrix4 as b, Vector3 as x, Quaternion as k } from "three";
4
+ import { ConvexGeometry as H, RoundedBoxGeometry as mt } from "three-stdlib";
5
+ import { Line as V, Environment as ht, Lightformer as G, useGLTF as dt } from "@react-three/drei";
6
+ import gt, { useMemo as L, forwardRef as Q, useRef as S, useImperativeHandle as B, useEffect as P, useState as C, useCallback as A, Suspense as X } from "react";
7
+ import { d as yt, v as wt, o as Rt } from "./converters-DpNB_WNQ.js";
8
+ import { JointTypeEnum as I } from "@wandelbots/nova-js/v2";
9
+ import { e as E } from "./externalizeComponent-_w2d1_pz.js";
10
+ import { c as _t, b as Y, a as j } from "./useSmoothedMotionState-COMJRcOt.js";
11
+ import { ErrorBoundary as Z } from "react-error-boundary";
12
+ import { useThree as K } from "@react-three/fiber";
13
+ function bt(t) {
14
+ switch (t.shape_type) {
15
+ case "convex_hull":
16
+ return new H(
17
+ t.vertices.map(
18
+ (e) => new R.Vector3(
19
+ e[0] / 1e3,
20
+ e[1] / 1e3,
21
+ e[2] / 1e3
22
+ )
23
+ )
24
+ );
25
+ case "box":
26
+ return new R.BoxGeometry(
27
+ t.size_x / 1e3,
28
+ t.size_y / 1e3,
29
+ t.size_z / 1e3
30
+ );
31
+ case "sphere":
32
+ return new R.SphereGeometry(t.radius / 1e3);
33
+ case "capsule":
34
+ return new R.CapsuleGeometry(
35
+ t.radius / 1e3,
36
+ t.cylinder_height / 1e3
37
+ );
38
+ case "cylinder":
39
+ return new R.CylinderGeometry(
40
+ t.radius / 1e3,
41
+ t.radius / 1e3,
42
+ t.height / 1e3
43
+ );
44
+ case "rectangle":
45
+ return new R.BoxGeometry(t.size_x / 1e3, t.size_y / 1e3, 0);
46
+ default:
47
+ return console.warn(`${t.shape_type} is not supported`), new R.BufferGeometry();
48
+ }
49
+ }
50
+ function vt({
51
+ name: t,
52
+ collider: n,
53
+ children: e
54
+ }) {
55
+ var c, l;
56
+ const o = ((c = n.pose) == null ? void 0 : c.position) ?? [0, 0, 0], r = ((l = n.pose) == null ? void 0 : l.orientation) ?? [0, 0, 0];
57
+ return n.margin && console.warn(`${t} margin is not supported`), /* @__PURE__ */ s(
58
+ "mesh",
59
+ {
60
+ name: t,
61
+ position: new R.Vector3(
62
+ o[0],
63
+ o[1],
64
+ o[2]
65
+ ).divideScalar(1e3),
66
+ rotation: new R.Euler(r[0], r[1], r[2], "XYZ"),
67
+ geometry: bt(n.shape),
68
+ children: e
69
+ }
70
+ );
71
+ }
72
+ function St({
73
+ name: t,
74
+ colliders: n,
75
+ meshChildrenProvider: e,
76
+ ...o
77
+ }) {
78
+ return /* @__PURE__ */ s("group", { name: t, ...o, children: Object.entries(n).map(([r, c]) => /* @__PURE__ */ s(
79
+ vt,
80
+ {
81
+ name: r,
82
+ collider: c,
83
+ children: e(r, c)
84
+ },
85
+ r
86
+ )) });
87
+ }
88
+ function se({
89
+ scene: t,
90
+ meshChildrenProvider: n
91
+ }) {
92
+ const e = t.colliders;
93
+ return /* @__PURE__ */ s("group", { children: e && /* @__PURE__ */ s(
94
+ St,
95
+ {
96
+ meshChildrenProvider: n,
97
+ colliders: e
98
+ }
99
+ ) });
100
+ }
101
+ function Tt(t) {
102
+ const n = (t == null ? void 0 : t.position) ?? [], e = (t == null ? void 0 : t.orientation) ?? [], o = new x(
103
+ e[0] ?? 0,
104
+ e[1] ?? 0,
105
+ e[2] ?? 0
106
+ ), r = o.length(), c = r > 0 ? new k().setFromAxisAngle(o.normalize(), r) : new k();
107
+ return new b().compose(
108
+ new x(
109
+ n[0] ?? 0,
110
+ n[1] ?? 0,
111
+ n[2] ?? 0
112
+ ).divideScalar(1e3),
113
+ c,
114
+ new x(1, 1, 1)
115
+ );
116
+ }
117
+ function Mt(t, n = null, e = []) {
118
+ const o = Tt(n);
119
+ return t.map((r, c) => {
120
+ const l = o.clone(), i = (r.reverse_rotation_direction ? -1 : 1) * (e[c] ?? 0), a = r.type === "PRISMATIC_JOINT", p = (r.theta ?? 0) + (a ? 0 : i), f = (r.d ?? 0) + (a ? i : 0);
121
+ return o.multiply(new b().makeRotationZ(p)).multiply(
122
+ new b().makeTranslation((r.a ?? 0) / 1e3, 0, f / 1e3)
123
+ ).multiply(new b().makeRotationX(r.alpha ?? 0)), l;
124
+ });
125
+ }
126
+ const N = "#ff4b4b", U = "#2fa8ff", xt = "#8a8d9e", Lt = 96, Ot = 0.15, Gt = new R.Vector3(0, 1, 0), Pt = 0.2, At = 2;
127
+ function Et(t) {
128
+ const { lower_limit: n, upper_limit: e } = t ?? {};
129
+ return typeof n != "number" || typeof e != "number" || !Number.isFinite(n) || !Number.isFinite(e) || !(n < e) ? null : { lower_limit: n, upper_limit: e };
130
+ }
131
+ function D({
132
+ base: t,
133
+ direction: n,
134
+ size: e,
135
+ color: o,
136
+ opacity: r
137
+ }) {
138
+ const c = new R.Quaternion().setFromUnitVectors(
139
+ Gt,
140
+ n.clone().normalize()
141
+ ), l = t.clone().addScaledVector(n.clone().normalize(), e / 2);
142
+ return /* @__PURE__ */ T("mesh", { position: l, quaternion: c, renderOrder: 10, children: [
143
+ /* @__PURE__ */ s("coneGeometry", { args: [e * 0.35, e, 16] }),
144
+ /* @__PURE__ */ s(
145
+ "meshBasicMaterial",
146
+ {
147
+ color: o,
148
+ depthTest: !1,
149
+ transparent: !0,
150
+ opacity: r
151
+ }
152
+ )
153
+ ] });
154
+ }
155
+ function $({
156
+ points: t,
157
+ color: n,
158
+ width: e,
159
+ opacity: o
160
+ }) {
161
+ return /* @__PURE__ */ s(
162
+ V,
163
+ {
164
+ points: t,
165
+ color: n,
166
+ lineWidth: e,
167
+ depthTest: !1,
168
+ transparent: !0,
169
+ opacity: o,
170
+ renderOrder: 10
171
+ }
172
+ );
173
+ }
174
+ function W(t, n) {
175
+ const e = [...t];
176
+ let o = n;
177
+ for (; e.length > 1; ) {
178
+ const r = e[e.length - 1], c = e[e.length - 2], l = r.distanceTo(c);
179
+ if (l > o)
180
+ return e[e.length - 1] = r.clone().lerp(c, o / l), e;
181
+ o -= l, e.pop();
182
+ }
183
+ return e;
184
+ }
185
+ function kt(t, n, e, o) {
186
+ const r = e * t, c = e * n, l = Math.abs(c - r), i = Math.max(
187
+ 2,
188
+ Math.ceil(l / (2 * Math.PI) * Lt)
189
+ );
190
+ return Array.from({ length: i + 1 }, (a, p) => {
191
+ const f = r + (c - r) * p / i, u = l * p / i / (2 * Math.PI), y = o * (1 + Ot * u);
192
+ return new R.Vector3(
193
+ Math.cos(f) * y,
194
+ Math.sin(f) * y,
195
+ 0
196
+ );
197
+ });
198
+ }
199
+ function It(t, n, e, o) {
200
+ const r = t.theta ?? 0, c = t.d ?? 0, l = t.type === "PRISMATIC_JOINT", i = t.reverse_rotation_direction ? -1 : 1, { lower_limit: a, upper_limit: p } = n;
201
+ return L(() => {
202
+ const f = new R.Matrix4().makeRotationZ(r).multiply(
203
+ new R.Matrix4().makeTranslation(0, 0, l ? c / 1e3 : 0)
204
+ ), u = (v, M, O) => new R.Vector3(v, M, O).applyMatrix4(f), y = new R.Vector3().applyMatrix4(f), w = u(0, 0, e), h = (l ? [
205
+ u(e * 0.25, 0, i * a / 1e3),
206
+ u(e * 0.25, 0, i * p / 1e3)
207
+ ] : kt(a, p, i, e * 0.6)).map((v) => l ? v : v.applyMatrix4(f)), m = u(l ? e * 0.25 : e * 0.6, 0, 0), _ = h.slice(1).reduce((v, M, O) => v + M.distanceTo(h[O]), 0), d = Math.min(o, _ / 3), g = W(
208
+ W(h, d).reverse(),
209
+ d
210
+ ).reverse();
211
+ return {
212
+ axisPoints: [y, w],
213
+ axisTip: w,
214
+ origin: y,
215
+ restPoints: [y, m],
216
+ range: h,
217
+ limitPoints: g,
218
+ rangeStart: g[0],
219
+ rangeEnd: g[g.length - 1]
220
+ };
221
+ }, [r, c, l, i, e, a, p, o]);
222
+ }
223
+ function Ft({
224
+ frame: t,
225
+ dh: n,
226
+ limit: e,
227
+ size: o,
228
+ emphasis: r
229
+ }) {
230
+ const c = r === "highlighted" ? At : 1, l = r === "dimmed" ? Pt : 1, i = o * 0.2 * (r === "highlighted" ? 1.4 : 1), a = 2 * c, {
231
+ axisPoints: p,
232
+ axisTip: f,
233
+ origin: u,
234
+ restPoints: y,
235
+ range: w,
236
+ limitPoints: h,
237
+ rangeStart: m,
238
+ rangeEnd: _
239
+ } = It(n, e, o, i), { position: d, quaternion: g } = L(() => {
240
+ const v = new R.Vector3(), M = new R.Quaternion();
241
+ return t.decompose(v, M, new R.Vector3()), { position: v, quaternion: M };
242
+ }, [t]);
243
+ return /* @__PURE__ */ T("group", { position: d, quaternion: g, children: [
244
+ /* @__PURE__ */ s(
245
+ $,
246
+ {
247
+ points: p,
248
+ color: U,
249
+ width: a,
250
+ opacity: l
251
+ }
252
+ ),
253
+ /* @__PURE__ */ s(
254
+ D,
255
+ {
256
+ base: f,
257
+ direction: f.clone().sub(u),
258
+ size: i,
259
+ color: U,
260
+ opacity: l
261
+ }
262
+ ),
263
+ /* @__PURE__ */ s(
264
+ $,
265
+ {
266
+ points: y,
267
+ color: xt,
268
+ width: 1.5 * c,
269
+ opacity: l
270
+ }
271
+ ),
272
+ /* @__PURE__ */ s(
273
+ $,
274
+ {
275
+ points: h,
276
+ color: N,
277
+ width: a,
278
+ opacity: l
279
+ }
280
+ ),
281
+ /* @__PURE__ */ s(
282
+ D,
283
+ {
284
+ base: m,
285
+ direction: w[0].clone().sub(m),
286
+ size: m.distanceTo(w[0]),
287
+ color: N,
288
+ opacity: l
289
+ }
290
+ ),
291
+ /* @__PURE__ */ s(
292
+ D,
293
+ {
294
+ base: _,
295
+ direction: w[w.length - 1].clone().sub(_),
296
+ size: _.distanceTo(w[w.length - 1]),
297
+ color: N,
298
+ opacity: l
299
+ }
300
+ )
301
+ ] });
302
+ }
303
+ function ae({
304
+ dhParameters: t,
305
+ chainOffset: n = null,
306
+ limits: e,
307
+ jointPositions: o,
308
+ size: r = 0.15,
309
+ highlightedJoint: c = null
310
+ }) {
311
+ const l = L(
312
+ () => Mt(t, n, o),
313
+ [t, n, o]
314
+ );
315
+ return /* @__PURE__ */ s("group", { children: l.map((i, a) => {
316
+ const p = Et(e[a]);
317
+ return p ? /* @__PURE__ */ s(
318
+ Ft,
319
+ {
320
+ frame: i,
321
+ dh: t[a],
322
+ limit: p,
323
+ size: r,
324
+ emphasis: c === null ? "normal" : c === a ? "highlighted" : "dimmed"
325
+ },
326
+ a
327
+ ) : null;
328
+ }) });
329
+ }
330
+ function ce() {
331
+ return /* @__PURE__ */ s(ht, { frames: 1, children: /* @__PURE__ */ s(Ct, {}) });
332
+ }
333
+ const Vt = [2, 0, 2, 0, 2, 0, 2, 0];
334
+ function Ct({ positions: t = Vt }) {
335
+ return /* @__PURE__ */ T(ft, { children: [
336
+ /* @__PURE__ */ s(
337
+ G,
338
+ {
339
+ intensity: 5,
340
+ "rotation-x": Math.PI / 2,
341
+ position: [0, 5, -9],
342
+ scale: [10, 10, 1]
343
+ }
344
+ ),
345
+ /* @__PURE__ */ s("group", { rotation: [0, 0.5, 0], children: /* @__PURE__ */ s("group", { children: t.map((n, e) => /* @__PURE__ */ s(
346
+ G,
347
+ {
348
+ form: "circle",
349
+ intensity: 5,
350
+ rotation: [Math.PI / 2, 0, 0],
351
+ position: [n, 4, e * 4],
352
+ scale: [3, 1, 1]
353
+ },
354
+ e
355
+ )) }) }),
356
+ /* @__PURE__ */ s(
357
+ G,
358
+ {
359
+ intensity: 40,
360
+ "rotation-y": Math.PI / 2,
361
+ position: [-5, 1, -1],
362
+ scale: [20, 0.1, 1]
363
+ }
364
+ ),
365
+ /* @__PURE__ */ s(
366
+ G,
367
+ {
368
+ intensity: 20,
369
+ "rotation-y": -Math.PI,
370
+ position: [-5, -2, -1],
371
+ scale: [20, 0.1, 1]
372
+ }
373
+ ),
374
+ /* @__PURE__ */ s(
375
+ G,
376
+ {
377
+ "rotation-y": Math.PI / 2,
378
+ position: [-5, -1, -1],
379
+ scale: [20, 0.5, 1],
380
+ intensity: 5
381
+ }
382
+ ),
383
+ /* @__PURE__ */ s(
384
+ G,
385
+ {
386
+ "rotation-y": -Math.PI / 2,
387
+ position: [10, 1, 0],
388
+ scale: [20, 1, 1],
389
+ intensity: 10
390
+ }
391
+ ),
392
+ /* @__PURE__ */ s(
393
+ G,
394
+ {
395
+ form: "ring",
396
+ color: "white",
397
+ intensity: 5,
398
+ scale: 10,
399
+ position: [-15, 4, -18],
400
+ target: [0, 0, 0]
401
+ }
402
+ )
403
+ ] });
404
+ }
405
+ const q = {
406
+ attach: "material",
407
+ color: "#009f4d",
408
+ opacity: 0.2,
409
+ depthTest: !1,
410
+ depthWrite: !1,
411
+ transparent: !0,
412
+ polygonOffset: !0
413
+ };
414
+ function le({
415
+ safetyZones: t,
416
+ dhParameters: n,
417
+ ...e
418
+ }) {
419
+ const o = L(
420
+ () => yt(n ?? []),
421
+ [n]
422
+ ), r = (l, i) => {
423
+ var y, w;
424
+ if (!((y = i == null ? void 0 : i.pose) != null && y.position) || !((w = i == null ? void 0 : i.pose) != null && w.orientation))
425
+ return null;
426
+ const a = new R.Vector3(
427
+ i.pose.position[0] / 1e3,
428
+ i.pose.position[1] / 1e3,
429
+ i.pose.position[2] / 1e3
430
+ ), p = new R.Vector3(
431
+ i.pose.orientation[0],
432
+ i.pose.orientation[1],
433
+ i.pose.orientation[2]
434
+ );
435
+ let f;
436
+ const u = i.shape.shape_type === "plane" ? { ...q, side: R.DoubleSide } : { ...q, side: R.FrontSide };
437
+ switch (i.shape.shape_type) {
438
+ /**
439
+ * Plane shape, uses DH parameters to calculate the size of the plane (reach distance of a robot)
440
+ */
441
+ case "plane":
442
+ f = /* @__PURE__ */ s("planeGeometry", { args: [o, o] });
443
+ break;
444
+ /**
445
+ * Sphere shape
446
+ */
447
+ case "sphere": {
448
+ const h = (i == null ? void 0 : i.shape).radius / 1e3;
449
+ f = /* @__PURE__ */ s("sphereGeometry", { args: [h] });
450
+ break;
451
+ }
452
+ /**
453
+ * Capsule shape
454
+ */
455
+ case "capsule": {
456
+ const h = (i == null ? void 0 : i.shape).radius / 1e3, m = (i == null ? void 0 : i.shape).cylinder_height / 1e3;
457
+ f = /* @__PURE__ */ s("capsuleGeometry", { args: [h, m] });
458
+ break;
459
+ }
460
+ /**
461
+ * Convex hull, checks at first if the vertices are coplanar - if yes, adds a small offset for
462
+ * renderer to be able to visualize the convex hull.
463
+ */
464
+ case "convex_hull": {
465
+ const h = (i == null ? void 0 : i.shape).vertices.map(
466
+ (_) => new R.Vector3(_[0] / 1e3, _[1] / 1e3, _[2] / 1e3)
467
+ ), m = wt(h);
468
+ if (m.isCoplanar && m.normal) {
469
+ const d = new R.Vector3().addVectors(
470
+ h[0],
471
+ m.normal.multiplyScalar(1e-4)
472
+ );
473
+ h.push(d);
474
+ }
475
+ try {
476
+ f = /* @__PURE__ */ s(
477
+ "primitive",
478
+ {
479
+ object: new H(h),
480
+ attach: "geometry"
481
+ }
482
+ );
483
+ } catch (_) {
484
+ return console.log("Error creating ConvexGeometry:", _), null;
485
+ }
486
+ break;
487
+ }
488
+ /**
489
+ * Convex hull around four spheres. Sphere center points in x/y-plane,
490
+ * offset by either combination "+/- sizeX" or "+/- sizeY".
491
+ * Alternative description: Rectangle in x/y-plane with a 3D padding (source: nova-api docs)
492
+ *
493
+ * Basically a rounded box with a rectangular cross-section.
494
+ */
495
+ case "rectangular_capsule": {
496
+ const h = i.shape, m = h.radius / 1e3, _ = h.sphere_center_distance_x / 1e3, d = h.sphere_center_distance_y / 1e3, g = m * 2;
497
+ f = /* @__PURE__ */ s(
498
+ "primitive",
499
+ {
500
+ object: new mt(_, d, g, 2, m),
501
+ attach: "geometry"
502
+ }
503
+ );
504
+ break;
505
+ }
506
+ default:
507
+ console.warn(
508
+ "Unsupported safety zone shape type:",
509
+ i.shape.shape_type
510
+ ), f = null;
511
+ }
512
+ return /* @__PURE__ */ T(
513
+ "mesh",
514
+ {
515
+ renderOrder: l,
516
+ position: a,
517
+ quaternion: Rt(p),
518
+ children: [
519
+ f,
520
+ /* @__PURE__ */ s("meshStandardMaterial", { ...u, polygonOffsetFactor: -l })
521
+ ]
522
+ },
523
+ `safety-zone-${i.shape.shape_type}-${l}`
524
+ );
525
+ }, c = L(() => Object.values(t ?? {}).map(
526
+ (l, i) => r(i, l)
527
+ ), [t, o]);
528
+ return /* @__PURE__ */ s("group", { ...e, children: c });
529
+ }
530
+ function ue({
531
+ trajectory: t,
532
+ ...n
533
+ }) {
534
+ const e = (t == null ? void 0 : t.map((o) => {
535
+ if (o.position && o.position.length >= 3) {
536
+ const [r, c, l] = o.position;
537
+ if (Number.isFinite(r) && Number.isFinite(c) && Number.isFinite(l))
538
+ return new R.Vector3(r / 1e3, l / 1e3, -c / 1e3);
539
+ }
540
+ return null;
541
+ }).filter((o) => o !== null)) || [];
542
+ return /* @__PURE__ */ s("group", { ...n, children: e.length > 0 && /* @__PURE__ */ s(
543
+ V,
544
+ {
545
+ points: e,
546
+ lineWidth: 3,
547
+ polygonOffset: !0,
548
+ polygonOffsetFactor: 10,
549
+ polygonOffsetUnits: 10
550
+ }
551
+ ) });
552
+ }
553
+ const F = /* @__PURE__ */ new Map();
554
+ async function J(t, n) {
555
+ const e = n || "";
556
+ if (!e)
557
+ throw new Error(
558
+ `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.`
559
+ );
560
+ const o = `${Jt(e)} ${t}`, r = F.get(o);
561
+ if (r) return r;
562
+ const c = (async () => {
563
+ const l = _t(e);
564
+ try {
565
+ const i = await l.api.motionGroupModels.getMotionGroupGlbModel(
566
+ t,
567
+ { responseType: "blob" }
568
+ );
569
+ return URL.createObjectURL(i);
570
+ } catch (i) {
571
+ throw console.error("Failed to fetch model:", i), i;
572
+ }
573
+ })();
574
+ return F.set(o, c), c.catch(() => {
575
+ F.get(o) === c && F.delete(o);
576
+ }), c;
577
+ }
578
+ function Jt(t) {
579
+ return typeof t == "string" ? t : t.config.instanceUrl;
580
+ }
581
+ function z(t) {
582
+ function n(e) {
583
+ return e.children.length === 0 ? [e] : [e, ...e.children.flatMap((o) => n(o))];
584
+ }
585
+ return n(t).filter((e) => et(e));
586
+ }
587
+ function tt(t) {
588
+ return t.name.endsWith("_FLG");
589
+ }
590
+ function et(t) {
591
+ return /_J[0-9]+$/.test(t.name);
592
+ }
593
+ function Nt(t, n) {
594
+ let e;
595
+ function o(r) {
596
+ if (tt(r)) {
597
+ if (e)
598
+ throw Error(
599
+ `Found multiple flange groups in robot model ${n}; first ${e.name} then ${r.name}. Only one _FLG group is allowed.`
600
+ );
601
+ e = r;
602
+ }
603
+ et(r), r.children.map(o);
604
+ }
605
+ if (o(t.scene), !e)
606
+ throw Error(
607
+ `No flange group found in robot model ${n}. Flange must be identified with a name ending in _FLG.`
608
+ );
609
+ return { gltf: t };
610
+ }
611
+ const nt = Q(function({
612
+ rapidlyChangingMotionState: n,
613
+ dhParameters: e,
614
+ chainOffsetPosition: o,
615
+ chainOffsetQuaternion: r,
616
+ onTranslationChanged: c,
617
+ children: l
618
+ }, i) {
619
+ const a = S(null), p = S([]), f = S(
620
+ n.joint_position.filter(
621
+ (d) => d !== void 0
622
+ )
623
+ ), { invalidate: u } = K(), y = S(n);
624
+ y.current = n;
625
+ function w(d) {
626
+ a.current = d, d && h();
627
+ }
628
+ function h() {
629
+ a.current && (p.current = z(a.current), m(), u());
630
+ }
631
+ B(i, () => ({ recollectJoints: h }));
632
+ function m() {
633
+ const d = f.current;
634
+ if (c)
635
+ c(p.current, d);
636
+ else
637
+ for (const [g, v] of p.current.entries()) {
638
+ const O = e[g].reverse_rotation_direction ? -1 : 1;
639
+ v.position.y = O * (d[g] || 0) / 1e3;
640
+ }
641
+ }
642
+ function _(d) {
643
+ f.current = d.joint_position.filter(
644
+ (g) => g !== void 0
645
+ ), m(), u();
646
+ }
647
+ return Y(() => {
648
+ _(y.current);
649
+ }), /* @__PURE__ */ s(
650
+ "group",
651
+ {
652
+ ref: w,
653
+ position: o,
654
+ quaternion: r,
655
+ children: l
656
+ }
657
+ );
658
+ });
659
+ function ot({
660
+ rapidlyChangingMotionState: t,
661
+ dhParameters: n,
662
+ ...e
663
+ }) {
664
+ const o = new b(), r = S(null), c = S(null);
665
+ function l(p) {
666
+ const f = new b();
667
+ for (let h = 0; h < n.length; h++) {
668
+ const m = n[h], _ = p[h] ?? 0, d = new b().makeRotationY(m.theta).multiply(
669
+ new b().makeTranslation(
670
+ m.a / 1e3,
671
+ (m.d + _ * (m.reverse_rotation_direction ? -1 : 1)) / 1e3,
672
+ 0
673
+ )
674
+ ).multiply(new b().makeRotationX(m.alpha));
675
+ f.multiply(d);
676
+ }
677
+ const u = new x(), y = new k(), w = new x();
678
+ return f.decompose(u, y, w), u;
679
+ }
680
+ const i = l(
681
+ t.joint_position
682
+ );
683
+ function a(p, f) {
684
+ o.identity();
685
+ let u = new x();
686
+ for (let m = 0; m < n.length; m++) {
687
+ const _ = f[m] ?? 0, d = n[m], g = new b().makeRotationY(d.theta).multiply(
688
+ new b().makeTranslation(
689
+ d.a / 1e3,
690
+ (d.d + _ * (d.reverse_rotation_direction ? -1 : 1)) / 1e3,
691
+ 0
692
+ )
693
+ ).multiply(new b().makeRotationX(d.alpha));
694
+ o.multiply(g);
695
+ }
696
+ const y = new x(), w = new k(), h = new x();
697
+ if (o.decompose(y, w, h), u = y, r.current && r.current.position.set(
698
+ u.x,
699
+ u.y,
700
+ u.z
701
+ ), c.current) {
702
+ const m = c.current.geometry;
703
+ m != null && m.setPositions && m.setPositions([
704
+ 0,
705
+ 0,
706
+ 0,
707
+ u.x,
708
+ u.y,
709
+ u.z
710
+ ]);
711
+ }
712
+ }
713
+ return /* @__PURE__ */ s(
714
+ nt,
715
+ {
716
+ rapidlyChangingMotionState: t,
717
+ dhParameters: n,
718
+ onTranslationChanged: a,
719
+ children: /* @__PURE__ */ T("group", { ...e, name: "Scene", children: [
720
+ /* @__PURE__ */ T("mesh", { name: "Base", position: [0, 0, 0], children: [
721
+ /* @__PURE__ */ s("sphereGeometry", { args: [0.02, 32, 32] }),
722
+ /* @__PURE__ */ s("meshStandardMaterial", { color: "green", depthTest: !0 })
723
+ ] }),
724
+ /* @__PURE__ */ s(
725
+ V,
726
+ {
727
+ ref: c,
728
+ points: [new x(0, 0, 0), i],
729
+ color: "White",
730
+ lineWidth: 5
731
+ }
732
+ ),
733
+ /* @__PURE__ */ T("mesh", { ref: r, name: "TCP", position: i, children: [
734
+ /* @__PURE__ */ s("sphereGeometry", { args: [0.025, 32, 32] }),
735
+ /* @__PURE__ */ s("meshStandardMaterial", { color: "red", depthTest: !0 })
736
+ ] })
737
+ ] })
738
+ }
739
+ );
740
+ }
741
+ const Dt = console.warn;
742
+ function rt() {
743
+ return P(() => {
744
+ console.warn = (t) => {
745
+ t !== "Cannot call the manual advancement of rafz whilst frameLoop is not set as demand" && Dt(t);
746
+ };
747
+ }, []), null;
748
+ }
749
+ function $t(t) {
750
+ return t.type === "Mesh";
751
+ }
752
+ function jt({
753
+ url: t,
754
+ flangeRef: n,
755
+ postModelRender: e,
756
+ ...o
757
+ }) {
758
+ const r = dt(t), l = Nt(r, "robot.glb").gltf;
759
+ P(() => {
760
+ e == null || e();
761
+ }, [t, e]);
762
+ function i(a) {
763
+ try {
764
+ return $t(a) ? a.geometry ? /* @__PURE__ */ s(
765
+ "mesh",
766
+ {
767
+ name: a.name,
768
+ geometry: a.geometry,
769
+ material: a.material,
770
+ position: a.position,
771
+ rotation: a.rotation
772
+ },
773
+ a.uuid
774
+ ) : /* @__PURE__ */ s(
775
+ "group",
776
+ {
777
+ name: a.name,
778
+ position: a.position,
779
+ rotation: a.rotation
780
+ },
781
+ a.uuid
782
+ ) : /* @__PURE__ */ s(
783
+ "group",
784
+ {
785
+ name: a.name,
786
+ position: a.position,
787
+ rotation: a.rotation,
788
+ ref: tt(a) ? n : void 0,
789
+ children: a.children.map(i)
790
+ },
791
+ a.uuid
792
+ );
793
+ } catch (p) {
794
+ return console.warn("Error rendering node", a.name, p), null;
795
+ }
796
+ }
797
+ return /* @__PURE__ */ s("group", { ...o, dispose: null, children: i(l.scene) });
798
+ }
799
+ function it({
800
+ modelURL: t,
801
+ flangeRef: n,
802
+ postModelRender: e,
803
+ ...o
804
+ }) {
805
+ const [r, c] = C(null);
806
+ return P(() => {
807
+ let l = !1;
808
+ return (async () => {
809
+ try {
810
+ const a = typeof t == "string" ? t : await t;
811
+ l || c((p) => p === a ? p : a);
812
+ } catch (a) {
813
+ console.error("Failed to resolve model URL:", a);
814
+ }
815
+ })(), () => {
816
+ l = !0;
817
+ };
818
+ }, [t]), r ? /* @__PURE__ */ s(
819
+ jt,
820
+ {
821
+ url: r,
822
+ flangeRef: n,
823
+ postModelRender: e,
824
+ ...o
825
+ }
826
+ ) : null;
827
+ }
828
+ const st = (t, n) => {
829
+ t.userData.isGhost || (t.traverse((e) => {
830
+ if (e instanceof R.Mesh) {
831
+ e.material instanceof R.Material && (e.material.colorWrite = !1);
832
+ const o = e.clone(), r = e.clone();
833
+ o.material = new R.MeshStandardMaterial({
834
+ depthTest: !0,
835
+ depthWrite: !0,
836
+ colorWrite: !1,
837
+ polygonOffset: !0,
838
+ polygonOffsetFactor: -1,
839
+ side: R.DoubleSide
840
+ }), o.userData.isGhost = !0, r.material = new R.MeshStandardMaterial({
841
+ color: n,
842
+ opacity: 0.3,
843
+ depthTest: !0,
844
+ depthWrite: !1,
845
+ transparent: !0,
846
+ polygonOffset: !0,
847
+ polygonOffsetFactor: -2,
848
+ side: R.DoubleSide
849
+ }), r.userData.isGhost = !0, e.parent && (e.parent.add(o), e.parent.add(r));
850
+ }
851
+ }), t.userData.isGhost = !0);
852
+ }, at = (t) => {
853
+ if (!t.userData.isGhost) return;
854
+ const n = [];
855
+ t.traverse((e) => {
856
+ var o;
857
+ e instanceof R.Mesh && ((o = e.userData) != null && o.isGhost ? n.push(e) : e.material instanceof R.Material && (e.material.colorWrite = !0));
858
+ }), n.forEach((e) => {
859
+ e.parent && e.parent.remove(e);
860
+ }), t.userData.isGhost = !1;
861
+ }, ct = E(
862
+ ({
863
+ rapidlyChangingMotionState: t,
864
+ modelFromController: n,
865
+ dhParameters: e,
866
+ chainOffsetPosition: o,
867
+ chainOffsetQuaternion: r,
868
+ getModel: c = J,
869
+ flangeRef: l,
870
+ postModelRender: i,
871
+ transparentColor: a,
872
+ instanceUrl: p,
873
+ ...f
874
+ }) => {
875
+ const [u, y] = C(null), w = S(null), h = A((g) => {
876
+ y(g);
877
+ }, []), m = A(() => {
878
+ var g;
879
+ (g = w.current) == null || g.recollectJoints(), i == null || i();
880
+ }, [i]);
881
+ P(() => {
882
+ u && (a ? st(u, a) : at(u));
883
+ }, [u, a]);
884
+ const _ = L(() => {
885
+ const g = c(n, p);
886
+ if (!g) {
887
+ const v = new Blob([], { type: "model/gltf-binary" }), M = new File([v], `${n}.glb`, {
888
+ type: "model/gltf-binary"
889
+ });
890
+ return Promise.resolve(URL.createObjectURL(M));
891
+ }
892
+ return g;
893
+ }, [n, p, c]), d = /* @__PURE__ */ s(
894
+ ot,
895
+ {
896
+ rapidlyChangingMotionState: t,
897
+ dhParameters: e,
898
+ ...f
899
+ }
900
+ );
901
+ return /* @__PURE__ */ T(
902
+ Z,
903
+ {
904
+ fallback: d,
905
+ onError: (g) => {
906
+ console.warn(g);
907
+ },
908
+ children: [
909
+ /* @__PURE__ */ s(X, { fallback: d, children: /* @__PURE__ */ s("group", { ref: h, children: /* @__PURE__ */ s(
910
+ nt,
911
+ {
912
+ ref: w,
913
+ rapidlyChangingMotionState: t,
914
+ dhParameters: e,
915
+ chainOffsetPosition: o,
916
+ chainOffsetQuaternion: r,
917
+ children: /* @__PURE__ */ s(
918
+ it,
919
+ {
920
+ modelURL: _,
921
+ postModelRender: m,
922
+ flangeRef: l,
923
+ ...f
924
+ }
925
+ )
926
+ }
927
+ ) }) }),
928
+ /* @__PURE__ */ s(rt, {})
929
+ ]
930
+ }
931
+ );
932
+ }
933
+ ), Ut = E(
934
+ ({ rapidlyChangingMotionState: t, ...n }) => {
935
+ const e = j(
936
+ t
937
+ );
938
+ return /* @__PURE__ */ s(
939
+ ct,
940
+ {
941
+ rapidlyChangingMotionState: e,
942
+ ...n
943
+ }
944
+ );
945
+ }
946
+ );
947
+ function pe({
948
+ connectedMotionGroup: t,
949
+ getModel: n,
950
+ flangeRef: e,
951
+ transparentColor: o,
952
+ postModelRender: r,
953
+ ...c
954
+ }) {
955
+ const l = A(
956
+ (y) => J(y, t.nova),
957
+ [t]
958
+ ), i = n ?? l;
959
+ if (!t.dhParameters)
960
+ return null;
961
+ const a = t.mountingPosition, p = t.mountingQuaternion, f = t.modelFromController || "";
962
+ return f ? /* @__PURE__ */ s(
963
+ Ut,
964
+ {
965
+ rapidlyChangingMotionState: t.rapidlyChangingMotionState,
966
+ modelFromController: f,
967
+ dhParameters: t.dhParameters,
968
+ getModel: i,
969
+ flangeRef: e,
970
+ transparentColor: o,
971
+ postModelRender: r,
972
+ chainOffsetPosition: a,
973
+ chainOffsetQuaternion: p,
974
+ ...c
975
+ }
976
+ ) : /* @__PURE__ */ s(
977
+ ot,
978
+ {
979
+ rapidlyChangingMotionState: t.rapidlyChangingMotionState,
980
+ dhParameters: t.dhParameters,
981
+ chainOffsetPosition: a,
982
+ chainOffsetQuaternion: p,
983
+ ...c
984
+ }
985
+ );
986
+ }
987
+ const lt = Q(
988
+ function({
989
+ rapidlyChangingMotionState: n,
990
+ dhParameters: e,
991
+ chainOffsetPosition: o,
992
+ chainOffsetQuaternion: r,
993
+ onRotationChanged: c,
994
+ children: l
995
+ }, i) {
996
+ const a = S(null), p = S([]), f = S(
997
+ n.joint_position.filter(
998
+ (d) => d !== void 0
999
+ )
1000
+ ), { invalidate: u } = K(), y = S(n);
1001
+ y.current = n;
1002
+ function w(d) {
1003
+ a.current = d, d && h();
1004
+ }
1005
+ function h() {
1006
+ a.current && (p.current = z(a.current), m(), u());
1007
+ }
1008
+ B(i, () => ({ recollectJoints: h }));
1009
+ function m() {
1010
+ const d = f.current;
1011
+ if (c)
1012
+ c(p.current, d);
1013
+ else
1014
+ for (const [g, v] of p.current.entries()) {
1015
+ const M = e[g], O = M.theta || 0, pt = M.reverse_rotation_direction ? -1 : 1;
1016
+ v.rotation.y = pt * (d[g] || 0) + O;
1017
+ }
1018
+ }
1019
+ function _(d) {
1020
+ f.current = d.joint_position.filter(
1021
+ (g) => g !== void 0
1022
+ ), m(), u();
1023
+ }
1024
+ return Y(() => {
1025
+ _(y.current);
1026
+ }), P(() => {
1027
+ _(n);
1028
+ }, [n]), /* @__PURE__ */ s(
1029
+ "group",
1030
+ {
1031
+ ref: w,
1032
+ position: o,
1033
+ quaternion: r,
1034
+ children: l
1035
+ }
1036
+ );
1037
+ }
1038
+ ), Wt = "line", qt = "mesh";
1039
+ function Ht({
1040
+ rapidlyChangingMotionState: t,
1041
+ dhParameters: n,
1042
+ ...e
1043
+ }) {
1044
+ const o = new b(), r = S([]), c = S([]);
1045
+ gt.useEffect(() => {
1046
+ r.current = new Array(n.length).fill(null), c.current = new Array(n.length).fill(null);
1047
+ }, [n.length]);
1048
+ function l(p, f) {
1049
+ const u = new x(), y = new k(), w = new x();
1050
+ o.decompose(u, y, w);
1051
+ const h = u.clone(), m = new b().makeRotationY(
1052
+ p.theta + f * (p.reverse_rotation_direction ? -1 : 1)
1053
+ ).multiply(new b().makeTranslation(0, p.d / 1e3, 0)).multiply(new b().makeTranslation(p.a / 1e3, 0, 0)).multiply(new b().makeRotationX(p.alpha));
1054
+ return o.multiply(m), o.decompose(u, y, w), { a: h, b: u };
1055
+ }
1056
+ function i(p, f, u, y) {
1057
+ if (!n)
1058
+ return;
1059
+ const w = n[p];
1060
+ if (!w)
1061
+ return;
1062
+ const { a: h, b: m } = l(w, y);
1063
+ f.geometry.setPositions([h.toArray(), m.toArray()].flat()), u.position.set(m.x, m.y, m.z);
1064
+ }
1065
+ function a(p, f) {
1066
+ o.identity();
1067
+ for (let u = 0; u < Math.min(p.length, f.length); u++) {
1068
+ const y = r.current[u], w = c.current[u];
1069
+ y && w && i(u, y, w, f[u]);
1070
+ }
1071
+ }
1072
+ return /* @__PURE__ */ s(
1073
+ lt,
1074
+ {
1075
+ rapidlyChangingMotionState: t,
1076
+ dhParameters: n,
1077
+ onRotationChanged: a,
1078
+ children: /* @__PURE__ */ T("group", { ...e, name: "Scene", children: [
1079
+ /* @__PURE__ */ T("mesh", { children: [
1080
+ /* @__PURE__ */ s("sphereGeometry", { args: [0.01, 32, 32] }),
1081
+ /* @__PURE__ */ s("meshStandardMaterial", { color: "black", depthTest: !0 })
1082
+ ] }),
1083
+ n == null ? void 0 : n.map((p, f) => {
1084
+ const { a: u, b: y } = l(
1085
+ p,
1086
+ t.joint_position[f] ?? 0
1087
+ ), w = `dhrobot_J0${f}`;
1088
+ return /* @__PURE__ */ T("group", { name: w, children: [
1089
+ /* @__PURE__ */ s(
1090
+ V,
1091
+ {
1092
+ ref: (h) => {
1093
+ r.current[f] = h;
1094
+ },
1095
+ name: Wt,
1096
+ points: [u, y],
1097
+ color: "white",
1098
+ lineWidth: 5
1099
+ }
1100
+ ),
1101
+ /* @__PURE__ */ T(
1102
+ "mesh",
1103
+ {
1104
+ ref: (h) => {
1105
+ c.current[f] = h;
1106
+ },
1107
+ name: qt,
1108
+ position: y,
1109
+ children: [
1110
+ /* @__PURE__ */ s("sphereGeometry", { args: [0.01, 32, 32] }),
1111
+ /* @__PURE__ */ s("meshStandardMaterial", { color: "black", depthTest: !0 })
1112
+ ]
1113
+ },
1114
+ `mesh_${f}`
1115
+ )
1116
+ ] }, w);
1117
+ })
1118
+ ] })
1119
+ }
1120
+ );
1121
+ }
1122
+ const ut = E(
1123
+ ({
1124
+ rapidlyChangingMotionState: t,
1125
+ modelFromController: n,
1126
+ dhParameters: e,
1127
+ chainOffsetPosition: o,
1128
+ chainOffsetQuaternion: r,
1129
+ getModel: c = J,
1130
+ flangeRef: l,
1131
+ postModelRender: i,
1132
+ transparentColor: a,
1133
+ instanceUrl: p,
1134
+ ...f
1135
+ }) => {
1136
+ const [u, y] = C(null), w = S(null), h = A((g) => {
1137
+ y(g);
1138
+ }, []), m = A(() => {
1139
+ var g;
1140
+ (g = w.current) == null || g.recollectJoints(), i == null || i();
1141
+ }, [i]);
1142
+ P(() => {
1143
+ u && (a ? st(u, a) : at(u));
1144
+ }, [u, a]);
1145
+ const _ = L(() => {
1146
+ const g = c(n, p);
1147
+ if (!g)
1148
+ throw new Error(
1149
+ `No model found for robot "${n}". Ensure the model is available or provide a custom getModel function.`
1150
+ );
1151
+ return g;
1152
+ }, [n, p, c]), d = /* @__PURE__ */ s(
1153
+ Ht,
1154
+ {
1155
+ rapidlyChangingMotionState: t,
1156
+ dhParameters: e,
1157
+ ...f
1158
+ }
1159
+ );
1160
+ return /* @__PURE__ */ T(
1161
+ Z,
1162
+ {
1163
+ fallback: d,
1164
+ onError: (g) => {
1165
+ console.warn(g);
1166
+ },
1167
+ children: [
1168
+ /* @__PURE__ */ s(X, { fallback: d, children: /* @__PURE__ */ s("group", { ref: h, children: /* @__PURE__ */ s(
1169
+ lt,
1170
+ {
1171
+ ref: w,
1172
+ rapidlyChangingMotionState: t,
1173
+ dhParameters: e,
1174
+ chainOffsetPosition: o,
1175
+ chainOffsetQuaternion: r,
1176
+ children: /* @__PURE__ */ s(
1177
+ it,
1178
+ {
1179
+ modelURL: _,
1180
+ postModelRender: m,
1181
+ flangeRef: l,
1182
+ ...f
1183
+ }
1184
+ )
1185
+ }
1186
+ ) }) }),
1187
+ /* @__PURE__ */ s(rt, {})
1188
+ ]
1189
+ }
1190
+ );
1191
+ }
1192
+ ), Qt = E(
1193
+ ({ rapidlyChangingMotionState: t, ...n }) => {
1194
+ const e = j(
1195
+ t
1196
+ );
1197
+ return /* @__PURE__ */ s(
1198
+ ut,
1199
+ {
1200
+ rapidlyChangingMotionState: e,
1201
+ ...n
1202
+ }
1203
+ );
1204
+ }
1205
+ ), Bt = E((t) => {
1206
+ const { inverseSolver: n, dhParameters: e, ...o } = t, [r, c] = C(
1207
+ I.RevoluteJoint
1208
+ );
1209
+ P(() => {
1210
+ e.length && c(e[0].type ?? I.RevoluteJoint);
1211
+ }, [e]);
1212
+ const l = L(() => n === null && r === I.RevoluteJoint, [n, r]), i = L(() => n === null && r === I.PrismaticJoint, [n, r]);
1213
+ return L(() => !!n, [n]) || l ? /* @__PURE__ */ s(ut, { dhParameters: e, ...o }) : i ? /* @__PURE__ */ s(ct, { dhParameters: e, ...o }) : null;
1214
+ }), fe = E((t) => {
1215
+ const n = j(
1216
+ t.rapidlyChangingMotionState
1217
+ );
1218
+ return /* @__PURE__ */ s(
1219
+ Bt,
1220
+ {
1221
+ ...t,
1222
+ rapidlyChangingMotionState: n
1223
+ }
1224
+ );
1225
+ });
1226
+ function me({
1227
+ connectedMotionGroup: t,
1228
+ getModel: n,
1229
+ flangeRef: e,
1230
+ transparentColor: o,
1231
+ postModelRender: r,
1232
+ ...c
1233
+ }) {
1234
+ const l = A(
1235
+ (p) => J(p, t.nova),
1236
+ [t]
1237
+ );
1238
+ if (!t.dhParameters)
1239
+ return null;
1240
+ const i = t.mountingPosition, a = t.mountingQuaternion;
1241
+ return /* @__PURE__ */ s(
1242
+ Qt,
1243
+ {
1244
+ rapidlyChangingMotionState: t.rapidlyChangingMotionState,
1245
+ modelFromController: t.modelFromController || "",
1246
+ dhParameters: t.dhParameters,
1247
+ getModel: n ?? l,
1248
+ flangeRef: e,
1249
+ transparentColor: o,
1250
+ postModelRender: r,
1251
+ chainOffsetPosition: i,
1252
+ chainOffsetQuaternion: a,
1253
+ ...c
1254
+ }
1255
+ );
1256
+ }
1257
+ export {
1258
+ se as C,
1259
+ ae as J,
1260
+ pe as L,
1261
+ fe as M,
1262
+ ce as P,
1263
+ me as R,
1264
+ le as S,
1265
+ ue as T,
1266
+ Bt as a,
1267
+ Ut as b,
1268
+ ct as c,
1269
+ Qt as d,
1270
+ ut as e,
1271
+ J as f
1272
+ };