fix(lab): AR Passthrough — prop isAR no ARBackground pra evitar background preto permanente
This commit is contained in:
+56
-52
@@ -314,59 +314,63 @@ 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 */}
|
|
||||||
{/* Em modo desktop (fora do XR), pinta fundo escuro pra não ficar transparente estranho */}
|
|
||||||
<ARBackground />
|
|
||||||
|
|
||||||
<ambientLight intensity={0.6} />
|
|
||||||
<directionalLight
|
|
||||||
position={[5, 5, 5]}
|
|
||||||
intensity={1.2}
|
|
||||||
castShadow
|
|
||||||
shadow-mapSize={[1024, 1024]}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Grid estilo HLA — funciona em ambos os modos */}
|
|
||||||
<Grid
|
|
||||||
position={[0, 0.001, 0]}
|
|
||||||
args={[20, 20]}
|
|
||||||
cellSize={0.25}
|
|
||||||
cellThickness={0.5}
|
|
||||||
cellColor="#334155"
|
|
||||||
sectionSize={1}
|
|
||||||
sectionThickness={1}
|
|
||||||
sectionColor="#64748b"
|
|
||||||
fadeDistance={12}
|
|
||||||
fadeStrength={1.5}
|
|
||||||
infiniteGrid
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Suspense fallback={null}>
|
|
||||||
<Environment preset="warehouse" />
|
|
||||||
</Suspense>
|
|
||||||
|
|
||||||
<PhysicsScene locked={locked} resetSignal={resetSignal} />
|
|
||||||
|
|
||||||
{/* Controles pra visualização fora do XR (mouse) */}
|
|
||||||
<OrbitControls
|
|
||||||
makeDefault
|
|
||||||
target={[0, 0.5, 0]}
|
|
||||||
enablePan={true}
|
|
||||||
minDistance={1}
|
|
||||||
maxDistance={10}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
|
|
||||||
// ===================================================================
|
|
||||||
// FUNDO DINÂMICO — VR imersivo fica preto; AR Passthrough fica transparente
|
|
||||||
// ===================================================================
|
|
||||||
const ARBackground = () => {
|
|
||||||
const session = useXR((s) => s.session);
|
const session = useXR((s) => s.session);
|
||||||
const isAR = session && "environmentBlendMode" in session && (session as any).environmentBlendMode === "additive";
|
const isAR = !!(session && (session as any).environmentBlendMode === "additive");
|
||||||
if (isAR) return null; // AR = transparente (mostra passthrough do Quest 3)
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ARBackground isAR={isAR} />
|
||||||
|
|
||||||
|
<ambientLight intensity={isAR ? 1.2 : 0.6} />
|
||||||
|
<directionalLight
|
||||||
|
position={[5, 5, 5]}
|
||||||
|
intensity={isAR ? 1.5 : 1.2}
|
||||||
|
castShadow
|
||||||
|
shadow-mapSize={[1024, 1024]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Grid estilo HLA — funciona em ambos os modos */}
|
||||||
|
<Grid
|
||||||
|
position={[0, 0.001, 0]}
|
||||||
|
args={[20, 20]}
|
||||||
|
cellSize={0.25}
|
||||||
|
cellThickness={0.5}
|
||||||
|
cellColor="#334155"
|
||||||
|
sectionSize={1}
|
||||||
|
sectionThickness={1}
|
||||||
|
sectionColor="#64748b"
|
||||||
|
fadeDistance={12}
|
||||||
|
fadeStrength={1.5}
|
||||||
|
infiniteGrid
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Suspense fallback={null}>
|
||||||
|
<Environment preset="warehouse" />
|
||||||
|
</Suspense>
|
||||||
|
|
||||||
|
<PhysicsScene locked={locked} resetSignal={resetSignal} />
|
||||||
|
|
||||||
|
<OrbitControls
|
||||||
|
makeDefault
|
||||||
|
target={[0, 0.5, 0]}
|
||||||
|
enablePan={true}
|
||||||
|
minDistance={1}
|
||||||
|
maxDistance={10}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// ===================================================================
|
||||||
|
// FUNDO DINÂMICO — Recebe prop isAR para evitar montagem/desmontagem
|
||||||
|
// ===================================================================
|
||||||
|
const ARBackground = ({ isAR }: { isAR: boolean }) => {
|
||||||
|
// Em AR Passthrough: nada (canal alpha fica livre pra passthrough)
|
||||||
|
if (isAR) return null;
|
||||||
|
|
||||||
|
// Fora de AR (modo desktop ou VR): fundo preto
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<color attach="background" args={["#0a0a0a"]} />
|
<color attach="background" args={["#0a0a0a"]} />
|
||||||
|
|||||||
Reference in New Issue
Block a user