reuse move function

This commit is contained in:
Zutatensuppe 2021-04-17 19:35:32 +02:00
parent 34c58dcd71
commit 7cfc1915a4

View file

@ -20,14 +20,12 @@ export default class Camera {
return false return false
} }
const zoomToCoord = viewportCoordCenter const zoomFactor = 1 - (this.zoom / zoom)
const zoomFactor = (1 / this.zoom) - (1 / zoom) this.move(
-viewportCoordCenter.x * zoomFactor,
this.x -= Math.round(zoomToCoord.x * zoomFactor) -viewportCoordCenter.y * zoomFactor,
this.y -= Math.round(zoomToCoord.y * zoomFactor) )
this.zoom = zoom this.zoom = zoom
return true return true
} }