🚀 Auto-deploy: melhoria no snap e medição AR em 04/08/2026 20:11:57
This commit is contained in:
+36
-37
@@ -7,6 +7,7 @@ import {
|
|||||||
Environment,
|
Environment,
|
||||||
PerspectiveCamera,
|
PerspectiveCamera,
|
||||||
} from "@react-three/drei";
|
} from "@react-three/drei";
|
||||||
|
import { XR, createXRStore } from "@react-three/xr";
|
||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
import {
|
import {
|
||||||
Beaker,
|
Beaker,
|
||||||
@@ -38,6 +39,10 @@ const CUBE_SIZE = 1;
|
|||||||
|
|
||||||
type AlignPhase = 'IDLE' | 'WAIT_SURFACE' | 'WAIT_FACE2' | 'WAIT_EDGE';
|
type AlignPhase = 'IDLE' | 'WAIT_SURFACE' | 'WAIT_FACE2' | 'WAIT_EDGE';
|
||||||
|
|
||||||
|
const store = createXRStore({
|
||||||
|
controller: { left: true, right: true },
|
||||||
|
});
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
// COMPONENTE: CuboControlado
|
// COMPONENTE: CuboControlado
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
@@ -274,16 +279,8 @@ const QuestCubeLab = () => {
|
|||||||
setAlignPhase('IDLE');
|
setAlignPhase('IDLE');
|
||||||
};
|
};
|
||||||
|
|
||||||
const enterXR = async () => {
|
const enterXR = () => {
|
||||||
try {
|
store.enterAR();
|
||||||
const xr = (navigator as Navigator & { xr?: { requestSession: (mode: string) => Promise<unknown> } })?.xr;
|
|
||||||
if (!xr) return;
|
|
||||||
const session = await xr.requestSession("immersive-ar");
|
|
||||||
void session;
|
|
||||||
alert("XR session requisitada.");
|
|
||||||
} catch (e) {
|
|
||||||
alert("Falha ao entrar em XR: " + (e as Error).message);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSurfaceClick = (point: THREE.Vector3, normal: THREE.Vector3) => {
|
const handleSurfaceClick = (point: THREE.Vector3, normal: THREE.Vector3) => {
|
||||||
@@ -415,34 +412,36 @@ const QuestCubeLab = () => {
|
|||||||
|
|
||||||
<div style={{ height: 600 }}>
|
<div style={{ height: 600 }}>
|
||||||
<Canvas shadows>
|
<Canvas shadows>
|
||||||
<PerspectiveCamera makeDefault position={[3, 4, 6]} fov={50} />
|
<XR store={store}>
|
||||||
<ambientLight intensity={0.5} />
|
<PerspectiveCamera makeDefault position={[3, 4, 6]} fov={50} />
|
||||||
<directionalLight position={[5, 8, 5]} intensity={1} castShadow shadow-mapSize-width={1024} shadow-mapSize-height={1024} />
|
<ambientLight intensity={0.5} />
|
||||||
|
<directionalLight position={[5, 8, 5]} intensity={1} castShadow shadow-mapSize-width={1024} shadow-mapSize-height={1024} />
|
||||||
<CubeControlado
|
|
||||||
posRef={posRef}
|
<CubeControlado
|
||||||
rotRef={rotRef}
|
posRef={posRef}
|
||||||
scaleRef={scaleRef}
|
rotRef={rotRef}
|
||||||
lockedRef={lockedRef}
|
scaleRef={scaleRef}
|
||||||
gamepadRef={gamepadRef}
|
lockedRef={lockedRef}
|
||||||
alignPhase={alignPhase}
|
gamepadRef={gamepadRef}
|
||||||
setAlignPhase={setAlignPhase}
|
alignPhase={alignPhase}
|
||||||
face1Ref={face1Ref}
|
setAlignPhase={setAlignPhase}
|
||||||
face2Ref={face2Ref}
|
face1Ref={face1Ref}
|
||||||
/>
|
face2Ref={face2Ref}
|
||||||
|
/>
|
||||||
<Table
|
|
||||||
onSurfaceClick={handleSurfaceClick}
|
<Table
|
||||||
onEdgeClick={handleEdgeClick}
|
onSurfaceClick={handleSurfaceClick}
|
||||||
/>
|
onEdgeClick={handleEdgeClick}
|
||||||
|
/>
|
||||||
|
|
||||||
<Grid args={[20, 20]} cellSize={0.25} cellThickness={0.5} cellColor="#475569" sectionSize={1} sectionThickness={1} sectionColor="#94a3b8" fadeDistance={18} fadeStrength={1} infiniteGrid={false} position={[0, 0, 0]} />
|
<Grid args={[20, 20]} cellSize={0.25} cellThickness={0.5} cellColor="#475569" sectionSize={1} sectionThickness={1} sectionColor="#94a3b8" fadeDistance={18} fadeStrength={1} infiniteGrid={false} position={[0, 0, 0]} />
|
||||||
<mesh receiveShadow rotation={[-Math.PI / 2, 0, 0]} position={[0, -0.001, 0]}>
|
<mesh receiveShadow rotation={[-Math.PI / 2, 0, 0]} position={[0, -0.001, 0]}>
|
||||||
<planeGeometry args={[20, 20]} />
|
<planeGeometry args={[20, 20]} />
|
||||||
<shadowMaterial transparent opacity={0.35} />
|
<shadowMaterial transparent opacity={0.35} />
|
||||||
</mesh>
|
</mesh>
|
||||||
<OrbitControls makeDefault enableDamping />
|
<OrbitControls makeDefault enableDamping />
|
||||||
<Environment preset="city" />
|
<Environment preset="city" />
|
||||||
|
</XR>
|
||||||
</Canvas>
|
</Canvas>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user