This commit is contained in:
gpt-engineer-app[bot]
2026-02-27 02:36:49 +00:00
parent 09d6b381a4
commit 11f16eff5a
5 changed files with 137 additions and 9 deletions
+12 -6
View File
@@ -6,6 +6,7 @@ import { useModelStore } from '@/stores/useModelStore';
import { toast } from 'sonner';
import { generateDemoBeamGLB } from '@/lib/generateDemoBeam';
import { getSupportedExtension, convertToGLB, ACCEPTED_EXTENSIONS } from '@/lib/convertToGLB';
import { convertIFCtoGLB } from '@/lib/convertIFC';
const Index = () => {
const navigate = useNavigate();
@@ -28,7 +29,7 @@ const Index = () => {
const ext = getSupportedExtension(file.name);
if (!ext) {
toast.error('Formato inválido. Selecione um arquivo .GLB, .OBJ ou .STL');
toast.error('Formato inválido. Selecione um arquivo .GLB, .OBJ, .STL ou .IFC');
return;
}
@@ -39,13 +40,18 @@ const Index = () => {
return;
}
// Convert OBJ/STL to GLB
// Convert OBJ/STL/IFC to GLB
setConverting(true);
try {
const buffer = await file.arrayBuffer();
const { blob, fileName, fileSize } = await convertToGLB(buffer, ext, file.name);
const url = URL.createObjectURL(blob);
setModel({ fileName, fileSize, url });
let result;
if (ext === 'ifc') {
result = await convertIFCtoGLB(buffer, file.name);
} else {
result = await convertToGLB(buffer, ext, file.name);
}
const url = URL.createObjectURL(result.blob);
setModel({ fileName: result.fileName, fileSize: result.fileSize, url });
toast.success(`"${file.name}" convertido para GLB e carregado!`);
} catch (err) {
console.error(err);
@@ -113,7 +119,7 @@ const Index = () => {
{converting ? <Loader2 className="h-8 w-8 animate-spin" /> : <Upload className="h-8 w-8" />}
<div className="text-center">
<p className="text-sm font-semibold">{converting ? 'Convertendo modelo…' : 'Importar Modelo 3D'}</p>
<p className="text-xs text-muted-foreground">GLB · OBJ · STL Escala 1:1</p>
<p className="text-xs text-muted-foreground">GLB · OBJ · STL · IFC Escala 1:1</p>
</div>
</Button>