From 9fc38a93441e91e34060a9ca0c4c4910eca6dbfe Mon Sep 17 00:00:00 2001 From: Vincent Rubinetti Date: Wed, 3 Jan 2024 11:21:11 -0500 Subject: [PATCH] fix resize --- src/viz.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/viz.js b/src/viz.js index ba62ba0..e5c75cd 100644 --- a/src/viz.js +++ b/src/viz.js @@ -76,16 +76,6 @@ scene.background = light; const camera = new PerspectiveCamera(); const clock = new Clock(); -// resize/reset scene/camera -const reset = () => { - camera.aspect = canvas.clientWidth / canvas.clientHeight; - camera.updateProjectionMatrix(); - renderer.setPixelRatio(window.devicePixelRatio); - renderer.setSize(canvas.clientWidth, canvas.clientHeight, false); -}; -reset(); -window.addEventListener("resize", reset); - // post-processing const renderPass = new RenderPass(scene, camera); const bloomPass = new UnrealBloomPass( @@ -100,6 +90,18 @@ composer.addPass(renderPass); composer.addPass(bloomPass); composer.addPass(outputPass); +// resize/reset scene/camera +const reset = async () => { + camera.aspect = canvas.clientWidth / canvas.clientHeight; + camera.updateProjectionMatrix(); + renderer.setPixelRatio(window.devicePixelRatio); + renderer.setSize(canvas.clientWidth, canvas.clientHeight, false); + composer.setPixelRatio(window.devicePixelRatio); + composer.setSize(canvas.clientWidth, canvas.clientHeight, false); +}; +reset(); +window.addEventListener("resize", reset); + // generate helix const leftPoints = []; const rightPoints = [];