fix camera
This commit is contained in:
@@ -48,21 +48,22 @@ export const CustomCameraControls = () => {
|
|||||||
}, [currentLevelId]);
|
}, [currentLevelId]);
|
||||||
|
|
||||||
// Configure mouse buttons based on control mode and camera mode
|
// Configure mouse buttons based on control mode and camera mode
|
||||||
|
const cameraMode = useViewer((state) => state.cameraMode);
|
||||||
const mouseButtons = useMemo(() => {
|
const mouseButtons = useMemo(() => {
|
||||||
// Use ZOOM for orthographic camera, DOLLY for perspective camera
|
// Use ZOOM for orthographic camera, DOLLY for perspective camera
|
||||||
// const wheelAction =
|
const wheelAction =
|
||||||
// cameraMode === 'orthographic'
|
cameraMode === 'orthographic'
|
||||||
// ? CameraControlsImpl.ACTION.ZOOM
|
? CameraControlsImpl.ACTION.ZOOM
|
||||||
// : CameraControlsImpl.ACTION.DOLLY
|
: CameraControlsImpl.ACTION.DOLLY
|
||||||
const wheelAction = CameraControlsImpl.ACTION.DOLLY;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
left: CameraControlsImpl.ACTION.NONE,
|
left: CameraControlsImpl.ACTION.NONE,
|
||||||
middle: CameraControlsImpl.ACTION.SCREEN_PAN,
|
middle: CameraControlsImpl.ACTION.SCREEN_PAN,
|
||||||
right: CameraControlsImpl.ACTION.ROTATE,
|
right: CameraControlsImpl.ACTION.ROTATE,
|
||||||
wheel: wheelAction,
|
wheel: wheelAction,
|
||||||
};
|
}
|
||||||
}, []);
|
}, [cameraMode]);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleNodeCapture = ({ nodeId }: CameraControlEvent) => {
|
const handleNodeCapture = ({ nodeId }: CameraControlEvent) => {
|
||||||
@@ -110,5 +111,8 @@ export const CustomCameraControls = () => {
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return <CameraControls ref={controls} mouseButtons={mouseButtons} />;
|
return <CameraControls maxDistance={100}
|
||||||
|
maxPolarAngle={Math.PI / 2 - 0.1}
|
||||||
|
minDistance={10}
|
||||||
|
minPolarAngle={0} ref={controls} mouseButtons={mouseButtons} />;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user