From 52ef40f8fb025d8cb98908daf0304fc662b71f11 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:15:14 +0000 Subject: [PATCH] Changes Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com> --- src/stores/useModelStore.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/stores/useModelStore.ts b/src/stores/useModelStore.ts index e07045f..abdf501 100644 --- a/src/stores/useModelStore.ts +++ b/src/stores/useModelStore.ts @@ -1,5 +1,5 @@ import { create } from 'zustand'; -import { worldToModelLocal } from '@/lib/modelTransforms'; +import { getModelWorldScaleFactor, worldToModelLocal } from '@/lib/modelTransforms'; import { sendRemoteLog } from '@/lib/remoteLogger'; // ── Persistência de placement (fineTuning + escala) e flags WebXR ───── @@ -558,27 +558,25 @@ export const useModelStore = create((set, get) => ({ const points = [...state.measurePoints, p]; if (points.length === 2) { const [a, b] = points; - const dx = (a.x - b.x) * 1000; - const dy = (a.y - b.y) * 1000; - const dz = (a.z - b.z) * 1000; - const distanceWorldMM = Math.sqrt(dx * dx + dy * dy + dz * dz); - const factor = state.scaleRatio?.factor ?? 1; - const distanceMM = distanceWorldMM / factor; const modelId = state.activeModelId ?? undefined; const aConv = modelId ? worldToModelLocal(modelId, a) : null; const bConv = modelId ? worldToModelLocal(modelId, b) : null; const attached = !!(aConv && bConv); + const pa = attached ? aConv! : a; + const pb = attached ? bConv! : b; + const dx = (pa.x - pb.x) * 1000; + const dy = (pa.y - pb.y) * 1000; + const dz = (pa.z - pb.z) * 1000; + const distanceMM = Math.sqrt(dx * dx + dy * dy + dz * dz); sendRemoteLog('info', `addMeasurePoint: calculando distância`, { - distanceWorldMM, distanceMM, - factor, modelId, attached }); const measurement: Measurement = { id: `m_${Date.now()}`, - pointA: attached ? aConv! : a, - pointB: attached ? bConv! : b, + pointA: pa, + pointB: pb, distanceMM, modelId: attached ? modelId : undefined, };