Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -564,14 +564,15 @@ export const useModelStore = create<ModelStore>((set, get) => ({
|
|||||||
const distanceMM = distanceWorldMM / factor;
|
const distanceMM = distanceWorldMM / factor;
|
||||||
// Convert world points to active model's local frame so they follow the model.
|
// Convert world points to active model's local frame so they follow the model.
|
||||||
const modelId = state.activeModelId ?? undefined;
|
const modelId = state.activeModelId ?? undefined;
|
||||||
const aLocal = (modelId && worldToModelLocal(modelId, a)) || a;
|
const aConv = modelId ? worldToModelLocal(modelId, a) : null;
|
||||||
const bLocal = (modelId && worldToModelLocal(modelId, b)) || b;
|
const bConv = modelId ? worldToModelLocal(modelId, b) : null;
|
||||||
|
const attached = !!(aConv && bConv);
|
||||||
const measurement: Measurement = {
|
const measurement: Measurement = {
|
||||||
id: `m_${Date.now()}`,
|
id: `m_${Date.now()}`,
|
||||||
pointA: aLocal,
|
pointA: attached ? aConv! : a,
|
||||||
pointB: bLocal,
|
pointB: attached ? bConv! : b,
|
||||||
distanceMM,
|
distanceMM,
|
||||||
modelId: worldToModelLocal(modelId, a) ? modelId : undefined,
|
modelId: attached ? modelId : undefined,
|
||||||
};
|
};
|
||||||
return { measurePoints: [], measurements: [...state.measurements, measurement] };
|
return { measurePoints: [], measurements: [...state.measurements, measurement] };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user