Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -123,22 +123,33 @@ 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 }}
|
||||
>
|
||||
<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]}
|
||||
>
|
||||
<primitive object={scene} />
|
||||
{/* Translation */}
|
||||
<group position={[fineTuning.posX, fineTuning.posY, fineTuning.posZ]}>
|
||||
{/* Rotation + scale around the geometry center */}
|
||||
<group
|
||||
ref={ref}
|
||||
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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user