pmndrs / react-three-fiber

🇨🇭 A React renderer for Three.js
https://docs.pmnd.rs/react-three-fiber
MIT License
27.62k stars 1.6k forks source link

fix: add orientation handling #3365

Closed DennisSmolek closed 1 month ago

DennisSmolek commented 1 month ago

This adds an orientation handler to useMeasure so that when the device rotates it correctly adjusts the canvas.

Right now, when a phone rotates the window resize event never fires so the canvas doesn't know it should change, and as the resize handler sets the css sizes directly on the canvas it causes it to bleed over the edge or if you go from horizontal to vertical causes it to leave a big black area in the viewport.

You can simulate this in chrome by using the developer tools device preview button. Load a mobile device, Load a canvas (typically a full size one) and then change the orientation with the orientation button.

codesandbox-ci[bot] commented 1 month ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 7a7850098f830d3c2dd6e7e33081daa7f87e35d0:

Sandbox Source
example Configuration
CodyJasonBennett commented 1 month ago

@drcmda, we'll want to upstream improvements here to use-measure.