Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -601,6 +601,7 @@ export const useModelStore = create<ModelStore>((set, get) => ({
|
||||
}),
|
||||
registerHoverMeasurement: (info) => set((state) => {
|
||||
const modelId = state.activeModelId ?? undefined;
|
||||
const modelScale = modelId ? getModelWorldScaleFactor(modelId) : 1;
|
||||
const toLocal = (p: MeasurePoint): { point: MeasurePoint; attached: boolean } => {
|
||||
const conv = modelId ? worldToModelLocal(modelId, p) : null;
|
||||
return conv ? { point: conv, attached: true } : { point: p, attached: false };
|
||||
@@ -611,13 +612,14 @@ export const useModelStore = create<ModelStore>((set, get) => ({
|
||||
const cw: MeasurePoint = { x: info.position[0], y: info.position[1], z: info.position[2] };
|
||||
const c = toLocal(cw);
|
||||
attached = c.attached;
|
||||
const valueMM = attached ? info.value / modelScale : info.value;
|
||||
measurement = {
|
||||
id: `m_${Date.now()}`,
|
||||
pointA: c.point,
|
||||
pointB: c.point,
|
||||
distanceMM: info.value,
|
||||
distanceMM: valueMM,
|
||||
kind: 'hole',
|
||||
label: `Ø ${info.value.toFixed(1)}`,
|
||||
label: `Ø ${valueMM.toFixed(1)}`,
|
||||
modelId: attached ? modelId : undefined,
|
||||
};
|
||||
} else {
|
||||
@@ -626,13 +628,19 @@ export const useModelStore = create<ModelStore>((set, get) => ({
|
||||
const a = toLocal(aw);
|
||||
const b = toLocal(bw);
|
||||
attached = a.attached && b.attached;
|
||||
const pa = attached ? a.point : aw;
|
||||
const pb = attached ? b.point : bw;
|
||||
const dx = (pa.x - pb.x) * 1000;
|
||||
const dy = (pa.y - pb.y) * 1000;
|
||||
const dz = (pa.z - pb.z) * 1000;
|
||||
const valueMM = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
measurement = {
|
||||
id: `m_${Date.now()}`,
|
||||
pointA: attached ? a.point : aw,
|
||||
pointB: attached ? b.point : bw,
|
||||
distanceMM: info.value,
|
||||
pointA: pa,
|
||||
pointB: pb,
|
||||
distanceMM: valueMM,
|
||||
kind: 'edge',
|
||||
label: `${info.value.toFixed(1)} mm`,
|
||||
label: `${valueMM.toFixed(1)} mm`,
|
||||
modelId: attached ? modelId : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user