Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -130,6 +130,7 @@ export function XRControllerMeasure() {
|
|||||||
let snapKind: 'vertex' | 'edge' | 'surface' | 'hole' = 'surface';
|
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 hoverDetected: { kind: 'hole' | 'edge'; value: number; position: THREE.Vector3; modelId?: string; endpoints?: { a: THREE.Vector3; b: THREE.Vector3 } } | null = null;
|
||||||
let hitModelId: string | undefined;
|
let hitModelId: string | undefined;
|
||||||
|
const nowT = performance.now();
|
||||||
|
|
||||||
const hits = raycaster.current.intersectObjects(scene.children, true);
|
const hits = raycaster.current.intersectObjects(scene.children, true);
|
||||||
const hit = hits.find((h) => {
|
const hit = hits.find((h) => {
|
||||||
@@ -190,16 +191,16 @@ export function XRControllerMeasure() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const strongSnap = snapKind === 'vertex' || snapKind === 'edge' || snapKind === 'hole';
|
const strongSnapKind = snapKind === 'vertex' || snapKind === 'edge' || snapKind === 'hole' ? snapKind : null;
|
||||||
if (snappedPoint && strongSnap) {
|
if (snappedPoint && strongSnapKind) {
|
||||||
const locked = lockedSnap.current;
|
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 (sameTarget && locked.point.distanceTo(snappedPoint) < (snapKind === 'edge' ? 0.08 : 0.12)) {
|
||||||
if (snapKind === 'edge') locked.point.lerp(snappedPoint, 0.25);
|
if (snapKind === 'edge') locked.point.lerp(snappedPoint, 0.25);
|
||||||
snappedPoint = locked.point.clone();
|
snappedPoint = locked.point.clone();
|
||||||
locked.lastSeen = nowT;
|
locked.lastSeen = nowT;
|
||||||
} else {
|
} 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) {
|
} else if (snappedPoint && lockedSnap.current && lockedSnap.current.point.distanceTo(snappedPoint) < 0.12 && nowT - lockedSnap.current.lastSeen < 600) {
|
||||||
snapKind = lockedSnap.current.kind;
|
snapKind = lockedSnap.current.kind;
|
||||||
@@ -211,7 +212,6 @@ export function XRControllerMeasure() {
|
|||||||
|
|
||||||
// ── Dwell detection (1 s) to auto-register hovered hole/edge ─────
|
// ── Dwell detection (1 s) to auto-register hovered hole/edge ─────
|
||||||
const measureModeNow = useModelStore.getState().measureMode;
|
const measureModeNow = useModelStore.getState().measureMode;
|
||||||
const nowT = performance.now();
|
|
||||||
if (snappedPoint && hoverDetected) {
|
if (snappedPoint && hoverDetected) {
|
||||||
const dist = dwellPos.current.distanceTo(snappedPoint);
|
const dist = dwellPos.current.distanceTo(snappedPoint);
|
||||||
if (dist > 0.005) {
|
if (dist > 0.005) {
|
||||||
|
|||||||
Reference in New Issue
Block a user