Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-05-20 20:50:15 +00:00
parent a134f1b0bf
commit 99ddbe793a
+16 -5
View File
@@ -123,24 +123,35 @@ function GLBModel({ sceneModel, isActive }: { sceneModel: SceneModel; isActive:
if (!sceneModel.visible) return null;
// Determine dominant local axis of the model (longest bbox side) for axial roll
const dominantAxis: 'x' | 'y' | 'z' =
modelInfo.size.x >= modelInfo.size.y && modelInfo.size.x >= modelInfo.size.z
? 'x'
: modelInfo.size.y >= modelInfo.size.z
? 'y'
: 'z';
return (
<group
scale={[renderFactor, renderFactor, renderFactor]}
onClick={(e) => { e.stopPropagation(); setActive(sceneModel.id); }}
userData={{ modelId: sceneModel.id, dominantAxis }}
>
{/* Translation */}
<group position={[fineTuning.posX, fineTuning.posY, fineTuning.posZ]}>
{/* Rotation + scale around the geometry center */}
<group
ref={ref}
position={[
-modelInfo.center.x + fineTuning.posX,
-modelInfo.center.y + fineTuning.posY,
-modelInfo.center.z + fineTuning.posZ,
]}
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]}>
<primitive object={scene} />
</group>
</group>
</group>
</group>
);
}