Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { create } from 'zustand';
|
import { create } from 'zustand';
|
||||||
import { worldToModelLocal } from '@/lib/modelTransforms';
|
import { getModelWorldScaleFactor, worldToModelLocal } from '@/lib/modelTransforms';
|
||||||
import { sendRemoteLog } from '@/lib/remoteLogger';
|
import { sendRemoteLog } from '@/lib/remoteLogger';
|
||||||
|
|
||||||
// ── Persistência de placement (fineTuning + escala) e flags WebXR ─────
|
// ── 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];
|
const points = [...state.measurePoints, p];
|
||||||
if (points.length === 2) {
|
if (points.length === 2) {
|
||||||
const [a, b] = points;
|
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 modelId = state.activeModelId ?? undefined;
|
||||||
const aConv = modelId ? worldToModelLocal(modelId, a) : null;
|
const aConv = modelId ? worldToModelLocal(modelId, a) : null;
|
||||||
const bConv = modelId ? worldToModelLocal(modelId, b) : null;
|
const bConv = modelId ? worldToModelLocal(modelId, b) : null;
|
||||||
const attached = !!(aConv && bConv);
|
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`, {
|
sendRemoteLog('info', `addMeasurePoint: calculando distância`, {
|
||||||
distanceWorldMM,
|
|
||||||
distanceMM,
|
distanceMM,
|
||||||
factor,
|
|
||||||
modelId,
|
modelId,
|
||||||
attached
|
attached
|
||||||
});
|
});
|
||||||
const measurement: Measurement = {
|
const measurement: Measurement = {
|
||||||
id: `m_${Date.now()}`,
|
id: `m_${Date.now()}`,
|
||||||
pointA: attached ? aConv! : a,
|
pointA: pa,
|
||||||
pointB: attached ? bConv! : b,
|
pointB: pb,
|
||||||
distanceMM,
|
distanceMM,
|
||||||
modelId: attached ? modelId : undefined,
|
modelId: attached ? modelId : undefined,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user