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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user