add hand tracking source debug switch
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { useSceneMode } from "@/hooks/debug/useSceneMode";
|
||||
import { useDebugStore } from "@/hooks/debug/useDebugStore";
|
||||
import { useInteraction } from "@/hooks/interaction/useInteraction";
|
||||
import {
|
||||
HAND_TRACKING_IDLE_SNAPSHOT,
|
||||
HandTrackingContext,
|
||||
} from "@/hooks/handTracking/useHandTrackingSnapshot";
|
||||
import { useBrowserHandTracking } from "@/hooks/handTracking/useBrowserHandTracking";
|
||||
import { useRemoteHandTracking } from "@/hooks/handTracking/useRemoteHandTracking";
|
||||
|
||||
export function HandTrackingProvider({
|
||||
@@ -13,9 +15,19 @@ export function HandTrackingProvider({
|
||||
children: ReactNode;
|
||||
}): React.JSX.Element {
|
||||
const sceneMode = useSceneMode();
|
||||
const handTrackingSource = useDebugStore((debug) =>
|
||||
debug.getHandTrackingSource(),
|
||||
);
|
||||
const { nearby, holding, handHolding } = useInteraction();
|
||||
const enabled = sceneMode === "physics" && (nearby || holding || handHolding);
|
||||
const snapshot = useRemoteHandTracking({ enabled });
|
||||
const backendSnapshot = useRemoteHandTracking({
|
||||
enabled: enabled && handTrackingSource === "backend",
|
||||
});
|
||||
const browserSnapshot = useBrowserHandTracking({
|
||||
enabled: enabled && handTrackingSource === "browser",
|
||||
});
|
||||
const snapshot =
|
||||
handTrackingSource === "browser" ? browserSnapshot : backendSnapshot;
|
||||
|
||||
return (
|
||||
<HandTrackingContext
|
||||
|
||||
Reference in New Issue
Block a user