🚀 Auto-deploy: melhoria no snap e medição AR em 10/06/2026 20:53:22
This commit is contained in:
+7
-18
@@ -7,7 +7,7 @@ import { xrStore as store } from '@/stores/useXRStore';
|
||||
import * as THREE from 'three';
|
||||
import { useModelStore } from '@/stores/useModelStore';
|
||||
import { toast } from 'sonner';
|
||||
import { ArrowLeft, Download, QrCode, Crosshair, Home, Glasses } from 'lucide-react';
|
||||
import { ArrowLeft, Download, QrCode, Crosshair, Home, Glasses, Loader2 } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { generateMarkerDownloadURL } from '@/lib/trackingMarker';
|
||||
import { XRHud } from '@/components/XRHud';
|
||||
@@ -1069,11 +1069,13 @@ const XRSession = () => {
|
||||
session.addEventListener('end', () => {
|
||||
console.log('[XR] ❌ Sessão AR encerrada');
|
||||
setInXR(false);
|
||||
setHasClickedEnter(false);
|
||||
navigate('/viewer');
|
||||
});
|
||||
}
|
||||
});
|
||||
return unsubscribe;
|
||||
}, [inXR, setAnchorMode]);
|
||||
}, [inXR, setAnchorMode, navigate]);
|
||||
|
||||
// Flag que indica que o usuário pediu para entrar no AR (enterAR chamado).
|
||||
// Usada para bloquear o auto-return durante o onboarding do WebXR.
|
||||
@@ -1099,20 +1101,6 @@ const XRSession = () => {
|
||||
toast.success('Marcador baixado — Imprima em 15×15cm');
|
||||
}, []);
|
||||
|
||||
// Auto-return to viewer if user exits AR session
|
||||
useEffect(() => {
|
||||
// Don't auto-return while we're waiting for the XR onboarding dialog to complete
|
||||
if (hasClickedEnter && !inXR) {
|
||||
const timer = setTimeout(() => {
|
||||
// Only return if the session is truly absent AND we're not in the middle of entering AR
|
||||
if (!store.getState().session) {
|
||||
navigate('/viewer');
|
||||
}
|
||||
}, 2000);
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
}, [inXR, hasClickedEnter, navigate]);
|
||||
|
||||
if (!model) return null;
|
||||
|
||||
return (
|
||||
@@ -1315,6 +1303,7 @@ const XRSession = () => {
|
||||
<div className="flex flex-col gap-3 pt-2">
|
||||
<Button
|
||||
className="h-12 text-sm font-semibold glow-primary w-full gap-2 text-primary-foreground"
|
||||
disabled={hasClickedEnter}
|
||||
onClick={async () => {
|
||||
setHasClickedEnter(true);
|
||||
try {
|
||||
@@ -1326,8 +1315,8 @@ const XRSession = () => {
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Glasses className="h-5 w-5 animate-bounce" />
|
||||
Iniciar Visualização AR
|
||||
{hasClickedEnter ? <Loader2 className="h-5 w-5 animate-spin" /> : <Glasses className="h-5 w-5 animate-bounce" />}
|
||||
{hasClickedEnter ? 'Aguardando Permissão AR...' : 'Iniciar Visualização AR'}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
|
||||
Reference in New Issue
Block a user