I've been experiencing an issue with the code I used to update everything (camera, renderer, etc) when resizing my window in order to prevent distortion. The code works perfectly when manually resizing the window, but when I simply maximize the window by clicking the icon, the images distort and the update loop breaks. Has anyone encountered this problem before? Thanks for your help!
// Code for handling window resize
window.addEventListener('resize', () => {
sizes.width = window.innerWidth
sizes.height = window.innerHeight
camera.updateProjectionMatrix()
camera.aspect = sizes.width / sizes.height
renderer.setSize(sizes.width, sizes.height)
})
// Rendering loop function
const loop = () => {
renderer.render(scene, camera)
window.requestAnimationFrame(loop)
}
loop();