This commit is contained in:
gpt-engineer-app[bot]
2026-02-28 18:51:23 +00:00
parent 6bec33474b
commit d9a8cc94c9
2 changed files with 349 additions and 13 deletions
+37 -13
View File
@@ -12,6 +12,7 @@ const Index = () => {
const navigate = useNavigate();
const fileInputRef = useRef<HTMLInputElement>(null);
const [loadingDemo, setLoadingDemo] = useState(false);
const [loadingDemoIFC, setLoadingDemoIFC] = useState(false);
const [converting, setConverting] = useState(false);
const { model, setModel, xrSupported, setXrSupported } = useModelStore();
@@ -76,6 +77,23 @@ const Index = () => {
}
}, [setModel]);
const handleLoadDemoIFC = useCallback(async () => {
setLoadingDemoIFC(true);
try {
const response = await fetch('/models/demo250hp.ifc');
const buffer = await response.arrayBuffer();
const result = await convertIFCtoGLB(buffer, 'demo250hp.ifc');
const url = URL.createObjectURL(result.blob);
setModel({ fileName: result.fileName, fileSize: result.fileSize, url });
toast.success('Modelo demo "250 HP" (IFC) carregado!');
} catch (err) {
console.error(err);
toast.error('Falha ao converter modelo demo IFC');
} finally {
setLoadingDemoIFC(false);
}
}, [setModel]);
const handleEnterViewer = () => {
if (!model) {
toast.error('Importe um modelo GLB primeiro');
@@ -123,20 +141,26 @@ const Index = () => {
</div>
</Button>
{/* Demo button */}
<Button
variant="outline"
className="h-12 w-full gap-3 border-muted-foreground/30 text-muted-foreground hover:border-primary hover:text-primary transition-all"
onClick={handleLoadDemo}
disabled={loadingDemo}>
{/* Demo buttons */}
<div className="grid grid-cols-2 gap-2">
<Button
variant="outline"
className="h-12 w-full gap-2 border-muted-foreground/30 text-muted-foreground hover:border-primary hover:text-primary transition-all text-xs"
onClick={handleLoadDemo}
disabled={loadingDemo}>
{loadingDemo ? <Loader2 className="h-4 w-4 animate-spin" /> : <Package className="h-4 w-4" />}
{loadingDemo ? 'Gerando…' : 'Demo — Viga IPE 200'}
</Button>
{loadingDemo ?
<Loader2 className="h-4 w-4 animate-spin" /> :
<Package className="h-4 w-4" />
}
{loadingDemo ? 'Gerando modelo…' : 'Carregar Demo — Viga IPE 200'}
</Button>
<Button
variant="outline"
className="h-12 w-full gap-2 border-muted-foreground/30 text-muted-foreground hover:border-primary hover:text-primary transition-all text-xs"
onClick={handleLoadDemoIFC}
disabled={loadingDemoIFC}>
{loadingDemoIFC ? <Loader2 className="h-4 w-4 animate-spin" /> : <Package className="h-4 w-4" />}
{loadingDemoIFC ? 'Convertendo…' : 'Demo — 250 HP (IFC)'}
</Button>
</div>
{model &&