update: enable hand tracking for repair steps (not only when we are close to something)

This commit is contained in:
Tom Boullay
2026-05-08 01:30:27 +01:00
parent c9db2637a6
commit 719f799515
3 changed files with 42 additions and 9 deletions
@@ -8,6 +8,14 @@ import {
} from "@/hooks/handTracking/useHandTrackingSnapshot";
import { useBrowserHandTracking } from "@/hooks/handTracking/useBrowserHandTracking";
import { useRemoteHandTracking } from "@/hooks/handTracking/useRemoteHandTracking";
import { useGameStore } from "@/managers/stores/useGameStore";
import type { MissionStep } from "@/managers/stores/useGameStore";
const REPAIR_HAND_TRACKING_STEPS = new Set<MissionStep>([
"inspected",
"repairing",
"done",
]);
export function HandTrackingProvider({
children,
@@ -18,8 +26,23 @@ export function HandTrackingProvider({
const handTrackingSource = useDebugStore((debug) =>
debug.getHandTrackingSource(),
);
const repairNeedsHands = useGameStore((state) => {
switch (state.mainState) {
case "bike":
return REPAIR_HAND_TRACKING_STEPS.has(state.bike.currentStep);
case "pylone":
return REPAIR_HAND_TRACKING_STEPS.has(state.pylone.currentStep);
case "ferme":
return REPAIR_HAND_TRACKING_STEPS.has(state.ferme.currentStep);
case "intro":
case "outro":
return false;
}
});
const { nearby, holding, handHolding } = useInteraction();
const enabled = sceneMode === "physics" && (nearby || holding || handHolding);
const enabled =
repairNeedsHands ||
(sceneMode === "physics" && (nearby || holding || handHolding));
const backendSnapshot = useRemoteHandTracking({
enabled: enabled && handTrackingSource === "backend",
});
+6 -3
View File
@@ -7,6 +7,7 @@ import {
} from "@/data/player/playerConfig";
import { useCameraMode } from "@/hooks/debug/useCameraMode";
import { useSceneMode } from "@/hooks/debug/useSceneMode";
import { useHandTrackingSnapshot } from "@/hooks/handTracking/useHandTrackingSnapshot";
import { DebugCameraControls } from "@/components/debug/scene/DebugCameraControls";
import { DebugHelpers } from "@/components/debug/scene/DebugHelpers";
import { HandTrackingGlove } from "@/components/three/handTracking/HandTrackingGlove";
@@ -21,25 +22,28 @@ import { TestMap } from "@/world/debug/TestMap";
export function World(): React.JSX.Element {
const cameraMode = useCameraMode();
const sceneMode = useSceneMode();
const { status, usageStatus } = useHandTrackingSnapshot();
const [octree, setOctree] = useState<Octree | null>(null);
const playerSpawnPosition =
sceneMode === "game"
? PLAYER_SPAWN_POSITION_GAME
: PLAYER_SPAWN_POSITION_PHYSICS;
const showHandTrackingGloves =
sceneMode === "physics" ||
(status !== "idle" && usageStatus !== "inactive");
return (
<>
<Environment />
<Lighting />
<DebugHelpers />
{sceneMode === "physics" ? (
{showHandTrackingGloves ? (
<>
<HandTrackingGlove handedness="left" />
<HandTrackingGlove handedness="right" />
</>
) : null}
{cameraMode === "debug" ? <DebugCameraControls /> : null}
{sceneMode === "game" ? (
<>
<GameMusic />
@@ -51,7 +55,6 @@ export function World(): React.JSX.Element {
) : (
<TestMap onOctreeReady={setOctree} />
)}
{cameraMode !== "debug" ? (
<Player octree={octree} spawnPosition={playerSpawnPosition} />
) : null}