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:
@@ -43,12 +43,14 @@ function positionModels(
|
||||
// Right sidebar center
|
||||
const rightLeft = appW - RIGHT_W - PAD;
|
||||
const rightMidX = rightLeft + RIGHT_W / 2;
|
||||
// PetZone sits near the bottom of the sidebar, above the status bar
|
||||
const catTargetH = 120;
|
||||
const catY = appH - BOTTOM_BAR_H - catTargetH / 2 - 18;
|
||||
const catY = appH - BOTTOM_BAR_H - 60 - 18;
|
||||
|
||||
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.anchor.set(0.5, 0.5);
|
||||
cat.position.set(rightMidX, catY);
|
||||
|
||||
Reference in New Issue
Block a user