- {serverGuards?.canDoMountingReset === false && (
+ {serverGuards?.mountingReset === ResetAvailability.NEEDS_FULL_RESET && (
<>
);
diff --git a/gui/app/src/components/onboarding/pages/mounting/mounting-steps/StepMountingStep.tsx b/gui/app/src/components/onboarding/pages/mounting/mounting-steps/StepMountingStep.tsx
new file mode 100644
index 000000000..8d747bcbc
--- /dev/null
+++ b/gui/app/src/components/onboarding/pages/mounting/mounting-steps/StepMountingStep.tsx
@@ -0,0 +1,81 @@
+import { useEffect, useState } from 'react';
+import { useAtomValue } from 'jotai';
+import { ResetLifecycle, ResetType } from 'solarxr-protocol';
+import { Button } from '@/components/commons/Button';
+import { Typography } from '@/components/commons/Typography';
+import { ResetButton } from '@/components/home/ResetButton';
+import { StepMountingStatusContent } from '@/components/mounting/StepMountingStatus';
+import { useCancelReset } from '@/hooks/reset';
+import { useStepMountingProgress } from '@/hooks/step-mounting';
+import { resetStatusAtom } from '@/store/app-store';
+import { useLocalization } from '@fluent/react';
+
+export function StepMountingStep({
+ nextStep,
+ prevStep,
+ variant,
+ active,
+}: {
+ nextStep: () => void;
+ prevStep: () => void;
+ variant: 'onboarding' | 'alone';
+ active: boolean;
+}) {
+ const { l10n } = useLocalization();
+ const cancel = useCancelReset();
+ const resetStatus = useAtomValue(resetStatusAtom);
+ const progress = useStepMountingProgress();
+ // A step mounting reported before this step opened belongs to an earlier visit
+ const [previousStatus, setPreviousStatus] = useState(resetStatus);
+
+ // The stepper keeps every step mounted, only the active one shows the progress
+ useEffect(() => {
+ if (active) setPreviousStatus(resetStatus);
+ }, [active]);
+
+ const current = resetStatus !== previousStatus ? progress : null;
+
+ return (
+
+ );
+}
diff --git a/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PreparationStep.tsx b/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PreparationStep.tsx
index 8653cfffb..ec9b385ac 100644
--- a/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PreparationStep.tsx
+++ b/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PreparationStep.tsx
@@ -6,7 +6,7 @@ import { Typography } from '@/components/commons/Typography';
import { VerticalStepComponentProps } from '@/components/commons/VerticalStepper';
import { ResetButton } from '@/components/home/ResetButton';
import { Localized } from '@fluent/react';
-import { ResetType } from 'solarxr-protocol';
+import { ResetAvailability, ResetType } from 'solarxr-protocol';
import { useAtomValue } from 'jotai';
import { serverGuardsAtom } from '@/store/app-store';
@@ -18,7 +18,7 @@ export function PreparationStep({
const serverGuards = useAtomValue(serverGuardsAtom);
return (
- {serverGuards?.canDoMountingReset === false && (
+ {serverGuards?.mountingReset === ResetAvailability.NEEDS_FULL_RESET && (
<>
@@ -68,23 +68,24 @@ export function PreparationStep({
>
)}
- {serverGuards?.canDoMountingReset === true && (
-
-
-
-
-
+ {serverGuards &&
+ serverGuards.mountingReset !== ResetAvailability.NEEDS_FULL_RESET && (
+
-
- )}
+ )}
);
}
diff --git a/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/VerifyMounting.tsx b/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/VerifyMounting.tsx
index 7cf3878b8..085364b2f 100644
--- a/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/VerifyMounting.tsx
+++ b/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/VerifyMounting.tsx
@@ -1,6 +1,7 @@
import { useState } from 'react';
import { Button } from '@/components/commons/Button';
import { Typography } from '@/components/commons/Typography';
+import { PoseMountingVideo } from '@/components/mounting/PoseMountingVideo';
import { ResetType } from 'solarxr-protocol';
import { ResetButton } from '@/components/home/ResetButton';
import { useBreakpoint } from '@/hooks/breakpoint';
@@ -34,21 +35,13 @@ export function VerifyMountingStep({
{isMobile && (
-
+
)}
{!isMobile && (
-
+
)}
@@ -82,7 +75,7 @@ export function VerifyMountingStep({
setDisableMounting(true)}
- type={ResetType.POSE_MOUNTING}
+ type={ResetType.MOUNTING}
group="default"
onReseted={() => {
if (isActive) {
diff --git a/gui/app/src/components/settings/pages/InterfaceSettings.tsx b/gui/app/src/components/settings/pages/InterfaceSettings.tsx
index 0a00ba558..c51274d8e 100644
--- a/gui/app/src/components/settings/pages/InterfaceSettings.tsx
+++ b/gui/app/src/components/settings/pages/InterfaceSettings.tsx
@@ -23,7 +23,8 @@ import { useElectron } from '@/hooks/electron';
import { handleResetSounds } from '@/sounds/sounds';
import {
ErrorReportingConsent,
- ResetStatus,
+ ResetDetail,
+ ResetLifecycle,
ResetType,
} from 'solarxr-protocol';
import { useErrorReporting } from '@/hooks/error-reporting';
@@ -131,10 +132,10 @@ export function InterfaceSettings() {
) {
handleResetSounds(values.notifications.feedbackSoundVolume, {
resetType: ResetType.FULL,
- status: ResetStatus.FINISHED,
+ lifecycle: ResetLifecycle.DONE,
bodyParts: [],
- progress: 0,
- duration: 0,
+ detailType: ResetDetail.NONE,
+ detail: null,
});
}
diff --git a/gui/app/src/components/settings/pages/components/ResetsSettings.tsx b/gui/app/src/components/settings/pages/components/ResetsSettings.tsx
index a4dd19863..a919ad4a8 100644
--- a/gui/app/src/components/settings/pages/components/ResetsSettings.tsx
+++ b/gui/app/src/components/settings/pages/components/ResetsSettings.tsx
@@ -1,20 +1,14 @@
import { useLocalization, Localized } from '@fluent/react';
import { useEffect } from 'react';
import { useForm } from 'react-hook-form';
-import {
- ResetsSettingsRequestT,
- ResetsSettingsResponseT,
- RpcMessage,
-} from 'solarxr-protocol';
-import { useWebsocketAPI } from '@/hooks/websocket-api';
+import { useResetsSettings } from '@/hooks/resets-settings';
import { useLocaleConfig } from '@/i18n/config';
import { CheckBox } from '@/components/commons/Checkbox';
import { NumberSelector } from '@/components/commons/NumberSelector';
import { Radio } from '@/components/commons/Radio';
import { Typography } from '@/components/commons/Typography';
-import { atom, useAtomValue, useSetAtom } from 'jotai';
-import { isEqual } from '@react-hookz/deep-equal';
-import { selectAtom } from 'jotai/utils';
+import { MountingMethodRadio } from '@/components/mounting/MountingMethodRadio';
+import { MountingMethod } from 'solarxr-protocol';
type ResetsSettingsForm = {
resetMountingFeet: boolean;
@@ -32,19 +26,11 @@ const defaultValues: ResetsSettingsForm = {
resetReliableReferenceAttitude: false,
};
-const resetsSettingsAtom = atom(new ResetsSettingsResponseT());
-const resetsSettingsValueAtom = selectAtom(
- resetsSettingsAtom,
- (settings) => settings,
- isEqual
-);
-
export function ResetsSettings() {
- const setSettings = useSetAtom(resetsSettingsAtom);
- const settings = useAtomValue(resetsSettingsValueAtom);
+ const { resetsSettings: settings, setResetsSettings } = useResetsSettings();
const { l10n } = useLocalization();
const { currentLocales } = useLocaleConfig();
- const { sendRPCPacket, useRPCPacket } = useWebsocketAPI();
+ const isPoseMounting = settings?.mountingMethod === MountingMethod.POSE;
const secondsFormat = new Intl.NumberFormat(currentLocales, {
style: 'unit',
@@ -61,15 +47,13 @@ export function ResetsSettings() {
});
const onSubmit = (values: ResetsSettingsForm) => {
- const resetsSettings = new ResetsSettingsResponseT();
- resetsSettings.resetMountingFeet = values.resetMountingFeet;
- resetsSettings.armsResetMode = values.armsResetMode;
- resetsSettings.yawResetSmoothTime = values.yawResetSmoothTime;
- resetsSettings.saveMountingReset = values.saveMountingReset;
- resetsSettings.resetReliableReferenceAttitude =
- values.resetReliableReferenceAttitude;
-
- sendRPCPacket(RpcMessage.ChangeResetsSettingsRequest, resetsSettings);
+ setResetsSettings({
+ resetMountingFeet: values.resetMountingFeet,
+ armsResetMode: values.armsResetMode,
+ yawResetSmoothTime: values.yawResetSmoothTime,
+ saveMountingReset: values.saveMountingReset,
+ resetReliableReferenceAttitude: values.resetReliableReferenceAttitude,
+ });
};
useEffect(() => {
@@ -80,25 +64,108 @@ export function ResetsSettings() {
}, []);
useEffect(() => {
- sendRPCPacket(
- RpcMessage.ResetsSettingsRequest,
- new ResetsSettingsRequestT()
- );
- }, []);
-
- useEffect(() => {
+ if (!settings) return;
reset({ ...getValues(), ...settings });
}, [settings]);
- useRPCPacket(
- RpcMessage.ResetsSettingsResponse,
- (settings: ResetsSettingsResponseT) => {
- setSettings(settings);
- }
- );
-
return (
<>
+
+
+
+
+
+
+ {isPoseMounting && (
+ <>
+
+
+ {l10n.getString('settings-general-fk_settings-arm_fk-reset_mode')}
+
+
+
+ {l10n.getString(
+ 'settings-general-fk_settings-arm_fk-reset_mode-description'
+ )}
+
+
+
+
+
+
+
+
+
+
+
+
+ {l10n.getString(
+ 'settings-general-fk_settings-leg_fk-reset_mounting_feet-v1'
+ )}
+
+
+
+ {l10n.getString(
+ 'settings-general-fk_settings-leg_fk-reset_mounting_feet-description-v1'
+ )}
+
+
+
+
+ >
+ )}
+
{l10n.getString(
@@ -122,87 +189,6 @@ export function ResetsSettings() {
/>
-
-
- {l10n.getString('settings-general-fk_settings-arm_fk-reset_mode')}
-
-
-
- {l10n.getString(
- 'settings-general-fk_settings-arm_fk-reset_mode-description'
- )}
-
-
-
-
-
-
-
-
-
-
-
-
- {l10n.getString(
- 'settings-general-fk_settings-leg_fk-reset_mounting_feet-v1'
- )}
-
-
-
- {l10n.getString(
- 'settings-general-fk_settings-leg_fk-reset_mounting_feet-description-v1'
- )}
-
-
-
-
-
{l10n.getString(
diff --git a/gui/app/src/components/tracking-checklist/TrackingChecklist.tsx b/gui/app/src/components/tracking-checklist/TrackingChecklist.tsx
index 7f9008f71..7f4b773cb 100644
--- a/gui/app/src/components/tracking-checklist/TrackingChecklist.tsx
+++ b/gui/app/src/components/tracking-checklist/TrackingChecklist.tsx
@@ -19,7 +19,11 @@ import {
BoneRoutingSettingsResponseT,
BoneRouteT,
ChangeBoneRoutingSettingsRequestT,
+ MountingMethod,
} from 'solarxr-protocol';
+import { PoseMountingVideo } from '@/components/mounting/PoseMountingVideo';
+import { MountingMethodRadio } from '@/components/mounting/MountingMethodRadio';
+import { useResetsSettings } from '@/hooks/resets-settings';
import { ReactNode, useEffect, useMemo, useState } from 'react';
import { CheckIcon } from '@/components/commons/icon/CheckIcon';
import { Typography } from '@/components/commons/Typography';
@@ -247,6 +251,56 @@ function StandableInstalled() {
);
}
+function MountingCalibrationStep({
+ step,
+ toggleSession,
+}: {
+ step: TrackingChecklistStep;
+ toggleSession: TrackingChecklistContext['toggleSession'];
+}) {
+ const { resetsSettings } = useResetsSettings();
+ const isStep = resetsSettings?.mountingMethod === MountingMethod.STEP;
+
+ return (
+
+ {isStep ? (
+ <>
+
+
+
+
+
+ >
+ ) : (
+ <>
+
+
+
+ >
+ )}
+
+
+ {step.ignorable && (
+ toggleSession(step.id)}
+ />
+ )}
+
+
+ );
+}
+
const stepContentLookup: Record<
number,
(
@@ -388,31 +442,19 @@ const stepContentLookup: Record<
>
);
},
- [TrackingChecklistStepId.MOUNTING_CALIBRATION]: (step, { toggleSession }) => {
+ [TrackingChecklistStepId.MOUNTING_METHOD]: () => {
return (
-
-
-
-
-
-
-
- {step.ignorable && (
- toggleSession(step.id)}
- />
- )}
-
+
+
);
},
+ [TrackingChecklistStepId.MOUNTING_CALIBRATION]: (step, { toggleSession }) => {
+ return (
+
+ );
+ },
[TrackingChecklistStepId.FEET_MOUNTING_CALIBRATION]: (
step,
{ toggleSession }
@@ -438,7 +480,7 @@ const stepContentLookup: Record<
-
+
{step.ignorable && (
) => {
- skeletonHelper.setTrackers(trackers);
- };
-
const setStyle = (newStyle: Config['skeletonPreviewStyle']) => {
if (newStyle === style) return;
style = newStyle;
@@ -400,7 +394,6 @@ function initializePreview(
}
}
},
- updateTrackers,
resetCamera: () => {
computeFollow(followOffset);
floor.position.set(followOffset.x, 0, followOffset.z);
@@ -513,29 +506,10 @@ function SkeletonVisualizer({
const containerRef = useRef(null);
const resizeObserver = useRef(new ResizeObserver(([e]) => onResize(e)));
const bonesList = useAtomValue(bonesAtom);
- const assignedTrackers = useAtomValue(assignedTrackersAtom);
const bones = useMemo(() => {
return new Map(bonesList.map((b) => [b.bodyPart, b]));
}, [bonesList]);
- const trackersByPart = useMemo(() => {
- const trackers = new Map();
- for (const { tracker } of assignedTrackers) {
- const bodyPart = tracker.info?.bodyPart;
- if (bodyPart == null || bodyPart === BodyPart.NONE) continue;
- trackers.set(bodyPart, {
- trackerId: tracker.trackerId,
- mountingOrientation: QuaternionFromQuatT(
- tracker.info?.lastMountingMethod == MountingMethod.MANUAL
- ? tracker.info?.mountingOrientation
- : tracker.info?.mountingResetOrientation
- ).normalize(),
- boneOffset: getTrackerBoneOffset(bodyPart),
- });
- }
- return trackers;
- }, [assignedTrackers]);
-
useEffect(() => {
if (bones.size === 0) return;
const context = previewContext.current;
@@ -547,21 +521,13 @@ function SkeletonVisualizer({
const context = previewContext.current;
if (!context || disabled) return;
context.updatesBones(bones);
- context.updateTrackers(trackersByPart);
}, [bones, disabled]);
- useEffect(() => {
- const context = previewContext.current;
- if (!context || disabled) return;
- context.updateTrackers(trackersByPart);
- }, [trackersByPart, disabled]);
-
useEffect(() => {
const context = previewContext.current;
if (!context || disabled) return;
context.setStyle(style);
context.updatesBones(bones);
- context.updateTrackers(trackersByPart);
}, [style, disabled]);
const onResize = (e: ResizeObserverEntry) => {
diff --git a/gui/app/src/hooks/app.ts b/gui/app/src/hooks/app.ts
index 52361eb74..82be72c28 100644
--- a/gui/app/src/hooks/app.ts
+++ b/gui/app/src/hooks/app.ts
@@ -2,7 +2,9 @@ import { createContext, useContext, useEffect, useLayoutEffect, useState } from
import {
DataFeedMessage,
DataFeedUpdateT,
- ResetResponseT,
+ ResetsSettingsRequestT,
+ ResetsSettingsResponseT,
+ ResetStatusResponseT,
RpcMessage,
StartDataFeedT,
} from 'solarxr-protocol';
@@ -11,7 +13,12 @@ import { useConfig } from './config';
import { useBonesDataFeedConfig, useDataFeedConfig } from './datafeed-config';
import { useWebsocketAPI } from './websocket-api';
import { useSetAtom } from 'jotai';
-import { bonesAtom, datafeedAtom } from '@/store/app-store';
+import {
+ bonesAtom,
+ datafeedAtom,
+ resetsSettingsAtom,
+ resetStatusAtom,
+} from '@/store/app-store';
import { fetchCurrentFirmwareRelease, FirmwareRelease } from './firmware-update';
import { DEFAULT_LOCALE, LangContext } from '@/i18n/config';
@@ -20,14 +27,21 @@ export interface AppContext {
}
export function useProvideAppContext(): AppContext {
- const { useRPCPacket, sendDataFeedPacket, useDataFeedPacket, isConnected } =
- useWebsocketAPI();
+ const {
+ useRPCPacket,
+ sendRPCPacket,
+ sendDataFeedPacket,
+ useDataFeedPacket,
+ isConnected,
+ } = useWebsocketAPI();
const { changeLocales } = useContext(LangContext);
const { config } = useConfig();
const { dataFeedConfig } = useDataFeedConfig();
const bonesDataFeedConfig = useBonesDataFeedConfig();
const setDatafeed = useSetAtom(datafeedAtom);
const setBones = useSetAtom(bonesAtom);
+ const setResetStatus = useSetAtom(resetStatusAtom);
+ const setResetsSettings = useSetAtom(resetsSettingsAtom);
const [currentFirmwareRelease, setCurrentFirmwareRelease] =
useState(null);
@@ -48,11 +62,24 @@ export function useProvideAppContext(): AppContext {
}
});
- useRPCPacket(RpcMessage.ResetResponse, (resetResponse: ResetResponseT) => {
+ useRPCPacket(RpcMessage.ResetStatusResponse, (resetStatus: ResetStatusResponseT) => {
+ setResetStatus(resetStatus);
if (!config?.feedbackSound) return;
- handleResetSounds(config?.feedbackSoundVolume ?? 1, resetResponse);
+ handleResetSounds(config?.feedbackSoundVolume ?? 1, resetStatus);
});
+ useRPCPacket(
+ RpcMessage.ResetsSettingsResponse,
+ (settings: ResetsSettingsResponseT) => {
+ setResetsSettings(settings);
+ }
+ );
+
+ useEffect(() => {
+ if (!isConnected) return;
+ sendRPCPacket(RpcMessage.ResetsSettingsRequest, new ResetsSettingsRequestT());
+ }, [isConnected]);
+
useEffect(() => {
if (!config) return;
diff --git a/gui/app/src/hooks/mounting-method.ts b/gui/app/src/hooks/mounting-method.ts
new file mode 100644
index 000000000..c9b1452bd
--- /dev/null
+++ b/gui/app/src/hooks/mounting-method.ts
@@ -0,0 +1,46 @@
+import { useState } from 'react';
+import { useNavigate } from 'react-router-dom';
+import { MountingMethod, ResetType } from 'solarxr-protocol';
+import { useResetsSettings } from './resets-settings';
+import { UseResetOptions } from './reset';
+
+export const STEP_MOUNTING_PATH = '/onboarding/mounting/step';
+export const MANUAL_MOUNTING_PATH = '/onboarding/mounting/manual';
+
+export function useMountingMethod(
+ options: UseResetOptions,
+ triggerReset: (method?: MountingMethod) => void
+) {
+ const navigate = useNavigate();
+ const { resetsSettings, setResetsSettings } = useResetsSettings();
+ const [pickerOpen, setPickerOpen] = useState(false);
+
+ const openManualMounting = () =>
+ navigate(MANUAL_MOUNTING_PATH, { state: { alonePage: true } });
+
+ const onClick = () => {
+ if (options.type !== ResetType.MOUNTING) return triggerReset();
+ switch (resetsSettings?.mountingMethod) {
+ case MountingMethod.UNKNOWN:
+ return setPickerOpen(true);
+ case MountingMethod.MANUAL:
+ return openManualMounting();
+ default:
+ return triggerReset();
+ }
+ };
+
+ const onPick = (method: MountingMethod) => {
+ setPickerOpen(false);
+ setResetsSettings({ mountingMethod: method });
+ if (method === MountingMethod.MANUAL) openManualMounting();
+ else triggerReset(method);
+ };
+
+ return {
+ onClick,
+ onPick,
+ pickerOpen,
+ closePicker: () => setPickerOpen(false),
+ };
+}
diff --git a/gui/app/src/hooks/reset.ts b/gui/app/src/hooks/reset.ts
index f28a8f3a0..7e1f2b4e1 100644
--- a/gui/app/src/hooks/reset.ts
+++ b/gui/app/src/hooks/reset.ts
@@ -1,24 +1,34 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import {
BodyPart,
+ CancelResetRequestT,
+ CountdownDetailT,
+ MountingMethod,
+ ResetAvailability,
+ ResetDetail,
+ ResetLifecycle,
ResetRequestT,
- ResetResponseT,
- ResetStatus,
+ ResetStatusResponseT,
ResetType,
RpcMessage,
} from 'solarxr-protocol';
import { useWebsocketAPI } from './websocket-api';
import { useAtomValue } from 'jotai';
-import { assignedTrackersAtom, serverGuardsAtom } from '@/store/app-store';
+import {
+ assignedTrackersAtom,
+ resetStatusAtom,
+ serverGuardsAtom,
+} from '@/store/app-store';
import { FEET_BODY_PARTS, FINGER_BODY_PARTS, TOE_BODY_PARTS } from './body-parts';
import { useLocaleConfig } from '@/i18n/config';
+import { useResetsSettings } from './resets-settings';
export type ResetBtnStatus = 'idle' | 'counting' | 'finished';
export type MountingResetGroup = 'default' | 'feet' | 'fingers' | 'toes';
export type UseResetOptions =
| { type: ResetType.FULL | ResetType.YAW }
- | { type: ResetType.POSE_MOUNTING; group: MountingResetGroup };
+ | { type: ResetType.MOUNTING; group: MountingResetGroup };
export const BODY_PARTS_GROUPS: Record = {
default: [],
@@ -27,26 +37,58 @@ export const BODY_PARTS_GROUPS: Record = {
fingers: FINGER_BODY_PARTS,
};
+export function useCancelReset() {
+ const { sendRPCPacket } = useWebsocketAPI();
+ return () => {
+ sendRPCPacket(RpcMessage.CancelResetRequest, new CancelResetRequestT());
+ };
+}
+
+function sameBodyParts(a: BodyPart[], b: BodyPart[]) {
+ return a.length === b.length && [...a].sort().join() === [...b].sort().join();
+}
+
+function guardError(type: ResetType, availability: ResetAvailability) {
+ switch (availability) {
+ case ResetAvailability.NEEDS_FULL_RESET:
+ return type === ResetType.YAW
+ ? 'reset-error-yaw-need_full_reset'
+ : 'reset-error-mounting-need_full_reset';
+ case ResetAvailability.NEEDS_POSITIONAL_HEAD:
+ return 'reset-error-need_positional_head';
+ case ResetAvailability.NO_TRACKERS:
+ return 'reset-error-no_trackers';
+ default:
+ return null;
+ }
+}
+
export function useReset(
options: UseResetOptions,
onReseted?: () => void,
onFailed?: () => void
) {
- if (options.type === ResetType.POSE_MOUNTING && !options.group)
- options.group = 'default';
+ if (options.type === ResetType.MOUNTING && !options.group) options.group = 'default';
const serverGuards = useAtomValue(serverGuardsAtom);
const assignedTrackers = useAtomValue(assignedTrackersAtom);
+ const resetStatus = useAtomValue(resetStatusAtom);
+ const { resetsSettings } = useResetsSettings();
const { currentLocales } = useLocaleConfig();
- const { sendRPCPacket, useRPCPacket } = useWebsocketAPI();
+ const { sendRPCPacket } = useWebsocketAPI();
const finishedTimeoutRef = useRef();
- const [status, setStatus] = useState('idle');
- const [progress, setProgress] = useState(0);
- const [duration, setDuration] = useState(0);
+ const handledStatusRef = useRef(resetStatus);
+ const [finished, setFinished] = useState(false);
const parts = BODY_PARTS_GROUPS['group' in options ? options.group : 'default'];
- const triggerReset = () => {
+ // check if it is this hook instance that triggered the reset
+ const isMine = (status: ResetStatusResponseT | null) =>
+ !!status &&
+ status.resetType === options.type &&
+ (options.type !== ResetType.MOUNTING || sameBodyParts(status.bodyParts, parts));
+
+ const triggerReset = (method = resetsSettings?.mountingMethod) => {
const req = new ResetRequestT();
req.resetType = options.type;
req.bodyParts = parts;
@@ -57,65 +99,53 @@ export function useReset(
case ResetType.FULL:
req.delay = 3;
break;
- case ResetType.POSE_MOUNTING:
- req.delay = 3;
+ case ResetType.MOUNTING:
+ req.delay = method === MountingMethod.STEP ? 0 : 3;
break;
}
sendRPCPacket(RpcMessage.ResetRequest, req);
};
- const onResetFinished = () => {
- setStatus('finished');
- if (onReseted) onReseted();
- };
-
- const onResetCanceled = () => {
- if (status !== 'finished') setStatus('idle');
- if (onFailed) onFailed();
- };
+ const cancel = useCancelReset();
useEffect(() => {
- if (status === 'finished') {
+ if (resetStatus === handledStatusRef.current) return;
+ handledStatusRef.current = resetStatus;
+ if (!resetStatus || !isMine(resetStatus)) return;
+
+ if (resetStatus.lifecycle === ResetLifecycle.DONE) {
+ setFinished(true);
+ if (onReseted) onReseted();
+ } else if (
+ resetStatus.lifecycle === ResetLifecycle.CANCELED ||
+ resetStatus.lifecycle === ResetLifecycle.FAILED
+ ) {
+ if (onFailed) onFailed();
+ }
+ }, [resetStatus]);
+
+ useEffect(() => {
+ if (finished) {
finishedTimeoutRef.current = setTimeout(() => {
- setStatus('idle'); // only do that if we were on finished status. Allows to reset the outlined border
+ setFinished(false);
}, 2000);
- } else {
- clearTimeout(finishedTimeoutRef.current);
}
return () => {
clearTimeout(finishedTimeoutRef.current);
};
- }, [status]);
+ }, [finished]);
- const onResetProgress = (progress: number, duration: number) => {
- setProgress(progress / 1000);
- setDuration(duration / 1000);
- };
+ const counting =
+ isMine(resetStatus) && resetStatus?.lifecycle === ResetLifecycle.RUNNING;
+ const status: ResetBtnStatus = counting ? 'counting' : finished ? 'finished' : 'idle';
- useRPCPacket(
- RpcMessage.ResetResponse,
- ({ status, resetType, progress, duration, bodyParts }: ResetResponseT) => {
- if (
- resetType !== options.type ||
- (resetType == ResetType.POSE_MOUNTING &&
- JSON.stringify(parts) !== JSON.stringify(bodyParts))
- ) {
- onResetCanceled();
- return;
- }
- onResetProgress(progress, duration);
- switch (status) {
- case ResetStatus.FINISHED: {
- onResetFinished();
- break;
- }
- case ResetStatus.STARTED: {
- setStatus('counting');
- break;
- }
- }
- }
- );
+ // Step mounting runs without a countdown
+ const countdown =
+ counting && resetStatus?.detailType === ResetDetail.CountdownDetail
+ ? (resetStatus.detail as CountdownDetailT)
+ : null;
+ const progress = (countdown?.progress ?? 0) / 1000;
+ const duration = (countdown?.duration ?? 0) / 1000;
const name = useMemo(() => {
switch (options.type) {
@@ -123,7 +153,7 @@ export function useReset(
return 'reset-yaw';
case ResetType.FULL:
return 'reset-full';
- case ResetType.POSE_MOUNTING:
+ case ResetType.MOUNTING:
if (options.group !== 'default') return `reset-mounting-${options.group}`;
return 'reset-mounting';
default:
@@ -132,11 +162,23 @@ export function useReset(
}, [options.type]);
let disabled = status === 'counting';
- let error = null;
- if (options.type === ResetType.POSE_MOUNTING && !serverGuards?.canDoMountingReset) {
+ let error: string | null = null;
+ // A manual or unpicked method runs no reset, so its button has nothing to guard
+ const mountingRuns =
+ resetsSettings?.mountingMethod === MountingMethod.STEP ||
+ resetsSettings?.mountingMethod === MountingMethod.POSE;
+ const availability =
+ options.type === ResetType.MOUNTING
+ ? mountingRuns
+ ? serverGuards?.mountingReset
+ : ResetAvailability.AVAILABLE
+ : options.type === ResetType.YAW
+ ? serverGuards?.yawReset
+ : ResetAvailability.AVAILABLE;
+ if (availability !== undefined && availability !== ResetAvailability.AVAILABLE) {
disabled = true;
- error = 'reset-error-mounting-need_full_reset';
- } else if (options.type === ResetType.POSE_MOUNTING && options.group !== 'default') {
+ error = guardError(options.type, availability);
+ } else if (options.type === ResetType.MOUNTING && options.group !== 'default') {
if (
!assignedTrackers.some(
({ tracker }) =>
@@ -147,9 +189,6 @@ export function useReset(
disabled = true;
error = `reset-error-no_${options.group}_tracker`;
}
- } else if (options.type === ResetType.YAW && !serverGuards?.canDoYawReset) {
- disabled = true;
- error = 'reset-error-yaw-need_full_reset';
}
const localized = useMemo(
@@ -165,6 +204,7 @@ export function useReset(
return {
triggerReset,
+ cancel,
progress,
duration,
status,
diff --git a/gui/app/src/hooks/resets-settings.ts b/gui/app/src/hooks/resets-settings.ts
new file mode 100644
index 000000000..1ee8909b7
--- /dev/null
+++ b/gui/app/src/hooks/resets-settings.ts
@@ -0,0 +1,28 @@
+import { useRef } from 'react';
+import { useAtomValue } from 'jotai';
+import {
+ ChangeResetsSettingsRequestT,
+ ResetsSettingsRequestT,
+ RpcMessage,
+} from 'solarxr-protocol';
+import { resetsSettingsAtom } from '@/store/app-store';
+import { useWebsocketAPI } from './websocket-api';
+
+export function useResetsSettings() {
+ const resetsSettings = useAtomValue(resetsSettingsAtom);
+ const { sendRPCPacket } = useWebsocketAPI();
+ const latestSettings = useRef(resetsSettings);
+ latestSettings.current = resetsSettings;
+
+ const setResetsSettings = (partial: Partial) => {
+ const request = Object.assign(
+ new ChangeResetsSettingsRequestT(),
+ latestSettings.current,
+ partial
+ );
+ sendRPCPacket(RpcMessage.ChangeResetsSettingsRequest, request);
+ sendRPCPacket(RpcMessage.ResetsSettingsRequest, new ResetsSettingsRequestT());
+ };
+
+ return { resetsSettings, setResetsSettings };
+}
diff --git a/gui/app/src/hooks/step-mounting.ts b/gui/app/src/hooks/step-mounting.ts
new file mode 100644
index 000000000..807374508
--- /dev/null
+++ b/gui/app/src/hooks/step-mounting.ts
@@ -0,0 +1,28 @@
+import { useAtomValue } from 'jotai';
+import {
+ ResetDetail,
+ ResetLifecycle,
+ ResetType,
+ StepMountingDetailT,
+ StepMountingStatus,
+} from 'solarxr-protocol';
+import { resetStatusAtom } from '@/store/app-store';
+
+export interface StepMountingProgress {
+ status: StepMountingStatus;
+ lifecycle: ResetLifecycle;
+}
+
+export function useStepMountingProgress(): StepMountingProgress | null {
+ const resetStatus = useAtomValue(resetStatusAtom);
+ if (
+ resetStatus?.resetType !== ResetType.MOUNTING ||
+ resetStatus.detailType !== ResetDetail.StepMountingDetail
+ ) {
+ return null;
+ }
+ return {
+ status: (resetStatus.detail as StepMountingDetailT).status,
+ lifecycle: resetStatus.lifecycle,
+ };
+}
diff --git a/gui/app/src/hooks/tracking-checklist.ts b/gui/app/src/hooks/tracking-checklist.ts
index b916fe1af..ffe5d41d1 100644
--- a/gui/app/src/hooks/tracking-checklist.ts
+++ b/gui/app/src/hooks/tracking-checklist.ts
@@ -31,6 +31,7 @@ export const trackingchecklistIdtoLabel: Record
[TrackingChecklistStepId.TRACKER_ERROR]: 'tracking_checklist-TRACKER_ERROR',
[TrackingChecklistStepId.NETWORK_PROFILE_PUBLIC]:
'tracking_checklist-NETWORK_PROFILE_PUBLIC',
+ [TrackingChecklistStepId.MOUNTING_METHOD]: 'tracking_checklist-MOUNTING_METHOD',
[TrackingChecklistStepId.MOUNTING_CALIBRATION]:
'tracking_checklist-MOUNTING_CALIBRATION',
[TrackingChecklistStepId.FEET_MOUNTING_CALIBRATION]:
diff --git a/gui/app/src/sounds/sounds.ts b/gui/app/src/sounds/sounds.ts
index 4f46e51ed..5e18eac90 100644
--- a/gui/app/src/sounds/sounds.ts
+++ b/gui/app/src/sounds/sounds.ts
@@ -1,4 +1,10 @@
-import { ResetResponseT, ResetStatus, ResetType } from 'solarxr-protocol';
+import {
+ CountdownDetailT,
+ ResetDetail,
+ ResetLifecycle,
+ ResetStatusResponseT,
+ ResetType,
+} from 'solarxr-protocol';
import Xylophone, { ValidNote } from './xylophone';
const tones: ValidNote[][] = [
@@ -39,7 +45,7 @@ const resetSounds: Record<
end: createAudio('/sounds/yaw-reset/yaw-reset.ogg'),
mew: null,
},
- [ResetType.POSE_MOUNTING]: {
+ [ResetType.MOUNTING]: {
initial: createAudio('/sounds/mounting-reset/init-mounting-reset-with-tail.ogg'),
tick: [
createAudio('/sounds/mounting-reset/mount-click-1.ogg'),
@@ -112,13 +118,17 @@ export function restartAndPlay(audio: HTMLAudioElement | null, volume: number) {
export function handleResetSounds(
volume: number,
- { progress, status, resetType }: Omit
+ { lifecycle, resetType, detailType, detail }: Omit
) {
if (!resetSounds) throw 'sounds not loaded';
const sounds = resetSounds[resetType];
if (!sounds) throw 'reset type does not have a reset sound: ' + resetType;
- if (status === ResetStatus.STARTED) {
+ if (
+ lifecycle === ResetLifecycle.RUNNING &&
+ detailType === ResetDetail.CountdownDetail
+ ) {
+ const { progress } = detail as CountdownDetailT;
if (progress === 0) {
restartAndPlay(sounds.initial, volume);
}
@@ -143,7 +153,7 @@ export function handleResetSounds(
}
}
- if (status === ResetStatus.FINISHED) {
+ if (lifecycle === ResetLifecycle.DONE) {
restartAndPlay(sounds.end, volume);
restartAndPlay(sounds.mew, volume);
}
diff --git a/gui/app/src/store/app-store.ts b/gui/app/src/store/app-store.ts
index 4f166c59a..5ae24afea 100644
--- a/gui/app/src/store/app-store.ts
+++ b/gui/app/src/store/app-store.ts
@@ -7,6 +7,8 @@ import {
DeviceOrigin,
DongleDataT,
DongleStatus,
+ ResetStatusResponseT,
+ ResetsSettingsResponseT,
TrackerDataT,
TrackerStatus,
} from 'solarxr-protocol';
@@ -24,6 +26,11 @@ export const datafeedAtom = atom(new DataFeedUpdateT());
export const bonesAtom = atom([]);
+// Latest reset status pushed by the server, null until a reset has run
+export const resetStatusAtom = atom(null);
+
+export const resetsSettingsAtom = atom(null);
+
export const devicesAtom = selectAtom(
datafeedAtom,
(datafeed) => datafeed.devices,
diff --git a/gui/app/src/utils/skeletonHelper.ts b/gui/app/src/utils/skeletonHelper.ts
index 346d37da0..2667880ba 100644
--- a/gui/app/src/utils/skeletonHelper.ts
+++ b/gui/app/src/utils/skeletonHelper.ts
@@ -1,12 +1,4 @@
-import {
- BoxGeometry,
- Color,
- Mesh,
- MeshStandardMaterial,
- Quaternion,
- Vector2,
- Vector3,
-} from 'three';
+import { Color, Vector2, Vector3 } from 'three';
import { LineSegments2 } from 'three/examples/jsm/lines/LineSegments2';
import { LineMaterial } from 'three/examples/jsm/lines/LineMaterial.js';
import { LineSegmentsGeometry } from 'three/examples/jsm/lines/LineSegmentsGeometry.js';
@@ -17,9 +9,6 @@ import { FINGER_BODY_PARTS, TOE_BODY_PARTS } from '@/hooks/body-parts';
const boneHead = new Vector3();
const boneTail = new Vector3();
-const markerOffset = new Vector3();
-
-const EXTREMITY_TRACKER_PARTS = new Set([...FINGER_BODY_PARTS, ...TOE_BODY_PARTS]);
const BONE_COLOR_GROUPS: [BodyPart[], string][] = [
[[BodyPart.HEAD, BodyPart.LEFT_FOOT, BodyPart.RIGHT_FOOT], 'gold'],
@@ -48,10 +37,6 @@ export function getBoneColor(bodyPart: BodyPart) {
return new Color(color ?? 'white');
}
-export function getTrackerMarkerScale(bodyPart: BodyPart) {
- return EXTREMITY_TRACKER_PARTS.has(bodyPart) ? 0.35 : 1;
-}
-
export function getBoneTail(bone: BoneT, target = new Vector3()) {
return target
.set(0, -bone.boneLength, 0)
@@ -59,26 +44,14 @@ export function getBoneTail(bone: BoneT, target = new Vector3()) {
.add(Vector3FromVec3fT(bone.headPosition));
}
-export interface TrackerPreviewData {
- trackerId: number;
- mountingOrientation: Quaternion;
- boneOffset: number;
-}
-
export interface SkeletonRenderPart {
bone: BoneT;
- tracker?: TrackerPreviewData;
-}
-
-interface LineRenderPart extends SkeletonRenderPart {
- marker?: Mesh;
}
export class BasedSkeletonHelper extends LineSegments2 {
readonly type = 'SkeletonHelper';
readonly isSkeletonHelper = true;
- private parts: LineRenderPart[];
- private trackerMarkerGeometry = new BoxGeometry(0.06, 0.025, 0.04);
+ private parts: SkeletonRenderPart[];
get resolution() {
return this.material.resolution;
@@ -117,47 +90,15 @@ export class BasedSkeletonHelper extends LineSegments2 {
}
}
- setTrackers(trackers: Map) {
- for (const part of this.parts) {
- part.tracker = trackers.get(part.bone.bodyPart);
- if (!part.tracker && part.marker) part.marker.visible = false;
- }
- }
-
updateMatrixWorld(force: boolean) {
const vertices: number[] = [];
for (const part of this.parts) {
- const { bone, tracker } = part;
+ const { bone } = part;
boneHead.copy(Vector3FromVec3fT(bone.headPosition));
getBoneTail(bone, boneTail);
vertices.push(boneHead.x, boneHead.y, boneHead.z);
vertices.push(boneTail.x, boneTail.y, boneTail.z);
-
- if (!tracker) continue;
- if (!part.marker) {
- const color = getBoneColor(bone.bodyPart);
- part.marker = new Mesh(
- this.trackerMarkerGeometry,
- new MeshStandardMaterial({
- color,
- emissive: color.clone().multiplyScalar(0.25),
- emissiveIntensity: 0.8,
- roughness: 0.45,
- })
- );
- this.add(part.marker);
- }
-
- const orientation = QuaternionFromQuatT(bone.orientation)
- .normalize()
- .multiply(tracker.mountingOrientation);
- part.marker.visible = true;
- part.marker.scale.setScalar(getTrackerMarkerScale(bone.bodyPart));
- part.marker.quaternion.copy(orientation);
- part.marker.position.lerpVectors(boneHead, boneTail, tracker.boneOffset);
- markerOffset.set(0, 0, 0.02).applyQuaternion(orientation);
- part.marker.position.add(markerOffset);
}
this.geometry.setPositions(vertices);
@@ -166,10 +107,6 @@ export class BasedSkeletonHelper extends LineSegments2 {
dispose() {
this.geometry.dispose();
- this.trackerMarkerGeometry.dispose();
- for (const part of this.parts) {
- (part.marker?.material as MeshStandardMaterial | undefined)?.dispose();
- }
if (Array.isArray(this.material)) {
this.material.forEach((material) => material.dispose());
} else {
diff --git a/gui/app/src/utils/skeletonMeshHelper.ts b/gui/app/src/utils/skeletonMeshHelper.ts
index 99fef0416..136048209 100644
--- a/gui/app/src/utils/skeletonMeshHelper.ts
+++ b/gui/app/src/utils/skeletonMeshHelper.ts
@@ -1,20 +1,6 @@
-import {
- Box3,
- BoxGeometry,
- Matrix4,
- Mesh,
- MeshStandardMaterial,
- Object3D,
- Quaternion,
- Raycaster,
- Vector3,
-} from 'three';
+import { Box3, Object3D, Quaternion, Vector3 } from 'three';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
-import {
- getTrackerMarkerScale,
- SkeletonRenderPart,
- TrackerPreviewData,
-} from './skeletonHelper';
+import { SkeletonRenderPart } from './skeletonHelper';
import { BodyPart, BoneT } from 'solarxr-protocol';
import { QuaternionFromQuatT } from '@/maths/quaternion';
import { Vector3FromVec3fT } from '@/maths/vector3';
@@ -29,16 +15,8 @@ import { SkeletonProportions, deriveSkeletonProportions } from './skeletonPropor
const position = new Vector3();
const quat = new Quaternion();
-const localOffset = new Vector3();
const modelBox = new Box3();
-const shapeBounds = new Box3();
-const shapeToBone = new Matrix4();
-const corner = new Vector3();
-const mountingNormal = new Vector3();
-const rayOrigin = new Vector3();
-const rayDirection = new Vector3();
-const surfaceRaycaster = new Raycaster();
// Shared loader + cache: each model URL is fetched and parsed once, then cloned
// per instance. Same pattern as the tracker preview (IMUVisualizerWidget).
@@ -72,39 +50,8 @@ interface AttachedShape {
bounds: Box3 | null;
}
-/**
- * A point inside the shape, in the bone's axes and from its head, out of a
- * position in the shape's bounds (-1 to 1 per axis from its centre). False until
- * the model has loaded.
- */
-function shapeAnchor(
- { node, tilt, offset, bounds }: AttachedShape,
- anchor: Vector3,
- out: Vector3
-) {
- if (!bounds) return false;
-
- tilt.updateMatrix();
- shapeToBone.makeScale(node.scale.x, node.scale.y, node.scale.z).multiply(tilt.matrix);
- shapeBounds.makeEmpty();
- for (const x of [bounds.min.x, bounds.max.x]) {
- for (const y of [bounds.min.y, bounds.max.y]) {
- for (const z of [bounds.min.z, bounds.max.z]) {
- shapeBounds.expandByPoint(corner.set(x, y, z).applyMatrix4(shapeToBone));
- }
- }
- }
- shapeBounds.getCenter(out);
- shapeBounds.getSize(corner).multiplyScalar(0.5);
- out.add(corner.multiply(anchor)).add(offset);
- return true;
-}
-
interface BonePart extends SkeletonRenderPart {
shapes: AttachedShape[];
- marker?: Mesh;
- surfaceDistance: number;
- surfaceDirty: boolean;
}
/**
@@ -117,13 +64,6 @@ export class BasedSkeletonMeshHelper extends Object3D {
private parts: BonePart[] = [];
private proportions: SkeletonProportions = deriveSkeletonProportions(new Map());
private disposed = false;
- private trackerMarkerGeometry = new BoxGeometry(0.03, 0.03, 0.02);
- private trackerMarkerMaterial = new MeshStandardMaterial({
- color: 0x49e5ff,
- emissive: 0x0c5966,
- emissiveIntensity: 0.8,
- roughness: 0.45,
- });
constructor(bones: Map) {
super();
@@ -141,8 +81,6 @@ export class BasedSkeletonMeshHelper extends Object3D {
const part: BonePart = {
bone,
shapes: [],
- surfaceDistance: 0,
- surfaceDirty: true,
};
for (const shapeConfig of config.shapes) {
const node = new Object3D();
@@ -201,7 +139,6 @@ export class BasedSkeletonMeshHelper extends Object3D {
attached.bounds = modelBox.clone();
attached.tilt.clear();
attached.tilt.add(o);
- part.surfaceDirty = true;
}
});
})
@@ -209,15 +146,6 @@ export class BasedSkeletonMeshHelper extends Object3D {
}
setProportions(proportions: SkeletonProportions) {
- if (
- proportions.bodyScale !== this.proportions.bodyScale ||
- proportions.shoulderWidth !== this.proportions.shoulderWidth ||
- proportions.hipWidth !== this.proportions.hipWidth ||
- proportions.handLength !== this.proportions.handLength ||
- proportions.footLength !== this.proportions.footLength
- ) {
- for (const part of this.parts) part.surfaceDirty = true;
- }
this.proportions = proportions;
}
@@ -225,28 +153,10 @@ export class BasedSkeletonMeshHelper extends Object3D {
for (const part of this.parts) {
const bone = bones.get(part.bone.bodyPart);
if (!bone) continue;
- if (bone.boneLength !== part.bone.boneLength) part.surfaceDirty = true;
part.bone = bone;
}
}
- setTrackers(trackers: Map) {
- for (const part of this.parts) {
- const tracker = trackers.get(part.bone.bodyPart);
- if (
- tracker?.trackerId !== part.tracker?.trackerId ||
- tracker?.boneOffset !== part.tracker?.boneOffset ||
- (tracker &&
- part.tracker &&
- tracker.mountingOrientation.angleTo(part.tracker.mountingOrientation) > 1e-6)
- ) {
- part.surfaceDirty = true;
- }
- part.tracker = tracker;
- if (!part.tracker && part.marker) part.marker.visible = false;
- }
- }
-
updateMatrixWorld(force: boolean) {
for (const part of this.parts) {
const { bone, shapes } = part;
@@ -278,49 +188,6 @@ export class BasedSkeletonMeshHelper extends Object3D {
if (config.rotation) tilt.quaternion.copy(config.rotation);
}
-
- if (part.tracker) {
- if (!part.marker) {
- part.marker = new Mesh(
- this.trackerMarkerGeometry,
- this.trackerMarkerMaterial
- );
- this.add(part.marker);
- }
-
- part.marker.visible = true;
- part.marker.scale.setScalar(getTrackerMarkerScale(bone.bodyPart));
- part.marker.quaternion.copy(quat).multiply(part.tracker.mountingOrientation);
- part.marker.position.copy(position);
- const anchor = SKELETON_PART_PRESETS[bone.bodyPart]?.trackerAnchor;
- const anchored =
- anchor && shapes[0] && shapeAnchor(shapes[0], anchor, localOffset);
- if (!anchored) {
- localOffset.set(0, -boneLength * part.tracker.boneOffset, 0);
- }
- localOffset.applyQuaternion(quat);
- part.marker.position.add(localOffset);
- mountingNormal.set(0, 0, 1).applyQuaternion(part.marker.quaternion);
- if (part.surfaceDirty) {
- // The mesh and marker move rigidly with the bone, so the surface
- // distance only changes when mounting or mesh-shape inputs change.
- for (const { node } of shapes) node.updateMatrixWorld(true);
- rayOrigin.copy(part.marker.position).applyMatrix4(this.matrixWorld);
- rayDirection.copy(mountingNormal).transformDirection(this.matrixWorld);
- surfaceRaycaster.set(rayOrigin, rayDirection);
- // The last hit is the outermost surface: the marker starts inside the
- // shape, and a plate's inner face comes before its outer one.
- part.surfaceDistance =
- surfaceRaycaster
- .intersectObjects(
- shapes.map(({ node }) => node),
- true
- )
- .at(-1)?.distance ?? 0;
- part.surfaceDirty = false;
- }
- part.marker.position.addScaledVector(mountingNormal, part.surfaceDistance);
- }
}
super.updateMatrixWorld(force);
@@ -328,8 +195,6 @@ export class BasedSkeletonMeshHelper extends Object3D {
dispose() {
this.disposed = true;
- this.trackerMarkerGeometry.dispose();
- this.trackerMarkerMaterial.dispose();
for (const part of this.parts) {
for (const attached of part.shapes) {
this.remove(attached.node);
diff --git a/gui/app/src/utils/skeletonParts.ts b/gui/app/src/utils/skeletonParts.ts
index 7814f8046..af5c63873 100644
--- a/gui/app/src/utils/skeletonParts.ts
+++ b/gui/app/src/utils/skeletonParts.ts
@@ -151,14 +151,6 @@ export interface BoneShapeConfig {
export interface BonePartConfig {
visible: boolean;
shapes: BoneShapeConfig[];
- /** Where an assigned tracker sits from this bone's head (0) to tail (1). */
- trackerOffset?: number;
- /**
- * Where the marker starts inside the part's first shape, in the bone's own
- * axes: -1 to 1 on each, 0 at the shape's centre. Used instead of
- * `trackerOffset` for bones whose length doesn't span their shape.
- */
- trackerAnchor?: Vector3;
}
export const shape = (overrides: Partial = {}): BoneShapeConfig => ({
@@ -245,26 +237,13 @@ const footScale: ShapeScale = {
const footOffset: ShapeOffset = ({ boneLength, proportions }) =>
new Vector3(0, -0.1 * boneLength, -0.1 * proportions.bodyScale);
-const CHEST_TRACKER_OFFSET = 0.2;
-const WAIST_TRACKER_OFFSET = 0.8;
-const HIP_TRACKER_OFFSET = 0.75;
-const UPPER_ARM_TRACKER_OFFSET = 0.75;
-const LOWER_ARM_TRACKER_OFFSET = 0.15;
-const UPPER_LEG_TRACKER_OFFSET = 0.7;
-const LOWER_LEG_TRACKER_OFFSET = 0.75;
-
-const FOOT_MARKER: Partial = {
- trackerAnchor: new Vector3(0, -0.3, 0),
-};
-
export const SKELETON_PART_PRESETS: Record = {
[BodyPart.NONE]: part(shape(), { visible: false }),
[BodyPart.HEAD]: part(
model('head', {
scale: headScale,
offset: headOffset,
- }),
- { trackerAnchor: new Vector3(0, 0.2, 0) }
+ })
),
[BodyPart.NECK]: part(
model('neck', {
@@ -292,29 +271,25 @@ export const SKELETON_PART_PRESETS: Record = {
depth: 0.95,
}),
offset: inBoneLengths({ length: -0.1 }),
- }),
- { trackerOffset: CHEST_TRACKER_OFFSET }
+ })
),
[BodyPart.UPPER_WAIST]: part(
model('upper_waist', {
scale: spanBone({ girthFrom: 'hips', length: 0.9, width: 0.95, depth: 0.9 }),
offset: inBoneLengths({ length: 0.3 }),
- }),
- { trackerOffset: WAIST_TRACKER_OFFSET }
+ })
),
[BodyPart.LOWER_WAIST]: part(
model('lower_waist', {
scale: spanBone({ girthFrom: 'hips', length: 0.85, width: 0.95, depth: 0.9 }),
offset: inBoneLengths({ length: 0.1 }),
- }),
- { trackerOffset: WAIST_TRACKER_OFFSET }
+ })
),
[BodyPart.HIP]: part(
model('hip', {
scale: spanBone({ girthFrom: 'hips', width: 1, depth: 1, length: 1 }),
offset: inBoneLengths({ length: -1.6 }),
- }),
- { trackerOffset: HIP_TRACKER_OFFSET }
+ })
),
[BodyPart.LEFT_SHOULDER]: part(
model('shoulder', {
@@ -328,19 +303,13 @@ export const SKELETON_PART_PRESETS: Record = {
offset: inBoneLengths({ width: -0.075 }),
})
),
- [BodyPart.LEFT_UPPER_ARM]: part(model('upper_arm', { scale: upperArmScale }), {
- trackerOffset: UPPER_ARM_TRACKER_OFFSET,
- }),
+ [BodyPart.LEFT_UPPER_ARM]: part(model('upper_arm', { scale: upperArmScale })),
[BodyPart.RIGHT_UPPER_ARM]: part(
- model('upper_arm', { scale: otherSide(upperArmScale) }),
- { trackerOffset: UPPER_ARM_TRACKER_OFFSET }
+ model('upper_arm', { scale: otherSide(upperArmScale) })
),
- [BodyPart.LEFT_LOWER_ARM]: part(model('lower_arm', { scale: lowerArmScale }), {
- trackerOffset: LOWER_ARM_TRACKER_OFFSET,
- }),
+ [BodyPart.LEFT_LOWER_ARM]: part(model('lower_arm', { scale: lowerArmScale })),
[BodyPart.RIGHT_LOWER_ARM]: part(
- model('lower_arm', { scale: otherSide(lowerArmScale) }),
- { trackerOffset: LOWER_ARM_TRACKER_OFFSET }
+ model('lower_arm', { scale: otherSide(lowerArmScale) })
),
[BodyPart.LEFT_HAND]: part(
model('hand', {
@@ -355,42 +324,35 @@ export const SKELETON_PART_PRESETS: Record = {
})
),
- [BodyPart.LEFT_UPPER_LEG]: part(model('upper_leg', { scale: upperLegScale }), {
- trackerOffset: UPPER_LEG_TRACKER_OFFSET,
- }),
+ [BodyPart.LEFT_UPPER_LEG]: part(model('upper_leg', { scale: upperLegScale })),
[BodyPart.RIGHT_UPPER_LEG]: part(
- model('upper_leg', { scale: otherSide(upperLegScale) }),
- { trackerOffset: UPPER_LEG_TRACKER_OFFSET }
+ model('upper_leg', { scale: otherSide(upperLegScale) })
),
[BodyPart.LEFT_LOWER_LEG]: part(
model('lower_leg', {
scale: lowerLegScale,
offset: inBoneLengths({ depth: -0.0 }),
- }),
- { trackerOffset: LOWER_LEG_TRACKER_OFFSET }
+ })
),
[BodyPart.RIGHT_LOWER_LEG]: part(
model('lower_leg', {
scale: otherSide(lowerLegScale),
offset: inBoneLengths({ depth: -0.0 }),
- }),
- { trackerOffset: LOWER_LEG_TRACKER_OFFSET }
+ })
),
[BodyPart.LEFT_FOOT]: part(
model('foot', {
offset: footOffset,
scale: footScale,
rotation: turn({ width: -42 }),
- }),
- FOOT_MARKER
+ })
),
[BodyPart.RIGHT_FOOT]: part(
model('foot', {
offset: footOffset,
scale: otherSide(footScale),
rotation: turn({ width: -42 }),
- }),
- FOOT_MARKER
+ })
),
[BodyPart.LEFT_THUMB_METACARPAL]: finger('thumb_metacarpal'),
@@ -437,10 +399,6 @@ export const SKELETON_PART_PRESETS: Record = {
[BodyPart.RIGHT_LITTLE_TOE]: toeRight('little_toe'),
};
-export function getTrackerBoneOffset(bodyPart: BodyPart) {
- return SKELETON_PART_PRESETS[bodyPart]?.trackerOffset ?? 0.5;
-}
-
const DEFAULT_SCALE = spanBone();
export function computeShapeScale(
diff --git a/package.json b/package.json
index 0ff193497..2e3bf708a 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "slimevr",
"version": "0.0.0",
"private": true,
- "packageManager": "pnpm@10.33.0",
+ "packageManager": "pnpm@12.3.4",
"workspaces": [
"solarxr-protocol",
"gui/app",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1c681a28e..ecd1f15ae 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1,3 +1,104 @@
+---
+lockfileVersion: '9.0'
+
+importers:
+
+ .:
+ configDependencies: {}
+ packageManagerDependencies:
+ pnpm:
+ specifier: 12.3.4
+ version: 12.3.4
+
+packages:
+
+ '@pnpm/exe.darwin-arm64@12.3.4':
+ resolution: {integrity: sha512-PAyUol8T1+/+ViOiXAt51ECA+QnfXCqz6foL4bW+LsoX0NcVd5XVEM2mRQu+LV4oc7uRz9zf9U0P+XFfuQeDAw==}
+ cpu: [arm64]
+ os: [darwin]
+
+ '@pnpm/exe.darwin-x64@12.3.4':
+ resolution: {integrity: sha512-fxP9JCk0Cdye+ePuj+GJJLMUMTqHGWRdb1dtv4How876uQ2ehxvenpgiYAir/ceO9PsYUZkFTtyZdx+rRu5QOA==}
+ cpu: [x64]
+ os: [darwin]
+
+ '@pnpm/exe.linux-arm64-musl@12.3.4':
+ resolution: {integrity: sha512-FBOt0/7ye6O6q4AllVV5QMviB6qE6fqkeczV/+MDWQsmo+QJrlfsh6X7CpH/tClVpBZEyIbjpUoT8bNhCYBxEg==}
+ cpu: [arm64]
+ os: [linux]
+ libc: [musl]
+
+ '@pnpm/exe.linux-arm64@12.3.4':
+ resolution: {integrity: sha512-t71AVA7LRqiKTyZ5xMYaZc2n5DfdpMbfokZuiIOXHBOM03ECnF0t4iYwaBDqJgVjlKYUOwaF/bRQajGNA4cJ4w==}
+ cpu: [arm64]
+ os: [linux]
+ libc: [glibc]
+
+ '@pnpm/exe.linux-x64-musl@12.3.4':
+ resolution: {integrity: sha512-RPmk7Jb/aYaFvL2iyDN/AtMY+hUEsue732WmXpcuQ9tBpMnGyA5py7Z3+e+qmQaJ0zY/4ni9jJiyPBQHujmv6w==}
+ cpu: [x64]
+ os: [linux]
+ libc: [musl]
+
+ '@pnpm/exe.linux-x64@12.3.4':
+ resolution: {integrity: sha512-2ZqOlSPkfwX1h5cR+FPiWf8+F+2hZT/3TvhUK5sigHqwaQCIiq8R7CGxhndKs63JtcLi2a1Qpo+wX/EoyfjyJQ==}
+ cpu: [x64]
+ os: [linux]
+ libc: [glibc]
+
+ '@pnpm/exe.win32-arm64@12.3.4':
+ resolution: {integrity: sha512-ANyrHqyqco6SXBysUTRF74itDyyraea7IbFsKFdNXTjcFnfycTDx37EwuhdpPYFNSIh2JhUG4fByclsRfiHX7w==}
+ cpu: [arm64]
+ os: [win32]
+
+ '@pnpm/exe.win32-x64@12.3.4':
+ resolution: {integrity: sha512-WH/KqBPY/hq2Tb7SgQltEZytimcjgKRaCRL/aM9CI0c67iKc5TVmHUhIiL3Ux9FB4bWn36i6XewUcScQI+zG8w==}
+ cpu: [x64]
+ os: [win32]
+
+ pnpm@12.3.4:
+ resolution: {integrity: sha512-lhqkH7B32joEpEHZ+OFevAyW2o73ELLrZ7+e58sGEOq9SPH9hfUc/+c4RnhfoPh8VqOocqHYk/hEZ0G1zORUVw==}
+ engines: {node: '>=18.*'}
+ hasBin: true
+
+snapshots:
+
+ '@pnpm/exe.darwin-arm64@12.3.4':
+ optional: true
+
+ '@pnpm/exe.darwin-x64@12.3.4':
+ optional: true
+
+ '@pnpm/exe.linux-arm64-musl@12.3.4':
+ optional: true
+
+ '@pnpm/exe.linux-arm64@12.3.4':
+ optional: true
+
+ '@pnpm/exe.linux-x64-musl@12.3.4':
+ optional: true
+
+ '@pnpm/exe.linux-x64@12.3.4':
+ optional: true
+
+ '@pnpm/exe.win32-arm64@12.3.4':
+ optional: true
+
+ '@pnpm/exe.win32-x64@12.3.4':
+ optional: true
+
+ pnpm@12.3.4:
+ optionalDependencies:
+ '@pnpm/exe.darwin-arm64': 12.3.4
+ '@pnpm/exe.darwin-x64': 12.3.4
+ '@pnpm/exe.linux-arm64': 12.3.4
+ '@pnpm/exe.linux-arm64-musl': 12.3.4
+ '@pnpm/exe.linux-x64': 12.3.4
+ '@pnpm/exe.linux-x64-musl': 12.3.4
+ '@pnpm/exe.win32-arm64': 12.3.4
+ '@pnpm/exe.win32-x64': 12.3.4
+
+---
lockfileVersion: '9.0'
settings:
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index db34cf1cc..18a571f43 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -5,12 +5,10 @@ packages:
- "gui/shared"
- "!solarxr-protocol/lib/flatbuffers/**"
-onlyBuiltDependencies:
- - '@parcel/watcher'
- - '@sentry/cli'
- - '@swc/core'
- - 'electron'
- - 'electron-winstaller'
- - 'esbuild'
- - 'register-scheme'
- - 'unrs-resolver'
+allowBuilds:
+ '@parcel/watcher': true
+ '@sentry/cli': true
+ '@swc/core': true
+ electron-winstaller: true
+ esbuild: true
+ unrs-resolver: true
diff --git a/server/core/src/main/java/dev/slimevr/config/settings.kt b/server/core/src/main/java/dev/slimevr/config/settings.kt
index 39ac44678..a5cfcc320 100644
--- a/server/core/src/main/java/dev/slimevr/config/settings.kt
+++ b/server/core/src/main/java/dev/slimevr/config/settings.kt
@@ -102,8 +102,8 @@ data class ResetsConfig(
val saveMountingReset: Boolean = false,
/** Reset a reliable reference's (HMD) attitude on full reset */
val resetReliableReferenceAttitude: Boolean = false,
- /** How a mounting reset calibrates the trackers */
- val mountingMethod: MountingMethod = MountingMethod.POSE,
+ /** How a mounting reset calibrates the trackers, UNKNOWN until the user has picked one */
+ val mountingMethod: MountingMethod = MountingMethod.UNKNOWN,
)
@Serializable
diff --git a/server/core/src/main/java/dev/slimevr/resets/module.kt b/server/core/src/main/java/dev/slimevr/resets/module.kt
index 0c12c90d0..1864f6ebe 100644
--- a/server/core/src/main/java/dev/slimevr/resets/module.kt
+++ b/server/core/src/main/java/dev/slimevr/resets/module.kt
@@ -104,8 +104,8 @@ class ResetsManager(
*/
suspend fun scheduleReset(resetSourceName: String, resetType: ResetType, delay: Float = 0f, bodyParts: List? = null) {
val method = settings.context.state.value.data.resetsConfig.mountingMethod.takeIf { resetType == ResetType.MOUNTING }
- if (method == MountingMethod.MANUAL) {
- AppLogger.resets.info("Ignoring mounting reset from $resetSourceName: the mounting method is manual")
+ if (method == MountingMethod.UNKNOWN || method == MountingMethod.MANUAL) {
+ AppLogger.resets.info("Ignoring mounting reset from $resetSourceName: the mounting method is $method")
return
}
val availability = availability(resetType)
diff --git a/server/core/src/main/java/dev/slimevr/solarxr/rpc/tracking-checklist.kt b/server/core/src/main/java/dev/slimevr/solarxr/rpc/tracking-checklist.kt
index daa6cd537..5fae9d336 100644
--- a/server/core/src/main/java/dev/slimevr/solarxr/rpc/tracking-checklist.kt
+++ b/server/core/src/main/java/dev/slimevr/solarxr/rpc/tracking-checklist.kt
@@ -23,6 +23,7 @@ private val CHECKLIST_STEP_ORDER: List = listOf(
TrackingChecklistStepId.TRACKER_ERROR,
TrackingChecklistStepId.TRACKERS_REST_CALIBRATION,
TrackingChecklistStepId.FULL_RESET,
+ TrackingChecklistStepId.MOUNTING_METHOD,
TrackingChecklistStepId.MOUNTING_CALIBRATION,
TrackingChecklistStepId.FEET_MOUNTING_CALIBRATION,
TrackingChecklistStepId.UNASSIGNED_RELIABLE_REFERENCE,
diff --git a/server/core/src/main/java/dev/slimevr/trackingchecklist/behaviours.kt b/server/core/src/main/java/dev/slimevr/trackingchecklist/behaviours.kt
index d7debeb48..c06cee91a 100644
--- a/server/core/src/main/java/dev/slimevr/trackingchecklist/behaviours.kt
+++ b/server/core/src/main/java/dev/slimevr/trackingchecklist/behaviours.kt
@@ -356,7 +356,7 @@ class MountingCalibrationCheckBehaviour(
bodyPart !in ResetBodyParts.FINGERS &&
bodyPart !in ResetBodyParts.TOES
- MountingMethod.MANUAL -> false
+ MountingMethod.MANUAL, MountingMethod.UNKNOWN -> false
}
override fun observe(receiver: TrackingChecklist) {
@@ -378,6 +378,29 @@ class MountingCalibrationCheckBehaviour(
}
}
+class MountingMethodCheckBehaviour(
+ private val settings: Settings,
+) : TrackingChecklistBehaviourType {
+ override fun observe(receiver: TrackingChecklist) {
+ settings.context.state.map { it.data.resetsConfig.mountingMethod != MountingMethod.UNKNOWN }
+ .distinctUntilChanged()
+ .onEach { picked ->
+ receiver.context.dispatch(
+ TrackingChecklistActions.UpdateStep(
+ TrackingChecklistStepId.MOUNTING_METHOD,
+ TrackingChecklistStep(
+ valid = picked,
+ enabled = !picked,
+ ignorable = false,
+ visibility = TrackingChecklistStepVisibility.WHEN_INVALID,
+ ),
+ ),
+ )
+ }
+ .launchIn(receiver.context.scope)
+ }
+}
+
// The feet need their own pose mounting reset, unless the step mounting calibrates them or the
// pose mounting reset is forced to include them
class FeetMountingCalibrationCheckBehaviour(
diff --git a/server/core/src/main/java/dev/slimevr/trackingchecklist/module.kt b/server/core/src/main/java/dev/slimevr/trackingchecklist/module.kt
index 839702c74..7709b4752 100644
--- a/server/core/src/main/java/dev/slimevr/trackingchecklist/module.kt
+++ b/server/core/src/main/java/dev/slimevr/trackingchecklist/module.kt
@@ -32,6 +32,7 @@ class TrackingChecklist(
add(ReliableReferenceCheckBehaviour(trackerStates))
add(TrackerRestCheckBehaviour(trackerStates))
add(FullResetCheckBehaviour(trackerStates))
+ add(MountingMethodCheckBehaviour(appContext.config.settings))
add(MountingCalibrationCheckBehaviour(trackerStates, appContext.config.settings))
add(TrackerErrorCheckBehaviour(trackerStates))
add(SteamVRHandsCheckBehaviour(trackerStates, appContext.server, appContext.boneRouting))
diff --git a/server/core/src/test/java/dev/slimevr/resets/ResetsTest.kt b/server/core/src/test/java/dev/slimevr/resets/ResetsTest.kt
index d43a7b862..4ac37aebf 100644
--- a/server/core/src/test/java/dev/slimevr/resets/ResetsTest.kt
+++ b/server/core/src/test/java/dev/slimevr/resets/ResetsTest.kt
@@ -83,4 +83,18 @@ class ResetsTest {
assertEquals(ResetAvailability.NO_TRACKERS, resets.availability(ResetType.YAW))
assertEquals(ResetAvailability.NO_TRACKERS, resets.availability(ResetType.MOUNTING))
}
+
+ @Test
+ fun `a mounting reset is ignored until a mounting method is picked`() = runTest {
+ val server = buildTestVrServer(backgroundScope)
+ val settings = buildTestSettings(backgroundScope)
+ val resets = buildTestResetsManager(server, settings, backgroundScope)
+ val tracker = buildTestTracker(server.context.scope, buildTestAppContext(server), settings, id = 1, bodyPart = BodyPart.HIP, status = TrackerStatus.OK)
+ server.context.dispatch(VRServerActions.NewTracker(1, tracker))
+ resets.context.dispatch(ResetsActions.EndReset(ResetType.FULL))
+
+ resets.scheduleReset("test", ResetType.MOUNTING)
+ runCurrent()
+ assertEquals(null, resets.context.state.value.status)
+ }
}
diff --git a/server/core/src/test/java/dev/slimevr/trackingchecklist/TrackingChecklistTest.kt b/server/core/src/test/java/dev/slimevr/trackingchecklist/TrackingChecklistTest.kt
index 0072c165c..6c1b511f5 100644
--- a/server/core/src/test/java/dev/slimevr/trackingchecklist/TrackingChecklistTest.kt
+++ b/server/core/src/test/java/dev/slimevr/trackingchecklist/TrackingChecklistTest.kt
@@ -58,8 +58,10 @@ class TrackingChecklistTest {
.stateIn(scope.backgroundScope, SharingStarted.Eagerly, initialValue = emptyList())
init {
+ setMountingMethod(MountingMethod.POSE)
checklist.context.behaviours.addAll(
listOf(
+ MountingMethodCheckBehaviour(settings),
ReliableReferenceCheckBehaviour(trackerStates),
TrackerRestCheckBehaviour(trackerStates),
TrackerErrorCheckBehaviour(trackerStates),
@@ -227,6 +229,25 @@ class TrackingChecklistTest {
assertEquals(false, h.step(TrackingChecklistStepId.MOUNTING_CALIBRATION).valid)
}
+ @Test
+ fun `a mounting method is asked for until one is picked`() = runTest {
+ val h = Harness(this)
+ h.settings.context.dispatch(SettingsActions.Update { copy(resetsConfig = resetsConfig.copy(mountingMethod = MountingMethod.UNKNOWN)) })
+ h.addTracker(bodyPart = BodyPart.LOWER_CHEST)
+ h.addTracker(bodyPart = BodyPart.LEFT_FOOT)
+ runCurrent()
+
+ assertEquals(true, h.step(TrackingChecklistStepId.MOUNTING_METHOD).enabled)
+ assertEquals(false, h.step(TrackingChecklistStepId.MOUNTING_METHOD).valid)
+ assertEquals(false, h.step(TrackingChecklistStepId.MOUNTING_CALIBRATION).enabled)
+ assertEquals(false, h.step(TrackingChecklistStepId.FEET_MOUNTING_CALIBRATION).enabled)
+
+ h.setMountingMethod(MountingMethod.POSE)
+ runCurrent()
+ assertEquals(false, h.step(TrackingChecklistStepId.MOUNTING_METHOD).enabled)
+ assertEquals(true, h.step(TrackingChecklistStepId.MOUNTING_CALIBRATION).enabled)
+ }
+
@Test
fun `a step mounting calibrates the feet too`() = runTest {
val h = Harness(this)