reuse move function
This commit is contained in:
parent
34c58dcd71
commit
7cfc1915a4
1 changed files with 5 additions and 7 deletions
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue