fix(cat): use getLocalBounds for accurate scale calculation

Cat was rendering huge because scale was computed from current model.width
which included previous scale transforms. Now resets to scale(1) first,
reads natural bounds, then computes target scale for 100px rendered height.
This commit is contained in:
2026-06-05 13:45:32 -04:00
parent 9d2ba052f4
commit f76ae3faec
+6 -4
View File
@@ -43,12 +43,14 @@ function positionModels(
// Right sidebar center // Right sidebar center
const rightLeft = appW - RIGHT_W - PAD; const rightLeft = appW - RIGHT_W - PAD;
const rightMidX = rightLeft + RIGHT_W / 2; const rightMidX = rightLeft + RIGHT_W / 2;
// PetZone sits near the bottom of the sidebar, above the status bar const catY = appH - BOTTOM_BAR_H - 60 - 18;
const catTargetH = 120;
const catY = appH - BOTTOM_BAR_H - catTargetH / 2 - 18;
if (cat) { if (cat) {
const cs = catTargetH / cat.height; // Set scale to 1 first to get natural bounds, then compute target
cat.scale.set(1);
const naturalH = cat.getLocalBounds().height;
const targetPx = 100; // ~100px tall rendered
const cs = naturalH > 0 ? targetPx / naturalH : 0.05;
cat.scale.set(cs); cat.scale.set(cs);
cat.anchor.set(0.5, 0.5); cat.anchor.set(0.5, 0.5);
cat.position.set(rightMidX, catY); cat.position.set(rightMidX, catY);