Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Day 1/skybox.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ function init(){
let skyBox = new THREE.Mesh(skyBoxGeo, materialArray); //Mesh requires

scene.add(skyBox);
window.addEventListener('resize', ()=>{window.location.reload()});
// In the resize event handler, you are reloading the entire page when the window is resized.
// This approach may cause unnecessary resource reloads and reinitialization. Instead, consider updating the camera and
// renderer aspect ratio directly without reloading the whole page
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
}
function animate() {

Expand Down