You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the viewport changes size the default camera changes for some reason.
Here is my custom <OrthographicCamera /> implementation (modification of drei's <OrthographicCamera /> implementation):
import{useLayoutEffect,useRef,FunctionComponent}from'react';import{OrthographicCameraasOrthographicCameraImpl,Vector3}from'three';import{useThree}from'@react-three/fiber';typeProps=Omit<JSX.IntrinsicElements['orthographicCamera'],'children'>;exportconstOrthographicCamera: FunctionComponent<Props>=({ ...props})=>{constset=useThree(({ set })=>set);constcamera=useThree(({ camera })=>camera);constsize=useThree(({ size })=>size);// eslint-disable-next-line @typescript-eslint/no-non-null-assertionconstcameraRef=useRef<OrthographicCameraImpl>(null!);useLayoutEffect(()=>{cameraRef.current.updateProjectionMatrix();},[size]);useLayoutEffect(()=>{cameraRef.current.updateProjectionMatrix();});useLayoutEffect(()=>{camera.lookAt(newVector3(0,0,0));},[camera]);useLayoutEffect(()=>{constoldCam=camera;set(()=>({camera: cameraRef.current}));return()=>set(()=>({camera: oldCam}));// The camera should not be part of the dependency list because this// components camera is a stable reference that must exchange the default,// and clean up after itself on unmount.// eslint-disable-next-line react-hooks/exhaustive-deps},[set,cameraRef]);return(<orthographicCameraleft={size.width/-2}right={size.width/2}top={size.height/2}bottom={size.height/-2}ref={cameraRef}far={2000}near={0.1}{...props}/>);};
Now it's entirely possible that my implementation of <OrthographicCamera /> has some flaw but on the other hand I usually don't expect a patch version change to cause breaking changes.
Here is a video showing the bug in action:
broken.mov
The text was updated successfully, but these errors were encountered:
Patch version
8.11.6
has introduced a breaking change to default camera set logic. The specific commit is 99fef6c27294024b1bda35730a6edc17e32ef390.When the viewport changes size the default camera changes for some reason.
Here is my custom
<OrthographicCamera />
implementation (modification of drei's<OrthographicCamera />
implementation):Now it's entirely possible that my implementation of
<OrthographicCamera />
has some flaw but on the other hand I usually don't expect a patch version change to cause breaking changes.Here is a video showing the bug in action:
broken.mov
The text was updated successfully, but these errors were encountered: