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 { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
|
||||||
import { getApiBaseURL } from '@/utils/axios.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 {
|
export default {
|
||||||
name: 'Character3D',
|
name: 'Character3D',
|
||||||
props: {
|
props: {
|
||||||
@@ -76,11 +79,9 @@ export default {
|
|||||||
return 'adult';
|
return 'adult';
|
||||||
},
|
},
|
||||||
modelPath() {
|
modelPath() {
|
||||||
const gender = this.actualGender;
|
|
||||||
const ageGroup = this.ageGroup;
|
|
||||||
const base = getApiBaseURL();
|
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;
|
||||||
return `${prefix}/${gender}_${ageGroup}.glb`;
|
return `${prefix}/${this.actualGender}_${this.ageGroup}.glb`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -204,9 +205,9 @@ export default {
|
|||||||
const loader = new GLTFLoader();
|
const loader = new GLTFLoader();
|
||||||
loader.setDRACOLoader(dracoLoader);
|
loader.setDRACOLoader(dracoLoader);
|
||||||
|
|
||||||
const modelPath = this.modelPath;
|
|
||||||
const base = getApiBaseURL();
|
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`;
|
const fallbackPath = `${prefix}/${this.actualGender}.glb`;
|
||||||
|
|
||||||
let gltf;
|
let gltf;
|
||||||
|
|||||||
Reference in New Issue
Block a user