🚀 Auto-deploy: melhoria no snap e medição AR em 30/05/2026 10:28:12
This commit is contained in:
+47
-12
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user