🚀 Auto-deploy: melhoria no snap e medição AR em 30/05/2026 10:30:57

This commit is contained in:
2026-05-30 10:30:57 +00:00
parent 5a08868b83
commit b6912bd070
+7 -3
View File
@@ -1,5 +1,6 @@
import { useRef, ReactNode, useEffect } from 'react'; import { useRef, ReactNode, useEffect } from 'react';
import { useFrame } from '@react-three/fiber'; import { useFrame } from '@react-three/fiber';
import { useXR } from '@react-three/xr';
import * as THREE from 'three'; import * as THREE from 'three';
import { useControllerGrab, ControllerGrabSnapshot } from '@/hooks/useControllerGrab'; import { useControllerGrab, ControllerGrabSnapshot } from '@/hooks/useControllerGrab';
import { useModelStore } from '@/stores/useModelStore'; import { useModelStore } from '@/stores/useModelStore';
@@ -57,6 +58,7 @@ const _tmpQuat = new THREE.Quaternion();
export function XRGrabbable({ allowScale = true, lockedActive = false, onGrabStart, children }: XRGrabbableProps) { export function XRGrabbable({ allowScale = true, lockedActive = false, onGrabStart, children }: XRGrabbableProps) {
const groupRef = useRef<THREE.Group>(null); const groupRef = useRef<THREE.Group>(null);
const grab = useControllerGrab(); const grab = useControllerGrab();
const session = useXR((s) => s.session);
const single = useRef<SingleGrabRecord | null>(null); const single = useRef<SingleGrabRecord | null>(null);
const dual = useRef<DualGrabRecord | null>(null); const dual = useRef<DualGrabRecord | null>(null);
@@ -74,9 +76,10 @@ export function XRGrabbable({ allowScale = true, lockedActive = false, onGrabSta
}, [scaleResetNonce]); }, [scaleResetNonce]);
useEffect(() => { useEffect(() => {
activeModelGroupRef.current = groupRef.current; const currentGroup = groupRef.current;
activeModelGroupRef.current = currentGroup;
return () => { return () => {
if (activeModelGroupRef.current === groupRef.current) { if (activeModelGroupRef.current === currentGroup) {
activeModelGroupRef.current = null; activeModelGroupRef.current = null;
} }
}; };
@@ -232,7 +235,8 @@ export function XRGrabbable({ allowScale = true, lockedActive = false, onGrabSta
} }
// Rotação Y via analógico do controle ativo // 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) { if (gp && gp.axes.length >= 4) {
const stickX = gp.axes[2]; // horizontal do thumbstick const stickX = gp.axes[2]; // horizontal do thumbstick
const deadzone = 0.15; const deadzone = 0.15;