- Added a new modelsProxyRouter to handle requests for optimized 3D character models. - Introduced modelsProxyService to manage GLB file optimization using gltf-transform with Draco compression. - Updated app.js to include the new modelsProxyRouter for API access. - Enhanced .gitignore to exclude model cache files. - Added scripts for optimizing GLB models and updated README with optimization instructions. - Integrated DRACOLoader in Character3D.vue for loading compressed models. - Updated FamilyView.vue to streamline character rendering logic.
46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Optimiert Falukant-Charakter-GLBs mit Draco + Textur-Optimierung.
|
|
* Ausgabe: *_opt.glb im selben Verzeichnis.
|
|
* Voraussetzung: npm install (@gltf-transform/cli als Dev-Dep)
|
|
*
|
|
* Aufruf: npm run optimize-models
|
|
*/
|
|
|
|
import { execSync } from 'child_process';
|
|
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 models = [
|
|
'male.glb', 'female.glb',
|
|
'male_adult.glb', 'male_child.glb', 'male_preteen.glb', 'male_teen.glb', 'male_toddler.glb',
|
|
'female_adult.glb', 'female_child.glb', 'female_preteen.glb', 'female_teen.glb', 'female_toddler.glb',
|
|
];
|
|
|
|
const cli = path.join(__dirname, '..', 'node_modules', '.bin', 'gltf-transform');
|
|
const cmd = (input, output) =>
|
|
`"${cli}" optimize "${input}" "${output}" --compress draco --texture-size 1024`;
|
|
|
|
console.log('Optimize Falukant character GLBs (Draco + texture 1024)\n');
|
|
|
|
for (const f of models) {
|
|
const input = path.join(charsDir, f);
|
|
const out = f.replace(/\.glb$/, '_opt.glb');
|
|
const output = path.join(charsDir, out);
|
|
|
|
try {
|
|
execSync(`node "${cli}" optimize "${input}" "${output}" --compress draco --texture-size 1024`, {
|
|
stdio: 'inherit',
|
|
cwd: path.join(__dirname, '..'),
|
|
});
|
|
} catch (e) {
|
|
console.error(`Failed: ${f}`);
|
|
process.exitCode = 1;
|
|
}
|
|
}
|
|
|
|
console.log('\nDone. Use *_opt.glb in Character3D (with DRACOLoader).');
|