Add male toddler character model in GLB format
All checks were successful
Deploy to production / deploy (push) Successful in 3m27s

This commit is contained in:
Torsten Schulz (local)
2026-07-30 09:59:53 +02:00
parent b3f6429307
commit 60ad24d317
38 changed files with 67 additions and 91 deletions

View File

@@ -13,18 +13,42 @@ import { fileURLToPath } from 'url';
import path from 'path';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const charsDir = path.join(__dirname, '..', 'public', 'models', '3d', 'falukant', 'characters');
const sourceDir = path.join(__dirname, '..', 'models-src', '3d', 'falukant', 'characters');
const outputDir = path.join(__dirname, '..', 'public', 'models', '3d', 'falukant', 'characters');
const cli = path.join(__dirname, '..', 'node_modules', '.bin', 'gltf-transform');
function listSourceModels() {
return fs.readdirSync(charsDir)
return fs.readdirSync(sourceDir)
.filter((file) => file.endsWith('.glb'))
.filter((file) => !file.endsWith('_opt.glb'))
.sort((a, b) => a.localeCompare(b));
}
function ensureOutputDir() {
fs.mkdirSync(outputDir, { recursive: true });
}
function removeStaleOptimizedModels() {
if (!fs.existsSync(outputDir)) {
return;
}
for (const file of fs.readdirSync(outputDir)) {
if (file.endsWith('_opt.glb')) {
fs.unlinkSync(path.join(outputDir, file));
}
}
}
console.log('Optimize Falukant character GLBs (Draco + texture 1024)\n');
if (!fs.existsSync(sourceDir)) {
console.error(`Source directory not found: ${sourceDir}`);
process.exit(1);
}
ensureOutputDir();
removeStaleOptimizedModels();
const models = listSourceModels();
if (models.length === 0) {
console.log('No source GLBs found.');
@@ -32,9 +56,9 @@ if (models.length === 0) {
}
for (const f of models) {
const input = path.join(charsDir, f);
const input = path.join(sourceDir, f);
const out = f.replace(/\.glb$/, '_opt.glb');
const output = path.join(charsDir, out);
const output = path.join(outputDir, out);
try {
const result = spawnSync(
@@ -54,4 +78,4 @@ for (const f of models) {
}
}
console.log('\nDone. Use *_opt.glb in Character3D (with DRACOLoader).');
console.log(`\nDone. Optimized models written to ${outputDir}`);