I am currently in the process of creating a website using a Three.js canvas that covers the entire viewport. My goal is to keep the visuals consistent even when resizing the window, without any scaling.
Here is my current approach:
renderer.setSize(window.screen.width, window.screen.height)
- Then, on initialization and window resize:
camera.fov = window.innerHeight / window.screen.height;
camera.aspect = window.innerWidth / window.innerHeight;
renderer.setViewport(0, 0, window.innerWidth, window.innerHeight);
While this method works effectively, I have some concerns about its efficiency. Since the renderer size remains constant regardless of the browser window's size, I wonder if there might be unnecessary calculations taking place. Does setViewport
efficiently reduce the computational workload for each frame, or are all calculations still performed before cropping?