🚀 Auto-deploy: melhoria no snap e medição AR em 30/05/2026 10:28:12

This commit is contained in:
2026-05-30 10:28:12 +00:00
parent 7ff4ed3176
commit 5a08868b83
3 changed files with 136 additions and 15 deletions
+47 -12
View File
@@ -34,6 +34,7 @@ import {
pushXRRealPoint,
pushXRVirtualPoint,
computeVirtRealTransform,
activeModelGroupRef,
} from '@/components/three/xrCalibrationBus';
// --- Diagnóstico XR ---
@@ -973,20 +974,54 @@ function XRVirtRealDesktopAligner() {
function XRGrid() {
const showGrid = useModelStore((s) => s.showGrid);
const gridY = useModelStore((s) => s.gridY);
const activeModelId = useModelStore((s) => s.activeModelId);
const activeModel = useModelStore((s) => s.models.find(m => m.id === activeModelId));
const groupRef = useRef<THREE.Group>(null);
useFrame(() => {
if (!showGrid || !groupRef.current) return;
let px = 0;
let pz = 0;
let ry = 0;
if (activeModelGroupRef.current) {
const g = activeModelGroupRef.current;
const wp = new THREE.Vector3();
g.getWorldPosition(wp);
px = wp.x;
pz = wp.z;
const wq = new THREE.Quaternion();
g.getWorldQuaternion(wq);
const euler = new THREE.Euler().setFromQuaternion(wq, 'YXZ');
ry = euler.y;
} else if (activeModel) {
px = activeModel.fineTuning.posX;
pz = activeModel.fineTuning.posZ;
ry = (activeModel.fineTuning.rotY * Math.PI) / 180;
}
groupRef.current.position.set(px, gridY, pz);
groupRef.current.rotation.set(0, ry, 0);
});
if (!showGrid) return null;
return (
<Grid
position={[0, gridY, 0]}
infiniteGrid
cellSize={0.01}
sectionSize={0.1}
cellThickness={0.5}
sectionThickness={1}
cellColor="#334155"
sectionColor="#475569"
fadeDistance={5}
fadeStrength={1}
/>
<group ref={groupRef}>
<Grid
infiniteGrid
cellSize={0.01}
sectionSize={0.1}
cellThickness={0.5}
sectionThickness={1}
cellColor="#334155"
sectionColor="#475569"
fadeDistance={5}
fadeStrength={1}
/>
</group>
);
}