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

Scale on resize after animating camera position Y #3368

Open KrystofCernik opened 1 month ago

KrystofCernik commented 1 month ago

Heey! I just spend too much time trying to figure this out, but cannot really find a solution.. I animate camera position y, sync it with scroll actually so in my useFrame, I run camera.position.y = -window.scrollY * ratio (which just turns the scrollY to threejs units) ... The problem is that if I resize, all things in the scene get kinda zoom, scaled more of, and more I resize, camera position y is increasing, even though window.scrollY is constant. If camera.position.y = 0, which means I'm at top of my page, this is not happening, only if camera position y is bigger than zero .. Would you have any idea why is this happening? Hopefully I'm being clear :) Seems like calling updateProjectionMatrix or gl.setSize would fix this, but no