fix viewport shrinking permanently (#113)

what was happening is we were setting style.width and style.height which overrode the styles from CSS that gave us the BoundingClientRect from which we were calculating the canvas size
I also added a sendViewportUpdate to prevent chunk jank
This commit is contained in:
りき萌 2025-05-27 20:20:10 +02:00
parent 65645f410f
commit 598c0348f6

View file

@ -40,13 +40,14 @@ class CanvasRenderer extends HTMLElement {
// To properly handle DPI scaling, we want the canvas's layout size to be equal to that of
// its parent container,
this.style.width = `${width}px`;
this.style.height = `${height}px`;
this.canvas.width = width * window.devicePixelRatio;
this.canvas.height = height * window.devicePixelRatio;
// Rerender immediately after the canvas is resized, as its contents have now been invalidated.
this.#render();
// Send a viewport update so that the server knows to send new chunks.
this.sendViewportUpdate();
}
getWindowSize() {