Files
Spellcast3d/code/tests/bake/node/validate.mjs
Igor AherneandClaude Opus 5.5 56d85f6eeb Spellcast3D 0.1.0
A free, open-source Windows app that takes an artist from an idea to game-ready 3D props on their own PC: pictures with Qwen-Image 2.1, 3D models with Pixal3D, an optional repaint of their textures, retopology with TriFlow, LATO.2 or Instant Meshes, and a baker for the final textures. See README.md, and DEVELOPERS.md for building from source.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 02:38:33 +01:00

35 lines
1.3 KiB
JavaScript

// Dev-only: run the Khronos glTF-Validator (2.0.0-dev.3.10) on baked GLBs.
//
// node validate.mjs baked.glb [more.glb ...]
//
// Exit code 0 when every file has 0 errors and 0 warnings (infos and hints are listed).
import fs from 'fs';
import path from 'path';
import validator from 'gltf-validator';
const SEVERITY = ['E', 'W', 'I', 'H'];
async function validate(file) {
const report = await validator.validateBytes(new Uint8Array(fs.readFileSync(file)), {
uri: path.basename(file),
maxIssues: 100,
externalResourceFunction: (uri) => Promise.resolve(new Uint8Array(fs.readFileSync(path.join(path.dirname(file), uri)))),
});
const { numErrors, numWarnings, numInfos, numHints, messages } = report.issues;
const ok = numErrors === 0 && numWarnings === 0;
console.log(`${ok ? 'PASS' : 'FAIL'} ${path.basename(file)}: ${numErrors} errors, ${numWarnings} warnings, `
+ `${numInfos} infos, ${numHints} hints`);
for (const m of messages) console.log(` ${SEVERITY[m.severity]} ${m.code} ${m.pointer || ''} ${m.message}`);
return ok;
}
const files = process.argv.slice(2);
if (files.length === 0) {
console.error('usage: node validate.mjs baked.glb [more.glb ...]');
process.exitCode = 2;
} else {
const results = [];
for (const file of files) results.push(await validate(file));
process.exitCode = results.every(Boolean) ? 0 : 1;
}