From c926c55499ef948b21cb64fb50e791161cb6685c Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Tue, 12 May 2026 10:41:09 +0000 Subject: [PATCH] Changes Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com> --- src/pages/XRSession.tsx | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/pages/XRSession.tsx b/src/pages/XRSession.tsx index db9c001..77bbc85 100644 --- a/src/pages/XRSession.tsx +++ b/src/pages/XRSession.tsx @@ -338,6 +338,59 @@ function XRGrid() { // ImageTrackingAnchor removed — replaced by XRHitTestPlacement +// ─── XR Debug HUD (floats in front of viewer) ────────── +// Shows live grip/trigger values and isGrabbing state per hand. +// Essential for diagnosing grab issues without external monitoring. +function XRDebugHud() { + const session = useXR((s) => s.session); + const groupRef = useRef(null); + const { camera } = useThree(); + const [text, setText] = useState('XR aguardando inputs...'); + + useFrame(() => { + if (!groupRef.current) return; + // Anchor the HUD to a fixed offset in front of the camera + const offset = new THREE.Vector3(-0.25, -0.18, -0.6).applyQuaternion(camera.quaternion); + groupRef.current.position.copy(camera.position).add(offset); + groupRef.current.quaternion.copy(camera.quaternion); + + if (!session) return; + const sources = Array.from(session.inputSources); + const lines: string[] = [`inputs: ${sources.length}`]; + for (const src of sources) { + const gp = src.gamepad; + const grip = gp?.buttons[2]; + const trig = gp?.buttons[1]; + const gv = grip ? (grip.value || (grip.pressed ? 1 : 0)) : 0; + const tv = trig ? (trig.value || (trig.pressed ? 1 : 0)) : 0; + const grabbing = gv > 0.7 ? 'GRAB' : gv > 0.3 ? '...' : ' '; + lines.push(`${src.handedness.padEnd(5)} grip:${gv.toFixed(2)} trg:${tv.toFixed(2)} ${grabbing}`); + } + setText(lines.join('\n')); + }); + + return ( + + + + + + + {text} + + + ); +} + + // ─── XRSession Page ──────────────────────────────────── const XRSession = () => { const navigate = useNavigate();