1
0
Fork 0

Fix chunk loading when zoomed in.

This commit is contained in:
Starbeamrainbowlabs 2017-06-15 17:20:22 +01:00
parent 653df90674
commit dc795f6d00
4 changed files with 10 additions and 5 deletions

View File

@ -62,11 +62,11 @@ class BoardWindow extends EventEmitter
y: 0,
// The width of the viewport
get width() {
return canvas.width * 1/this.zoomLevel
return canvas.width * (1/this.zoomLevel)
},
// The height of the viewport
get height() {
return canvas.height * 1/this.zoomLevel
return canvas.height * (1/this.zoomLevel)
},
// The zoom level of the viewport. 1 = normal.
zoomLevel: 1,

View File

@ -50,8 +50,8 @@ class ChunkCache
let chunkArea = new Rectangle(
Math.floor(visibleArea.x / chunkSize) * chunkSize,
Math.floor(visibleArea.y / chunkSize) * chunkSize,
(Math.floor((visibleArea.x + (visibleArea.width / visibleArea.zoomLevel)) / chunkSize) * chunkSize),
(Math.floor((visibleArea.y + (visibleArea.height / visibleArea.zoomLevel)) / chunkSize) * chunkSize)
(Math.ceil((visibleArea.x + (visibleArea.width)) / chunkSize) * chunkSize),
(Math.ceil((visibleArea.y + (visibleArea.height)) / chunkSize) * chunkSize)
);

View File

@ -126,6 +126,11 @@ hr
z-index: 5000;
}
.debug-value
{
font-family: monospace; /* todo: use custom fonts! :D */
}
.fps
{

View File

@ -44,7 +44,7 @@
</aside>
<aside id="debuginfo">
<label>Viewport:</label> <output id="debug-viewport">?</output>
<label>Viewport:</label> <output id="debug-viewport" class="debug-value">?</output>
</aside>