🚀 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 * as THREE from 'three';
|
||||||
import { useModelStore } from '@/stores/useModelStore';
|
import { useModelStore } from '@/stores/useModelStore';
|
||||||
import { toast } from 'sonner';
|
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 { Button } from '@/components/ui/button';
|
||||||
import { generateMarkerDownloadURL } from '@/lib/trackingMarker';
|
import { generateMarkerDownloadURL } from '@/lib/trackingMarker';
|
||||||
import { XRHud } from '@/components/XRHud';
|
import { XRHud } from '@/components/XRHud';
|
||||||
@@ -1069,11 +1069,13 @@ const XRSession = () => {
|
|||||||
session.addEventListener('end', () => {
|
session.addEventListener('end', () => {
|
||||||
console.log('[XR] ❌ Sessão AR encerrada');
|
console.log('[XR] ❌ Sessão AR encerrada');
|
||||||
setInXR(false);
|
setInXR(false);
|
||||||
|
setHasClickedEnter(false);
|
||||||
|
navigate('/viewer');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return unsubscribe;
|
return unsubscribe;
|
||||||
}, [inXR, setAnchorMode]);
|
}, [inXR, setAnchorMode, navigate]);
|
||||||
|
|
||||||
// Flag que indica que o usuário pediu para entrar no AR (enterAR chamado).
|
// 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.
|
// 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');
|
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;
|
if (!model) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -1315,6 +1303,7 @@ const XRSession = () => {
|
|||||||
<div className="flex flex-col gap-3 pt-2">
|
<div className="flex flex-col gap-3 pt-2">
|
||||||
<Button
|
<Button
|
||||||
className="h-12 text-sm font-semibold glow-primary w-full gap-2 text-primary-foreground"
|
className="h-12 text-sm font-semibold glow-primary w-full gap-2 text-primary-foreground"
|
||||||
|
disabled={hasClickedEnter}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
setHasClickedEnter(true);
|
setHasClickedEnter(true);
|
||||||
try {
|
try {
|
||||||
@@ -1326,8 +1315,8 @@ const XRSession = () => {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Glasses className="h-5 w-5 animate-bounce" />
|
{hasClickedEnter ? <Loader2 className="h-5 w-5 animate-spin" /> : <Glasses className="h-5 w-5 animate-bounce" />}
|
||||||
Iniciar Visualização AR
|
{hasClickedEnter ? 'Aguardando Permissão AR...' : 'Iniciar Visualização AR'}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Reference in New Issue
Block a user