@wandelbots/wandelbots-js-react-components 6.3.0 → 6.4.0-pr.feat-jogging-gizmo.649.179415f
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.
- package/README.md +202 -120
- package/dist/3d.cjs +1 -1
- package/dist/3d.d.ts +3 -3
- package/dist/3d.js +19 -22
- package/dist/SafetyBar/index.cjs +1 -1
- package/dist/SafetyBar/index.js +1 -1
- package/dist/chunks/ConnectedMotionGroup-_YUOhOLL.cjs +4 -0
- package/dist/chunks/ConnectedMotionGroup-neDeA3uW.js +2617 -0
- package/dist/chunks/Robot-CvviE5MR.js +1684 -0
- package/dist/chunks/Robot-VZaqKPxi.cjs +1 -0
- package/dist/chunks/{SafetyBar-Cy9DiXp9.js → SafetyBar-B9OQgerp.js} +1 -1
- package/dist/chunks/{SafetyBar-DPrv_OQA.cjs → SafetyBar-D7QT6J0m.cjs} +1 -1
- package/dist/chunks/{externalizeComponent-EDymnaGR.js → externalizeComponent-CZu38L-d.js} +29 -105
- package/dist/chunks/externalizeComponent-CdX5L_lW.cjs +2 -0
- package/dist/chunks/useSmoothedMotionState-BidFV3kQ.js +255 -0
- package/dist/chunks/useSmoothedMotionState-CdhkBCqt.cjs +1 -0
- package/dist/components/AppHeader.d.ts +1 -1
- package/dist/components/jogging/JoggingCartesianAxisControl.d.ts +1 -1
- package/dist/components/jogging/JoggingJointTab.d.ts +1 -1
- package/dist/components/jogging/JoggingPanel.d.ts +6 -3
- package/dist/components/jogging/JoggingStore.d.ts +5 -1
- package/dist/components/jogging/gizmo/JoggingGizmo.d.ts +42 -0
- package/dist/components/jogging/gizmo/JoggingGizmoOrientation.d.ts +31 -0
- package/dist/components/jogging/gizmo/gizmoShared.d.ts +60 -0
- package/dist/components/jogging/gizmo/gizmoTranslation.d.ts +11 -0
- package/dist/components/jogging/gizmo/jogGizmoProjection.d.ts +65 -0
- package/dist/components/jogging/jogHandle.d.ts +26 -0
- package/dist/components/jogging/joggingColors.d.ts +18 -0
- package/dist/components/jogging/useHold.d.ts +33 -0
- package/dist/components/jogging/useHoldToJog.d.ts +23 -0
- package/dist/components/robots/GenericRobot.d.ts +2 -1
- package/dist/components/robots/LinearAxis.d.ts +1 -1
- package/dist/components/robots/LinearAxisAnimator.d.ts +11 -2
- package/dist/components/robots/Robot.d.ts +1 -1
- package/dist/components/robots/robotModelLogic.d.ts +11 -9
- package/dist/components/utils/hooks.d.ts +1 -6
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +3 -18
- package/dist/core.js +27 -54
- package/dist/index.cjs +1 -1
- package/dist/index.js +42 -72
- package/dist/lib/ConnectedMotionGroup.d.ts +5 -7
- package/dist/lib/JoggerConnection.d.ts +29 -5
- package/dist/lib/MotionStreamConnection.d.ts +4 -6
- package/dist/lib/novaConnection.d.ts +23 -0
- package/package.json +31 -66
- package/dist/Setup.d.ts +0 -11
- package/dist/chunks/MotionGroupVisualizer-DshWR1wY.js +0 -1653
- package/dist/chunks/MotionGroupVisualizer-eD7yFEcF.cjs +0 -1
- package/dist/chunks/externalizeComponent-OO4jcrz5.cjs +0 -2
- package/dist/chunks/theming-DfSy4-Ic.cjs +0 -4
- package/dist/chunks/theming-mF9Rt8SS.js +0 -5542
- package/dist/chunks/useSmoothedMotionState-DyDgSVYX.js +0 -478
- package/dist/chunks/useSmoothedMotionState-VYxEIyfr.cjs +0 -1
- package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts +0 -11
- package/dist/components/AdornedTextField.d.ts +0 -7
- package/dist/components/CopyableText.d.ts +0 -6
- package/dist/components/CycleTimer/CycleTimer.d.ts +0 -3
- package/dist/components/CycleTimer/DefaultVariant.d.ts +0 -9
- package/dist/components/CycleTimer/SmallVariant.d.ts +0 -10
- package/dist/components/CycleTimer/index.d.ts +0 -27
- package/dist/components/CycleTimer/types.d.ts +0 -49
- package/dist/components/CycleTimer/useAnimations.d.ts +0 -14
- package/dist/components/CycleTimer/useTimerLogic.d.ts +0 -24
- package/dist/components/CycleTimer/utils.d.ts +0 -21
- package/dist/components/CycleTimer.d.ts +0 -3
- package/dist/components/DataGrid.d.ts +0 -66
- package/dist/components/LogPanel.d.ts +0 -38
- package/dist/components/LogStore.d.ts +0 -12
- package/dist/components/LogViewer.d.ts +0 -46
- package/dist/components/ProgramControl.d.ts +0 -55
- package/dist/components/ProgramStateIndicator.d.ts +0 -26
- package/dist/components/RobotCard.d.ts +0 -98
- package/dist/components/RobotListItem.d.ts +0 -34
- package/dist/components/RobotSetupReadinessIndicator.d.ts +0 -37
- package/dist/components/SelectableFab.d.ts +0 -7
- package/dist/components/TabBar.d.ts +0 -45
- package/dist/components/ThemeSelect.d.ts +0 -6
- package/dist/components/Timer/Timer.d.ts +0 -3
- package/dist/components/Timer/TimerDefaultVariant.d.ts +0 -9
- package/dist/components/Timer/TimerSmallVariant.d.ts +0 -10
- package/dist/components/Timer/index.d.ts +0 -19
- package/dist/components/Timer/types.d.ts +0 -35
- package/dist/components/Timer/useTimerAnimations.d.ts +0 -10
- package/dist/components/Timer/useTimerLogic.d.ts +0 -19
- package/dist/components/Timer/utils.d.ts +0 -17
- package/dist/components/Timer.d.ts +0 -3
- package/dist/components/TransparentOverlay.d.ts +0 -4
- package/dist/components/jogging/JoggingFreedriveTab.d.ts +0 -1
- package/dist/components/jogging/PoseCartesianValues.d.ts +0 -9
- package/dist/components/jogging/PoseJointValues.d.ts +0 -8
- package/dist/components/robots/AxisConfig.d.ts +0 -2
- package/dist/components/robots/manufacturerHomePositions.d.ts +0 -20
- package/dist/icons/DropdownArrowIcon.d.ts +0 -2
- package/dist/icons/index.d.ts +0 -12
- package/dist/lib/novaCompat.d.ts +0 -16
- package/dist/themes/createDarkTheme.d.ts +0 -7
- package/dist/themes/themeTypes.d.ts +0 -40
- package/dist/themes/theming.d.ts +0 -24
|
@@ -0,0 +1,1684 @@
|
|
|
1
|
+
import { jsx as c, jsxs as _, Fragment as ct } from "react/jsx-runtime";
|
|
2
|
+
import * as b from "three";
|
|
3
|
+
import { Matrix4 as T, Vector3 as v, Quaternion as L } from "three";
|
|
4
|
+
import { ConvexGeometry as lt, RoundedBoxGeometry as Ot } from "three-stdlib";
|
|
5
|
+
import { Line as H, Environment as Gt, Lightformer as G, useGLTF as It } from "@react-three/drei";
|
|
6
|
+
import Ft, { useMemo as E, useRef as R, useState as I, useCallback as A, useEffect as M, forwardRef as ut, useImperativeHandle as pt, Suspense as ft } from "react";
|
|
7
|
+
import { d as Ct, v as kt, o as Nt, e as F } from "./externalizeComponent-CZu38L-d.js";
|
|
8
|
+
import q from "@mui/material/Box";
|
|
9
|
+
import { useThree as $, useFrame as mt, Canvas as Ht } from "@react-three/fiber";
|
|
10
|
+
import { useTranslation as $t } from "react-i18next";
|
|
11
|
+
import { e as Jt, c as Vt, f as ht, a as X } from "./useSmoothedMotionState-BidFV3kQ.js";
|
|
12
|
+
import { useTheme as Dt, alpha as K } from "@mui/material/styles";
|
|
13
|
+
import { JointTypeEnum as C } from "@wandelbots/nova-js/v2";
|
|
14
|
+
import { ErrorBoundary as dt } from "react-error-boundary";
|
|
15
|
+
function Ut(t) {
|
|
16
|
+
switch (t.shape_type) {
|
|
17
|
+
case "convex_hull":
|
|
18
|
+
return new lt(
|
|
19
|
+
t.vertices.map(
|
|
20
|
+
(e) => new b.Vector3(
|
|
21
|
+
e[0] / 1e3,
|
|
22
|
+
e[1] / 1e3,
|
|
23
|
+
e[2] / 1e3
|
|
24
|
+
)
|
|
25
|
+
)
|
|
26
|
+
);
|
|
27
|
+
case "box":
|
|
28
|
+
return new b.BoxGeometry(
|
|
29
|
+
t.size_x / 1e3,
|
|
30
|
+
t.size_y / 1e3,
|
|
31
|
+
t.size_z / 1e3
|
|
32
|
+
);
|
|
33
|
+
case "sphere":
|
|
34
|
+
return new b.SphereGeometry(t.radius / 1e3);
|
|
35
|
+
case "capsule":
|
|
36
|
+
return new b.CapsuleGeometry(
|
|
37
|
+
t.radius / 1e3,
|
|
38
|
+
t.cylinder_height / 1e3
|
|
39
|
+
);
|
|
40
|
+
case "cylinder":
|
|
41
|
+
return new b.CylinderGeometry(
|
|
42
|
+
t.radius / 1e3,
|
|
43
|
+
t.radius / 1e3,
|
|
44
|
+
t.height / 1e3
|
|
45
|
+
);
|
|
46
|
+
case "rectangle":
|
|
47
|
+
return new b.BoxGeometry(t.size_x / 1e3, t.size_y / 1e3, 0);
|
|
48
|
+
default:
|
|
49
|
+
return console.warn(`${t.shape_type} is not supported`), new b.BufferGeometry();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function jt({
|
|
53
|
+
name: t,
|
|
54
|
+
collider: n,
|
|
55
|
+
children: e
|
|
56
|
+
}) {
|
|
57
|
+
var s, u;
|
|
58
|
+
const o = ((s = n.pose) == null ? void 0 : s.position) ?? [0, 0, 0], r = ((u = n.pose) == null ? void 0 : u.orientation) ?? [0, 0, 0];
|
|
59
|
+
return n.margin && console.warn(`${t} margin is not supported`), /* @__PURE__ */ c(
|
|
60
|
+
"mesh",
|
|
61
|
+
{
|
|
62
|
+
name: t,
|
|
63
|
+
position: new b.Vector3(
|
|
64
|
+
o[0],
|
|
65
|
+
o[1],
|
|
66
|
+
o[2]
|
|
67
|
+
).divideScalar(1e3),
|
|
68
|
+
rotation: new b.Euler(r[0], r[1], r[2], "XYZ"),
|
|
69
|
+
geometry: Ut(n.shape),
|
|
70
|
+
children: e
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
function qt({
|
|
75
|
+
name: t,
|
|
76
|
+
colliders: n,
|
|
77
|
+
meshChildrenProvider: e,
|
|
78
|
+
...o
|
|
79
|
+
}) {
|
|
80
|
+
return /* @__PURE__ */ c("group", { name: t, ...o, children: Object.entries(n).map(([r, s]) => /* @__PURE__ */ c(
|
|
81
|
+
jt,
|
|
82
|
+
{
|
|
83
|
+
name: r,
|
|
84
|
+
collider: s,
|
|
85
|
+
children: e(r, s)
|
|
86
|
+
},
|
|
87
|
+
r
|
|
88
|
+
)) });
|
|
89
|
+
}
|
|
90
|
+
function Qe({
|
|
91
|
+
scene: t,
|
|
92
|
+
meshChildrenProvider: n
|
|
93
|
+
}) {
|
|
94
|
+
const e = t.colliders;
|
|
95
|
+
return /* @__PURE__ */ c("group", { children: e && /* @__PURE__ */ c(
|
|
96
|
+
qt,
|
|
97
|
+
{
|
|
98
|
+
meshChildrenProvider: n,
|
|
99
|
+
colliders: e
|
|
100
|
+
}
|
|
101
|
+
) });
|
|
102
|
+
}
|
|
103
|
+
function Wt(t) {
|
|
104
|
+
const n = (t == null ? void 0 : t.position) ?? [], e = (t == null ? void 0 : t.orientation) ?? [], o = new v(
|
|
105
|
+
e[0] ?? 0,
|
|
106
|
+
e[1] ?? 0,
|
|
107
|
+
e[2] ?? 0
|
|
108
|
+
), r = o.length(), s = r > 0 ? new L().setFromAxisAngle(o.normalize(), r) : new L();
|
|
109
|
+
return new T().compose(
|
|
110
|
+
new v(
|
|
111
|
+
n[0] ?? 0,
|
|
112
|
+
n[1] ?? 0,
|
|
113
|
+
n[2] ?? 0
|
|
114
|
+
).divideScalar(1e3),
|
|
115
|
+
s,
|
|
116
|
+
new v(1, 1, 1)
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
function Bt(t, n = null, e = []) {
|
|
120
|
+
const o = Wt(n);
|
|
121
|
+
return t.map((r, s) => {
|
|
122
|
+
const u = o.clone(), i = (r.reverse_rotation_direction ? -1 : 1) * (e[s] ?? 0), a = r.type === "PRISMATIC_JOINT", l = (r.theta ?? 0) + (a ? 0 : i), p = (r.d ?? 0) + (a ? i : 0);
|
|
123
|
+
return o.multiply(new T().makeRotationZ(l)).multiply(
|
|
124
|
+
new T().makeTranslation((r.a ?? 0) / 1e3, 0, p / 1e3)
|
|
125
|
+
).multiply(new T().makeRotationX(r.alpha ?? 0)), u;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
const V = "#ff4b4b", z = "#2fa8ff", Qt = "#8a8d9e", Xt = 96, Yt = 0.15, Zt = new b.Vector3(0, 1, 0), Kt = 0.2, zt = 2;
|
|
129
|
+
function te(t) {
|
|
130
|
+
const { lower_limit: n, upper_limit: e } = t ?? {};
|
|
131
|
+
return typeof n != "number" || typeof e != "number" || !Number.isFinite(n) || !Number.isFinite(e) || !(n < e) ? null : { lower_limit: n, upper_limit: e };
|
|
132
|
+
}
|
|
133
|
+
function D({
|
|
134
|
+
base: t,
|
|
135
|
+
direction: n,
|
|
136
|
+
size: e,
|
|
137
|
+
color: o,
|
|
138
|
+
opacity: r
|
|
139
|
+
}) {
|
|
140
|
+
const s = new b.Quaternion().setFromUnitVectors(
|
|
141
|
+
Zt,
|
|
142
|
+
n.clone().normalize()
|
|
143
|
+
), u = t.clone().addScaledVector(n.clone().normalize(), e / 2);
|
|
144
|
+
return /* @__PURE__ */ _("mesh", { position: u, quaternion: s, renderOrder: 10, children: [
|
|
145
|
+
/* @__PURE__ */ c("coneGeometry", { args: [e * 0.35, e, 16] }),
|
|
146
|
+
/* @__PURE__ */ c(
|
|
147
|
+
"meshBasicMaterial",
|
|
148
|
+
{
|
|
149
|
+
color: o,
|
|
150
|
+
depthTest: !1,
|
|
151
|
+
transparent: !0,
|
|
152
|
+
opacity: r
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
] });
|
|
156
|
+
}
|
|
157
|
+
function U({
|
|
158
|
+
points: t,
|
|
159
|
+
color: n,
|
|
160
|
+
width: e,
|
|
161
|
+
opacity: o
|
|
162
|
+
}) {
|
|
163
|
+
return /* @__PURE__ */ c(
|
|
164
|
+
H,
|
|
165
|
+
{
|
|
166
|
+
points: t,
|
|
167
|
+
color: n,
|
|
168
|
+
lineWidth: e,
|
|
169
|
+
depthTest: !1,
|
|
170
|
+
transparent: !0,
|
|
171
|
+
opacity: o,
|
|
172
|
+
renderOrder: 10
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
function tt(t, n) {
|
|
177
|
+
const e = [...t];
|
|
178
|
+
let o = n;
|
|
179
|
+
for (; e.length > 1; ) {
|
|
180
|
+
const r = e[e.length - 1], s = e[e.length - 2], u = r.distanceTo(s);
|
|
181
|
+
if (u > o)
|
|
182
|
+
return e[e.length - 1] = r.clone().lerp(s, o / u), e;
|
|
183
|
+
o -= u, e.pop();
|
|
184
|
+
}
|
|
185
|
+
return e;
|
|
186
|
+
}
|
|
187
|
+
function ee(t, n, e, o) {
|
|
188
|
+
const r = e * t, s = e * n, u = Math.abs(s - r), i = Math.max(
|
|
189
|
+
2,
|
|
190
|
+
Math.ceil(u / (2 * Math.PI) * Xt)
|
|
191
|
+
);
|
|
192
|
+
return Array.from({ length: i + 1 }, (a, l) => {
|
|
193
|
+
const p = r + (s - r) * l / i, f = u * l / i / (2 * Math.PI), g = o * (1 + Yt * f);
|
|
194
|
+
return new b.Vector3(
|
|
195
|
+
Math.cos(p) * g,
|
|
196
|
+
Math.sin(p) * g,
|
|
197
|
+
0
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
function ne(t, n, e, o) {
|
|
202
|
+
const r = t.theta ?? 0, s = t.d ?? 0, u = t.type === "PRISMATIC_JOINT", i = t.reverse_rotation_direction ? -1 : 1, { lower_limit: a, upper_limit: l } = n;
|
|
203
|
+
return E(() => {
|
|
204
|
+
const p = new b.Matrix4().makeRotationZ(r).multiply(
|
|
205
|
+
new b.Matrix4().makeTranslation(0, 0, u ? s / 1e3 : 0)
|
|
206
|
+
), f = (S, P, O) => new b.Vector3(S, P, O).applyMatrix4(p), g = new b.Vector3().applyMatrix4(p), m = f(0, 0, e), h = (u ? [
|
|
207
|
+
f(e * 0.25, 0, i * a / 1e3),
|
|
208
|
+
f(e * 0.25, 0, i * l / 1e3)
|
|
209
|
+
] : ee(a, l, i, e * 0.6)).map((S) => u ? S : S.applyMatrix4(p)), d = f(u ? e * 0.25 : e * 0.6, 0, 0), x = h.slice(1).reduce((S, P, O) => S + P.distanceTo(h[O]), 0), y = Math.min(o, x / 3), w = tt(
|
|
210
|
+
tt(h, y).reverse(),
|
|
211
|
+
y
|
|
212
|
+
).reverse();
|
|
213
|
+
return {
|
|
214
|
+
axisPoints: [g, m],
|
|
215
|
+
axisTip: m,
|
|
216
|
+
origin: g,
|
|
217
|
+
restPoints: [g, d],
|
|
218
|
+
range: h,
|
|
219
|
+
limitPoints: w,
|
|
220
|
+
rangeStart: w[0],
|
|
221
|
+
rangeEnd: w[w.length - 1]
|
|
222
|
+
};
|
|
223
|
+
}, [r, s, u, i, e, a, l, o]);
|
|
224
|
+
}
|
|
225
|
+
function oe({
|
|
226
|
+
frame: t,
|
|
227
|
+
dh: n,
|
|
228
|
+
limit: e,
|
|
229
|
+
size: o,
|
|
230
|
+
emphasis: r
|
|
231
|
+
}) {
|
|
232
|
+
const s = r === "highlighted" ? zt : 1, u = r === "dimmed" ? Kt : 1, i = o * 0.2 * (r === "highlighted" ? 1.4 : 1), a = 2 * s, {
|
|
233
|
+
axisPoints: l,
|
|
234
|
+
axisTip: p,
|
|
235
|
+
origin: f,
|
|
236
|
+
restPoints: g,
|
|
237
|
+
range: m,
|
|
238
|
+
limitPoints: h,
|
|
239
|
+
rangeStart: d,
|
|
240
|
+
rangeEnd: x
|
|
241
|
+
} = ne(n, e, o, i), { position: y, quaternion: w } = E(() => {
|
|
242
|
+
const S = new b.Vector3(), P = new b.Quaternion();
|
|
243
|
+
return t.decompose(S, P, new b.Vector3()), { position: S, quaternion: P };
|
|
244
|
+
}, [t]);
|
|
245
|
+
return /* @__PURE__ */ _("group", { position: y, quaternion: w, children: [
|
|
246
|
+
/* @__PURE__ */ c(
|
|
247
|
+
U,
|
|
248
|
+
{
|
|
249
|
+
points: l,
|
|
250
|
+
color: z,
|
|
251
|
+
width: a,
|
|
252
|
+
opacity: u
|
|
253
|
+
}
|
|
254
|
+
),
|
|
255
|
+
/* @__PURE__ */ c(
|
|
256
|
+
D,
|
|
257
|
+
{
|
|
258
|
+
base: p,
|
|
259
|
+
direction: p.clone().sub(f),
|
|
260
|
+
size: i,
|
|
261
|
+
color: z,
|
|
262
|
+
opacity: u
|
|
263
|
+
}
|
|
264
|
+
),
|
|
265
|
+
/* @__PURE__ */ c(
|
|
266
|
+
U,
|
|
267
|
+
{
|
|
268
|
+
points: g,
|
|
269
|
+
color: Qt,
|
|
270
|
+
width: 1.5 * s,
|
|
271
|
+
opacity: u
|
|
272
|
+
}
|
|
273
|
+
),
|
|
274
|
+
/* @__PURE__ */ c(
|
|
275
|
+
U,
|
|
276
|
+
{
|
|
277
|
+
points: h,
|
|
278
|
+
color: V,
|
|
279
|
+
width: a,
|
|
280
|
+
opacity: u
|
|
281
|
+
}
|
|
282
|
+
),
|
|
283
|
+
/* @__PURE__ */ c(
|
|
284
|
+
D,
|
|
285
|
+
{
|
|
286
|
+
base: d,
|
|
287
|
+
direction: m[0].clone().sub(d),
|
|
288
|
+
size: d.distanceTo(m[0]),
|
|
289
|
+
color: V,
|
|
290
|
+
opacity: u
|
|
291
|
+
}
|
|
292
|
+
),
|
|
293
|
+
/* @__PURE__ */ c(
|
|
294
|
+
D,
|
|
295
|
+
{
|
|
296
|
+
base: x,
|
|
297
|
+
direction: m[m.length - 1].clone().sub(x),
|
|
298
|
+
size: x.distanceTo(m[m.length - 1]),
|
|
299
|
+
color: V,
|
|
300
|
+
opacity: u
|
|
301
|
+
}
|
|
302
|
+
)
|
|
303
|
+
] });
|
|
304
|
+
}
|
|
305
|
+
function Xe({
|
|
306
|
+
dhParameters: t,
|
|
307
|
+
chainOffset: n = null,
|
|
308
|
+
limits: e,
|
|
309
|
+
jointPositions: o,
|
|
310
|
+
size: r = 0.15,
|
|
311
|
+
highlightedJoint: s = null
|
|
312
|
+
}) {
|
|
313
|
+
const u = E(
|
|
314
|
+
() => Bt(t, n, o),
|
|
315
|
+
[t, n, o]
|
|
316
|
+
);
|
|
317
|
+
return /* @__PURE__ */ c("group", { children: u.map((i, a) => {
|
|
318
|
+
const l = te(e[a]);
|
|
319
|
+
return l ? /* @__PURE__ */ c(
|
|
320
|
+
oe,
|
|
321
|
+
{
|
|
322
|
+
frame: i,
|
|
323
|
+
dh: t[a],
|
|
324
|
+
limit: l,
|
|
325
|
+
size: r,
|
|
326
|
+
emphasis: s === null ? "normal" : s === a ? "highlighted" : "dimmed"
|
|
327
|
+
},
|
|
328
|
+
a
|
|
329
|
+
) : null;
|
|
330
|
+
}) });
|
|
331
|
+
}
|
|
332
|
+
function Ye() {
|
|
333
|
+
return /* @__PURE__ */ c(Gt, { frames: 1, children: /* @__PURE__ */ c(ie, {}) });
|
|
334
|
+
}
|
|
335
|
+
const re = [2, 0, 2, 0, 2, 0, 2, 0];
|
|
336
|
+
function ie({ positions: t = re }) {
|
|
337
|
+
return /* @__PURE__ */ _(ct, { children: [
|
|
338
|
+
/* @__PURE__ */ c(
|
|
339
|
+
G,
|
|
340
|
+
{
|
|
341
|
+
intensity: 5,
|
|
342
|
+
"rotation-x": Math.PI / 2,
|
|
343
|
+
position: [0, 5, -9],
|
|
344
|
+
scale: [10, 10, 1]
|
|
345
|
+
}
|
|
346
|
+
),
|
|
347
|
+
/* @__PURE__ */ c("group", { rotation: [0, 0.5, 0], children: /* @__PURE__ */ c("group", { children: t.map((n, e) => /* @__PURE__ */ c(
|
|
348
|
+
G,
|
|
349
|
+
{
|
|
350
|
+
form: "circle",
|
|
351
|
+
intensity: 5,
|
|
352
|
+
rotation: [Math.PI / 2, 0, 0],
|
|
353
|
+
position: [n, 4, e * 4],
|
|
354
|
+
scale: [3, 1, 1]
|
|
355
|
+
},
|
|
356
|
+
e
|
|
357
|
+
)) }) }),
|
|
358
|
+
/* @__PURE__ */ c(
|
|
359
|
+
G,
|
|
360
|
+
{
|
|
361
|
+
intensity: 40,
|
|
362
|
+
"rotation-y": Math.PI / 2,
|
|
363
|
+
position: [-5, 1, -1],
|
|
364
|
+
scale: [20, 0.1, 1]
|
|
365
|
+
}
|
|
366
|
+
),
|
|
367
|
+
/* @__PURE__ */ c(
|
|
368
|
+
G,
|
|
369
|
+
{
|
|
370
|
+
intensity: 20,
|
|
371
|
+
"rotation-y": -Math.PI,
|
|
372
|
+
position: [-5, -2, -1],
|
|
373
|
+
scale: [20, 0.1, 1]
|
|
374
|
+
}
|
|
375
|
+
),
|
|
376
|
+
/* @__PURE__ */ c(
|
|
377
|
+
G,
|
|
378
|
+
{
|
|
379
|
+
"rotation-y": Math.PI / 2,
|
|
380
|
+
position: [-5, -1, -1],
|
|
381
|
+
scale: [20, 0.5, 1],
|
|
382
|
+
intensity: 5
|
|
383
|
+
}
|
|
384
|
+
),
|
|
385
|
+
/* @__PURE__ */ c(
|
|
386
|
+
G,
|
|
387
|
+
{
|
|
388
|
+
"rotation-y": -Math.PI / 2,
|
|
389
|
+
position: [10, 1, 0],
|
|
390
|
+
scale: [20, 1, 1],
|
|
391
|
+
intensity: 10
|
|
392
|
+
}
|
|
393
|
+
),
|
|
394
|
+
/* @__PURE__ */ c(
|
|
395
|
+
G,
|
|
396
|
+
{
|
|
397
|
+
form: "ring",
|
|
398
|
+
color: "white",
|
|
399
|
+
intensity: 5,
|
|
400
|
+
scale: 10,
|
|
401
|
+
position: [-15, 4, -18],
|
|
402
|
+
target: [0, 0, 0]
|
|
403
|
+
}
|
|
404
|
+
)
|
|
405
|
+
] });
|
|
406
|
+
}
|
|
407
|
+
const et = {
|
|
408
|
+
attach: "material",
|
|
409
|
+
color: "#009f4d",
|
|
410
|
+
opacity: 0.2,
|
|
411
|
+
depthTest: !1,
|
|
412
|
+
depthWrite: !1,
|
|
413
|
+
transparent: !0,
|
|
414
|
+
polygonOffset: !0
|
|
415
|
+
};
|
|
416
|
+
function Ze({
|
|
417
|
+
safetyZones: t,
|
|
418
|
+
dhParameters: n,
|
|
419
|
+
...e
|
|
420
|
+
}) {
|
|
421
|
+
const o = E(
|
|
422
|
+
() => Ct(n ?? []),
|
|
423
|
+
[n]
|
|
424
|
+
), r = (u, i) => {
|
|
425
|
+
var g, m;
|
|
426
|
+
if (!((g = i == null ? void 0 : i.pose) != null && g.position) || !((m = i == null ? void 0 : i.pose) != null && m.orientation))
|
|
427
|
+
return null;
|
|
428
|
+
const a = new b.Vector3(
|
|
429
|
+
i.pose.position[0] / 1e3,
|
|
430
|
+
i.pose.position[1] / 1e3,
|
|
431
|
+
i.pose.position[2] / 1e3
|
|
432
|
+
), l = new b.Vector3(
|
|
433
|
+
i.pose.orientation[0],
|
|
434
|
+
i.pose.orientation[1],
|
|
435
|
+
i.pose.orientation[2]
|
|
436
|
+
);
|
|
437
|
+
let p;
|
|
438
|
+
const f = i.shape.shape_type === "plane" ? { ...et, side: b.DoubleSide } : { ...et, side: b.FrontSide };
|
|
439
|
+
switch (i.shape.shape_type) {
|
|
440
|
+
/**
|
|
441
|
+
* Plane shape, uses DH parameters to calculate the size of the plane (reach distance of a robot)
|
|
442
|
+
*/
|
|
443
|
+
case "plane":
|
|
444
|
+
p = /* @__PURE__ */ c("planeGeometry", { args: [o, o] });
|
|
445
|
+
break;
|
|
446
|
+
/**
|
|
447
|
+
* Sphere shape
|
|
448
|
+
*/
|
|
449
|
+
case "sphere": {
|
|
450
|
+
const h = (i == null ? void 0 : i.shape).radius / 1e3;
|
|
451
|
+
p = /* @__PURE__ */ c("sphereGeometry", { args: [h] });
|
|
452
|
+
break;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Capsule shape
|
|
456
|
+
*/
|
|
457
|
+
case "capsule": {
|
|
458
|
+
const h = (i == null ? void 0 : i.shape).radius / 1e3, d = (i == null ? void 0 : i.shape).cylinder_height / 1e3;
|
|
459
|
+
p = /* @__PURE__ */ c("capsuleGeometry", { args: [h, d] });
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Convex hull, checks at first if the vertices are coplanar - if yes, adds a small offset for
|
|
464
|
+
* renderer to be able to visualize the convex hull.
|
|
465
|
+
*/
|
|
466
|
+
case "convex_hull": {
|
|
467
|
+
const h = (i == null ? void 0 : i.shape).vertices.map(
|
|
468
|
+
(x) => new b.Vector3(x[0] / 1e3, x[1] / 1e3, x[2] / 1e3)
|
|
469
|
+
), d = kt(h);
|
|
470
|
+
if (d.isCoplanar && d.normal) {
|
|
471
|
+
const y = new b.Vector3().addVectors(
|
|
472
|
+
h[0],
|
|
473
|
+
d.normal.multiplyScalar(1e-4)
|
|
474
|
+
);
|
|
475
|
+
h.push(y);
|
|
476
|
+
}
|
|
477
|
+
try {
|
|
478
|
+
p = /* @__PURE__ */ c(
|
|
479
|
+
"primitive",
|
|
480
|
+
{
|
|
481
|
+
object: new lt(h),
|
|
482
|
+
attach: "geometry"
|
|
483
|
+
}
|
|
484
|
+
);
|
|
485
|
+
} catch (x) {
|
|
486
|
+
return console.log("Error creating ConvexGeometry:", x), null;
|
|
487
|
+
}
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Convex hull around four spheres. Sphere center points in x/y-plane,
|
|
492
|
+
* offset by either combination "+/- sizeX" or "+/- sizeY".
|
|
493
|
+
* Alternative description: Rectangle in x/y-plane with a 3D padding (source: nova-api docs)
|
|
494
|
+
*
|
|
495
|
+
* Basically a rounded box with a rectangular cross-section.
|
|
496
|
+
*/
|
|
497
|
+
case "rectangular_capsule": {
|
|
498
|
+
const h = i.shape, d = h.radius / 1e3, x = h.sphere_center_distance_x / 1e3, y = h.sphere_center_distance_y / 1e3, w = d * 2;
|
|
499
|
+
p = /* @__PURE__ */ c(
|
|
500
|
+
"primitive",
|
|
501
|
+
{
|
|
502
|
+
object: new Ot(x, y, w, 2, d),
|
|
503
|
+
attach: "geometry"
|
|
504
|
+
}
|
|
505
|
+
);
|
|
506
|
+
break;
|
|
507
|
+
}
|
|
508
|
+
default:
|
|
509
|
+
console.warn(
|
|
510
|
+
"Unsupported safety zone shape type:",
|
|
511
|
+
i.shape.shape_type
|
|
512
|
+
), p = null;
|
|
513
|
+
}
|
|
514
|
+
return /* @__PURE__ */ _(
|
|
515
|
+
"mesh",
|
|
516
|
+
{
|
|
517
|
+
renderOrder: u,
|
|
518
|
+
position: a,
|
|
519
|
+
quaternion: Nt(l),
|
|
520
|
+
children: [
|
|
521
|
+
p,
|
|
522
|
+
/* @__PURE__ */ c("meshStandardMaterial", { ...f, polygonOffsetFactor: -u })
|
|
523
|
+
]
|
|
524
|
+
},
|
|
525
|
+
`safety-zone-${i.shape.shape_type}-${u}`
|
|
526
|
+
);
|
|
527
|
+
}, s = E(() => Object.values(t ?? {}).map(
|
|
528
|
+
(u, i) => r(i, u)
|
|
529
|
+
), [t, o]);
|
|
530
|
+
return /* @__PURE__ */ c("group", { ...e, children: s });
|
|
531
|
+
}
|
|
532
|
+
function Ke({
|
|
533
|
+
trajectory: t,
|
|
534
|
+
...n
|
|
535
|
+
}) {
|
|
536
|
+
const e = (t == null ? void 0 : t.map((o) => {
|
|
537
|
+
if (o.position && o.position.length >= 3) {
|
|
538
|
+
const [r, s, u] = o.position;
|
|
539
|
+
if (Number.isFinite(r) && Number.isFinite(s) && Number.isFinite(u))
|
|
540
|
+
return new b.Vector3(r / 1e3, u / 1e3, -s / 1e3);
|
|
541
|
+
}
|
|
542
|
+
return null;
|
|
543
|
+
}).filter((o) => o !== null)) || [];
|
|
544
|
+
return /* @__PURE__ */ c("group", { ...n, children: e.length > 0 && /* @__PURE__ */ c(
|
|
545
|
+
H,
|
|
546
|
+
{
|
|
547
|
+
points: e,
|
|
548
|
+
lineWidth: 3,
|
|
549
|
+
polygonOffset: !0,
|
|
550
|
+
polygonOffsetFactor: 10,
|
|
551
|
+
polygonOffsetUnits: 10
|
|
552
|
+
}
|
|
553
|
+
) });
|
|
554
|
+
}
|
|
555
|
+
const N = ["x", "y", "z"], Y = ["-", "+"];
|
|
556
|
+
function W(t, n) {
|
|
557
|
+
return !!t && !!n && t.axis === n.axis && t.direction === n.direction;
|
|
558
|
+
}
|
|
559
|
+
function se(t) {
|
|
560
|
+
return `${t.axis.toUpperCase()}${t.direction}`;
|
|
561
|
+
}
|
|
562
|
+
const nt = (t) => t === " " || t === "Enter";
|
|
563
|
+
function ae({
|
|
564
|
+
onStart: t,
|
|
565
|
+
onStop: n,
|
|
566
|
+
disabled: e = !1,
|
|
567
|
+
isSame: o
|
|
568
|
+
}) {
|
|
569
|
+
const r = R(null), [s, u] = I(null), i = R({ onStop: n, isSame: o });
|
|
570
|
+
i.current = { onStop: n, isSame: o };
|
|
571
|
+
const a = A(
|
|
572
|
+
(m) => e || r.current !== null ? !1 : (r.current = m, u(m), t(m), !0),
|
|
573
|
+
[e, t]
|
|
574
|
+
), l = A((m) => {
|
|
575
|
+
const h = r.current;
|
|
576
|
+
h !== null && (m !== void 0 && !i.current.isSame(h, m) || (r.current = null, u(null), i.current.onStop()));
|
|
577
|
+
}, []);
|
|
578
|
+
M(() => {
|
|
579
|
+
e && l();
|
|
580
|
+
}, [e, l]), M(() => () => l(), [l]);
|
|
581
|
+
const p = s !== null;
|
|
582
|
+
M(() => {
|
|
583
|
+
if (!p) return;
|
|
584
|
+
const m = () => l(), h = () => {
|
|
585
|
+
document.visibilityState === "hidden" && l();
|
|
586
|
+
};
|
|
587
|
+
return window.addEventListener("blur", m), document.addEventListener("visibilitychange", h), () => {
|
|
588
|
+
window.removeEventListener("blur", m), document.removeEventListener("visibilitychange", h);
|
|
589
|
+
};
|
|
590
|
+
}, [p, l]);
|
|
591
|
+
const f = A(
|
|
592
|
+
(m) => ({
|
|
593
|
+
onPointerDown: (h) => {
|
|
594
|
+
var d, x;
|
|
595
|
+
h.button === 0 && a(m) && ((x = (d = h.currentTarget).setPointerCapture) == null || x.call(d, h.pointerId));
|
|
596
|
+
},
|
|
597
|
+
onPointerUp: () => l(m),
|
|
598
|
+
onPointerCancel: () => l(m),
|
|
599
|
+
onLostPointerCapture: () => l(m),
|
|
600
|
+
onKeyDown: (h) => {
|
|
601
|
+
nt(h.key) && (h.preventDefault(), h.repeat || a(m));
|
|
602
|
+
},
|
|
603
|
+
onKeyUp: (h) => {
|
|
604
|
+
nt(h.key) && l(m);
|
|
605
|
+
},
|
|
606
|
+
onBlur: (h) => l(m)
|
|
607
|
+
}),
|
|
608
|
+
[a, l]
|
|
609
|
+
), g = A(() => l(), [l]);
|
|
610
|
+
return { held: s, handlersFor: f, stop: g };
|
|
611
|
+
}
|
|
612
|
+
function ce({
|
|
613
|
+
onJogStart: t,
|
|
614
|
+
onJogStop: n,
|
|
615
|
+
disabled: e = !1
|
|
616
|
+
}) {
|
|
617
|
+
const o = A(
|
|
618
|
+
(r) => t(r.axis, r.direction),
|
|
619
|
+
[t]
|
|
620
|
+
);
|
|
621
|
+
return ae({
|
|
622
|
+
onStart: o,
|
|
623
|
+
onStop: n,
|
|
624
|
+
disabled: e,
|
|
625
|
+
isSame: W
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
const le = new v(0, 1, 0), B = (t) => `${t.axis}${t.direction}`, ue = { x: "X", y: "Y", z: "Z" };
|
|
629
|
+
function Q(t) {
|
|
630
|
+
var n;
|
|
631
|
+
return ((n = Jt[ue[t]].buttonBackgroundColor) == null ? void 0 : n.default) ?? "currentColor";
|
|
632
|
+
}
|
|
633
|
+
const pe = 200;
|
|
634
|
+
function Z(t) {
|
|
635
|
+
const n = t / pe;
|
|
636
|
+
return {
|
|
637
|
+
/** Room around the gizmo for the labels, arrowheads and grab bars */
|
|
638
|
+
marginPx: 30 * n,
|
|
639
|
+
/** Thickness of a handle's grab bar, which shows as its halo */
|
|
640
|
+
gripPx: 30 * n,
|
|
641
|
+
grab: {
|
|
642
|
+
// The center, where all axes cross, belongs to no handle
|
|
643
|
+
innerPx: 10 * n,
|
|
644
|
+
// The arrowhead is the obvious thing to grab, so the bar reaches past it
|
|
645
|
+
beyondTipPx: 10 * n,
|
|
646
|
+
minLengthPx: 32 * n
|
|
647
|
+
},
|
|
648
|
+
/** The axis labels, which stay readable on a small gizmo */
|
|
649
|
+
labelFontPx: Math.max(10, 13 * n)
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
function ot(t, n) {
|
|
653
|
+
return (e) => {
|
|
654
|
+
e ? t.current.set(n, e) : t.current.delete(n);
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
const gt = {
|
|
658
|
+
x: new v(1, 0, 0),
|
|
659
|
+
y: new v(0, 1, 0),
|
|
660
|
+
z: new v(0, 0, 1)
|
|
661
|
+
};
|
|
662
|
+
function fe(t, n, e = new L()) {
|
|
663
|
+
return e.copy(t).invert().multiply(n);
|
|
664
|
+
}
|
|
665
|
+
function me(t) {
|
|
666
|
+
const n = [];
|
|
667
|
+
for (const e of N)
|
|
668
|
+
for (const o of Y) {
|
|
669
|
+
const r = gt[e].clone().multiplyScalar(o === "+" ? 1 : -1).applyQuaternion(t);
|
|
670
|
+
n.push({
|
|
671
|
+
axis: e,
|
|
672
|
+
direction: o,
|
|
673
|
+
x: r.x + 0,
|
|
674
|
+
y: -r.y + 0,
|
|
675
|
+
depth: r.z
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
return n;
|
|
679
|
+
}
|
|
680
|
+
function he(t, n, e) {
|
|
681
|
+
return Math.max(1, Math.min(t, n) / 2 - e);
|
|
682
|
+
}
|
|
683
|
+
function de(t, n) {
|
|
684
|
+
const { radiusPx: e, innerPx: o, beyondTipPx: r, minLengthPx: s } = n, u = Math.hypot(t.x, t.y), i = u > 1e-6 ? Math.atan2(t.y, t.x) : 0, a = Math.cos(i), l = Math.sin(i), p = u * e + r;
|
|
685
|
+
if (p - o >= s)
|
|
686
|
+
return { x: a * o, y: l * o, length: p - o, angle: i };
|
|
687
|
+
const f = t.x * e, g = t.y * e;
|
|
688
|
+
return {
|
|
689
|
+
x: f - a * s / 2,
|
|
690
|
+
y: g - l * s / 2,
|
|
691
|
+
length: s,
|
|
692
|
+
angle: i
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
const ge = 1e-8;
|
|
696
|
+
function rt(t, n) {
|
|
697
|
+
return t ? Math.abs(t.dot(n)) < 1 - ge : !0;
|
|
698
|
+
}
|
|
699
|
+
const it = 0.035, j = 0.26, ye = 0.1, st = 1.28, yt = (t) => `label:${t}`;
|
|
700
|
+
function we({
|
|
701
|
+
orientation: t,
|
|
702
|
+
lit: n,
|
|
703
|
+
disabled: e,
|
|
704
|
+
size: o,
|
|
705
|
+
radius: r,
|
|
706
|
+
overlay: s
|
|
707
|
+
}) {
|
|
708
|
+
const u = R(null), i = R(null), a = o / 2, l = $((p) => p.invalidate);
|
|
709
|
+
return M(() => {
|
|
710
|
+
i.current = null, l();
|
|
711
|
+
}, [o, r, l]), M(() => {
|
|
712
|
+
let p = requestAnimationFrame(function f() {
|
|
713
|
+
const g = t.current;
|
|
714
|
+
g && rt(i.current, g) && l(), p = requestAnimationFrame(f);
|
|
715
|
+
});
|
|
716
|
+
return () => cancelAnimationFrame(p);
|
|
717
|
+
}, [t, l]), mt(() => {
|
|
718
|
+
const p = t.current;
|
|
719
|
+
if (!p || !u.current || !rt(i.current, p)) return;
|
|
720
|
+
u.current.quaternion.copy(p);
|
|
721
|
+
let f = !0;
|
|
722
|
+
for (const g of me(p)) {
|
|
723
|
+
const m = s.current.get(B(g));
|
|
724
|
+
if (m) {
|
|
725
|
+
const d = de(g, {
|
|
726
|
+
radiusPx: r,
|
|
727
|
+
...Z(o).grab
|
|
728
|
+
});
|
|
729
|
+
m.style.left = `${a + d.x}px`, m.style.top = `${a + d.y}px`, m.style.width = `${d.length}px`, m.style.transform = `translateY(-50%) rotate(${d.angle}rad)`, m.style.zIndex = String(10 + Math.round(g.depth * 5));
|
|
730
|
+
} else
|
|
731
|
+
f = !1;
|
|
732
|
+
if (g.direction !== "+") continue;
|
|
733
|
+
const h = s.current.get(yt(g.axis));
|
|
734
|
+
h ? (h.style.left = `${a + g.x * r * st}px`, h.style.top = `${a + g.y * r * st}px`) : f = !1;
|
|
735
|
+
}
|
|
736
|
+
f && (i.current = p.clone());
|
|
737
|
+
}), /* @__PURE__ */ _("group", { ref: u, children: [
|
|
738
|
+
/* @__PURE__ */ _("mesh", { children: [
|
|
739
|
+
/* @__PURE__ */ c("sphereGeometry", { args: [0.07, 16, 16] }),
|
|
740
|
+
/* @__PURE__ */ c("meshBasicMaterial", { color: "#c4c8d0" })
|
|
741
|
+
] }),
|
|
742
|
+
N.map((p) => /* @__PURE__ */ c(
|
|
743
|
+
be,
|
|
744
|
+
{
|
|
745
|
+
axis: p,
|
|
746
|
+
color: Q(p),
|
|
747
|
+
lit: (n == null ? void 0 : n.axis) === p ? n.direction : null,
|
|
748
|
+
disabled: e
|
|
749
|
+
},
|
|
750
|
+
p
|
|
751
|
+
))
|
|
752
|
+
] });
|
|
753
|
+
}
|
|
754
|
+
function be({
|
|
755
|
+
axis: t,
|
|
756
|
+
color: n,
|
|
757
|
+
lit: e,
|
|
758
|
+
disabled: o
|
|
759
|
+
}) {
|
|
760
|
+
const r = E(
|
|
761
|
+
() => new L().setFromUnitVectors(le, gt[t]),
|
|
762
|
+
[t]
|
|
763
|
+
), s = 1 - j;
|
|
764
|
+
return /* @__PURE__ */ c("group", { quaternion: r, children: Y.map((u) => {
|
|
765
|
+
const i = e === u, a = i ? 1 : o ? 0.35 : 0.8, l = i ? it * 1.5 : it;
|
|
766
|
+
return (
|
|
767
|
+
// The minus half is the plus half turned around
|
|
768
|
+
/* @__PURE__ */ _(
|
|
769
|
+
"group",
|
|
770
|
+
{
|
|
771
|
+
rotation: [u === "+" ? 0 : Math.PI, 0, 0],
|
|
772
|
+
children: [
|
|
773
|
+
/* @__PURE__ */ _("mesh", { position: [0, s / 2, 0], children: [
|
|
774
|
+
/* @__PURE__ */ c(
|
|
775
|
+
"cylinderGeometry",
|
|
776
|
+
{
|
|
777
|
+
args: [l, l, s, 12]
|
|
778
|
+
}
|
|
779
|
+
),
|
|
780
|
+
/* @__PURE__ */ c("meshBasicMaterial", { color: n, transparent: !0, opacity: a })
|
|
781
|
+
] }),
|
|
782
|
+
/* @__PURE__ */ _(
|
|
783
|
+
"mesh",
|
|
784
|
+
{
|
|
785
|
+
position: [0, 1 - j / 2, 0],
|
|
786
|
+
scale: i ? 1.2 : 1,
|
|
787
|
+
children: [
|
|
788
|
+
/* @__PURE__ */ c("coneGeometry", { args: [ye, j, 20] }),
|
|
789
|
+
/* @__PURE__ */ c("meshBasicMaterial", { color: n, transparent: !0, opacity: a })
|
|
790
|
+
]
|
|
791
|
+
}
|
|
792
|
+
)
|
|
793
|
+
]
|
|
794
|
+
},
|
|
795
|
+
u
|
|
796
|
+
)
|
|
797
|
+
);
|
|
798
|
+
}) });
|
|
799
|
+
}
|
|
800
|
+
function xe({
|
|
801
|
+
held: t,
|
|
802
|
+
activeHandle: n,
|
|
803
|
+
disabled: e,
|
|
804
|
+
onHover: o,
|
|
805
|
+
handlersFor: r,
|
|
806
|
+
label: s,
|
|
807
|
+
overlay: u,
|
|
808
|
+
size: i
|
|
809
|
+
}) {
|
|
810
|
+
const a = Dt(), { gripPx: l, labelFontPx: p } = Z(i);
|
|
811
|
+
return /* @__PURE__ */ _(ct, { children: [
|
|
812
|
+
N.map((f) => /* @__PURE__ */ c(
|
|
813
|
+
q,
|
|
814
|
+
{
|
|
815
|
+
component: "span",
|
|
816
|
+
"aria-hidden": !0,
|
|
817
|
+
ref: ot(u, yt(f)),
|
|
818
|
+
sx: {
|
|
819
|
+
position: "absolute",
|
|
820
|
+
transform: "translate(-50%, -50%)",
|
|
821
|
+
pointerEvents: "none",
|
|
822
|
+
fontSize: p,
|
|
823
|
+
color: Q(f),
|
|
824
|
+
opacity: e ? 0.4 : 1
|
|
825
|
+
},
|
|
826
|
+
children: f.toUpperCase()
|
|
827
|
+
},
|
|
828
|
+
f
|
|
829
|
+
)),
|
|
830
|
+
N.flatMap(
|
|
831
|
+
(f) => Y.map((g) => {
|
|
832
|
+
const m = { axis: f, direction: g }, h = Q(f), d = W(t, m) || W(n, m);
|
|
833
|
+
return /* @__PURE__ */ c(
|
|
834
|
+
q,
|
|
835
|
+
{
|
|
836
|
+
component: "button",
|
|
837
|
+
type: "button",
|
|
838
|
+
ref: ot(u, B(m)),
|
|
839
|
+
disabled: e,
|
|
840
|
+
"aria-label": s(m),
|
|
841
|
+
"aria-pressed": d,
|
|
842
|
+
onPointerEnter: () => o(m),
|
|
843
|
+
onPointerLeave: () => o(null),
|
|
844
|
+
...r(m),
|
|
845
|
+
sx: {
|
|
846
|
+
// Placed, sized and turned along its half of the axis by
|
|
847
|
+
// TranslationScene, every frame the gizmo turns
|
|
848
|
+
position: "absolute",
|
|
849
|
+
height: l,
|
|
850
|
+
transformOrigin: "0 50%",
|
|
851
|
+
padding: 0,
|
|
852
|
+
borderRadius: `${l / 2}px`,
|
|
853
|
+
border: "none",
|
|
854
|
+
background: "transparent",
|
|
855
|
+
cursor: e ? "default" : "pointer",
|
|
856
|
+
touchAction: "none",
|
|
857
|
+
userSelect: "none",
|
|
858
|
+
"&:hover:not(:disabled)": { background: K(h, 0.12) },
|
|
859
|
+
"&:focus-visible": {
|
|
860
|
+
outline: `2px solid ${a.palette.primary.main}`
|
|
861
|
+
},
|
|
862
|
+
...d && { background: K(h, 0.25) }
|
|
863
|
+
}
|
|
864
|
+
},
|
|
865
|
+
B(m)
|
|
866
|
+
);
|
|
867
|
+
})
|
|
868
|
+
)
|
|
869
|
+
] });
|
|
870
|
+
}
|
|
871
|
+
const _e = 3e3;
|
|
872
|
+
function Re(t) {
|
|
873
|
+
const [n, e] = I(() => t.current !== null);
|
|
874
|
+
return M(() => {
|
|
875
|
+
if (n) return;
|
|
876
|
+
let o = requestAnimationFrame(function s() {
|
|
877
|
+
t.current !== null ? e(!0) : o = requestAnimationFrame(s);
|
|
878
|
+
});
|
|
879
|
+
const r = setTimeout(() => {
|
|
880
|
+
t.current === null && console.warn(
|
|
881
|
+
"JoggingGizmo has no orientation, so it stays disabled. Put a JoggingGizmoOrientation with the same ref into the app's 3D scene."
|
|
882
|
+
);
|
|
883
|
+
}, _e);
|
|
884
|
+
return () => {
|
|
885
|
+
cancelAnimationFrame(o), clearTimeout(r);
|
|
886
|
+
};
|
|
887
|
+
}, [n, t]), n;
|
|
888
|
+
}
|
|
889
|
+
const ze = F(
|
|
890
|
+
({
|
|
891
|
+
orientation: t,
|
|
892
|
+
onJogStart: n,
|
|
893
|
+
onJogStop: e,
|
|
894
|
+
activeHandle: o,
|
|
895
|
+
disabled: r = !1,
|
|
896
|
+
size: s = 200
|
|
897
|
+
}) => {
|
|
898
|
+
const { t: u } = $t(), i = Re(t), a = r || !i, { held: l, handlersFor: p } = ce({
|
|
899
|
+
onJogStart: n,
|
|
900
|
+
onJogStop: e,
|
|
901
|
+
disabled: a
|
|
902
|
+
}), [f, g] = I(null), m = R(/* @__PURE__ */ new Map()), h = he(s, s, Z(s).marginPx);
|
|
903
|
+
return /* @__PURE__ */ _(
|
|
904
|
+
q,
|
|
905
|
+
{
|
|
906
|
+
"data-testid": "jogging-gizmo",
|
|
907
|
+
sx: { position: "relative", width: s, height: s, flexShrink: 0 },
|
|
908
|
+
children: [
|
|
909
|
+
/* @__PURE__ */ c(
|
|
910
|
+
Ht,
|
|
911
|
+
{
|
|
912
|
+
orthographic: !0,
|
|
913
|
+
flat: !0,
|
|
914
|
+
frameloop: "demand",
|
|
915
|
+
camera: { position: [0, 0, 10], zoom: h, near: 0.1, far: 100 },
|
|
916
|
+
gl: { alpha: !0, antialias: !0 },
|
|
917
|
+
style: { position: "absolute", inset: 0, pointerEvents: "none" },
|
|
918
|
+
children: /* @__PURE__ */ c(
|
|
919
|
+
we,
|
|
920
|
+
{
|
|
921
|
+
orientation: t,
|
|
922
|
+
lit: l ?? o ?? f,
|
|
923
|
+
disabled: a,
|
|
924
|
+
size: s,
|
|
925
|
+
radius: h,
|
|
926
|
+
overlay: m
|
|
927
|
+
}
|
|
928
|
+
)
|
|
929
|
+
}
|
|
930
|
+
),
|
|
931
|
+
/* @__PURE__ */ c(
|
|
932
|
+
xe,
|
|
933
|
+
{
|
|
934
|
+
held: l,
|
|
935
|
+
activeHandle: o,
|
|
936
|
+
disabled: a,
|
|
937
|
+
size: s,
|
|
938
|
+
onHover: g,
|
|
939
|
+
handlersFor: p,
|
|
940
|
+
label: (d) => u("Jogging.Handle.lb", { handle: se(d) }),
|
|
941
|
+
overlay: m
|
|
942
|
+
}
|
|
943
|
+
)
|
|
944
|
+
]
|
|
945
|
+
}
|
|
946
|
+
);
|
|
947
|
+
}
|
|
948
|
+
), Te = new L(), at = new L();
|
|
949
|
+
function tn({
|
|
950
|
+
target: t,
|
|
951
|
+
frameQuaternion: n = Te
|
|
952
|
+
}) {
|
|
953
|
+
const e = $((o) => o.camera);
|
|
954
|
+
return mt(() => {
|
|
955
|
+
const o = typeof n == "function" ? n() : n;
|
|
956
|
+
e.getWorldQuaternion(at), t.current = fe(
|
|
957
|
+
at,
|
|
958
|
+
o,
|
|
959
|
+
t.current ?? new L()
|
|
960
|
+
);
|
|
961
|
+
}), null;
|
|
962
|
+
}
|
|
963
|
+
const k = /* @__PURE__ */ new Map();
|
|
964
|
+
async function J(t, n) {
|
|
965
|
+
const e = n || "";
|
|
966
|
+
if (!e)
|
|
967
|
+
throw new Error(
|
|
968
|
+
`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.`
|
|
969
|
+
);
|
|
970
|
+
const o = `${Se(e)} ${t}`, r = k.get(o);
|
|
971
|
+
if (r) return r;
|
|
972
|
+
const s = (async () => {
|
|
973
|
+
const u = Vt(e);
|
|
974
|
+
try {
|
|
975
|
+
const i = await u.api.motionGroupModels.getMotionGroupGlbModel(
|
|
976
|
+
t,
|
|
977
|
+
{ responseType: "blob" }
|
|
978
|
+
);
|
|
979
|
+
return URL.createObjectURL(i);
|
|
980
|
+
} catch (i) {
|
|
981
|
+
throw console.error("Failed to fetch model:", i), i;
|
|
982
|
+
}
|
|
983
|
+
})();
|
|
984
|
+
return k.set(o, s), s.catch(() => {
|
|
985
|
+
k.get(o) === s && k.delete(o);
|
|
986
|
+
}), s;
|
|
987
|
+
}
|
|
988
|
+
function Se(t) {
|
|
989
|
+
return typeof t == "string" ? t : t.config.instanceUrl;
|
|
990
|
+
}
|
|
991
|
+
function wt(t) {
|
|
992
|
+
function n(e) {
|
|
993
|
+
return e.children.length === 0 ? [e] : [e, ...e.children.flatMap((o) => n(o))];
|
|
994
|
+
}
|
|
995
|
+
return n(t).filter((e) => xt(e));
|
|
996
|
+
}
|
|
997
|
+
function bt(t) {
|
|
998
|
+
return t.name.endsWith("_FLG");
|
|
999
|
+
}
|
|
1000
|
+
function xt(t) {
|
|
1001
|
+
return /_J[0-9]+$/.test(t.name);
|
|
1002
|
+
}
|
|
1003
|
+
function ve(t, n) {
|
|
1004
|
+
let e;
|
|
1005
|
+
function o(r) {
|
|
1006
|
+
if (bt(r)) {
|
|
1007
|
+
if (e)
|
|
1008
|
+
throw Error(
|
|
1009
|
+
`Found multiple flange groups in robot model ${n}; first ${e.name} then ${r.name}. Only one _FLG group is allowed.`
|
|
1010
|
+
);
|
|
1011
|
+
e = r;
|
|
1012
|
+
}
|
|
1013
|
+
xt(r), r.children.map(o);
|
|
1014
|
+
}
|
|
1015
|
+
if (o(t.scene), !e)
|
|
1016
|
+
throw Error(
|
|
1017
|
+
`No flange group found in robot model ${n}. Flange must be identified with a name ending in _FLG.`
|
|
1018
|
+
);
|
|
1019
|
+
return { gltf: t };
|
|
1020
|
+
}
|
|
1021
|
+
const _t = ut(function({
|
|
1022
|
+
rapidlyChangingMotionState: n,
|
|
1023
|
+
dhParameters: e,
|
|
1024
|
+
chainOffsetPosition: o,
|
|
1025
|
+
chainOffsetQuaternion: r,
|
|
1026
|
+
onTranslationChanged: s,
|
|
1027
|
+
children: u
|
|
1028
|
+
}, i) {
|
|
1029
|
+
const a = R(null), l = R([]), p = R(
|
|
1030
|
+
n.joint_position.filter(
|
|
1031
|
+
(y) => y !== void 0
|
|
1032
|
+
)
|
|
1033
|
+
), { invalidate: f } = $(), g = R(n);
|
|
1034
|
+
g.current = n;
|
|
1035
|
+
function m(y) {
|
|
1036
|
+
a.current = y, y && h();
|
|
1037
|
+
}
|
|
1038
|
+
function h() {
|
|
1039
|
+
a.current && (l.current = wt(a.current), d(), f());
|
|
1040
|
+
}
|
|
1041
|
+
pt(i, () => ({ recollectJoints: h }));
|
|
1042
|
+
function d() {
|
|
1043
|
+
const y = p.current;
|
|
1044
|
+
if (s)
|
|
1045
|
+
s(l.current, y);
|
|
1046
|
+
else
|
|
1047
|
+
for (const [w, S] of l.current.entries()) {
|
|
1048
|
+
const O = e[w].reverse_rotation_direction ? -1 : 1;
|
|
1049
|
+
S.position.y = O * (y[w] || 0) / 1e3;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
function x(y) {
|
|
1053
|
+
p.current = y.joint_position.filter(
|
|
1054
|
+
(w) => w !== void 0
|
|
1055
|
+
), d(), f();
|
|
1056
|
+
}
|
|
1057
|
+
return ht(() => {
|
|
1058
|
+
x(g.current);
|
|
1059
|
+
}), /* @__PURE__ */ c(
|
|
1060
|
+
"group",
|
|
1061
|
+
{
|
|
1062
|
+
ref: m,
|
|
1063
|
+
position: o,
|
|
1064
|
+
quaternion: r,
|
|
1065
|
+
children: u
|
|
1066
|
+
}
|
|
1067
|
+
);
|
|
1068
|
+
});
|
|
1069
|
+
function Rt({
|
|
1070
|
+
rapidlyChangingMotionState: t,
|
|
1071
|
+
dhParameters: n,
|
|
1072
|
+
...e
|
|
1073
|
+
}) {
|
|
1074
|
+
const o = new T(), r = R(null), s = R(null);
|
|
1075
|
+
function u(l) {
|
|
1076
|
+
const p = new T();
|
|
1077
|
+
for (let h = 0; h < n.length; h++) {
|
|
1078
|
+
const d = n[h], x = l[h] ?? 0, y = new T().makeRotationY(d.theta).multiply(
|
|
1079
|
+
new T().makeTranslation(
|
|
1080
|
+
d.a / 1e3,
|
|
1081
|
+
(d.d + x * (d.reverse_rotation_direction ? -1 : 1)) / 1e3,
|
|
1082
|
+
0
|
|
1083
|
+
)
|
|
1084
|
+
).multiply(new T().makeRotationX(d.alpha));
|
|
1085
|
+
p.multiply(y);
|
|
1086
|
+
}
|
|
1087
|
+
const f = new v(), g = new L(), m = new v();
|
|
1088
|
+
return p.decompose(f, g, m), f;
|
|
1089
|
+
}
|
|
1090
|
+
const i = u(
|
|
1091
|
+
t.joint_position
|
|
1092
|
+
);
|
|
1093
|
+
function a(l, p) {
|
|
1094
|
+
o.identity();
|
|
1095
|
+
let f = new v();
|
|
1096
|
+
for (let d = 0; d < n.length; d++) {
|
|
1097
|
+
const x = p[d] ?? 0, y = n[d], w = new T().makeRotationY(y.theta).multiply(
|
|
1098
|
+
new T().makeTranslation(
|
|
1099
|
+
y.a / 1e3,
|
|
1100
|
+
(y.d + x * (y.reverse_rotation_direction ? -1 : 1)) / 1e3,
|
|
1101
|
+
0
|
|
1102
|
+
)
|
|
1103
|
+
).multiply(new T().makeRotationX(y.alpha));
|
|
1104
|
+
o.multiply(w);
|
|
1105
|
+
}
|
|
1106
|
+
const g = new v(), m = new L(), h = new v();
|
|
1107
|
+
if (o.decompose(g, m, h), f = g, r.current && r.current.position.set(
|
|
1108
|
+
f.x,
|
|
1109
|
+
f.y,
|
|
1110
|
+
f.z
|
|
1111
|
+
), s.current) {
|
|
1112
|
+
const d = s.current.geometry;
|
|
1113
|
+
d != null && d.setPositions && d.setPositions([
|
|
1114
|
+
0,
|
|
1115
|
+
0,
|
|
1116
|
+
0,
|
|
1117
|
+
f.x,
|
|
1118
|
+
f.y,
|
|
1119
|
+
f.z
|
|
1120
|
+
]);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
return /* @__PURE__ */ c(
|
|
1124
|
+
_t,
|
|
1125
|
+
{
|
|
1126
|
+
rapidlyChangingMotionState: t,
|
|
1127
|
+
dhParameters: n,
|
|
1128
|
+
onTranslationChanged: a,
|
|
1129
|
+
children: /* @__PURE__ */ _("group", { ...e, name: "Scene", children: [
|
|
1130
|
+
/* @__PURE__ */ _("mesh", { name: "Base", position: [0, 0, 0], children: [
|
|
1131
|
+
/* @__PURE__ */ c("sphereGeometry", { args: [0.02, 32, 32] }),
|
|
1132
|
+
/* @__PURE__ */ c("meshStandardMaterial", { color: "green", depthTest: !0 })
|
|
1133
|
+
] }),
|
|
1134
|
+
/* @__PURE__ */ c(
|
|
1135
|
+
H,
|
|
1136
|
+
{
|
|
1137
|
+
ref: s,
|
|
1138
|
+
points: [new v(0, 0, 0), i],
|
|
1139
|
+
color: "White",
|
|
1140
|
+
lineWidth: 5
|
|
1141
|
+
}
|
|
1142
|
+
),
|
|
1143
|
+
/* @__PURE__ */ _("mesh", { ref: r, name: "TCP", position: i, children: [
|
|
1144
|
+
/* @__PURE__ */ c("sphereGeometry", { args: [0.025, 32, 32] }),
|
|
1145
|
+
/* @__PURE__ */ c("meshStandardMaterial", { color: "red", depthTest: !0 })
|
|
1146
|
+
] })
|
|
1147
|
+
] })
|
|
1148
|
+
}
|
|
1149
|
+
);
|
|
1150
|
+
}
|
|
1151
|
+
const Me = console.warn;
|
|
1152
|
+
function Tt() {
|
|
1153
|
+
return M(() => {
|
|
1154
|
+
console.warn = (t) => {
|
|
1155
|
+
t !== "Cannot call the manual advancement of rafz whilst frameLoop is not set as demand" && Me(t);
|
|
1156
|
+
};
|
|
1157
|
+
}, []), null;
|
|
1158
|
+
}
|
|
1159
|
+
function Pe(t) {
|
|
1160
|
+
return t.type === "Mesh";
|
|
1161
|
+
}
|
|
1162
|
+
function Ae({
|
|
1163
|
+
url: t,
|
|
1164
|
+
flangeRef: n,
|
|
1165
|
+
postModelRender: e,
|
|
1166
|
+
...o
|
|
1167
|
+
}) {
|
|
1168
|
+
const r = It(t), u = ve(r, "robot.glb").gltf;
|
|
1169
|
+
M(() => {
|
|
1170
|
+
e == null || e();
|
|
1171
|
+
}, [t, e]);
|
|
1172
|
+
function i(a) {
|
|
1173
|
+
try {
|
|
1174
|
+
return Pe(a) ? a.geometry ? /* @__PURE__ */ c(
|
|
1175
|
+
"mesh",
|
|
1176
|
+
{
|
|
1177
|
+
name: a.name,
|
|
1178
|
+
geometry: a.geometry,
|
|
1179
|
+
material: a.material,
|
|
1180
|
+
position: a.position,
|
|
1181
|
+
rotation: a.rotation
|
|
1182
|
+
},
|
|
1183
|
+
a.uuid
|
|
1184
|
+
) : /* @__PURE__ */ c(
|
|
1185
|
+
"group",
|
|
1186
|
+
{
|
|
1187
|
+
name: a.name,
|
|
1188
|
+
position: a.position,
|
|
1189
|
+
rotation: a.rotation
|
|
1190
|
+
},
|
|
1191
|
+
a.uuid
|
|
1192
|
+
) : /* @__PURE__ */ c(
|
|
1193
|
+
"group",
|
|
1194
|
+
{
|
|
1195
|
+
name: a.name,
|
|
1196
|
+
position: a.position,
|
|
1197
|
+
rotation: a.rotation,
|
|
1198
|
+
ref: bt(a) ? n : void 0,
|
|
1199
|
+
children: a.children.map(i)
|
|
1200
|
+
},
|
|
1201
|
+
a.uuid
|
|
1202
|
+
);
|
|
1203
|
+
} catch (l) {
|
|
1204
|
+
return console.warn("Error rendering node", a.name, l), null;
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
return /* @__PURE__ */ c("group", { ...o, dispose: null, children: i(u.scene) });
|
|
1208
|
+
}
|
|
1209
|
+
function St({
|
|
1210
|
+
modelURL: t,
|
|
1211
|
+
flangeRef: n,
|
|
1212
|
+
postModelRender: e,
|
|
1213
|
+
...o
|
|
1214
|
+
}) {
|
|
1215
|
+
const [r, s] = I(null);
|
|
1216
|
+
return M(() => {
|
|
1217
|
+
let u = !1;
|
|
1218
|
+
return (async () => {
|
|
1219
|
+
try {
|
|
1220
|
+
const a = typeof t == "string" ? t : await t;
|
|
1221
|
+
u || s((l) => l === a ? l : a);
|
|
1222
|
+
} catch (a) {
|
|
1223
|
+
console.error("Failed to resolve model URL:", a);
|
|
1224
|
+
}
|
|
1225
|
+
})(), () => {
|
|
1226
|
+
u = !0;
|
|
1227
|
+
};
|
|
1228
|
+
}, [t]), r ? /* @__PURE__ */ c(
|
|
1229
|
+
Ae,
|
|
1230
|
+
{
|
|
1231
|
+
url: r,
|
|
1232
|
+
flangeRef: n,
|
|
1233
|
+
postModelRender: e,
|
|
1234
|
+
...o
|
|
1235
|
+
}
|
|
1236
|
+
) : null;
|
|
1237
|
+
}
|
|
1238
|
+
const vt = (t, n) => {
|
|
1239
|
+
t.userData.isGhost || (t.traverse((e) => {
|
|
1240
|
+
if (e instanceof b.Mesh) {
|
|
1241
|
+
e.material instanceof b.Material && (e.material.colorWrite = !1);
|
|
1242
|
+
const o = e.clone(), r = e.clone();
|
|
1243
|
+
o.material = new b.MeshStandardMaterial({
|
|
1244
|
+
depthTest: !0,
|
|
1245
|
+
depthWrite: !0,
|
|
1246
|
+
colorWrite: !1,
|
|
1247
|
+
polygonOffset: !0,
|
|
1248
|
+
polygonOffsetFactor: -1,
|
|
1249
|
+
side: b.DoubleSide
|
|
1250
|
+
}), o.userData.isGhost = !0, r.material = new b.MeshStandardMaterial({
|
|
1251
|
+
color: n,
|
|
1252
|
+
opacity: 0.3,
|
|
1253
|
+
depthTest: !0,
|
|
1254
|
+
depthWrite: !1,
|
|
1255
|
+
transparent: !0,
|
|
1256
|
+
polygonOffset: !0,
|
|
1257
|
+
polygonOffsetFactor: -2,
|
|
1258
|
+
side: b.DoubleSide
|
|
1259
|
+
}), r.userData.isGhost = !0, e.parent && (e.parent.add(o), e.parent.add(r));
|
|
1260
|
+
}
|
|
1261
|
+
}), t.userData.isGhost = !0);
|
|
1262
|
+
}, Mt = (t) => {
|
|
1263
|
+
if (!t.userData.isGhost) return;
|
|
1264
|
+
const n = [];
|
|
1265
|
+
t.traverse((e) => {
|
|
1266
|
+
var o;
|
|
1267
|
+
e instanceof b.Mesh && ((o = e.userData) != null && o.isGhost ? n.push(e) : e.material instanceof b.Material && (e.material.colorWrite = !0));
|
|
1268
|
+
}), n.forEach((e) => {
|
|
1269
|
+
e.parent && e.parent.remove(e);
|
|
1270
|
+
}), t.userData.isGhost = !1;
|
|
1271
|
+
}, Pt = F(
|
|
1272
|
+
({
|
|
1273
|
+
rapidlyChangingMotionState: t,
|
|
1274
|
+
modelFromController: n,
|
|
1275
|
+
dhParameters: e,
|
|
1276
|
+
chainOffsetPosition: o,
|
|
1277
|
+
chainOffsetQuaternion: r,
|
|
1278
|
+
getModel: s = J,
|
|
1279
|
+
flangeRef: u,
|
|
1280
|
+
postModelRender: i,
|
|
1281
|
+
transparentColor: a,
|
|
1282
|
+
instanceUrl: l,
|
|
1283
|
+
...p
|
|
1284
|
+
}) => {
|
|
1285
|
+
const [f, g] = I(null), m = R(null), h = A((w) => {
|
|
1286
|
+
g(w);
|
|
1287
|
+
}, []), d = A(() => {
|
|
1288
|
+
var w;
|
|
1289
|
+
(w = m.current) == null || w.recollectJoints(), i == null || i();
|
|
1290
|
+
}, [i]);
|
|
1291
|
+
M(() => {
|
|
1292
|
+
f && (a ? vt(f, a) : Mt(f));
|
|
1293
|
+
}, [f, a]);
|
|
1294
|
+
const x = E(() => {
|
|
1295
|
+
const w = s(n, l);
|
|
1296
|
+
if (!w) {
|
|
1297
|
+
const S = new Blob([], { type: "model/gltf-binary" }), P = new File([S], `${n}.glb`, {
|
|
1298
|
+
type: "model/gltf-binary"
|
|
1299
|
+
});
|
|
1300
|
+
return Promise.resolve(URL.createObjectURL(P));
|
|
1301
|
+
}
|
|
1302
|
+
return w;
|
|
1303
|
+
}, [n, l, s]), y = /* @__PURE__ */ c(
|
|
1304
|
+
Rt,
|
|
1305
|
+
{
|
|
1306
|
+
rapidlyChangingMotionState: t,
|
|
1307
|
+
dhParameters: e,
|
|
1308
|
+
...p
|
|
1309
|
+
}
|
|
1310
|
+
);
|
|
1311
|
+
return /* @__PURE__ */ _(
|
|
1312
|
+
dt,
|
|
1313
|
+
{
|
|
1314
|
+
fallback: y,
|
|
1315
|
+
onError: (w) => {
|
|
1316
|
+
console.warn(w);
|
|
1317
|
+
},
|
|
1318
|
+
children: [
|
|
1319
|
+
/* @__PURE__ */ c(ft, { fallback: y, children: /* @__PURE__ */ c("group", { ref: h, children: /* @__PURE__ */ c(
|
|
1320
|
+
_t,
|
|
1321
|
+
{
|
|
1322
|
+
ref: m,
|
|
1323
|
+
rapidlyChangingMotionState: t,
|
|
1324
|
+
dhParameters: e,
|
|
1325
|
+
chainOffsetPosition: o,
|
|
1326
|
+
chainOffsetQuaternion: r,
|
|
1327
|
+
children: /* @__PURE__ */ c(
|
|
1328
|
+
St,
|
|
1329
|
+
{
|
|
1330
|
+
modelURL: x,
|
|
1331
|
+
postModelRender: d,
|
|
1332
|
+
flangeRef: u,
|
|
1333
|
+
...p
|
|
1334
|
+
}
|
|
1335
|
+
)
|
|
1336
|
+
}
|
|
1337
|
+
) }) }),
|
|
1338
|
+
/* @__PURE__ */ c(Tt, {})
|
|
1339
|
+
]
|
|
1340
|
+
}
|
|
1341
|
+
);
|
|
1342
|
+
}
|
|
1343
|
+
), Ee = F(
|
|
1344
|
+
({ rapidlyChangingMotionState: t, ...n }) => {
|
|
1345
|
+
const e = X(
|
|
1346
|
+
t
|
|
1347
|
+
);
|
|
1348
|
+
return /* @__PURE__ */ c(
|
|
1349
|
+
Pt,
|
|
1350
|
+
{
|
|
1351
|
+
rapidlyChangingMotionState: e,
|
|
1352
|
+
...n
|
|
1353
|
+
}
|
|
1354
|
+
);
|
|
1355
|
+
}
|
|
1356
|
+
);
|
|
1357
|
+
function en({
|
|
1358
|
+
connectedMotionGroup: t,
|
|
1359
|
+
getModel: n,
|
|
1360
|
+
flangeRef: e,
|
|
1361
|
+
transparentColor: o,
|
|
1362
|
+
postModelRender: r,
|
|
1363
|
+
...s
|
|
1364
|
+
}) {
|
|
1365
|
+
const u = A(
|
|
1366
|
+
(g) => J(g, t.nova),
|
|
1367
|
+
[t]
|
|
1368
|
+
), i = n ?? u;
|
|
1369
|
+
if (!t.dhParameters)
|
|
1370
|
+
return null;
|
|
1371
|
+
const a = t.mountingPosition, l = t.mountingQuaternion, p = t.modelFromController || "";
|
|
1372
|
+
return p ? /* @__PURE__ */ c(
|
|
1373
|
+
Ee,
|
|
1374
|
+
{
|
|
1375
|
+
rapidlyChangingMotionState: t.rapidlyChangingMotionState,
|
|
1376
|
+
modelFromController: p,
|
|
1377
|
+
dhParameters: t.dhParameters,
|
|
1378
|
+
getModel: i,
|
|
1379
|
+
flangeRef: e,
|
|
1380
|
+
transparentColor: o,
|
|
1381
|
+
postModelRender: r,
|
|
1382
|
+
chainOffsetPosition: a,
|
|
1383
|
+
chainOffsetQuaternion: l,
|
|
1384
|
+
...s
|
|
1385
|
+
}
|
|
1386
|
+
) : /* @__PURE__ */ c(
|
|
1387
|
+
Rt,
|
|
1388
|
+
{
|
|
1389
|
+
rapidlyChangingMotionState: t.rapidlyChangingMotionState,
|
|
1390
|
+
dhParameters: t.dhParameters,
|
|
1391
|
+
chainOffsetPosition: a,
|
|
1392
|
+
chainOffsetQuaternion: l,
|
|
1393
|
+
...s
|
|
1394
|
+
}
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
const At = ut(
|
|
1398
|
+
function({
|
|
1399
|
+
rapidlyChangingMotionState: n,
|
|
1400
|
+
dhParameters: e,
|
|
1401
|
+
chainOffsetPosition: o,
|
|
1402
|
+
chainOffsetQuaternion: r,
|
|
1403
|
+
onRotationChanged: s,
|
|
1404
|
+
children: u
|
|
1405
|
+
}, i) {
|
|
1406
|
+
const a = R(null), l = R([]), p = R(
|
|
1407
|
+
n.joint_position.filter(
|
|
1408
|
+
(y) => y !== void 0
|
|
1409
|
+
)
|
|
1410
|
+
), { invalidate: f } = $(), g = R(n);
|
|
1411
|
+
g.current = n;
|
|
1412
|
+
function m(y) {
|
|
1413
|
+
a.current = y, y && h();
|
|
1414
|
+
}
|
|
1415
|
+
function h() {
|
|
1416
|
+
a.current && (l.current = wt(a.current), d(), f());
|
|
1417
|
+
}
|
|
1418
|
+
pt(i, () => ({ recollectJoints: h }));
|
|
1419
|
+
function d() {
|
|
1420
|
+
const y = p.current;
|
|
1421
|
+
if (s)
|
|
1422
|
+
s(l.current, y);
|
|
1423
|
+
else
|
|
1424
|
+
for (const [w, S] of l.current.entries()) {
|
|
1425
|
+
const P = e[w], O = P.theta || 0, Lt = P.reverse_rotation_direction ? -1 : 1;
|
|
1426
|
+
S.rotation.y = Lt * (y[w] || 0) + O;
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
function x(y) {
|
|
1430
|
+
p.current = y.joint_position.filter(
|
|
1431
|
+
(w) => w !== void 0
|
|
1432
|
+
), d(), f();
|
|
1433
|
+
}
|
|
1434
|
+
return ht(() => {
|
|
1435
|
+
x(g.current);
|
|
1436
|
+
}), M(() => {
|
|
1437
|
+
x(n);
|
|
1438
|
+
}, [n]), /* @__PURE__ */ c(
|
|
1439
|
+
"group",
|
|
1440
|
+
{
|
|
1441
|
+
ref: m,
|
|
1442
|
+
position: o,
|
|
1443
|
+
quaternion: r,
|
|
1444
|
+
children: u
|
|
1445
|
+
}
|
|
1446
|
+
);
|
|
1447
|
+
}
|
|
1448
|
+
), Le = "line", Oe = "mesh";
|
|
1449
|
+
function Ge({
|
|
1450
|
+
rapidlyChangingMotionState: t,
|
|
1451
|
+
dhParameters: n,
|
|
1452
|
+
...e
|
|
1453
|
+
}) {
|
|
1454
|
+
const o = new T(), r = R([]), s = R([]);
|
|
1455
|
+
Ft.useEffect(() => {
|
|
1456
|
+
r.current = new Array(n.length).fill(null), s.current = new Array(n.length).fill(null);
|
|
1457
|
+
}, [n.length]);
|
|
1458
|
+
function u(l, p) {
|
|
1459
|
+
const f = new v(), g = new L(), m = new v();
|
|
1460
|
+
o.decompose(f, g, m);
|
|
1461
|
+
const h = f.clone(), d = new T().makeRotationY(
|
|
1462
|
+
l.theta + p * (l.reverse_rotation_direction ? -1 : 1)
|
|
1463
|
+
).multiply(new T().makeTranslation(0, l.d / 1e3, 0)).multiply(new T().makeTranslation(l.a / 1e3, 0, 0)).multiply(new T().makeRotationX(l.alpha));
|
|
1464
|
+
return o.multiply(d), o.decompose(f, g, m), { a: h, b: f };
|
|
1465
|
+
}
|
|
1466
|
+
function i(l, p, f, g) {
|
|
1467
|
+
if (!n)
|
|
1468
|
+
return;
|
|
1469
|
+
const m = n[l];
|
|
1470
|
+
if (!m)
|
|
1471
|
+
return;
|
|
1472
|
+
const { a: h, b: d } = u(m, g);
|
|
1473
|
+
p.geometry.setPositions([h.toArray(), d.toArray()].flat()), f.position.set(d.x, d.y, d.z);
|
|
1474
|
+
}
|
|
1475
|
+
function a(l, p) {
|
|
1476
|
+
o.identity();
|
|
1477
|
+
for (let f = 0; f < Math.min(l.length, p.length); f++) {
|
|
1478
|
+
const g = r.current[f], m = s.current[f];
|
|
1479
|
+
g && m && i(f, g, m, p[f]);
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
return /* @__PURE__ */ c(
|
|
1483
|
+
At,
|
|
1484
|
+
{
|
|
1485
|
+
rapidlyChangingMotionState: t,
|
|
1486
|
+
dhParameters: n,
|
|
1487
|
+
onRotationChanged: a,
|
|
1488
|
+
children: /* @__PURE__ */ _("group", { ...e, name: "Scene", children: [
|
|
1489
|
+
/* @__PURE__ */ _("mesh", { children: [
|
|
1490
|
+
/* @__PURE__ */ c("sphereGeometry", { args: [0.01, 32, 32] }),
|
|
1491
|
+
/* @__PURE__ */ c("meshStandardMaterial", { color: "black", depthTest: !0 })
|
|
1492
|
+
] }),
|
|
1493
|
+
n == null ? void 0 : n.map((l, p) => {
|
|
1494
|
+
const { a: f, b: g } = u(
|
|
1495
|
+
l,
|
|
1496
|
+
t.joint_position[p] ?? 0
|
|
1497
|
+
), m = `dhrobot_J0${p}`;
|
|
1498
|
+
return /* @__PURE__ */ _("group", { name: m, children: [
|
|
1499
|
+
/* @__PURE__ */ c(
|
|
1500
|
+
H,
|
|
1501
|
+
{
|
|
1502
|
+
ref: (h) => {
|
|
1503
|
+
r.current[p] = h;
|
|
1504
|
+
},
|
|
1505
|
+
name: Le,
|
|
1506
|
+
points: [f, g],
|
|
1507
|
+
color: "white",
|
|
1508
|
+
lineWidth: 5
|
|
1509
|
+
}
|
|
1510
|
+
),
|
|
1511
|
+
/* @__PURE__ */ _(
|
|
1512
|
+
"mesh",
|
|
1513
|
+
{
|
|
1514
|
+
ref: (h) => {
|
|
1515
|
+
s.current[p] = h;
|
|
1516
|
+
},
|
|
1517
|
+
name: Oe,
|
|
1518
|
+
position: g,
|
|
1519
|
+
children: [
|
|
1520
|
+
/* @__PURE__ */ c("sphereGeometry", { args: [0.01, 32, 32] }),
|
|
1521
|
+
/* @__PURE__ */ c("meshStandardMaterial", { color: "black", depthTest: !0 })
|
|
1522
|
+
]
|
|
1523
|
+
},
|
|
1524
|
+
`mesh_${p}`
|
|
1525
|
+
)
|
|
1526
|
+
] }, m);
|
|
1527
|
+
})
|
|
1528
|
+
] })
|
|
1529
|
+
}
|
|
1530
|
+
);
|
|
1531
|
+
}
|
|
1532
|
+
const Et = F(
|
|
1533
|
+
({
|
|
1534
|
+
rapidlyChangingMotionState: t,
|
|
1535
|
+
modelFromController: n,
|
|
1536
|
+
dhParameters: e,
|
|
1537
|
+
chainOffsetPosition: o,
|
|
1538
|
+
chainOffsetQuaternion: r,
|
|
1539
|
+
getModel: s = J,
|
|
1540
|
+
flangeRef: u,
|
|
1541
|
+
postModelRender: i,
|
|
1542
|
+
transparentColor: a,
|
|
1543
|
+
instanceUrl: l,
|
|
1544
|
+
...p
|
|
1545
|
+
}) => {
|
|
1546
|
+
const [f, g] = I(null), m = R(null), h = A((w) => {
|
|
1547
|
+
g(w);
|
|
1548
|
+
}, []), d = A(() => {
|
|
1549
|
+
var w;
|
|
1550
|
+
(w = m.current) == null || w.recollectJoints(), i == null || i();
|
|
1551
|
+
}, [i]);
|
|
1552
|
+
M(() => {
|
|
1553
|
+
f && (a ? vt(f, a) : Mt(f));
|
|
1554
|
+
}, [f, a]);
|
|
1555
|
+
const x = E(() => {
|
|
1556
|
+
const w = s(n, l);
|
|
1557
|
+
if (!w)
|
|
1558
|
+
throw new Error(
|
|
1559
|
+
`No model found for robot "${n}". Ensure the model is available or provide a custom getModel function.`
|
|
1560
|
+
);
|
|
1561
|
+
return w;
|
|
1562
|
+
}, [n, l, s]), y = /* @__PURE__ */ c(
|
|
1563
|
+
Ge,
|
|
1564
|
+
{
|
|
1565
|
+
rapidlyChangingMotionState: t,
|
|
1566
|
+
dhParameters: e,
|
|
1567
|
+
...p
|
|
1568
|
+
}
|
|
1569
|
+
);
|
|
1570
|
+
return /* @__PURE__ */ _(
|
|
1571
|
+
dt,
|
|
1572
|
+
{
|
|
1573
|
+
fallback: y,
|
|
1574
|
+
onError: (w) => {
|
|
1575
|
+
console.warn(w);
|
|
1576
|
+
},
|
|
1577
|
+
children: [
|
|
1578
|
+
/* @__PURE__ */ c(ft, { fallback: y, children: /* @__PURE__ */ c("group", { ref: h, children: /* @__PURE__ */ c(
|
|
1579
|
+
At,
|
|
1580
|
+
{
|
|
1581
|
+
ref: m,
|
|
1582
|
+
rapidlyChangingMotionState: t,
|
|
1583
|
+
dhParameters: e,
|
|
1584
|
+
chainOffsetPosition: o,
|
|
1585
|
+
chainOffsetQuaternion: r,
|
|
1586
|
+
children: /* @__PURE__ */ c(
|
|
1587
|
+
St,
|
|
1588
|
+
{
|
|
1589
|
+
modelURL: x,
|
|
1590
|
+
postModelRender: d,
|
|
1591
|
+
flangeRef: u,
|
|
1592
|
+
...p
|
|
1593
|
+
}
|
|
1594
|
+
)
|
|
1595
|
+
}
|
|
1596
|
+
) }) }),
|
|
1597
|
+
/* @__PURE__ */ c(Tt, {})
|
|
1598
|
+
]
|
|
1599
|
+
}
|
|
1600
|
+
);
|
|
1601
|
+
}
|
|
1602
|
+
), Ie = F(
|
|
1603
|
+
({ rapidlyChangingMotionState: t, ...n }) => {
|
|
1604
|
+
const e = X(
|
|
1605
|
+
t
|
|
1606
|
+
);
|
|
1607
|
+
return /* @__PURE__ */ c(
|
|
1608
|
+
Et,
|
|
1609
|
+
{
|
|
1610
|
+
rapidlyChangingMotionState: e,
|
|
1611
|
+
...n
|
|
1612
|
+
}
|
|
1613
|
+
);
|
|
1614
|
+
}
|
|
1615
|
+
), Fe = F((t) => {
|
|
1616
|
+
const { inverseSolver: n, dhParameters: e, ...o } = t, [r, s] = I(
|
|
1617
|
+
C.RevoluteJoint
|
|
1618
|
+
);
|
|
1619
|
+
M(() => {
|
|
1620
|
+
e.length && s(e[0].type ?? C.RevoluteJoint);
|
|
1621
|
+
}, [e]);
|
|
1622
|
+
const u = E(() => n === null && r === C.RevoluteJoint, [n, r]), i = E(() => n === null && r === C.PrismaticJoint, [n, r]);
|
|
1623
|
+
return E(() => !!n, [n]) || u ? /* @__PURE__ */ c(Et, { dhParameters: e, ...o }) : i ? /* @__PURE__ */ c(Pt, { dhParameters: e, ...o }) : null;
|
|
1624
|
+
}), nn = F((t) => {
|
|
1625
|
+
const n = X(
|
|
1626
|
+
t.rapidlyChangingMotionState
|
|
1627
|
+
);
|
|
1628
|
+
return /* @__PURE__ */ c(
|
|
1629
|
+
Fe,
|
|
1630
|
+
{
|
|
1631
|
+
...t,
|
|
1632
|
+
rapidlyChangingMotionState: n
|
|
1633
|
+
}
|
|
1634
|
+
);
|
|
1635
|
+
});
|
|
1636
|
+
function on({
|
|
1637
|
+
connectedMotionGroup: t,
|
|
1638
|
+
getModel: n,
|
|
1639
|
+
flangeRef: e,
|
|
1640
|
+
transparentColor: o,
|
|
1641
|
+
postModelRender: r,
|
|
1642
|
+
...s
|
|
1643
|
+
}) {
|
|
1644
|
+
const u = A(
|
|
1645
|
+
(l) => J(l, t.nova),
|
|
1646
|
+
[t]
|
|
1647
|
+
);
|
|
1648
|
+
if (!t.dhParameters)
|
|
1649
|
+
return null;
|
|
1650
|
+
const i = t.mountingPosition, a = t.mountingQuaternion;
|
|
1651
|
+
return /* @__PURE__ */ c(
|
|
1652
|
+
Ie,
|
|
1653
|
+
{
|
|
1654
|
+
rapidlyChangingMotionState: t.rapidlyChangingMotionState,
|
|
1655
|
+
modelFromController: t.modelFromController || "",
|
|
1656
|
+
dhParameters: t.dhParameters,
|
|
1657
|
+
getModel: n ?? u,
|
|
1658
|
+
flangeRef: e,
|
|
1659
|
+
transparentColor: o,
|
|
1660
|
+
postModelRender: r,
|
|
1661
|
+
chainOffsetPosition: i,
|
|
1662
|
+
chainOffsetQuaternion: a,
|
|
1663
|
+
...s
|
|
1664
|
+
}
|
|
1665
|
+
);
|
|
1666
|
+
}
|
|
1667
|
+
export {
|
|
1668
|
+
Qe as C,
|
|
1669
|
+
ze as J,
|
|
1670
|
+
en as L,
|
|
1671
|
+
nn as M,
|
|
1672
|
+
Ye as P,
|
|
1673
|
+
on as R,
|
|
1674
|
+
Ze as S,
|
|
1675
|
+
Ke as T,
|
|
1676
|
+
tn as a,
|
|
1677
|
+
Xe as b,
|
|
1678
|
+
Fe as c,
|
|
1679
|
+
Ee as d,
|
|
1680
|
+
Pt as e,
|
|
1681
|
+
Ie as f,
|
|
1682
|
+
Et as g,
|
|
1683
|
+
J as h
|
|
1684
|
+
};
|