🚀 Auto-deploy: melhoria no snap e medição AR em 22/05/2026 21:38:44
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { create } from 'zustand';
|
||||
import { worldToModelLocal } from '@/lib/modelTransforms';
|
||||
import { sendRemoteLog } from '@/lib/remoteLogger';
|
||||
|
||||
// ── Persistência de placement (fineTuning + escala) e flags WebXR ─────
|
||||
const PLACEMENT_KEY = 'tsxr_placements_v1';
|
||||
@@ -553,6 +554,7 @@ export const useModelStore = create<ModelStore>((set, get) => ({
|
||||
}),
|
||||
measurePoints: [],
|
||||
addMeasurePoint: (p) => set((state) => {
|
||||
sendRemoteLog('info', `addMeasurePoint acionado: ponto atual ${state.measurePoints.length + 1}`, p);
|
||||
const points = [...state.measurePoints, p];
|
||||
if (points.length === 2) {
|
||||
const [a, b] = points;
|
||||
@@ -562,11 +564,17 @@ export const useModelStore = create<ModelStore>((set, get) => ({
|
||||
const distanceWorldMM = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
const factor = state.scaleRatio?.factor ?? 1;
|
||||
const distanceMM = distanceWorldMM / factor;
|
||||
// Convert world points to active model's local frame so they follow the model.
|
||||
const modelId = state.activeModelId ?? undefined;
|
||||
const aConv = modelId ? worldToModelLocal(modelId, a) : null;
|
||||
const bConv = modelId ? worldToModelLocal(modelId, b) : null;
|
||||
const attached = !!(aConv && bConv);
|
||||
sendRemoteLog('info', `addMeasurePoint: calculando distância`, {
|
||||
distanceWorldMM,
|
||||
distanceMM,
|
||||
factor,
|
||||
modelId,
|
||||
attached
|
||||
});
|
||||
const measurement: Measurement = {
|
||||
id: `m_${Date.now()}`,
|
||||
pointA: attached ? aConv! : a,
|
||||
@@ -574,6 +582,7 @@ export const useModelStore = create<ModelStore>((set, get) => ({
|
||||
distanceMM,
|
||||
modelId: attached ? modelId : undefined,
|
||||
};
|
||||
sendRemoteLog('info', `addMeasurePoint: medição gerada com sucesso`, measurement);
|
||||
return { measurePoints: [], measurements: [...state.measurements, measurement] };
|
||||
}
|
||||
return { measurePoints: points };
|
||||
|
||||
Reference in New Issue
Block a user