adiciona modelo real

This commit is contained in:
Rodrigo Bertoldo de Sousa Martins committed 2026-09-07 21:30:18 -03:00
1 parent 71d13753c9
commit 3a659a52c7
18 files changed
+612 -176

No files matched your search

@@ -0,0 +1,32 @@
import { createWriteStream, existsSync, mkdirSync, statSync } from "node:fs";
import { pipeline } from "node:stream/promises";
import { Readable } from "node:stream";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { RAW_BASE, SOURCES } from "./sources.mjs";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const RAW_DIR = path.resolve(__dirname, "../raw");
mkdirSync(RAW_DIR, { recursive: true });
async function download(fbx) {
const dest = path.join(RAW_DIR, fbx);
if (existsSync(dest) && statSync(dest).size > 0) {
console.log(`✓ já baixado: ${fbx}`);
return;
}
const url = RAW_BASE + fbx;
console.log(`↓ baixando ${fbx}...`);
const res = await fetch(url);
if (!res.ok || !res.body) {
throw new Error(`Falha ao baixar ${fbx}: HTTP ${res.status} (${url})`);
}
await pipeline(Readable.fromWeb(res.body), createWriteStream(dest));
console.log(`✓ ${fbx} baixado (${(statSync(dest).size / 1024 / 1024).toFixed(1)} MB)`);
}
for (const { fbx } of SOURCES) {
await download(fbx);
}
console.log("Todos os modelos-fonte baixados.");