feat(optimize): optimize Falukant 3D models during build and update deployment scripts

This commit is contained in:
Torsten Schulz (local)
2026-07-24 13:31:08 +02:00
parent 2b6c747616
commit 12985bf3fa
6 changed files with 51 additions and 20 deletions

View File

@@ -26,6 +26,7 @@ import { getApiBaseURL } from '@/utils/axios.js';
/** Backend-Route: GET /api/models/3d/falukant/characters/:filename (Proxy mit Draco-Optimierung) */
const MODELS_API_PATH = '/api/models/3d/falukant/characters';
const OPTIMIZED_MODEL_SUFFIX = '_opt.glb';
// Optional: zusätzliche Namenskonventionen, die vor dem Standardpfad ausprobiert werden.
// Hier werden mögliche Alternativ-Dateinamen aufgeführt, die für bestimmte Altersstufen
// (z.B. weibliche Modelle für 1-4 Jahre) existieren könnten. Trage hier die tatsächlichen
@@ -273,6 +274,10 @@ export default {
this.cleanup();
},
methods: {
toOptimizedModelPath(url) {
return String(url || '').replace(/\.glb$/i, OPTIMIZED_MODEL_SUFFIX);
},
async ensureThreeRuntime() {
if (!this.threeRuntime) {
this.threeRuntime = markRaw(await loadThreeRuntime());
@@ -457,9 +462,9 @@ export default {
// Lightweight:
// 1. Altersbereich
// 2. Basis-Modell
const exactAgePath = this.exactAgeModelPath;
const ageGroupPath = this.modelPath;
const fallbackPath = `${prefix}/${this.actualGender}.glb`;
const exactAgePath = this.toOptimizedModelPath(this.exactAgeModelPath);
const ageGroupPath = this.toOptimizedModelPath(this.modelPath);
const fallbackPath = `${prefix}/${this.actualGender}${OPTIMIZED_MODEL_SUFFIX}`;
// Build a list of candidate paths. For every age and gender we first try
// possible alternate filenames for the exact-age model (e.g. female_1y_alt.glb),
@@ -471,7 +476,7 @@ export default {
// Try exact-age variants with configured suffixes first (works for any gender/age)
for (const sfx of AGE_ALTERNATIVE_SUFFIXES) {
candidates.push(`${prefix}/${this.actualGender}_${modelAge}y${sfx}`);
candidates.push(this.toOptimizedModelPath(`${prefix}/${this.actualGender}_${modelAge}y${sfx}`));
}
// Standard preference order: exact age, age group, fallback