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;
|
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 (
|
return (
|
||||||
<group
|
<group
|
||||||
scale={[renderFactor, renderFactor, renderFactor]}
|
scale={[renderFactor, renderFactor, renderFactor]}
|
||||||
onClick={(e) => { e.stopPropagation(); setActive(sceneModel.id); }}
|
onClick={(e) => { e.stopPropagation(); setActive(sceneModel.id); }}
|
||||||
|
userData={{ modelId: sceneModel.id, dominantAxis }}
|
||||||
>
|
>
|
||||||
<group
|
{/* Translation */}
|
||||||
ref={ref}
|
<group position={[fineTuning.posX, fineTuning.posY, fineTuning.posZ]}>
|
||||||
position={[
|
{/* Rotation + scale around the geometry center */}
|
||||||
-modelInfo.center.x + fineTuning.posX,
|
<group
|
||||||
-modelInfo.center.y + fineTuning.posY,
|
ref={ref}
|
||||||
-modelInfo.center.z + fineTuning.posZ,
|
rotation={[rotXRad, rotYRad, rotZRad]}
|
||||||
]}
|
scale={[s, s, s]}
|
||||||
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} />
|
<primitive object={scene} />
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user