25 lines
918 B
JavaScript
25 lines
918 B
JavaScript
import { execFileSync } from "node:child_process";
|
|
import { existsSync, mkdirSync } from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { SOURCES } from "./sources.mjs";
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const RAW_DIR = path.resolve(__dirname, "../raw");
|
|
const CONVERTED_DIR = path.resolve(__dirname, "../converted");
|
|
mkdirSync(CONVERTED_DIR, { recursive: true });
|
|
|
|
for (const { fbx, key } of SOURCES) {
|
|
const inPath = path.join(RAW_DIR, fbx);
|
|
const outPath = path.join(CONVERTED_DIR, `${key}.glb`);
|
|
if (existsSync(outPath)) {
|
|
console.log(`✓ já convertido: ${fbx}`);
|
|
continue;
|
|
}
|
|
console.log(`⚙ convertendo ${fbx} → ${key}.glb ...`);
|
|
execFileSync("assimp", ["export", inPath, outPath, "-f", "glb2"], { stdio: "inherit" });
|
|
console.log(`✓ ${key}.glb gerado`);
|
|
}
|
|
|
|
console.log("Conversão FBX → glTF concluída.");
|