async function LoadCamera($id) { const path = "./camera/" + $id + ".vmd"; return new Promise((resolve, reject) => { // Check if the file exists fetch(path) .then((response) => { if (response.ok) { const loader = new THREE.MMDLoader(); loader.loadAnimation(path, camera, (animation) => { if (!animation || !animation.animations || animation.animations.length === 0) { console.error('Failed to load animation:', animation); reject(new Error('Failed to load animation.')); return; } // Check the animation clip properties for (const clip of animation.animations) { if (!clip.name || clip.name.trim() === '') { console.error('Animation clip has an empty name:', clip); reject(new Error('Animation clip has an empty name.')); return; } if (!clip.duration || clip.duration <= 0) { console.error('Animation clip has an invalid duration:', clip); reject(new Error('Animation clip has an invalid duration.')); return; } } console.log('Loaded animation:', animation); for (const clip of animation.animations) { console.log('Animation clip:', clip); } console.log('Camera:', camera); const mixer = new THREE.AnimationMixer(camera); }); } else { reject(new Error('Failed to load file.')); } }) .catch((error) => { reject(error); }); }); }