Skip to content

Commit

Permalink
feat - clamp cam bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
sdubourg committed Jul 26, 2023
1 parent 0e42cbc commit 6c00329
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions src/components/gl/World/Cam.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,25 @@
import { CameraControls } from '@react-three/drei';
import { useControls } from 'leva';

Check warning on line 2 in src/components/gl/World/Cam.tsx

View workflow job for this annotation

GitHub Actions / main - Build and deploy

'useControls' is defined but never used

Check failure on line 2 in src/components/gl/World/Cam.tsx

View workflow job for this annotation

GitHub Actions / main - Build and deploy

'useControls' is declared but its value is never read.
import { useEffect, useRef } from 'react';
import { Box3, Vector3 } from 'three';
import { DEG2RAD } from 'three/src/math/MathUtils';

export const Cam = () => {
const cameraControlsRef = useRef<CameraControls>(null);

// DEBUG
// const { d, t } = useControls({
// d: {
// step: 0.1,
// value: 22.95,
// min: 22,
// max: 28,
// },
// t: {
// step: 0.1,
// value: 85,
// min: 60,
// max: 100,
// },
// });

useEffect(() => {
cameraControlsRef.current?.setBoundary(
new Box3(new Vector3(-40, 2, 0), new Vector3(80, 2, 0)),
new Box3(new Vector3(-26, 2, 0), new Vector3(55.5, 2, 0)),
);
}, [cameraControlsRef]);

return (
<>
<CameraControls
ref={cameraControlsRef}
// enabled={!isDragging}
maxDistance={23}
distance={23}
truckSpeed={4}
// truckSpeed={isDragging ? -4 : 4}
polarAngle={DEG2RAD * 87}
minPolarAngle={DEG2RAD * 87}
maxPolarAngle={DEG2RAD * 87}
Expand Down

0 comments on commit 6c00329

Please sign in to comment.