From cff4935705adcc6ca58aa401b093ee7f55510b8e 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:40:46 +0000 Subject: [PATCH 1/5] Changes Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com> --- src/pages/XRSession.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/XRSession.tsx b/src/pages/XRSession.tsx index 672120c..90756aa 100644 --- a/src/pages/XRSession.tsx +++ b/src/pages/XRSession.tsx @@ -1,8 +1,8 @@ import { useEffect, useRef, useMemo, useCallback, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { Canvas, useFrame, useThree } from '@react-three/fiber'; -import { useGLTF, Grid, Html, Line } from '@react-three/drei'; -import { XR, createXRStore, useXR, XROrigin } from '@react-three/xr'; +import { useGLTF, Grid, Html, Line, OrbitControls, Text } from '@react-three/drei'; +import { XR, createXRStore, useXR, XROrigin, useXRInputSourceStateContext } from '@react-three/xr'; import * as THREE from 'three'; import { useModelStore } from '@/stores/useModelStore'; import { toast } from 'sonner'; From 71d0d36b368f207d9bf28e6c0d9e28e79c9337fe 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:40:53 +0000 Subject: [PATCH 2/5] Changes Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com> --- src/pages/XRSession.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/XRSession.tsx b/src/pages/XRSession.tsx index 90756aa..db9c001 100644 --- a/src/pages/XRSession.tsx +++ b/src/pages/XRSession.tsx @@ -2,7 +2,7 @@ import { useEffect, useRef, useMemo, useCallback, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { Canvas, useFrame, useThree } from '@react-three/fiber'; import { useGLTF, Grid, Html, Line, OrbitControls, Text } from '@react-three/drei'; -import { XR, createXRStore, useXR, XROrigin, useXRInputSourceStateContext } from '@react-three/xr'; +import { XR, createXRStore, useXR, XROrigin } from '@react-three/xr'; import * as THREE from 'three'; import { useModelStore } from '@/stores/useModelStore'; import { toast } from 'sonner'; 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 3/5] 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(); From f5d2591fbfdd94e54a818a3aa55c9007ca2d8469 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:29 +0000 Subject: [PATCH 4/5] Changes Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com> --- src/pages/XRSession.tsx | 61 ++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/src/pages/XRSession.tsx b/src/pages/XRSession.tsx index 77bbc85..d87b200 100644 --- a/src/pages/XRSession.tsx +++ b/src/pages/XRSession.tsx @@ -491,28 +491,51 @@ const XRSession = () => { - { - setPlacementMode(false); - toast.success('Modelo posicionado na superfície!'); - }} - > - { - if (placementMode) setPlacementMode(false); - }} - > - - - + {inXR ? ( + <> + {/* In XR: hit-test placement → grab wrapper → model */} + { + setPlacementMode(false); + toast.success('Modelo posicionado na superfície!'); + }} + > + { + if (placementMode) setPlacementMode(false); + }} + > + + + + + + + + + ) : ( + <> + {/* Desktop preview (no headset): show model with OrbitControls */} + + + + + + + )} - - From ea509a0cbf912ae412002c6b8fdaac91c814a3c5 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:42 +0000 Subject: [PATCH 5/5] Changes Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com> --- src/pages/XRSession.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/XRSession.tsx b/src/pages/XRSession.tsx index d87b200..c68431e 100644 --- a/src/pages/XRSession.tsx +++ b/src/pages/XRSession.tsx @@ -475,7 +475,7 @@ const XRSession = () => {
{ gl.setPixelRatio(Math.min(window.devicePixelRatio, 1.5));