diff --git a/src/components/three/ModelViewer.tsx b/src/components/three/ModelViewer.tsx
index c507ce0..2e4bde1 100644
--- a/src/components/three/ModelViewer.tsx
+++ b/src/components/three/ModelViewer.tsx
@@ -210,16 +210,44 @@ function GLBModel({ sceneModel, isActive }: { sceneModel: SceneModel; isActive:
rotation={[rotXRad, rotYRad, rotZRad]}
scale={[s, s, s]}
>
- {/* Shift geometry so its center sits at the parent's origin (pivot = center) */}
-
+ {/* Shift geometry so its center sits at the parent's origin (pivot = center).
+ This is the local frame where measurement points are stored, so measurements
+ follow the model when posX/Y/Z or rotX/Y/Z change in "Posicionar" mode. */}
+
-
+
+
);
}
+/** Innermost local frame of a model. Registers itself in the global model
+ * registry so the store can convert world points to this group's local frame. */
+function ModelLocalFrame({
+ modelId,
+ center,
+ children,
+}: {
+ modelId: string;
+ center: THREE.Vector3;
+ children: React.ReactNode;
+}) {
+ const ref = useRef(null);
+ useEffect(() => {
+ const g = ref.current;
+ if (!g) return;
+ registerModelLocalGroup(modelId, g);
+ return () => unregisterModelLocalGroup(modelId, g);
+ }, [modelId]);
+ return (
+
+ {children}
+
+ );
+}
+
function SceneModels() {
const models = useModelStore((s) => s.models);
const activeId = useModelStore((s) => s.activeModelId);