From 66f12af03fc379cc60bc8821516e9d937957b4e0 Mon Sep 17 00:00:00 2001 From: Lenny Lord <32369619+thelennylord@users.noreply.github.com> Date: Sat, 16 Jul 2022 16:39:20 +0530 Subject: [PATCH] Resize renderer on browser window resize Fixes #39 --- js/main.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/main.js b/js/main.js index 0f53024..cdd7557 100644 --- a/js/main.js +++ b/js/main.js @@ -333,6 +333,17 @@ function setup(){ pointLight.position.set(0, 300, 200); scene.add(pointLight); + + // Resize view + window.addEventListener("resize", () => { + width = $("#gl").width(); + height = $("#gl").height(); + + camera.aspect = width / height; + camera.updateProjectionMatrix(); + + renderer.setSize(width, height); + }); } // Write stuff from input into variables