fix(lab): AR Passthrough — prop isAR no ARBackground pra evitar background preto permanente

This commit is contained in:
Hermes
2026-08-05 00:16:48 +00:00
parent f54efbf734
commit 3f01190559
+17 -13
View File
@@ -314,16 +314,19 @@ const PhysicsScene = ({
// =================================================================== // ===================================================================
// SCENE WRAPPER — junta o Canvas + R3F // SCENE WRAPPER — junta o Canvas + R3F
// =================================================================== // ===================================================================
const SceneContent = ({ locked, resetSignal }: { locked: boolean; resetSignal: number }) => ( const SceneContent = ({ locked, resetSignal }: { locked: boolean; resetSignal: number }) => {
<> // Detecta modo AR para ajustar iluminação e fundo
{/* Em modo AR Passthrough, NÃO pinta cor de fundo — ela veda o passthrough */} const session = useXR((s) => s.session);
{/* Em modo desktop (fora do XR), pinta fundo escuro pra não ficar transparente estranho */} const isAR = !!(session && (session as any).environmentBlendMode === "additive");
<ARBackground />
<ambientLight intensity={0.6} /> return (
<>
<ARBackground isAR={isAR} />
<ambientLight intensity={isAR ? 1.2 : 0.6} />
<directionalLight <directionalLight
position={[5, 5, 5]} position={[5, 5, 5]}
intensity={1.2} intensity={isAR ? 1.5 : 1.2}
castShadow castShadow
shadow-mapSize={[1024, 1024]} shadow-mapSize={[1024, 1024]}
/> />
@@ -349,7 +352,6 @@ const SceneContent = ({ locked, resetSignal }: { locked: boolean; resetSignal: n
<PhysicsScene locked={locked} resetSignal={resetSignal} /> <PhysicsScene locked={locked} resetSignal={resetSignal} />
{/* Controles pra visualização fora do XR (mouse) */}
<OrbitControls <OrbitControls
makeDefault makeDefault
target={[0, 0.5, 0]} target={[0, 0.5, 0]}
@@ -359,14 +361,16 @@ const SceneContent = ({ locked, resetSignal }: { locked: boolean; resetSignal: n
/> />
</> </>
); );
};
// =================================================================== // ===================================================================
// FUNDO DINÂMICO — VR imersivo fica preto; AR Passthrough fica transparente // FUNDO DINÂMICO — Recebe prop isAR para evitar montagem/desmontagem
// =================================================================== // ===================================================================
const ARBackground = () => { const ARBackground = ({ isAR }: { isAR: boolean }) => {
const session = useXR((s) => s.session); // Em AR Passthrough: nada (canal alpha fica livre pra passthrough)
const isAR = session && "environmentBlendMode" in session && (session as any).environmentBlendMode === "additive"; if (isAR) return null;
if (isAR) return null; // AR = transparente (mostra passthrough do Quest 3)
// Fora de AR (modo desktop ou VR): fundo preto
return ( return (
<> <>
<color attach="background" args={["#0a0a0a"]} /> <color attach="background" args={["#0a0a0a"]} />