feat: models

This commit is contained in:
TrèsAbhi committed 2023-12-31 20:47:21 -06:00
1 parent 28dde23115
commit 8b10f2cc4a
7 files changed
+122 -76

No files matched your search

@@ -0,0 +1,22 @@
import { useThree } from '@react-three/fiber';
import { RefObject, useEffect } from 'react';
import { Box3, Group } from 'three';
interface TankAlignmentProps {
model: RefObject<Group>;
}
export function TankAlignment({ model }: TankAlignmentProps) {
const camera = useThree((state) => state.camera);
useEffect(() => {
const box = new Box3().setFromObject(model.current!);
const diameter = Math.max(box.max.x - box.min.x, box.max.z - box.min.z);
const radius = diameter / 2;
model.current?.position.set(0, -(box.min.y + box.max.y) / 2, 0);
// camera.position.set(radius * -0.25, radius * 0.1, radius * -1.5);
}, []);
return null;
}