From ace976965da27c7df8fa979e434cf21907bc29c4 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Thu, 22 Jan 2026 13:42:27 +0100 Subject: [PATCH] Refactor model path handling in Character3D component - Introduced a constant for the models API path to streamline model path construction. - Updated modelPath method to utilize the new constant, improving code clarity and maintainability. - Adjusted fallback model path logic to ensure consistent API usage. --- frontend/src/components/Character3D.vue | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/Character3D.vue b/frontend/src/components/Character3D.vue index 28aee65..8fc9054 100644 --- a/frontend/src/components/Character3D.vue +++ b/frontend/src/components/Character3D.vue @@ -9,6 +9,9 @@ import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js'; import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js'; 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'; + export default { name: 'Character3D', props: { @@ -76,11 +79,9 @@ export default { return 'adult'; }, modelPath() { - const gender = this.actualGender; - const ageGroup = this.ageGroup; const base = getApiBaseURL(); - const prefix = base ? `${base}/api/models/3d/falukant/characters` : '/api/models/3d/falukant/characters'; - return `${prefix}/${gender}_${ageGroup}.glb`; + const prefix = base ? `${base}${MODELS_API_PATH}` : MODELS_API_PATH; + return `${prefix}/${this.actualGender}_${this.ageGroup}.glb`; } }, watch: { @@ -204,9 +205,9 @@ export default { const loader = new GLTFLoader(); loader.setDRACOLoader(dracoLoader); - const modelPath = this.modelPath; const base = getApiBaseURL(); - const prefix = base ? `${base}/api/models/3d/falukant/characters` : '/api/models/3d/falukant/characters'; + const prefix = base ? `${base}${MODELS_API_PATH}` : MODELS_API_PATH; + const modelPath = this.modelPath; const fallbackPath = `${prefix}/${this.actualGender}.glb`; let gltf;