update: enable hand tracking for repair steps (not only when we are close to something)
This commit is contained in:
@@ -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
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user