Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-05-24 19:15:14 +00:00
parent 9970571fad
commit 52ef40f8fb
+9 -11
View File
@@ -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<ModelStore>((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,
};