import { useProgress } from '@react-three/drei'; import { useViewerStore } from '../../store/viewerStore'; export function LoadingProgressOverlay() { const loading = useViewerStore((state) => state.loading); const { active, progress, item, errors } = useProgress(); const isError = loading.phase === 'error' || errors.length > 0; const visible = active || loading.phase === 'loading' || loading.phase === 'preparing' || isError; if (!visible) { return null; } const progressValue = isError ? 100 : Math.max( loading.progress, Number.isFinite(progress) ? Math.round(progress) : 0 ); return (
{isError ? 'Unable to load machine asset' : 'Preparing 3D machine'}
{isError ? loading.error ?? String(errors[0] ?? 'Unknown loader error') : item || loading.label || 'Building scene graph'}