question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Window on resize, and aspect ratio

See original GitHub issue

Here is another one: I wanted to handle window resizing,

window.addEventListener( 'resize', onWindowResize, false );
function onWindowResize(){
    renderer.setSize( window.innerWidth, window.innerHeight );
}

This “mostly” works, except that the particles color is reset to black, and the aspect ratio is not updated, transforming balls in eggs … and I have no idea how to fix this.

Thanks 😃

Issue Analytics

  • State:closed
  • Created 13 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

55reactions
mrdoobcommented, Apr 3, 2012

You also need to update the camera:

window.addEventListener( 'resize', onWindowResize, false );

function onWindowResize(){

    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();

    renderer.setSize( window.innerWidth, window.innerHeight );

}
0reactions
omnicron96commented, Dec 8, 2020

i want to resize glft in react three fiber

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implement responsive aspect ratio on window resize ... - Daily.co
In today's tutorial, we'll look at two ways to manage setting Daily Prebuilt iframe's dimensions on window resize while maintaining a constant ...
Read more >
Keep aspect ratio of div when resizing window - Stack Overflow
To resize to fit inside the window while maintaining aspect ratio, set up your container with an initial size and then divide the...
Read more >
Resizing a desktop window to a specific size or aspect ratio
We need a way to resize a window on the desktop so that it will be a specifc size (height x width) or...
Read more >
How to allow window resize to set an aspect ratio, for a video ...
I draw an fbo inside. But when I set the window shape, (after calculating the window height related to the fbo aspect ratio),...
Read more >
Aspect ratio in non-maximised Windows - TechSmith Support
Yes, you can. If you want to rescale the capture area to maintain a 16 x 9 aspect ratio............
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found