🚀 Auto-deploy: melhoria no snap e medição AR em 24/05/2026 02:00:33

This commit is contained in:
2026-05-24 02:00:33 +00:00
parent c839653a97
commit c8d51e0e1b
7 changed files with 170 additions and 26 deletions
+21 -4
View File
@@ -59,6 +59,15 @@ export function findElementRoot(obj: THREE.Object3D | null): THREE.Object3D | nu
return fallback;
}
export function findModelId(obj: THREE.Object3D | null): string | undefined {
let cur: THREE.Object3D | null = obj;
while (cur) {
if (cur.userData?.modelId) return cur.userData.modelId as string;
cur = cur.parent;
}
return undefined;
}
function hasIfcAncestor(obj: THREE.Object3D): boolean {
let cur = obj.parent;
while (cur) {
@@ -574,7 +583,9 @@ function SmartSnapHandler() {
}
}
if (bestHole) {
setSnapPoint(bestHole);
// Find the measurement we matched
const matched = st.measurements.find(m => m.pointA.x === bestHole.x && m.pointA.y === bestHole.y && m.pointA.z === bestHole.z);
setSnapPoint({ ...bestHole, modelId: matched?.modelId });
return;
}
@@ -585,7 +596,8 @@ function SmartSnapHandler() {
10
);
if (snap) {
setSnapPoint({ x: snap.x, y: snap.y, z: snap.z });
const hitModelId = findModelId(hit.object);
setSnapPoint({ x: snap.x, y: snap.y, z: snap.z, modelId: hitModelId });
} else {
setSnapPoint(null);
}
@@ -653,11 +665,13 @@ function HoverDetector() {
// 1) Try circle fit from edge vertices around the hit (catches holes on flat faces)
const circ = detectCircularEdgeAtPoint(hit.object, hit.point, camera, canvasSize, 50);
const hitModelId = findModelId(hit.object);
if (circ) {
setHoverInfo({
type: 'hole',
position: [circ.center.x, circ.center.y, circ.center.z],
value: circ.diameterMM,
modelId: hitModelId,
});
} else if (hit.faceIndex !== undefined && (() => {
const hole = detectHoleAtFace(hit.object, hit.faceIndex);
@@ -666,6 +680,7 @@ function HoverDetector() {
type: 'hole',
position: [hole.center.x, hole.center.y, hole.center.z],
value: hole.diameterMM,
modelId: hitModelId,
});
return true;
}
@@ -680,6 +695,7 @@ function HoverDetector() {
type: 'edge',
position: [edge.midpoint.x, edge.midpoint.y, edge.midpoint.z],
value: edge.lengthMM,
modelId: hitModelId,
endpoints: {
a: { x: edge.a.x, y: edge.a.y, z: edge.a.z },
b: { x: edge.b.x, y: edge.b.y, z: edge.b.z },
@@ -763,7 +779,7 @@ function MeasureClickHandler() {
// Prefer snap (vertex snap, or hole-center snap from SmartSnapHandler)
if (st.snapPoint) {
st.addMeasurePoint({ x: st.snapPoint.x, y: st.snapPoint.y, z: st.snapPoint.z });
st.addMeasurePoint({ x: st.snapPoint.x, y: st.snapPoint.y, z: st.snapPoint.z, modelId: st.snapPoint.modelId });
return;
}
@@ -782,7 +798,8 @@ function MeasureClickHandler() {
return true;
});
if (hit) {
st.addMeasurePoint({ x: hit.point.x, y: hit.point.y, z: hit.point.z });
const hitModelId = findModelId(hit.object);
st.addMeasurePoint({ x: hit.point.x, y: hit.point.y, z: hit.point.z, modelId: hitModelId });
}
};