Skip to content

Commit

Permalink
rename set camera
Browse files Browse the repository at this point in the history
  • Loading branch information
interim17 committed Sep 8, 2023
1 parent 49598cc commit a78dee4
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/components/CameraControls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const CameraControls = ({
}: CameraControlsProps): JSX.Element => {
const [isFocused, saveFocusMode] = useState(true);
const [mode, setMode] = useState(ROTATE);
const [camera, setCamera] = useState(PERSPECTIVE);
const [cameraProjectionType, setCameraProjectionType] =
useState(PERSPECTIVE);
const [keyPressed, setKeyPressed] = useState("");
const lastKeyPressed = useRef("");

Expand Down Expand Up @@ -104,8 +105,8 @@ const CameraControls = ({
}, [mode]);

useEffect(() => {
setCameraType(camera === ORTHOGRAPHIC);
}, [camera]);
setCameraType(cameraProjectionType === ORTHOGRAPHIC);
}, [cameraProjectionType]);

useEffect(() => {
if (
Expand All @@ -130,10 +131,10 @@ const CameraControls = ({
saveFocusMode(!isFocused);
break;
case ORTHOGRAPHIC:
setCamera(ORTHOGRAPHIC);
setCameraProjectionType(ORTHOGRAPHIC);
break;
case PERSPECTIVE:
setCamera(PERSPECTIVE);
setCameraProjectionType(PERSPECTIVE);
break;
default:
break;
Expand Down Expand Up @@ -227,11 +228,14 @@ const CameraControls = ({
detaches keypressed listener after the button is pressed */}
<Button
className={classNames([
{ [styles.active]: camera === ORTHOGRAPHIC },
{
[styles.active]:
cameraProjectionType === ORTHOGRAPHIC,
},
styles.radioBtn,
])}
onClick={() => {
setCamera(ORTHOGRAPHIC);
setCameraProjectionType(ORTHOGRAPHIC);
}}
icon={Icons.OrthographicCamera}
></Button>
Expand All @@ -243,11 +247,14 @@ const CameraControls = ({
>
<Button
className={classNames([
{ [styles.active]: camera === PERSPECTIVE },
{
[styles.active]:
cameraProjectionType === PERSPECTIVE,
},
styles.radioBtn,
])}
onClick={() => {
setCamera(PERSPECTIVE);
setCameraProjectionType(PERSPECTIVE);
}}
icon={Icons.PerspectiveCamera}
></Button>
Expand Down

0 comments on commit a78dee4

Please sign in to comment.