-
Notifications
You must be signed in to change notification settings - Fork 703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Canvas view is skewed when using ScrollControls #2081
Comments
Update: as mentioned in this post, adding a useLayoutEffect helps a little bit. However, I'm not able to control the aspect that well so that cameraRef.current remains consistently unstretched. If I set the aspect to a decimal, it doesn't look stretched, but it stretches when I scroll closer to the bottom. Also the useLayoutEffect only seems to trigger whenever I resize the window. I was expecting scroll.offset to trigger this aspect change, but it doesn't. |
Update: I found a hacky sort of solution, I created a state that was changed to the scrollTop value using the onWheel event handler on the , and I passed this value onto the camera where I had the state be a dependency in useLayoutEffect. For the equation for calculating the correct aspect, I wrote down x and y values (x = scrollTop, y=aspect) starting from the top and plugged them into here, which gave me an equation to use in useLayoutEffect to update the aspect more accurately. The onWheel event listener doesn't detect every minute wheel movement though, so there are small moments here and there that the aspect has a slight stretch effect before it corrects itself, but at least it is easier to look at now. Here is my code: ScrollControls Canvas Component:
Scroll Camera Component:
|
Hello!
I am currently using
"@react-three/drei": "^9.111.3",
"@react-three/fiber": "^8.17.5",
"three": "^0.167.1"
I am having an issue with the canvas in r3f. When I implemented ScrollControls on the camera, the environment and all the items in the scene appear to be stretched out vertically, and would return to normal as soon as I scrolled to the bottom. Also, the Environment takes up the whole canvas when PerspectiveCamera is used, unlike Orthographic camera, but I originally intended to use OrthographicCamera.
Here is my example of the problem I am encountering. I would like the skewed effect to not happen, and for the camera’s animation to happen instead. If you know what might be causing this issue, please let me know!
Thank you!
The text was updated successfully, but these errors were encountered: