import { Box3, BoxGeometry, EdgesGeometry, Vector3 } from "three";

export const AssetBoundingBox = ({ boundingBox }: { boundingBox: Box3 | null }) => {
    if (!boundingBox) return null;

    const size = boundingBox.getSize(new Vector3());
    const center = boundingBox.getCenter(new Vector3());

    const boxGeometry = new BoxGeometry(size.x, size.y, size.z);
    const edges = new EdgesGeometry(boxGeometry);

    return (
        <group name='Asset FallBack'>
            <lineSegments position={center}>
                <bufferGeometry attach="geometry" {...edges} />
                <lineBasicMaterial depthWrite={false} attach="material" color="gray" linewidth={1} />
            </lineSegments>
        </group>
    );
};