Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-05-21 21:38:42 +00:00
parent da9399305e
commit de11c4e119
+9 -5
View File
@@ -149,18 +149,20 @@ export function XRControllerMeasure() {
snappedPoint = bestHoleCenter; snappedPoint = bestHoleCenter;
snapKind = 'hole'; snapKind = 'hole';
} else if (snapEnabled) { } else if (snapEnabled) {
// Try detecting a circular edge (hole) at hit // Try detecting a circular edge (hole) at hit — radius mais generoso
const circle = detectCircularEdgeAtPoint(hit.object, hit.point, fakeCam, canvasSize, 60); const circle = detectCircularEdgeAtPoint(hit.object, hit.point, fakeCam, canvasSize, 90);
if (circle) { if (circle) {
snappedPoint = circle.center; snappedPoint = circle.center;
snapKind = 'hole'; snapKind = 'hole';
hoverDetected = { kind: 'hole', value: circle.diameterMM, position: circle.center }; hoverDetected = { kind: 'hole', value: circle.diameterMM, position: circle.center };
} else { } else {
const snap = resolveSnap(hit.object, hit.point, fakeCam, canvasSize, 14, 18); // Snap mais "magnético": raios maiores de busca em pixels
// vértice: 32px (antes 14), aresta: 48px (antes 18)
const snap = resolveSnap(hit.object, hit.point, fakeCam, canvasSize, 32, 48);
snappedPoint = snap.point; snappedPoint = snap.point;
snapKind = snap.type; snapKind = snap.type;
if (snap.type === 'edge') { if (snap.type === 'edge') {
const seg = findNearestEdgeSegment(hit.object, hit.point, fakeCam, canvasSize, 18); const seg = findNearestEdgeSegment(hit.object, hit.point, fakeCam, canvasSize, 48);
if (seg) { if (seg) {
const lenMM = seg.a.distanceTo(seg.b) * 1000; const lenMM = seg.a.distanceTo(seg.b) * 1000;
hoverDetected = { kind: 'edge', value: lenMM, position: seg.midpoint, endpoints: { a: seg.a, b: seg.b } }; hoverDetected = { kind: 'edge', value: lenMM, position: seg.midpoint, endpoints: { a: seg.a, b: seg.b } };
@@ -172,7 +174,9 @@ export function XRControllerMeasure() {
snapKind = 'surface'; snapKind = 'surface';
} }
} }
// Cache for non-heavy frames so the laser + trigger still have a target // Cache for non-heavy frames so the laser + trigger still have a target.
// Sticky: se conseguimos um snap "forte" (vertex/edge/hole), preservamos
// ele entre frames leves para evitar cintilação.
cachedSnappedPoint.current = snappedPoint ? snappedPoint.clone() : null; cachedSnappedPoint.current = snappedPoint ? snappedPoint.clone() : null;
cachedSnapKind.current = snapKind; cachedSnapKind.current = snapKind;
} else { } else {