From 2ebd8216fa10c7f4cc395db45157a16d5294b47b Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Tue, 29 Sep 2026 11:56:53 +0200 Subject: [PATCH] perf(falukant): simplify house runtime geometry --- frontend/scripts/build-falukant-runtime-models.mjs | 9 ++++++++- frontend/scripts/optimize-glb.mjs | 12 +++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/frontend/scripts/build-falukant-runtime-models.mjs b/frontend/scripts/build-falukant-runtime-models.mjs index b59fb5f..e49b371 100644 --- a/frontend/scripts/build-falukant-runtime-models.mjs +++ b/frontend/scripts/build-falukant-runtime-models.mjs @@ -16,13 +16,20 @@ const scriptDir = path.dirname(fileURLToPath(import.meta.url)); const frontendDir = path.resolve(scriptDir, '..'); const args = process.argv.slice(2); const optionIndex = args.indexOf('--assets-dir'); +const categoryIndex = args.indexOf('--category'); const assetsDir = path.resolve(optionIndex >= 0 && args[optionIndex + 1] ? args[optionIndex + 1] : path.join(frontendDir, '..', '..', 'YourPart3Assets')); const sourceRoot = path.join(assetsDir, 'models-src', '3d', 'falukant'); const outputRoot = path.join(assetsDir, 'public', 'models', '3d', 'falukant'); -for (const category of ['characters', 'houses']) { +const selectedCategory = categoryIndex >= 0 ? args[categoryIndex + 1] : null; +const categories = selectedCategory ? [selectedCategory] : ['characters', 'houses']; +if (categories.some((category) => !['characters', 'houses'].includes(category))) { + throw new Error('Use --category characters or --category houses.'); +} + +for (const category of categories) { const sourceDir = path.join(sourceRoot, category); const outputDir = path.join(outputRoot, category); if (!fs.existsSync(sourceDir)) { diff --git a/frontend/scripts/optimize-glb.mjs b/frontend/scripts/optimize-glb.mjs index 3f80ab8..65e6ea1 100755 --- a/frontend/scripts/optimize-glb.mjs +++ b/frontend/scripts/optimize-glb.mjs @@ -62,6 +62,7 @@ function optimizeModelDirectory({ name, sourceDir, outputDir, required = false } } console.log(`Optimize Falukant ${name} GLBs (Draco + texture 1024)\n`); + const isHouse = name === 'house' || name === 'houses' || path.basename(sourceDir) === 'houses'; for (const f of models) { const input = path.join(sourceDir, f); @@ -71,7 +72,16 @@ function optimizeModelDirectory({ name, sourceDir, outputDir, required = false } try { const result = spawnSync( 'node', - [cli, 'optimize', input, output, '--compress', 'draco', '--texture-size', '1024'], + [ + cli, 'optimize', input, output, + '--compress', 'draco', + '--texture-size', '1024', + // Draco reduces download size, while simplify prevents high-poly + // scans from exhausting browser GPU memory. Houses are small + // previews, so they get a deliberately stronger reduction. + '--simplify-ratio', isHouse ? '0.05' : '0.35', + '--simplify-error', isHouse ? '0.02' : '0.01', + ], { stdio: 'inherit', cwd: path.join(__dirname, '..'),