Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-05-21 20:50:13 +00:00
parent 3472a44a2f
commit 1139337dbb
+31 -3
View File
@@ -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) */}
<group position={[-modelInfo.center.x, -modelInfo.center.y, -modelInfo.center.z]}>
{/* 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. */}
<ModelLocalFrame modelId={sceneModel.id} center={modelInfo.center}>
<primitive object={scene} />
</group>
<ModelMeasurements modelId={sceneModel.id} />
</ModelLocalFrame>
</group>
</group>
</group>
);
}
/** 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<THREE.Group>(null);
useEffect(() => {
const g = ref.current;
if (!g) return;
registerModelLocalGroup(modelId, g);
return () => unregisterModelLocalGroup(modelId, g);
}, [modelId]);
return (
<group ref={ref} position={[-center.x, -center.y, -center.z]}>
{children}
</group>
);
}
function SceneModels() {
const models = useModelStore((s) => s.models);
const activeId = useModelStore((s) => s.activeModelId);