Files
blitzkit/src/app/tools/tankopedia/[id]/components/Control.tsx
T

25 lines
754 B
TypeScript
Raw Normal View History

2024-01-03 12:21:30 -06:00
import { OrbitControls } from '@react-three/drei';
import { useThree } from '@react-three/fiber';
2024-01-04 13:37:36 -06:00
import { useEffect, useRef } from 'react';
2024-01-03 12:21:30 -06:00
import { OrbitControls as OrbitControlsClass } from 'three-stdlib';
2024-01-04 13:06:40 -06:00
import { useTankopedia } from '../../../../../stores/tankopedia';
2024-01-03 12:21:30 -06:00
2024-01-04 13:37:36 -06:00
export function Controls() {
2024-01-03 12:21:30 -06:00
const camera = useThree((state) => state.camera);
const orbitControls = useRef<OrbitControlsClass>(null);
2024-01-04 13:06:40 -06:00
const enabled = useTankopedia((state) => state.model.controlsEnabled);
2024-01-03 12:21:30 -06:00
useEffect(() => {
2024-01-04 13:37:36 -06:00
camera.position.set(-5, 4, -20);
orbitControls.current?.target.set(0, 1.5, 0);
}, []);
2024-01-03 12:21:30 -06:00
2024-01-06 18:17:04 -06:00
return (
2024-01-12 20:22:53 -06:00
<OrbitControls
ref={orbitControls}
enabled={enabled}
rotateSpeed={0.25}
enableDamping={false}
/>
2024-01-06 18:17:04 -06:00
);
2024-01-03 12:21:30 -06:00
}