mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Merge branch 'master' of https://github.com/tobspr/shapez.io
This commit is contained in:
commit
1837e72952
@ -500,6 +500,7 @@ export class Camera extends BasicSerializableObject {
|
||||
event.preventDefault();
|
||||
// event.stopPropagation();
|
||||
}
|
||||
const prevZoom = this.zoomLevel;
|
||||
|
||||
const delta = Math.sign(event.deltaY) * -0.15 * this.root.app.settings.getScrollWheelSensitivity();
|
||||
assert(Number.isFinite(delta), "Got invalid delta in mouse wheel event: " + event.deltaY);
|
||||
@ -509,6 +510,16 @@ export class Camera extends BasicSerializableObject {
|
||||
|
||||
this.clampZoomLevel();
|
||||
this.desiredZoom = null;
|
||||
|
||||
const mousePosition = this.root.app.mousePosition;
|
||||
if (mousePosition) {
|
||||
const worldPos = this.root.camera.screenToWorld(mousePosition);
|
||||
const worldDelta = worldPos.sub(this.center);
|
||||
const actualDelta = this.zoomLevel / prevZoom - 1;
|
||||
this.center = this.center.add(worldDelta.multiplyScalar(actualDelta));
|
||||
this.desiredCenter = null;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user