♻️ revert zoom to simple center zoom, remove mouse targeting

This commit is contained in:
2026-03-20 20:21:49 +00:00
parent 216c70dbd9
commit cccfd9ba73

View File

@@ -52,19 +52,10 @@ export class CameraSystem {
d: kb.addKey(Phaser.Input.Keyboard.KeyCodes.D),
}
// Scroll wheel zoom — zoom toward mouse pointer
this.scene.input.on('wheel', (ptr: Phaser.Input.Pointer, _objs: unknown, _dx: number, dy: number) => {
// Scroll wheel zoom
this.scene.input.on('wheel', (_ptr: Phaser.Input.Pointer, _objs: unknown, _dx: number, dy: number) => {
const newZoom = Phaser.Math.Clamp(cam.zoom - Math.sign(dy) * ZOOM_STEP, MIN_ZOOM, MAX_ZOOM)
if (newZoom === cam.zoom) return
// ptr.worldX/Y is pre-computed by Phaser and represents the world position under the pointer
const worldX = ptr.worldX
const worldY = ptr.worldY
// Apply zoom first, then reposition scroll so worldX stays under ptr.x
cam.setZoom(newZoom)
cam.scrollX = worldX - ptr.x / newZoom
cam.scrollY = worldY - ptr.y / newZoom
})
// Middle-click pan: start on button down