1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

Merge branch 'master' into symmetric-piece-generator

This commit is contained in:
Martin Spanel 2020-07-04 19:05:35 +02:00
commit ecb8381c93
4 changed files with 14 additions and 3 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:4846f685f3e242444706e1f295347f6c6205984edff75ddf32fbb5a7d497c598 oid sha256:ff5ce5977b343577cc189f1e32cf16e6ecd36e8c97be40877199d546fdbeae17
size 215617 size 211969

View File

@ -10,7 +10,7 @@ export const CHANGELOG = [
"Added keybinding to close menus (by isaisstillalive / Sandwichs-del)", "Added keybinding to close menus (by isaisstillalive / Sandwichs-del)",
"Fix rare crash regarding the buildings toolbar (by isaisstillalive)", "Fix rare crash regarding the buildings toolbar (by isaisstillalive)",
"Fixed some phrases (By EnderDoom77)", "Fixed some phrases (By EnderDoom77)",
"Zoom towards mouse cursor (by Dimava)",
"Updated the soundtrack again, it is now 20 minutes in total!", "Updated the soundtrack again, it is now 20 minutes in total!",
"Updated and added new translations (Thanks to all contributors!)", "Updated and added new translations (Thanks to all contributors!)",
], ],

View File

@ -500,6 +500,7 @@ export class Camera extends BasicSerializableObject {
event.preventDefault(); event.preventDefault();
// event.stopPropagation(); // event.stopPropagation();
} }
const prevZoom = this.zoomLevel;
const delta = Math.sign(event.deltaY) * -0.15 * this.root.app.settings.getScrollWheelSensitivity(); 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); 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.clampZoomLevel();
this.desiredZoom = null; 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; return false;
} }