From b6912bd07038fffea278236f081af2928da857e8 Mon Sep 17 00:00:00 2001 From: admtracksteel Date: Sat, 30 May 2026 10:30:57 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Auto-deploy:=20melhoria=20no=20s?= =?UTF-8?q?nap=20e=20medi=C3=A7=C3=A3o=20AR=20em=2030/05/2026=2010:30:57?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/three/XRGrabbable.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/three/XRGrabbable.tsx b/src/components/three/XRGrabbable.tsx index a565099..5fa624c 100644 --- a/src/components/three/XRGrabbable.tsx +++ b/src/components/three/XRGrabbable.tsx @@ -1,5 +1,6 @@ import { useRef, ReactNode, useEffect } from 'react'; import { useFrame } from '@react-three/fiber'; +import { useXR } from '@react-three/xr'; import * as THREE from 'three'; import { useControllerGrab, ControllerGrabSnapshot } from '@/hooks/useControllerGrab'; import { useModelStore } from '@/stores/useModelStore'; @@ -57,6 +58,7 @@ const _tmpQuat = new THREE.Quaternion(); export function XRGrabbable({ allowScale = true, lockedActive = false, onGrabStart, children }: XRGrabbableProps) { const groupRef = useRef(null); const grab = useControllerGrab(); + const session = useXR((s) => s.session); const single = useRef(null); const dual = useRef(null); @@ -74,9 +76,10 @@ export function XRGrabbable({ allowScale = true, lockedActive = false, onGrabSta }, [scaleResetNonce]); useEffect(() => { - activeModelGroupRef.current = groupRef.current; + const currentGroup = groupRef.current; + activeModelGroupRef.current = currentGroup; return () => { - if (activeModelGroupRef.current === groupRef.current) { + if (activeModelGroupRef.current === currentGroup) { activeModelGroupRef.current = null; } }; @@ -232,7 +235,8 @@ export function XRGrabbable({ allowScale = true, lockedActive = false, onGrabSta } // Rotação Y via analógico do controle ativo - const gp = slot.gamepad; + const inputSource = session?.inputSources ? Array.from(session.inputSources).find(s => s.handedness === activeHand) : null; + const gp = inputSource?.gamepad; if (gp && gp.axes.length >= 4) { const stickX = gp.axes[2]; // horizontal do thumbstick const deadzone = 0.15;