Replies: 2 comments
-
I've found a workaround, although it involves calculating the projection matrix multiple times on resize so it's to ideal. I'm adding my own resize eventlistener and recalculating the projection matrix after R3F overwrites mine: const get = useThree((state) => state.get);
const onResize = () => {
const customProjectionMatrix = calculateCustomProjectionMatrix(get().size, spec);
camera.projectionMatrix.copy(customProjectionMatrix );
};
window.addEventListener('resize', onResize); So far its working well, although I'm a little worried about the order of the even listeners firing - if mine fires after the R3F internal |
Beta Was this translation helpful? Give feedback.
-
r3f v7.0.27 And obviously, now it's up to you to calculate camera frustrum and canvas dimensions. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I need to handle updating the camera's projection matrix manually to create a smooth animation between orthographic and perspective views. Unfortunately this breaks whenever the scene is resized due to
camera.updateProjectionMatrix()
being called.There used to be a
Canvas.updateDefaultCamera
property but since that was removed I can't find an easy way to disable camera auto-resizing.Using the custom
render
function as suggested in #1371 would be complete overkill as I want all other normal functionality of<Canvas />
In #885 (comment) @drcmda suggestions doing this:
Unfortunately when I tried this it still auto-resizes the camera and overwrites my custom projection matrix.
Are there any simple solutions to this that I've overlooked?
Beta Was this translation helpful? Give feedback.
All reactions