fix hand tracking glove rendering
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useHandTrackingSnapshot } from "@/hooks/handTracking/useHandTrackingSnapshot";
|
||||
import { useHandTrackingGloveStatus } from "@/hooks/handTracking/useHandTrackingGloveStatus";
|
||||
|
||||
const HAND_CONNECTIONS: Array<[number, number]> = [
|
||||
[0, 1],
|
||||
@@ -26,8 +27,12 @@ const HAND_CONNECTIONS: Array<[number, number]> = [
|
||||
|
||||
export function HandTrackingVisualizer(): React.JSX.Element | null {
|
||||
const { hands, status } = useHandTrackingSnapshot();
|
||||
const gloves = useHandTrackingGloveStatus((state) => state.gloves);
|
||||
const shouldShowSvgFallback = Object.values(gloves).some(
|
||||
(gloveStatus) => gloveStatus === "error" || gloveStatus === "idle",
|
||||
);
|
||||
|
||||
if (status === "idle" || hands.length === 0) {
|
||||
if (status === "idle" || hands.length === 0 || !shouldShowSvgFallback) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useHandTrackingSnapshot } from "@/hooks/handTracking/useHandTrackingSnapshot";
|
||||
import { useHandTrackingGloveStatus } from "@/hooks/handTracking/useHandTrackingGloveStatus";
|
||||
import type { HandTrackingStatus } from "@/types/handTracking/handTracking";
|
||||
|
||||
const STATUS_LABELS: Record<HandTrackingStatus, string> = {
|
||||
@@ -15,22 +16,23 @@ const STATUS_LABELS: Record<HandTrackingStatus, string> = {
|
||||
export function HandTrackingDebugPanel(): React.JSX.Element | null {
|
||||
const { hands, status, usageStatus, serverStatus, error } =
|
||||
useHandTrackingSnapshot();
|
||||
const gloves = useHandTrackingGloveStatus((state) => state.gloves);
|
||||
|
||||
if (status === "idle") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const fist = hands.some((hand) => hand.isFist);
|
||||
const hasLeftHand = hands.some(
|
||||
(hand) => hand.handedness.toLowerCase() === "left",
|
||||
);
|
||||
const hasRightHand = hands.some(
|
||||
(hand) => hand.handedness.toLowerCase() === "right",
|
||||
);
|
||||
const modelLoaded =
|
||||
[hasLeftHand ? "gant_l" : null, hasRightHand ? "gant_r" : null]
|
||||
[
|
||||
gloves.left === "loaded" ? "gant_l" : null,
|
||||
gloves.right === "loaded" ? "gant_r" : null,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(", ") || "none";
|
||||
const modelFallback = Object.values(gloves).some(
|
||||
(gloveStatus) => gloveStatus === "error",
|
||||
);
|
||||
|
||||
return (
|
||||
<section
|
||||
@@ -51,6 +53,10 @@ export function HandTrackingDebugPanel(): React.JSX.Element | null {
|
||||
<dt>Model loaded</dt>
|
||||
<dd>{modelLoaded}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>SVG fallback</dt>
|
||||
<dd>{modelFallback ? "yes" : "no"}</dd>
|
||||
</div>
|
||||
{serverStatus ? (
|
||||
<div>
|
||||
<dt>Server</dt>
|
||||
|
||||
Reference in New Issue
Block a user