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) => {
|
registerHoverMeasurement: (info) => set((state) => {
|
||||||
const modelId = state.activeModelId ?? undefined;
|
const modelId = state.activeModelId ?? undefined;
|
||||||
|
const modelScale = modelId ? getModelWorldScaleFactor(modelId) : 1;
|
||||||
const toLocal = (p: MeasurePoint): { point: MeasurePoint; attached: boolean } => {
|
const toLocal = (p: MeasurePoint): { point: MeasurePoint; attached: boolean } => {
|
||||||
const conv = modelId ? worldToModelLocal(modelId, p) : null;
|
const conv = modelId ? worldToModelLocal(modelId, p) : null;
|
||||||
return conv ? { point: conv, attached: true } : { point: p, attached: false };
|
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 cw: MeasurePoint = { x: info.position[0], y: info.position[1], z: info.position[2] };
|
||||||
const c = toLocal(cw);
|
const c = toLocal(cw);
|
||||||
attached = c.attached;
|
attached = c.attached;
|
||||||
|
const valueMM = attached ? info.value / modelScale : info.value;
|
||||||
measurement = {
|
measurement = {
|
||||||
id: `m_${Date.now()}`,
|
id: `m_${Date.now()}`,
|
||||||
pointA: c.point,
|
pointA: c.point,
|
||||||
pointB: c.point,
|
pointB: c.point,
|
||||||
distanceMM: info.value,
|
distanceMM: valueMM,
|
||||||
kind: 'hole',
|
kind: 'hole',
|
||||||
label: `Ø ${info.value.toFixed(1)}`,
|
label: `Ø ${valueMM.toFixed(1)}`,
|
||||||
modelId: attached ? modelId : undefined,
|
modelId: attached ? modelId : undefined,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
@@ -626,13 +628,19 @@ export const useModelStore = create<ModelStore>((set, get) => ({
|
|||||||
const a = toLocal(aw);
|
const a = toLocal(aw);
|
||||||
const b = toLocal(bw);
|
const b = toLocal(bw);
|
||||||
attached = a.attached && b.attached;
|
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 = {
|
measurement = {
|
||||||
id: `m_${Date.now()}`,
|
id: `m_${Date.now()}`,
|
||||||
pointA: attached ? a.point : aw,
|
pointA: pa,
|
||||||
pointB: attached ? b.point : bw,
|
pointB: pb,
|
||||||
distanceMM: info.value,
|
distanceMM: valueMM,
|
||||||
kind: 'edge',
|
kind: 'edge',
|
||||||
label: `${info.value.toFixed(1)} mm`,
|
label: `${valueMM.toFixed(1)} mm`,
|
||||||
modelId: attached ? modelId : undefined,
|
modelId: attached ? modelId : undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user