Replies: 1 comment 2 replies
-
Aha! I see what the issue is. r3f modifies the passed-in camera's aspect ratio here and As an alternative, maybe we can adjust the camera's aspect before each scene renders. How may we do that? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've managed to reproduce one of the issues I have in a rather large application of mine. The large application isn't open source, but basically there is a non-react-three-fiber Three.js scene in the app, and I am rendering supplemental scenes in small parts of the UI (f.e. think of mini maps, or similar). So I have a plain Three.js scene that takes up most of the screen, and I decided to try and introduce r3f for the supplemental scenes.
One issue I have is that when I pass the main scene's camera to the supplemental react-three-fiber scenes with
sharedCanvasContext.setDefaultCamera()
so that I can render them with the same viewpoint as the main scene, it somehow causes the main scene to be distorted, or vice versa, as if some form ofscale
is being applied and it stretches one or the other.I've managed to reproduce this issue. In the following sandbox, the small scene at the top has a red box in the middle. It should look like a square. But after a brief moment, you will see that the box is stretched.
https://codesandbox.io/s/r3f-mouse-forked-ev9bg?file=/src/index.js
If you go to the very bottom of
index.js
and comment out theReactDOM.render()
call, so that react-three-fiber will not be used, you will notice that non-r3f scene works fine and the box is not stretched.For some reason, when we render the r3f scene also, then it distorts the main scene.
For reference, here it is without the r3f scenes and the plain-Three scene is fine:
https://codesandbox.io/s/r3f-mouse-forked-748g8?file=/src/index.js
Any ideas why?
Beta Was this translation helpful? Give feedback.
All reactions