export class GLTFUtils {
    static setup(gltf) {
        const obj = gltf.scene || gltf.scenes[0];
        let mesh;
        if (obj instanceof THREE.Mesh) {
            mesh = obj;
        }
        else {
            obj.children.forEach(child => {
                if (child instanceof THREE.Mesh) {
                    mesh = child;
                }
            });
        }
        let geom = mesh.geometry;
        if (geom instanceof THREE.BufferGeometry) {
            geom = new THREE.Geometry().fromBufferGeometry(mesh.geometry);
        }
        let maxDist = geom.vertices.reduce((a, b) => {
            return new THREE.Vector3(Math.min(a.length(), b.length()), 0, 0);
        }).x;
        return { mesh, maxDist };
    }
}
