From 1d788cdca32e5016360eebbfe6159d54926410df Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 24 May 2026 19:17:21 +0000 Subject: [PATCH] Changes Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com> --- src/components/three/XRControllerMeasure.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/three/XRControllerMeasure.tsx b/src/components/three/XRControllerMeasure.tsx index d90cbe4..ffb0dff 100644 --- a/src/components/three/XRControllerMeasure.tsx +++ b/src/components/three/XRControllerMeasure.tsx @@ -130,6 +130,7 @@ export function XRControllerMeasure() { let snapKind: 'vertex' | 'edge' | 'surface' | 'hole' = 'surface'; let hoverDetected: { kind: 'hole' | 'edge'; value: number; position: THREE.Vector3; modelId?: string; endpoints?: { a: THREE.Vector3; b: THREE.Vector3 } } | null = null; let hitModelId: string | undefined; + const nowT = performance.now(); const hits = raycaster.current.intersectObjects(scene.children, true); const hit = hits.find((h) => { @@ -190,16 +191,16 @@ export function XRControllerMeasure() { } } - const strongSnap = snapKind === 'vertex' || snapKind === 'edge' || snapKind === 'hole'; - if (snappedPoint && strongSnap) { + const strongSnapKind = snapKind === 'vertex' || snapKind === 'edge' || snapKind === 'hole' ? snapKind : null; + if (snappedPoint && strongSnapKind) { const locked = lockedSnap.current; - const sameTarget = locked && locked.kind === snapKind && locked.modelId === hitModelId; + const sameTarget = locked && locked.kind === strongSnapKind && locked.modelId === hitModelId; if (sameTarget && locked.point.distanceTo(snappedPoint) < (snapKind === 'edge' ? 0.08 : 0.12)) { if (snapKind === 'edge') locked.point.lerp(snappedPoint, 0.25); snappedPoint = locked.point.clone(); locked.lastSeen = nowT; } else { - lockedSnap.current = { point: snappedPoint.clone(), kind: snapKind, modelId: hitModelId, lastSeen: nowT }; + lockedSnap.current = { point: snappedPoint.clone(), kind: strongSnapKind, modelId: hitModelId, lastSeen: nowT }; } } else if (snappedPoint && lockedSnap.current && lockedSnap.current.point.distanceTo(snappedPoint) < 0.12 && nowT - lockedSnap.current.lastSeen < 600) { snapKind = lockedSnap.current.kind; @@ -211,7 +212,6 @@ export function XRControllerMeasure() { // ── Dwell detection (1 s) to auto-register hovered hole/edge ───── const measureModeNow = useModelStore.getState().measureMode; - const nowT = performance.now(); if (snappedPoint && hoverDetected) { const dist = dwellPos.current.distanceTo(snappedPoint); if (dist > 0.005) {