add ZoomMouseScene with zoom-to-mouse correction

Implements scroll correction after cam.setZoom() so the world point
under the mouse stays fixed. Formula accounts for Phaser's
center-based zoom: scrollX += (mouseX - cw/2) * (1/zBefore - 1/zAfter).
Tab switches between the two test scenes in both directions.
Also fixes centerWorld formula in ZoomTestScene overlay and logs.
This commit is contained in:
2026-03-21 11:49:39 +00:00
parent aefb67dba6
commit fede13d64a
3 changed files with 379 additions and 6 deletions

View File

@@ -1,12 +1,13 @@
import Phaser from 'phaser'
import { ZoomTestScene } from './ZoomTestScene'
import { ZoomMouseScene } from './ZoomMouseScene'
const config: Phaser.Types.Core.GameConfig = {
type: Phaser.AUTO,
width: window.innerWidth,
height: window.innerHeight,
backgroundColor: '#0d1a0d',
scene: [ZoomTestScene],
scene: [ZoomTestScene, ZoomMouseScene],
scale: {
mode: Phaser.Scale.RESIZE,
autoCenter: Phaser.Scale.CENTER_BOTH,