Moved hooks before early returns
X-Lovable-Edit-ID: edt-c703c880-46fb-435e-95fc-c26b2f4ac503 Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -239,17 +239,6 @@ function GLBModel({ sceneModel, isActive }: { sceneModel: SceneModel; isActive:
|
|||||||
const scaleRatio = useModelStore((st) => st.scaleRatio);
|
const scaleRatio = useModelStore((st) => st.scaleRatio);
|
||||||
const renderFactor = scaleRatio?.factor ?? 1;
|
const renderFactor = scaleRatio?.factor ?? 1;
|
||||||
|
|
||||||
if (!sceneModel.visible) return null;
|
|
||||||
if (!scene) 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';
|
|
||||||
|
|
||||||
// Calibration quaternion (applied innermost, around center). We render with identity
|
// Calibration quaternion (applied innermost, around center). We render with identity
|
||||||
// while calibration is in progress for this model so face normals reflect the
|
// while calibration is in progress for this model so face normals reflect the
|
||||||
// un-calibrated frame; the result is committed at the end.
|
// un-calibrated frame; the result is committed at the end.
|
||||||
@@ -262,6 +251,17 @@ function GLBModel({ sceneModel, isActive }: { sceneModel: SceneModel; isActive:
|
|||||||
}, [calQuatArr, isCalibratingThis]);
|
}, [calQuatArr, isCalibratingThis]);
|
||||||
const calGroupRef = useRef<THREE.Group>(null);
|
const calGroupRef = useRef<THREE.Group>(null);
|
||||||
|
|
||||||
|
if (!sceneModel.visible) return null;
|
||||||
|
if (!scene) 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]}
|
||||||
|
|||||||
Reference in New Issue
Block a user