🚀 Auto-deploy: melhoria no snap e medição AR em 29/05/2026 20:46:55
This commit is contained in:
@@ -153,6 +153,11 @@ export function XRControllerMeasure() {
|
||||
xrCalibration.step === 'await-real-2' ||
|
||||
xrCalibration.step === 'await-real-3');
|
||||
|
||||
const isVirtualStep = xrCalibration.alignType === 'virt-real' &&
|
||||
(xrCalibration.step === 'await-virtual-1' ||
|
||||
xrCalibration.step === 'await-virtual-2' ||
|
||||
xrCalibration.step === 'await-virtual-3');
|
||||
|
||||
if (session && right && !hitTestRequestedRef.current && isAligning) {
|
||||
hitTestRequestedRef.current = true;
|
||||
session.requestHitTestSource({ space: right.targetRaySpace })
|
||||
@@ -298,37 +303,42 @@ export function XRControllerMeasure() {
|
||||
|
||||
// ── Update laser visual ───────────────────────────────────────────
|
||||
if (laserRef.current && tipRef.current) {
|
||||
const end = isRealStep
|
||||
? realHitPoint
|
||||
: (snappedPoint ?? tmpOrigin.current.clone().add(tmpDir.current.clone().multiplyScalar(MAX_RAY)));
|
||||
|
||||
const positions = laserGeom.current.attributes.position as THREE.BufferAttribute;
|
||||
positions.setXYZ(0, tmpOrigin.current.x, tmpOrigin.current.y, tmpOrigin.current.z);
|
||||
positions.setXYZ(1, end.x, end.y, end.z);
|
||||
positions.needsUpdate = true;
|
||||
laserGeom.current.computeBoundingSphere();
|
||||
|
||||
const color = isAligning
|
||||
? '#eab308' // dourado para alinhamento Virt/Real
|
||||
: (selectionMode ? '#a855f7' : (snapKind === 'hole' ? '#f59e0b' : snapKind === 'vertex' ? '#22c55e' : snapKind === 'edge' ? '#3b82f6' : '#eab308'));
|
||||
|
||||
tipColor.current.set(color);
|
||||
(laserRef.current.material as THREE.LineBasicMaterial).color.set(color);
|
||||
((tipRef.current.material as THREE.MeshBasicMaterial)).color.copy(tipColor.current);
|
||||
|
||||
laserRef.current.visible = true;
|
||||
|
||||
const tipPos = isRealStep ? realHitPoint : snappedPoint;
|
||||
if (tipPos) {
|
||||
tipRef.current.visible = true;
|
||||
tipRef.current.position.copy(tipPos);
|
||||
const dist = tmpOrigin.current.distanceTo(tipPos);
|
||||
const strongSnap = isAligning || snapKind === 'vertex' || snapKind === 'edge' || snapKind === 'hole';
|
||||
const factor = strongSnap ? 0.030 : 0.012;
|
||||
const s = Math.max(strongSnap ? 0.010 : 0.004, dist * factor);
|
||||
tipRef.current.scale.setScalar(s);
|
||||
} else {
|
||||
if (isVirtualStep) {
|
||||
laserRef.current.visible = false;
|
||||
tipRef.current.visible = false;
|
||||
} else {
|
||||
const end = isRealStep
|
||||
? realHitPoint
|
||||
: (snappedPoint ?? tmpOrigin.current.clone().add(tmpDir.current.clone().multiplyScalar(MAX_RAY)));
|
||||
|
||||
const positions = laserGeom.current.attributes.position as THREE.BufferAttribute;
|
||||
positions.setXYZ(0, tmpOrigin.current.x, tmpOrigin.current.y, tmpOrigin.current.z);
|
||||
positions.setXYZ(1, end.x, end.y, end.z);
|
||||
positions.needsUpdate = true;
|
||||
laserGeom.current.computeBoundingSphere();
|
||||
|
||||
const color = isAligning
|
||||
? '#eab308' // dourado para alinhamento Virt/Real
|
||||
: (selectionMode ? '#a855f7' : (snapKind === 'hole' ? '#f59e0b' : snapKind === 'vertex' ? '#22c55e' : snapKind === 'edge' ? '#3b82f6' : '#eab308'));
|
||||
|
||||
tipColor.current.set(color);
|
||||
(laserRef.current.material as THREE.LineBasicMaterial).color.set(color);
|
||||
((tipRef.current.material as THREE.MeshBasicMaterial)).color.copy(tipColor.current);
|
||||
|
||||
laserRef.current.visible = true;
|
||||
|
||||
const tipPos = isRealStep ? realHitPoint : snappedPoint;
|
||||
if (tipPos) {
|
||||
tipRef.current.visible = true;
|
||||
tipRef.current.position.copy(tipPos);
|
||||
const dist = tmpOrigin.current.distanceTo(tipPos);
|
||||
const strongSnap = isAligning || snapKind === 'vertex' || snapKind === 'edge' || snapKind === 'hole';
|
||||
const factor = strongSnap ? 0.030 : 0.012;
|
||||
const s = Math.max(strongSnap ? 0.010 : 0.004, dist * factor);
|
||||
tipRef.current.scale.setScalar(s);
|
||||
} else {
|
||||
tipRef.current.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user