@wandelbots/wandelbots-js-react-components 6.3.0 → 6.4.0-pr.chore-public-names.673.cb7ee37
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 +255 -122
- package/dist/3d.cjs +1 -1
- package/dist/3d.d.ts +7 -3
- package/dist/3d.js +20 -20
- package/dist/CurrentPoseBar/index.cjs +1 -0
- package/dist/CurrentPoseBar/index.d.ts +2 -0
- package/dist/CurrentPoseBar/index.js +5 -0
- package/dist/JoggingButtons/index.cjs +1 -0
- package/dist/JoggingButtons/index.d.ts +3 -0
- package/dist/JoggingButtons/index.js +5 -0
- package/dist/JoggingGizmo/index.cjs +1 -0
- package/dist/JoggingGizmo/index.d.ts +5 -0
- package/dist/JoggingGizmo/index.js +6 -0
- package/dist/JoggingJointSlider/index.cjs +1 -0
- package/dist/JoggingJointSlider/index.d.ts +2 -0
- package/dist/JoggingJointSlider/index.js +5 -0
- package/dist/SafetyBar/index.cjs +1 -1
- package/dist/SafetyBar/index.js +1 -1
- package/dist/chunks/ConnectedMotionGroup-D9JJSyXB.js +1822 -0
- package/dist/chunks/ConnectedMotionGroup-ir7Vf690.cjs +3 -0
- package/dist/chunks/CurrentPoseBar-Cbz4AO36.cjs +1 -0
- package/dist/chunks/CurrentPoseBar-CpwvWpEY.js +619 -0
- package/dist/chunks/JoggingButtons-i8FdMpCx.js +108 -0
- package/dist/chunks/JoggingButtons-paQCBXf4.cjs +1 -0
- package/dist/chunks/JoggingGizmoOrientation-CKZeLcMp.js +893 -0
- package/dist/chunks/JoggingGizmoOrientation-EPtBeAun.cjs +1 -0
- package/dist/chunks/JoggingJointSlider-DQhJOmcc.js +378 -0
- package/dist/chunks/JoggingJointSlider-YcEBMgF1.cjs +1 -0
- package/dist/chunks/Pose3-Ci1bxEvz.js +1373 -0
- package/dist/chunks/Pose3-DwMOSTKO.cjs +1 -0
- package/dist/chunks/SafetyBar-Be1c6Vz9.cjs +1 -0
- package/dist/chunks/{SafetyBar-Cy9DiXp9.js → SafetyBar-WXLP3Yi0.js} +34 -32
- package/dist/chunks/{externalizeComponent-EDymnaGR.js → externalizeComponent-7OVHUIUh.js} +84 -134
- package/dist/chunks/externalizeComponent-B0n_tR3v.cjs +2 -0
- package/dist/chunks/holdSafety-Cbej6-Kc.js +62 -0
- package/dist/chunks/holdSafety-TeMXlYQe.cjs +1 -0
- package/dist/chunks/joggingColors-BKRoSGQu.js +132 -0
- package/dist/chunks/joggingColors-BkPm75Hr.cjs +1 -0
- package/dist/chunks/json-3cqBD7UQ.js +18 -0
- package/dist/chunks/json-Bd6uGfgP.cjs +1 -0
- package/dist/chunks/loadRobotSession-Bt1-Brjp.js +3761 -0
- package/dist/chunks/loadRobotSession-DHVuK_pj.cjs +1 -0
- package/dist/chunks/novaConnection-BTSIgWd1.cjs +1 -0
- package/dist/chunks/novaConnection-J6_ohIQ0.js +14 -0
- package/dist/chunks/poseText-BXUaQWnK.cjs +1 -0
- package/dist/chunks/poseText-CtdXIeT_.js +41 -0
- package/dist/chunks/useSmoothedMotionState-C_Vo0py0.js +202 -0
- package/dist/chunks/useSmoothedMotionState-Ce9NjwBu.cjs +1 -0
- package/dist/components/AppHeader.d.ts +1 -1
- package/dist/components/VelocitySlider.d.ts +6 -1
- package/dist/components/currentPoseBar/CurrentPoseBar.d.ts +48 -0
- package/dist/components/currentPoseBar/OrientationFormatPopover.d.ts +19 -0
- package/dist/components/currentPoseBar/StreamStatus.d.ts +10 -0
- package/dist/components/currentPoseBar/orientation.d.ts +34 -0
- package/dist/components/currentPoseBar/poseValues.d.ts +15 -0
- package/dist/components/jogging/JoggingButtons.d.ts +18 -0
- package/dist/components/jogging/JoggingCartesianAxisControl.d.ts +8 -2
- package/dist/components/jogging/JoggingCartesianTab.d.ts +3 -0
- package/dist/components/jogging/JoggingJointTab.d.ts +4 -1
- package/dist/components/jogging/JoggingJointValueControl.d.ts +7 -1
- package/dist/components/jogging/JoggingPanel.d.ts +6 -3
- package/dist/components/jogging/JoggingRefusedError.d.ts +24 -0
- package/dist/components/jogging/JoggingStore.d.ts +382 -40
- package/dist/components/jogging/gizmo/JoggingGizmo.d.ts +53 -0
- package/dist/components/jogging/gizmo/JoggingGizmoOrientation.d.ts +26 -0
- package/dist/components/jogging/gizmo/RotationHandles.d.ts +7 -0
- package/dist/components/jogging/gizmo/RotationScene.d.ts +6 -0
- package/dist/components/jogging/gizmo/TranslationHandles.d.ts +6 -0
- package/dist/components/jogging/gizmo/TranslationScene.d.ts +6 -0
- package/dist/components/jogging/gizmo/arcGrabAreas.d.ts +58 -0
- package/dist/components/jogging/gizmo/arcs.d.ts +54 -0
- package/dist/components/jogging/gizmo/arrows.d.ts +63 -0
- package/dist/components/jogging/gizmo/gizmoShared.d.ts +135 -0
- package/dist/components/jogging/gizmo/gizmoView.d.ts +42 -0
- package/dist/components/jogging/gizmo/useGizmoTurn.d.ts +11 -0
- package/dist/components/jogging/holdSafety.d.ts +82 -0
- package/dist/components/jogging/jogError.d.ts +9 -0
- package/dist/components/jogging/jogHandle.d.ts +23 -0
- package/dist/components/jogging/joggingColors.d.ts +30 -0
- package/dist/components/jogging/joggingVelocity.d.ts +21 -0
- package/dist/components/jogging/joint/JoggingJointSlider.d.ts +56 -0
- package/dist/components/jogging/joint/JointSliderTrack.d.ts +27 -0
- package/dist/components/jogging/joint/jointJog.d.ts +55 -0
- package/dist/components/jogging/joint/useJointJogHold.d.ts +43 -0
- package/dist/components/jogging/useHold.d.ts +42 -0
- package/dist/components/jogging/useJogControls.d.ts +44 -0
- package/dist/components/robotControl/PanelSelect.d.ts +13 -0
- package/dist/components/robotControl/SmallSelect.d.ts +15 -0
- package/dist/components/robotControl/poseText.d.ts +43 -0
- package/dist/components/robotControl/robotControlTypes.d.ts +36 -0
- package/dist/components/robotControl/useCopyText.d.ts +12 -0
- package/dist/components/robotControl/useEveryFrame.d.ts +6 -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/converters.d.ts +0 -2
- package/dist/components/utils/hooks.d.ts +1 -6
- package/dist/components/utils/json.d.ts +4 -0
- package/dist/components/utils/useSmoothedMotionState.d.ts +11 -2
- package/dist/components/utils/useWebGLRenderer.d.ts +32 -0
- package/dist/components/utils/webglSupport.d.ts +11 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +28 -20
- package/dist/core.js +57 -54
- package/dist/index.cjs +1 -1
- package/dist/index.js +73 -70
- package/dist/lib/ConnectedMotionGroup.d.ts +9 -8
- package/dist/lib/ControllerStateStream.d.ts +125 -0
- package/dist/lib/JoggerConnection.d.ts +172 -27
- package/dist/lib/MotionStreamConnection.d.ts +16 -6
- package/dist/lib/Pose3.d.ts +22 -0
- package/dist/lib/PoseTransformer.d.ts +44 -0
- package/dist/lib/TrajectoryExecutionStore.d.ts +260 -0
- package/dist/lib/connectionLogger.d.ts +9 -0
- package/dist/lib/controllerStateSource.d.ts +38 -0
- package/dist/lib/incrementalCartesianMotion.d.ts +40 -0
- package/dist/lib/motionGroupModelResources.d.ts +1 -0
- package/dist/lib/motionStateUpdate.d.ts +44 -0
- package/dist/lib/nats/natsControllerStateSource.d.ts +27 -0
- package/dist/lib/novaConnection.d.ts +23 -0
- package/dist/lib/planErrorTranslation.d.ts +8 -0
- package/dist/lib/poseMath.d.ts +51 -0
- package/dist/lib/robotSession/RobotActivation.d.ts +90 -0
- package/dist/lib/robotSession/RobotDescription.d.ts +84 -0
- package/dist/lib/robotSession/RobotLiveState.d.ts +65 -0
- package/dist/lib/robotSession/RobotLoadProgress.d.ts +72 -0
- package/dist/lib/robotSession/RobotSafety.d.ts +59 -0
- package/dist/lib/robotSession/RobotSession.d.ts +117 -0
- package/dist/lib/robotSession/RobotTargetPose.d.ts +116 -0
- package/dist/lib/robotSession/loadRobotResources.d.ts +46 -0
- package/dist/lib/robotSession/loadRobotSession.d.ts +81 -0
- package/dist/lib/robotSession/robotPose.d.ts +27 -0
- package/dist/lib/rotation.d.ts +12 -0
- package/dist/nats.cjs +1 -0
- package/dist/nats.d.ts +4 -0
- package/dist/nats.js +131 -0
- package/dist/session.cjs +1 -0
- package/dist/session.d.ts +22 -0
- package/dist/session.js +33 -0
- package/package.json +68 -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/SafetyBar-DPrv_OQA.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,893 @@
|
|
|
1
|
+
import { jsxs as S, jsx as y, Fragment as Mt } from "react/jsx-runtime";
|
|
2
|
+
import O from "@mui/material/Box";
|
|
3
|
+
import At from "@mui/material/Typography";
|
|
4
|
+
import { useThree as st, useFrame as at, Canvas as St } from "@react-three/fiber";
|
|
5
|
+
import { useMemo as H, useState as U, useRef as F, useEffect as L, useCallback as vt, Fragment as Et } from "react";
|
|
6
|
+
import { useTranslation as Rt } from "react-i18next";
|
|
7
|
+
import { WebGLRenderer as Tt, Vector3 as M, Quaternion as v, Matrix4 as ct } from "three";
|
|
8
|
+
import { e as Ot } from "./externalizeComponent-7OVHUIUh.js";
|
|
9
|
+
import { c as _t, i as It, J as P, a as k, u as Ft } from "./joggingColors-BKRoSGQu.js";
|
|
10
|
+
import { alpha as X, useTheme as it } from "@mui/material/styles";
|
|
11
|
+
function Pt() {
|
|
12
|
+
try {
|
|
13
|
+
const t = document.createElement("canvas");
|
|
14
|
+
return (t.getContext("webgl2") || t.getContext("webgl") || t.getContext("experimental-webgl")) != null;
|
|
15
|
+
} catch {
|
|
16
|
+
return !1;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function $t({
|
|
20
|
+
antialias: t = !0,
|
|
21
|
+
onContextLost: e,
|
|
22
|
+
onWebGLUnavailable: n
|
|
23
|
+
} = {}) {
|
|
24
|
+
const i = H(() => Pt(), []), [s, r] = U(!1), a = i ? s ? "renderer" : null : "preflight", u = F({ onContextLost: e, onWebGLUnavailable: n });
|
|
25
|
+
u.current = { onContextLost: e, onWebGLUnavailable: n }, L(() => {
|
|
26
|
+
var d, c;
|
|
27
|
+
a && ((c = (d = u.current).onWebGLUnavailable) == null || c.call(d, a));
|
|
28
|
+
}, [a]);
|
|
29
|
+
const o = F(!0);
|
|
30
|
+
L(() => (o.current = !0, () => {
|
|
31
|
+
o.current = !1;
|
|
32
|
+
}), []);
|
|
33
|
+
const l = vt(
|
|
34
|
+
(d) => {
|
|
35
|
+
let c;
|
|
36
|
+
try {
|
|
37
|
+
c = new Tt({ ...d, antialias: t, alpha: !0 });
|
|
38
|
+
} catch (h) {
|
|
39
|
+
throw console.warn("Failed to create WebGL renderer", h), r(!0), h;
|
|
40
|
+
}
|
|
41
|
+
return c.domElement.addEventListener("webglcontextlost", (h) => {
|
|
42
|
+
var m, p;
|
|
43
|
+
h.preventDefault(), o.current && ((p = (m = u.current).onContextLost) == null || p.call(m));
|
|
44
|
+
}), c;
|
|
45
|
+
},
|
|
46
|
+
[t]
|
|
47
|
+
);
|
|
48
|
+
return { unavailable: a, makeRenderer: l };
|
|
49
|
+
}
|
|
50
|
+
const lt = new M(0, 1, 0), G = 0.26, ut = 0.1, Gt = { x: "X", y: "Y", z: "Z" };
|
|
51
|
+
function z(t) {
|
|
52
|
+
var e;
|
|
53
|
+
return ((e = _t[Gt[t]].buttonBackgroundColor) == null ? void 0 : e.default) ?? "currentColor";
|
|
54
|
+
}
|
|
55
|
+
const Lt = 200;
|
|
56
|
+
function D(t) {
|
|
57
|
+
const e = t / Lt;
|
|
58
|
+
return {
|
|
59
|
+
/** Room around the gizmo for the labels, arrowheads and grab bars */
|
|
60
|
+
marginPx: 30 * e,
|
|
61
|
+
/** Thickness of a handle's grab bar, which shows as its halo */
|
|
62
|
+
gripPx: 30 * e,
|
|
63
|
+
grab: {
|
|
64
|
+
// The center, where all axes cross, belongs to no handle
|
|
65
|
+
innerPx: 10 * e,
|
|
66
|
+
// The arrowhead is the obvious thing to grab, so the bar reaches past it
|
|
67
|
+
beyondTipPx: 10 * e,
|
|
68
|
+
// Shorter, an arrow points within about 13° of the line of sight: its
|
|
69
|
+
// two halves can no longer be told apart
|
|
70
|
+
minTipPx: 16 * e
|
|
71
|
+
},
|
|
72
|
+
/** The axis labels, which stay readable on a small gizmo */
|
|
73
|
+
labelFontPx: Math.max(10, 13 * e)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function Nt(t, e, n) {
|
|
77
|
+
return Math.max(1, Math.min(t, e) / 2 - n);
|
|
78
|
+
}
|
|
79
|
+
function kt(t, e) {
|
|
80
|
+
const { gripPx: n, grab: i } = D(t);
|
|
81
|
+
return { radiusPx: e, gripPx: n, headLength: G, ...i };
|
|
82
|
+
}
|
|
83
|
+
function Ct(t, e) {
|
|
84
|
+
const { gripPx: n, grab: i } = D(t);
|
|
85
|
+
return {
|
|
86
|
+
radiusPx: e,
|
|
87
|
+
gripPx: n,
|
|
88
|
+
beyondTipPx: i.beyondTipPx,
|
|
89
|
+
headLength: G
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function $(t, e) {
|
|
93
|
+
return (n) => {
|
|
94
|
+
n ? t.current.set(e, n) : t.current.delete(e);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const R = (t) => `${t.axis}${t.direction}`, ht = (t) => `label:${t}`, V = [0, 1], q = (t, e) => `half:${R(t)}:${e}`, pt = (t) => `halo:${R(t)}`, dt = (t) => `focus:${R(t)}`, j = "polygon(0 0, 0 0, 0 0)";
|
|
98
|
+
function ft(t, {
|
|
99
|
+
isPressed: e,
|
|
100
|
+
hovered: n,
|
|
101
|
+
disabled: i
|
|
102
|
+
}) {
|
|
103
|
+
const s = e(t), r = !i && (s || It(n, t));
|
|
104
|
+
return { pressed: s, lit: r };
|
|
105
|
+
}
|
|
106
|
+
function mt(t, { pressed: e, lit: n }) {
|
|
107
|
+
return e ? X(t, 0.25) : n ? X(t, 0.12) : "transparent";
|
|
108
|
+
}
|
|
109
|
+
function zt(t, e) {
|
|
110
|
+
return [
|
|
111
|
+
R(t),
|
|
112
|
+
...V.map((i) => q(t, i))
|
|
113
|
+
].flatMap((i) => e.current.get(i) ?? []);
|
|
114
|
+
}
|
|
115
|
+
function gt(t, {
|
|
116
|
+
onHover: e,
|
|
117
|
+
handlersFor: n,
|
|
118
|
+
overlay: i
|
|
119
|
+
}) {
|
|
120
|
+
const s = n(
|
|
121
|
+
t,
|
|
122
|
+
(r) => zt(t, i).some((a) => a.contains(r))
|
|
123
|
+
);
|
|
124
|
+
return {
|
|
125
|
+
...s,
|
|
126
|
+
onPointerEnter: () => e(t),
|
|
127
|
+
onPointerLeave: (r) => {
|
|
128
|
+
e(null), s.onPointerLeave(r);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
const J = (t) => ({
|
|
133
|
+
cursor: t ? "default" : "pointer",
|
|
134
|
+
touchAction: "none",
|
|
135
|
+
userSelect: "none"
|
|
136
|
+
}), yt = (t) => `2px solid ${t.palette.primary.main}`, B = {
|
|
137
|
+
x: new M(1, 0, 0),
|
|
138
|
+
y: new M(0, 1, 0),
|
|
139
|
+
z: new M(0, 0, 1)
|
|
140
|
+
};
|
|
141
|
+
function Ht(t, e, n = new v()) {
|
|
142
|
+
return n.copy(t).invert().multiply(e);
|
|
143
|
+
}
|
|
144
|
+
const Dt = new v().setFromRotationMatrix(
|
|
145
|
+
new ct().makeBasis(
|
|
146
|
+
new M(1, 0, 0),
|
|
147
|
+
new M(0, 0, -1),
|
|
148
|
+
new M(0, 1, 0)
|
|
149
|
+
)
|
|
150
|
+
), Q = new v(), jt = new v();
|
|
151
|
+
function Bt(t) {
|
|
152
|
+
return t.up.z > 0.5 ? jt : Dt;
|
|
153
|
+
}
|
|
154
|
+
function Jt(t, e = new v()) {
|
|
155
|
+
return t.getWorldQuaternion(Q), Ht(Q, Bt(t), e);
|
|
156
|
+
}
|
|
157
|
+
function Wt(t, e, n = new v()) {
|
|
158
|
+
return n.copy(t).multiply(e);
|
|
159
|
+
}
|
|
160
|
+
const Ut = 1e-8;
|
|
161
|
+
function Y(t, e) {
|
|
162
|
+
return t ? Math.abs(t.dot(e)) < 1 - Ut : !0;
|
|
163
|
+
}
|
|
164
|
+
function Vt(t) {
|
|
165
|
+
const { disabled: e, label: n, overlay: i, size: s } = t, r = it(), { gripPx: a } = D(s);
|
|
166
|
+
return P.flatMap(
|
|
167
|
+
(u) => k.map((o) => {
|
|
168
|
+
const l = { axis: u, direction: o }, d = ft(l, t), c = gt(l, t);
|
|
169
|
+
return /* @__PURE__ */ S(Et, { children: [
|
|
170
|
+
/* @__PURE__ */ y(
|
|
171
|
+
O,
|
|
172
|
+
{
|
|
173
|
+
component: "span",
|
|
174
|
+
"aria-hidden": !0,
|
|
175
|
+
ref: $(i, pt(l)),
|
|
176
|
+
sx: {
|
|
177
|
+
// Cut to the band along the arc by RotationScene
|
|
178
|
+
position: "absolute",
|
|
179
|
+
inset: 0,
|
|
180
|
+
clipPath: j,
|
|
181
|
+
pointerEvents: "none",
|
|
182
|
+
background: mt(z(u), d)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
V.map((h) => /* @__PURE__ */ y(
|
|
187
|
+
O,
|
|
188
|
+
{
|
|
189
|
+
component: "span",
|
|
190
|
+
"aria-hidden": !0,
|
|
191
|
+
ref: $(i, q(l, h)),
|
|
192
|
+
...c,
|
|
193
|
+
sx: {
|
|
194
|
+
// Covers the gizmo, cut to its half of the band by
|
|
195
|
+
// RotationScene, every frame the gizmo turns
|
|
196
|
+
position: "absolute",
|
|
197
|
+
inset: 0,
|
|
198
|
+
clipPath: j,
|
|
199
|
+
...J(e)
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
h
|
|
203
|
+
)),
|
|
204
|
+
/* @__PURE__ */ y(
|
|
205
|
+
O,
|
|
206
|
+
{
|
|
207
|
+
component: "button",
|
|
208
|
+
type: "button",
|
|
209
|
+
ref: $(i, R(l)),
|
|
210
|
+
disabled: e,
|
|
211
|
+
"aria-label": n(l),
|
|
212
|
+
"aria-pressed": d.pressed,
|
|
213
|
+
...c,
|
|
214
|
+
sx: {
|
|
215
|
+
// Placed on the arrowhead by RotationScene. It shows nothing
|
|
216
|
+
// itself: the band's highlight covers the arrowhead
|
|
217
|
+
position: "absolute",
|
|
218
|
+
width: a,
|
|
219
|
+
height: a,
|
|
220
|
+
transform: "translate(-50%, -50%)",
|
|
221
|
+
padding: 0,
|
|
222
|
+
border: "none",
|
|
223
|
+
borderRadius: "50%",
|
|
224
|
+
background: "transparent",
|
|
225
|
+
// Around the arrowhead only where the arc has no band; else
|
|
226
|
+
// the ring below goes around the whole band
|
|
227
|
+
"&:focus-visible": { outline: yt(r) },
|
|
228
|
+
"&[data-band='shown']:focus-visible": { outline: "none" },
|
|
229
|
+
...J(e)
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
),
|
|
233
|
+
/* @__PURE__ */ y(
|
|
234
|
+
O,
|
|
235
|
+
{
|
|
236
|
+
component: "svg",
|
|
237
|
+
"aria-hidden": !0,
|
|
238
|
+
sx: {
|
|
239
|
+
position: "absolute",
|
|
240
|
+
left: 0,
|
|
241
|
+
top: 0,
|
|
242
|
+
width: s,
|
|
243
|
+
height: s,
|
|
244
|
+
overflow: "visible",
|
|
245
|
+
pointerEvents: "none",
|
|
246
|
+
display: "none",
|
|
247
|
+
zIndex: 100,
|
|
248
|
+
"button[data-band='shown']:focus-visible + &": {
|
|
249
|
+
display: "block"
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
children: /* @__PURE__ */ y(
|
|
253
|
+
"path",
|
|
254
|
+
{
|
|
255
|
+
ref: $(i, dt(l)),
|
|
256
|
+
fill: "none",
|
|
257
|
+
stroke: r.palette.primary.main,
|
|
258
|
+
strokeWidth: 2,
|
|
259
|
+
strokeLinejoin: "round"
|
|
260
|
+
}
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
)
|
|
264
|
+
] }, R(l));
|
|
265
|
+
})
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
const N = 0.8, Z = 0.45, xt = 2.25, bt = {
|
|
269
|
+
x: [new M(0, 1, 0), new M(0, 0, 1)],
|
|
270
|
+
y: [new M(-1, 0, 0), new M(0, 0, 1)],
|
|
271
|
+
z: [new M(1, 0, 0), new M(0, 1, 0)]
|
|
272
|
+
};
|
|
273
|
+
function K(t) {
|
|
274
|
+
const e = t === "+" ? Z : Z + Math.PI, n = e + xt;
|
|
275
|
+
return { start: e, end: n, head: t === "+" ? n : e };
|
|
276
|
+
}
|
|
277
|
+
const qt = new M(), C = new M(), Kt = new M();
|
|
278
|
+
function Xt(t, e = 24) {
|
|
279
|
+
const n = [];
|
|
280
|
+
for (const i of P) {
|
|
281
|
+
const [s, r] = bt[i], a = (o) => qt.copy(s).multiplyScalar(Math.cos(o) * N).addScaledVector(r, Math.sin(o) * N).applyQuaternion(t), u = Math.abs(
|
|
282
|
+
Kt.copy(B[i]).applyQuaternion(t).z
|
|
283
|
+
);
|
|
284
|
+
for (const o of k) {
|
|
285
|
+
const { start: l, end: d, head: c } = K(o), h = [];
|
|
286
|
+
for (let w = 0; w <= e; w++) {
|
|
287
|
+
const E = a(l + (d - l) * w / e);
|
|
288
|
+
h.push({ x: E.x + 0, y: -E.y + 0, depth: E.z });
|
|
289
|
+
}
|
|
290
|
+
const m = a(c), p = { x: m.x + 0, y: -m.y + 0, depth: m.z }, f = o === "+" ? 1 : -1;
|
|
291
|
+
C.copy(s).multiplyScalar(-Math.sin(c) * f).addScaledVector(r, Math.cos(c) * f).applyQuaternion(t);
|
|
292
|
+
const g = Math.hypot(C.x, C.y), x = g > 1e-9 ? C.x / g : 0, b = g > 1e-9 ? -C.y / g : 0;
|
|
293
|
+
n.push({
|
|
294
|
+
axis: i,
|
|
295
|
+
direction: o,
|
|
296
|
+
points: h,
|
|
297
|
+
head: { ...p, dx: x + 0, dy: b + 0 },
|
|
298
|
+
openness: u
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return n;
|
|
303
|
+
}
|
|
304
|
+
function Qt(t, e, n) {
|
|
305
|
+
let i = { distance: Number.POSITIVE_INFINITY, depth: 0 };
|
|
306
|
+
for (let s = 1; s < t.length; s++) {
|
|
307
|
+
const r = t[s - 1], a = t[s], u = (a.x - r.x) ** 2 + (a.y - r.y) ** 2, o = u === 0 ? 0 : Math.min(
|
|
308
|
+
1,
|
|
309
|
+
Math.max(
|
|
310
|
+
0,
|
|
311
|
+
((e - r.x) * (a.x - r.x) + (n - r.y) * (a.y - r.y)) / u
|
|
312
|
+
)
|
|
313
|
+
), l = Math.hypot(
|
|
314
|
+
e - (r.x + o * (a.x - r.x)),
|
|
315
|
+
n - (r.y + o * (a.y - r.y))
|
|
316
|
+
);
|
|
317
|
+
l < i.distance && (i = { distance: l, depth: r.depth + o * (a.depth - r.depth) });
|
|
318
|
+
}
|
|
319
|
+
return i;
|
|
320
|
+
}
|
|
321
|
+
function Yt(t, e) {
|
|
322
|
+
const n = t.length, i = t.map(() => new Array(n).fill(!1));
|
|
323
|
+
for (let o = 0; o < n; o++)
|
|
324
|
+
for (let l = o + 1; l < n; l++) {
|
|
325
|
+
if (t[o].arc === t[l].arc) continue;
|
|
326
|
+
let d = 0;
|
|
327
|
+
for (const c of t[o].line) {
|
|
328
|
+
const h = Qt(t[l].line, c.x, c.y);
|
|
329
|
+
h.distance < e && (d += c.depth - h.depth);
|
|
330
|
+
}
|
|
331
|
+
d > 0 ? i[o][l] = !0 : d < 0 && (i[l][o] = !0);
|
|
332
|
+
}
|
|
333
|
+
const s = t.map(
|
|
334
|
+
({ line: o }) => o.reduce((l, d) => l + d.depth, 0) / o.length
|
|
335
|
+
), r = (o, l) => s[o] - s[l], a = new Array(n).fill(0), u = new Set(t.keys());
|
|
336
|
+
for (let o = 1; u.size > 0; o++) {
|
|
337
|
+
const l = [...u], d = l.filter((h) => !l.some((m) => i[h][m])), c = (d.length > 0 ? d : l).sort(r)[0];
|
|
338
|
+
a[c] = o, u.delete(c);
|
|
339
|
+
}
|
|
340
|
+
return a;
|
|
341
|
+
}
|
|
342
|
+
const tt = 8;
|
|
343
|
+
function W(t, e) {
|
|
344
|
+
const n = [...t];
|
|
345
|
+
if (e >= 0) {
|
|
346
|
+
const s = n[n.length - 1], r = n[n.length - 2], a = Math.hypot(s.x - r.x, s.y - r.y) || 1;
|
|
347
|
+
return n.push({
|
|
348
|
+
x: s.x + (s.x - r.x) / a * e,
|
|
349
|
+
y: s.y + (s.y - r.y) / a * e,
|
|
350
|
+
depth: s.depth
|
|
351
|
+
}), n;
|
|
352
|
+
}
|
|
353
|
+
let i = -e;
|
|
354
|
+
for (; n.length > 2; ) {
|
|
355
|
+
const s = n[n.length - 1], r = n[n.length - 2], a = Math.hypot(s.x - r.x, s.y - r.y);
|
|
356
|
+
if (a > i) {
|
|
357
|
+
const u = i / a;
|
|
358
|
+
return n[n.length - 1] = {
|
|
359
|
+
x: s.x + (r.x - s.x) * u,
|
|
360
|
+
y: s.y + (r.y - s.y) * u,
|
|
361
|
+
depth: s.depth + (r.depth - s.depth) * u
|
|
362
|
+
}, n;
|
|
363
|
+
}
|
|
364
|
+
i -= a, n.pop();
|
|
365
|
+
}
|
|
366
|
+
return n;
|
|
367
|
+
}
|
|
368
|
+
const et = (t, e) => W([...t].reverse(), e).reverse();
|
|
369
|
+
function Zt(t, e) {
|
|
370
|
+
const n = e / 2, i = [], s = [], r = [];
|
|
371
|
+
let a = { x: 0, y: 0 };
|
|
372
|
+
for (const [o, l] of t.entries()) {
|
|
373
|
+
const d = t[Math.max(0, o - 1)], c = t[Math.min(t.length - 1, o + 1)], h = c.x - d.x, m = c.y - d.y, p = Math.hypot(h, m);
|
|
374
|
+
p > 1e-9 && (a = { x: -m / p, y: h / p }), r.push(a), i.push({ x: l.x + a.x * n, y: l.y + a.y * n }), s.push({ x: l.x - a.x * n, y: l.y - a.y * n });
|
|
375
|
+
}
|
|
376
|
+
const u = (o, l) => {
|
|
377
|
+
const d = r[o], c = { x: d.y, y: -d.x }, h = l ? 1 : -1;
|
|
378
|
+
return Array.from({ length: tt - 1 }, (m, p) => {
|
|
379
|
+
const f = Math.PI * (p + 1) / tt, g = Math.cos(f) * h, x = Math.sin(f) * h;
|
|
380
|
+
return {
|
|
381
|
+
x: t[o].x + (d.x * g + c.x * x) * n,
|
|
382
|
+
y: t[o].y + (d.y * g + c.y * x) * n
|
|
383
|
+
};
|
|
384
|
+
});
|
|
385
|
+
};
|
|
386
|
+
return (o, l) => [
|
|
387
|
+
...i.slice(o, l + 1),
|
|
388
|
+
...l === t.length - 1 ? u(l, !0) : [],
|
|
389
|
+
...s.slice(o, l + 1).reverse(),
|
|
390
|
+
...o === 0 ? u(o, !1) : []
|
|
391
|
+
];
|
|
392
|
+
}
|
|
393
|
+
function te(t, e) {
|
|
394
|
+
return [
|
|
395
|
+
{ from: 0, to: Math.min(t - 1, e + 1) },
|
|
396
|
+
{ from: Math.max(0, e - 1), to: t - 1 }
|
|
397
|
+
];
|
|
398
|
+
}
|
|
399
|
+
function ee(t, { radiusPx: e, gripPx: n, beyondTipPx: i, headLength: s }) {
|
|
400
|
+
const r = n / 2, a = s / 2 * e + i - r, u = i - r, o = t.map((p) => {
|
|
401
|
+
const f = p.points.map((b) => ({
|
|
402
|
+
x: b.x * e,
|
|
403
|
+
y: b.y * e,
|
|
404
|
+
depth: b.depth
|
|
405
|
+
})), g = f[f.length >> 1], x = p.direction === "+" ? et(W(f, a), u) : W(et(f, a), u);
|
|
406
|
+
return { line: x, middle: x.indexOf(g) };
|
|
407
|
+
}), l = o.map(({ line: p }) => p), d = t.map(
|
|
408
|
+
(p) => 2 * N * e * p.openness >= n
|
|
409
|
+
), c = l.flatMap(
|
|
410
|
+
(p, f) => d[f] ? te(p.length, o[f].middle).map(({ from: g, to: x }) => ({
|
|
411
|
+
arc: f,
|
|
412
|
+
from: g,
|
|
413
|
+
to: x,
|
|
414
|
+
line: p.slice(g, x + 1)
|
|
415
|
+
})) : []
|
|
416
|
+
), h = Yt(c, n), m = t.map((p, f) => f).sort((p, f) => t[p].head.depth - t[f].head.depth);
|
|
417
|
+
return t.map((p, f) => {
|
|
418
|
+
if (!d[f]) return null;
|
|
419
|
+
const g = Zt(l[f], n), x = c.flatMap(
|
|
420
|
+
(b, w) => b.arc === f ? [{ ...b, layer: h[w] }] : []
|
|
421
|
+
);
|
|
422
|
+
return {
|
|
423
|
+
band: g(0, l[f].length - 1),
|
|
424
|
+
halves: x.map(({ from: b, to: w, layer: E }) => ({
|
|
425
|
+
polygon: g(b, w),
|
|
426
|
+
layer: E
|
|
427
|
+
})),
|
|
428
|
+
head: { x: p.head.x * e, y: p.head.y * e },
|
|
429
|
+
headLayer: c.length + 1 + m.indexOf(f)
|
|
430
|
+
};
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
function wt(t, e, n, i) {
|
|
434
|
+
const s = F(null), r = st((a) => a.invalidate);
|
|
435
|
+
L(() => {
|
|
436
|
+
s.current = null, r();
|
|
437
|
+
}, [i, r]), L(() => {
|
|
438
|
+
let a = requestAnimationFrame(function u() {
|
|
439
|
+
const o = t.current;
|
|
440
|
+
o && Y(s.current, o) && r(), a = requestAnimationFrame(u);
|
|
441
|
+
});
|
|
442
|
+
return () => cancelAnimationFrame(a);
|
|
443
|
+
}, [t, r]), at(() => {
|
|
444
|
+
const a = t.current;
|
|
445
|
+
!a || !e.current || Y(s.current, a) && (e.current.quaternion.copy(a), n(a) && (s.current = a.clone()));
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
const nt = 0.03;
|
|
449
|
+
function ne({
|
|
450
|
+
orientation: t,
|
|
451
|
+
lit: e,
|
|
452
|
+
disabled: n,
|
|
453
|
+
size: i,
|
|
454
|
+
radius: s,
|
|
455
|
+
overlay: r
|
|
456
|
+
}) {
|
|
457
|
+
const a = F(null), u = i / 2, o = (c) => `${(u + c).toFixed(2)}px`, l = (c) => `polygon(${c.map((h) => `${o(h.x)} ${o(h.y)}`).join(", ")})`, d = (c) => `M${c.map((h) => `${(u + h.x).toFixed(2)} ${(u + h.y).toFixed(2)}`).join("L")}Z`;
|
|
458
|
+
return wt(
|
|
459
|
+
t,
|
|
460
|
+
a,
|
|
461
|
+
(c) => {
|
|
462
|
+
let h = !0;
|
|
463
|
+
const m = Xt(c), p = ee(m, Ct(i, s));
|
|
464
|
+
for (const [f, g] of m.entries()) {
|
|
465
|
+
const x = r.current.get(R(g)), b = r.current.get(pt(g)), w = r.current.get(dt(g)), E = V.map(
|
|
466
|
+
(_) => r.current.get(q(g, _))
|
|
467
|
+
);
|
|
468
|
+
if (!x || !b || !w || E.some((_) => !_)) {
|
|
469
|
+
h = !1;
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
const A = p[f];
|
|
473
|
+
x.style.left = o(g.head.x * s), x.style.top = o(g.head.y * s), x.style.zIndex = A ? String(A.headLayer) : "0", x.style.pointerEvents = A ? "" : "none", x.dataset.band = A ? "shown" : "none", b.style.clipPath = A ? l(A.band) : j, w.setAttribute("d", A ? d(A.band) : "");
|
|
474
|
+
for (const [_, I] of E.entries()) {
|
|
475
|
+
if (!I) continue;
|
|
476
|
+
const T = A == null ? void 0 : A.halves[_];
|
|
477
|
+
I.style.clipPath = T ? l(T.polygon) : j, I.style.zIndex = T ? String(T.layer) : "0", I.style.pointerEvents = T ? "" : "none";
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return h;
|
|
481
|
+
},
|
|
482
|
+
`${i}:${s}`
|
|
483
|
+
), /* @__PURE__ */ S("group", { ref: a, children: [
|
|
484
|
+
/* @__PURE__ */ S("mesh", { children: [
|
|
485
|
+
/* @__PURE__ */ y("sphereGeometry", { args: [0.07, 16, 16] }),
|
|
486
|
+
/* @__PURE__ */ y("meshBasicMaterial", { color: "#c4c8d0" })
|
|
487
|
+
] }),
|
|
488
|
+
P.map((c) => /* @__PURE__ */ y(
|
|
489
|
+
oe,
|
|
490
|
+
{
|
|
491
|
+
axis: c,
|
|
492
|
+
color: z(c),
|
|
493
|
+
lit: (e == null ? void 0 : e.axis) === c ? e.direction : null,
|
|
494
|
+
disabled: n
|
|
495
|
+
},
|
|
496
|
+
c
|
|
497
|
+
))
|
|
498
|
+
] });
|
|
499
|
+
}
|
|
500
|
+
function oe({
|
|
501
|
+
axis: t,
|
|
502
|
+
color: e,
|
|
503
|
+
lit: n,
|
|
504
|
+
disabled: i
|
|
505
|
+
}) {
|
|
506
|
+
const s = H(() => {
|
|
507
|
+
const [r, a] = bt[t];
|
|
508
|
+
return new v().setFromRotationMatrix(
|
|
509
|
+
new ct().makeBasis(r, a, B[t])
|
|
510
|
+
);
|
|
511
|
+
}, [t]);
|
|
512
|
+
return /* @__PURE__ */ y("group", { quaternion: s, children: k.map((r) => {
|
|
513
|
+
const a = n === r, u = a ? 1 : i ? 0.35 : 0.8, o = a ? nt * 1.5 : nt;
|
|
514
|
+
return /* @__PURE__ */ S("group", { children: [
|
|
515
|
+
/* @__PURE__ */ S("mesh", { rotation: [0, 0, K(r).start], children: [
|
|
516
|
+
/* @__PURE__ */ y("torusGeometry", { args: [N, o, 12, 48, xt] }),
|
|
517
|
+
/* @__PURE__ */ y("meshBasicMaterial", { color: e, transparent: !0, opacity: u })
|
|
518
|
+
] }),
|
|
519
|
+
/* @__PURE__ */ y(
|
|
520
|
+
re,
|
|
521
|
+
{
|
|
522
|
+
direction: r,
|
|
523
|
+
color: e,
|
|
524
|
+
opacity: u,
|
|
525
|
+
lit: a
|
|
526
|
+
}
|
|
527
|
+
)
|
|
528
|
+
] }, r);
|
|
529
|
+
}) });
|
|
530
|
+
}
|
|
531
|
+
function re({
|
|
532
|
+
direction: t,
|
|
533
|
+
color: e,
|
|
534
|
+
opacity: n,
|
|
535
|
+
lit: i
|
|
536
|
+
}) {
|
|
537
|
+
const { position: s, rotation: r } = H(() => {
|
|
538
|
+
const { head: a } = K(t), u = t === "+" ? 1 : -1;
|
|
539
|
+
return {
|
|
540
|
+
position: new M(
|
|
541
|
+
Math.cos(a) * N,
|
|
542
|
+
Math.sin(a) * N,
|
|
543
|
+
0
|
|
544
|
+
),
|
|
545
|
+
rotation: new v().setFromUnitVectors(
|
|
546
|
+
lt,
|
|
547
|
+
new M(-Math.sin(a) * u, Math.cos(a) * u, 0)
|
|
548
|
+
)
|
|
549
|
+
};
|
|
550
|
+
}, [t]);
|
|
551
|
+
return /* @__PURE__ */ S("mesh", { position: s, quaternion: r, scale: i ? 1.2 : 1, children: [
|
|
552
|
+
/* @__PURE__ */ y("coneGeometry", { args: [ut, G, 20] }),
|
|
553
|
+
/* @__PURE__ */ y("meshBasicMaterial", { color: e, transparent: !0, opacity: n })
|
|
554
|
+
] });
|
|
555
|
+
}
|
|
556
|
+
function se(t) {
|
|
557
|
+
const { disabled: e, label: n, overlay: i, size: s } = t, r = it(), { gripPx: a, labelFontPx: u } = D(s);
|
|
558
|
+
return /* @__PURE__ */ S(Mt, { children: [
|
|
559
|
+
P.map((o) => /* @__PURE__ */ y(
|
|
560
|
+
O,
|
|
561
|
+
{
|
|
562
|
+
component: "span",
|
|
563
|
+
"aria-hidden": !0,
|
|
564
|
+
ref: $(i, ht(o)),
|
|
565
|
+
sx: {
|
|
566
|
+
position: "absolute",
|
|
567
|
+
transform: "translate(-50%, -50%)",
|
|
568
|
+
pointerEvents: "none",
|
|
569
|
+
fontSize: u,
|
|
570
|
+
color: z(o),
|
|
571
|
+
opacity: e ? 0.4 : 1
|
|
572
|
+
},
|
|
573
|
+
children: o.toUpperCase()
|
|
574
|
+
},
|
|
575
|
+
o
|
|
576
|
+
)),
|
|
577
|
+
P.flatMap(
|
|
578
|
+
(o) => k.map((l) => {
|
|
579
|
+
const d = { axis: o, direction: l }, c = ft(d, t);
|
|
580
|
+
return /* @__PURE__ */ y(
|
|
581
|
+
O,
|
|
582
|
+
{
|
|
583
|
+
component: "button",
|
|
584
|
+
type: "button",
|
|
585
|
+
ref: $(i, R(d)),
|
|
586
|
+
disabled: e,
|
|
587
|
+
"aria-label": n(d),
|
|
588
|
+
"aria-pressed": c.pressed,
|
|
589
|
+
...gt(d, t),
|
|
590
|
+
sx: {
|
|
591
|
+
// Placed, sized and turned along its half of the axis by
|
|
592
|
+
// TranslationScene, every frame the gizmo turns
|
|
593
|
+
position: "absolute",
|
|
594
|
+
height: a,
|
|
595
|
+
transformOrigin: "0 50%",
|
|
596
|
+
padding: 0,
|
|
597
|
+
borderRadius: `${a / 2}px`,
|
|
598
|
+
border: "none",
|
|
599
|
+
background: mt(z(o), c),
|
|
600
|
+
"&:focus-visible": { outline: yt(r) },
|
|
601
|
+
...J(e)
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
R(d)
|
|
605
|
+
);
|
|
606
|
+
})
|
|
607
|
+
)
|
|
608
|
+
] });
|
|
609
|
+
}
|
|
610
|
+
function ae(t) {
|
|
611
|
+
const e = [];
|
|
612
|
+
for (const n of P)
|
|
613
|
+
for (const i of k) {
|
|
614
|
+
const s = B[n].clone().multiplyScalar(i === "+" ? 1 : -1).applyQuaternion(t);
|
|
615
|
+
e.push({
|
|
616
|
+
axis: n,
|
|
617
|
+
direction: i,
|
|
618
|
+
x: s.x + 0,
|
|
619
|
+
y: -s.y + 0,
|
|
620
|
+
depth: s.z
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
return e;
|
|
624
|
+
}
|
|
625
|
+
function ce(t, e) {
|
|
626
|
+
const { radiusPx: n, gripPx: i, innerPx: s, beyondTipPx: r, minTipPx: a, headLength: u } = e, o = t.map((c) => {
|
|
627
|
+
const h = Math.hypot(c.x, c.y) * n;
|
|
628
|
+
return {
|
|
629
|
+
tip: h,
|
|
630
|
+
angle: Math.atan2(c.y, c.x),
|
|
631
|
+
start: s,
|
|
632
|
+
end: h + r,
|
|
633
|
+
depth: c.depth,
|
|
634
|
+
grabbed: h >= a
|
|
635
|
+
};
|
|
636
|
+
});
|
|
637
|
+
for (const [c, h] of o.entries())
|
|
638
|
+
for (const m of o.slice(c + 1)) {
|
|
639
|
+
if (!h.grabbed || !m.grabbed) continue;
|
|
640
|
+
const [p, f] = h.tip <= m.tip ? [h, m] : [m, h], g = h.angle - m.angle, x = p.tip * Math.abs(Math.sin(g));
|
|
641
|
+
if (Math.cos(g) <= 0 || x >= i) continue;
|
|
642
|
+
const b = f.tip * (1 - u);
|
|
643
|
+
if (p.tip > b) {
|
|
644
|
+
const w = h.depth < m.depth ? h : m;
|
|
645
|
+
w.grabbed = !1;
|
|
646
|
+
} else {
|
|
647
|
+
const w = (p.tip + b) / 2;
|
|
648
|
+
p.end = Math.min(p.end, w), f.start = Math.max(f.start, w);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
const l = o.map((c, h) => h);
|
|
652
|
+
l.sort((c, h) => o[c].depth - o[h].depth);
|
|
653
|
+
const d = new Map(l.map((c, h) => [c, h + 1]));
|
|
654
|
+
return o.map((c, h) => !c.grabbed || c.end <= c.start ? null : {
|
|
655
|
+
x: Math.cos(c.angle) * c.start,
|
|
656
|
+
y: Math.sin(c.angle) * c.start,
|
|
657
|
+
length: c.end - c.start,
|
|
658
|
+
angle: c.angle,
|
|
659
|
+
layer: d.get(h) ?? 0
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
const ot = 0.035, rt = 1.28;
|
|
663
|
+
function ie({
|
|
664
|
+
orientation: t,
|
|
665
|
+
lit: e,
|
|
666
|
+
disabled: n,
|
|
667
|
+
size: i,
|
|
668
|
+
radius: s,
|
|
669
|
+
overlay: r
|
|
670
|
+
}) {
|
|
671
|
+
const a = F(null), u = i / 2;
|
|
672
|
+
return wt(
|
|
673
|
+
t,
|
|
674
|
+
a,
|
|
675
|
+
(o) => {
|
|
676
|
+
let l = !0;
|
|
677
|
+
const d = ae(o), c = ce(d, kt(i, s));
|
|
678
|
+
for (const [h, m] of d.entries()) {
|
|
679
|
+
const p = r.current.get(R(m)), f = c[h];
|
|
680
|
+
if (p ? f ? (p.style.left = `${u + f.x}px`, p.style.top = `${u + f.y}px`, p.style.width = `${f.length}px`, p.style.transform = `translateY(-50%) rotate(${f.angle}rad)`, p.style.zIndex = String(f.layer), p.style.pointerEvents = "") : p.style.pointerEvents = "none" : l = !1, m.direction !== "+") continue;
|
|
681
|
+
const g = r.current.get(ht(m.axis));
|
|
682
|
+
g ? (g.style.left = `${u + m.x * s * rt}px`, g.style.top = `${u + m.y * s * rt}px`) : l = !1;
|
|
683
|
+
}
|
|
684
|
+
return l;
|
|
685
|
+
},
|
|
686
|
+
`${i}:${s}`
|
|
687
|
+
), /* @__PURE__ */ S("group", { ref: a, children: [
|
|
688
|
+
/* @__PURE__ */ S("mesh", { children: [
|
|
689
|
+
/* @__PURE__ */ y("sphereGeometry", { args: [0.07, 16, 16] }),
|
|
690
|
+
/* @__PURE__ */ y("meshBasicMaterial", { color: "#c4c8d0" })
|
|
691
|
+
] }),
|
|
692
|
+
P.map((o) => /* @__PURE__ */ y(
|
|
693
|
+
le,
|
|
694
|
+
{
|
|
695
|
+
axis: o,
|
|
696
|
+
color: z(o),
|
|
697
|
+
lit: (e == null ? void 0 : e.axis) === o ? e.direction : null,
|
|
698
|
+
disabled: n
|
|
699
|
+
},
|
|
700
|
+
o
|
|
701
|
+
))
|
|
702
|
+
] });
|
|
703
|
+
}
|
|
704
|
+
function le({
|
|
705
|
+
axis: t,
|
|
706
|
+
color: e,
|
|
707
|
+
lit: n,
|
|
708
|
+
disabled: i
|
|
709
|
+
}) {
|
|
710
|
+
const s = H(
|
|
711
|
+
() => new v().setFromUnitVectors(lt, B[t]),
|
|
712
|
+
[t]
|
|
713
|
+
), r = 1 - G;
|
|
714
|
+
return /* @__PURE__ */ y("group", { quaternion: s, children: k.map((a) => {
|
|
715
|
+
const u = n === a, o = u ? 1 : i ? 0.35 : 0.8, l = u ? ot * 1.5 : ot;
|
|
716
|
+
return (
|
|
717
|
+
// The minus half is the plus half turned around
|
|
718
|
+
/* @__PURE__ */ S(
|
|
719
|
+
"group",
|
|
720
|
+
{
|
|
721
|
+
rotation: [a === "+" ? 0 : Math.PI, 0, 0],
|
|
722
|
+
children: [
|
|
723
|
+
/* @__PURE__ */ S("mesh", { position: [0, r / 2, 0], children: [
|
|
724
|
+
/* @__PURE__ */ y(
|
|
725
|
+
"cylinderGeometry",
|
|
726
|
+
{
|
|
727
|
+
args: [l, l, r, 12]
|
|
728
|
+
}
|
|
729
|
+
),
|
|
730
|
+
/* @__PURE__ */ y("meshBasicMaterial", { color: e, transparent: !0, opacity: o })
|
|
731
|
+
] }),
|
|
732
|
+
/* @__PURE__ */ S(
|
|
733
|
+
"mesh",
|
|
734
|
+
{
|
|
735
|
+
position: [0, 1 - G / 2, 0],
|
|
736
|
+
scale: u ? 1.2 : 1,
|
|
737
|
+
children: [
|
|
738
|
+
/* @__PURE__ */ y("coneGeometry", { args: [ut, G, 20] }),
|
|
739
|
+
/* @__PURE__ */ y("meshBasicMaterial", { color: e, transparent: !0, opacity: o })
|
|
740
|
+
]
|
|
741
|
+
}
|
|
742
|
+
)
|
|
743
|
+
]
|
|
744
|
+
},
|
|
745
|
+
a
|
|
746
|
+
)
|
|
747
|
+
);
|
|
748
|
+
}) });
|
|
749
|
+
}
|
|
750
|
+
const ue = new v();
|
|
751
|
+
function he(t, e = ue) {
|
|
752
|
+
const n = F(e);
|
|
753
|
+
return n.current = e, H(() => {
|
|
754
|
+
const i = new v();
|
|
755
|
+
return {
|
|
756
|
+
get current() {
|
|
757
|
+
const s = t.current;
|
|
758
|
+
if (!s) return null;
|
|
759
|
+
const r = n.current;
|
|
760
|
+
return Wt(s, typeof r == "function" ? r() : r, i);
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
}, [t]);
|
|
764
|
+
}
|
|
765
|
+
const pe = 3e3;
|
|
766
|
+
function de(t) {
|
|
767
|
+
const [e, n] = U(() => t.current !== null);
|
|
768
|
+
return L(() => {
|
|
769
|
+
if (e) return;
|
|
770
|
+
let i = requestAnimationFrame(function r() {
|
|
771
|
+
t.current !== null ? n(!0) : i = requestAnimationFrame(r);
|
|
772
|
+
});
|
|
773
|
+
const s = setTimeout(() => {
|
|
774
|
+
t.current === null && console.warn(
|
|
775
|
+
"JoggingGizmo has no orientation, so it stays disabled. Put a JoggingGizmoOrientation with the same ref into the app's 3D scene."
|
|
776
|
+
);
|
|
777
|
+
}, pe);
|
|
778
|
+
return () => {
|
|
779
|
+
cancelAnimationFrame(i), clearTimeout(s);
|
|
780
|
+
};
|
|
781
|
+
}, [e, t]), e;
|
|
782
|
+
}
|
|
783
|
+
const ve = Ot(
|
|
784
|
+
({
|
|
785
|
+
orientation: t,
|
|
786
|
+
frameQuaternion: e,
|
|
787
|
+
motion: n = "translate",
|
|
788
|
+
onJogStart: i,
|
|
789
|
+
onJogStop: s,
|
|
790
|
+
activeHandle: r,
|
|
791
|
+
disabled: a = !1,
|
|
792
|
+
size: u = 200,
|
|
793
|
+
onWebGLUnavailable: o
|
|
794
|
+
}) => {
|
|
795
|
+
const { t: l } = Rt(), { unavailable: d, makeRenderer: c } = $t({
|
|
796
|
+
onWebGLUnavailable: o
|
|
797
|
+
}), h = de(t), m = a || !h, p = he(t, e), { held: f, handlersFor: g, label: x, isPressed: b } = Ft({
|
|
798
|
+
motion: n,
|
|
799
|
+
onJogStart: i,
|
|
800
|
+
onJogStop: s,
|
|
801
|
+
activeHandle: r,
|
|
802
|
+
disabled: m
|
|
803
|
+
}), [w, E] = U(null);
|
|
804
|
+
L(() => E(null), [n]);
|
|
805
|
+
const A = n === "rotate" ? ne : ie, _ = n === "rotate" ? Vt : se, I = F(/* @__PURE__ */ new Map()), T = Nt(u, u, D(u).marginPx);
|
|
806
|
+
return d ? /* @__PURE__ */ y(
|
|
807
|
+
O,
|
|
808
|
+
{
|
|
809
|
+
"data-testid": "jogging-gizmo-unavailable",
|
|
810
|
+
sx: {
|
|
811
|
+
width: u,
|
|
812
|
+
height: u,
|
|
813
|
+
flexShrink: 0,
|
|
814
|
+
display: "flex",
|
|
815
|
+
alignItems: "center",
|
|
816
|
+
justifyContent: "center",
|
|
817
|
+
textAlign: "center"
|
|
818
|
+
},
|
|
819
|
+
children: /* @__PURE__ */ y(At, { variant: "body2", color: "text.secondary", children: l("JoggingGizmo.WebGLUnavailable.lb") })
|
|
820
|
+
}
|
|
821
|
+
) : /* @__PURE__ */ S(
|
|
822
|
+
O,
|
|
823
|
+
{
|
|
824
|
+
"data-testid": "jogging-gizmo",
|
|
825
|
+
sx: {
|
|
826
|
+
position: "relative",
|
|
827
|
+
width: u,
|
|
828
|
+
height: u,
|
|
829
|
+
flexShrink: 0,
|
|
830
|
+
// Keeps the z-indexes of the handles inside the gizmo: without it,
|
|
831
|
+
// they would lie over the app's own elements that cover the gizmo
|
|
832
|
+
// (e.g. a sticky header), and a press there would jog
|
|
833
|
+
isolation: "isolate"
|
|
834
|
+
},
|
|
835
|
+
children: [
|
|
836
|
+
/* @__PURE__ */ y(
|
|
837
|
+
St,
|
|
838
|
+
{
|
|
839
|
+
orthographic: !0,
|
|
840
|
+
flat: !0,
|
|
841
|
+
frameloop: "demand",
|
|
842
|
+
camera: {
|
|
843
|
+
position: [0, 0, 10],
|
|
844
|
+
up: [0, 1, 0],
|
|
845
|
+
zoom: T,
|
|
846
|
+
near: 0.1,
|
|
847
|
+
far: 100
|
|
848
|
+
},
|
|
849
|
+
gl: c,
|
|
850
|
+
style: { position: "absolute", inset: 0, pointerEvents: "none" },
|
|
851
|
+
children: /* @__PURE__ */ y(
|
|
852
|
+
A,
|
|
853
|
+
{
|
|
854
|
+
orientation: p,
|
|
855
|
+
lit: f ?? r ?? w,
|
|
856
|
+
disabled: m,
|
|
857
|
+
size: u,
|
|
858
|
+
radius: T,
|
|
859
|
+
overlay: I
|
|
860
|
+
}
|
|
861
|
+
)
|
|
862
|
+
}
|
|
863
|
+
),
|
|
864
|
+
/* @__PURE__ */ y(
|
|
865
|
+
_,
|
|
866
|
+
{
|
|
867
|
+
isPressed: b,
|
|
868
|
+
hovered: w,
|
|
869
|
+
disabled: m,
|
|
870
|
+
size: u,
|
|
871
|
+
onHover: E,
|
|
872
|
+
handlersFor: g,
|
|
873
|
+
label: x,
|
|
874
|
+
overlay: I
|
|
875
|
+
}
|
|
876
|
+
)
|
|
877
|
+
]
|
|
878
|
+
}
|
|
879
|
+
);
|
|
880
|
+
}
|
|
881
|
+
);
|
|
882
|
+
function Ee({
|
|
883
|
+
target: t
|
|
884
|
+
}) {
|
|
885
|
+
const e = st((n) => n.camera);
|
|
886
|
+
return at(() => {
|
|
887
|
+
t.current = Jt(e, t.current ?? new v());
|
|
888
|
+
}), null;
|
|
889
|
+
}
|
|
890
|
+
export {
|
|
891
|
+
ve as J,
|
|
892
|
+
Ee as a
|
|
893
|
+
};
|