Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -338,6 +338,59 @@ function XRGrid() {
|
|||||||
|
|
||||||
// ImageTrackingAnchor removed — replaced by XRHitTestPlacement
|
// 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<THREE.Group>(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 (
|
||||||
|
<group ref={groupRef}>
|
||||||
|
<mesh position={[0, 0, -0.001]}>
|
||||||
|
<planeGeometry args={[0.32, 0.10]} />
|
||||||
|
<meshBasicMaterial color="#000000" transparent opacity={0.55} depthWrite={false} />
|
||||||
|
</mesh>
|
||||||
|
<Text
|
||||||
|
fontSize={0.012}
|
||||||
|
color="#22c55e"
|
||||||
|
anchorX="left"
|
||||||
|
anchorY="top"
|
||||||
|
position={[-0.155, 0.045, 0]}
|
||||||
|
maxWidth={0.30}
|
||||||
|
lineHeight={1.25}
|
||||||
|
>
|
||||||
|
{text}
|
||||||
|
</Text>
|
||||||
|
</group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ─── XRSession Page ────────────────────────────────────
|
// ─── XRSession Page ────────────────────────────────────
|
||||||
const XRSession = () => {
|
const XRSession = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|||||||
Reference in New Issue
Block a user