I have tried over the last days to implement a working animated camera to my already running MMD / PMX environment.
However I cannot for the life of me figure out how to do it.
The regular animations for model and stage props already work,
But the camera eludes me.
I currently call the camera in a simple manner:
async function LoadCamera(id) {
const path = "./camera/" + id + ".vmd";
return new Promise((resolve, reject) => {
const loader = new THREE.MMDLoader();
loader.loadAnimation(path, camera, (animation) => {
if (!animation || !animation.animations || animation.animations.length === 0) {
reject(new Error(`Invalid animation file: ${path}`));
return;
}
const mixer = new THREE.AnimationMixer(camera);
const action = mixer.clipAction(animation.animations[0]);
action.play();
function animateCamera() {
requestAnimationFrame(animateCamera);
mixer.update(clock.getDelta());
renderer.render(scene, camera);
}
animateCamera();
resolve(true);
}, (error) => {
console.error('Error loading animation:', error);
reject(new Error(`Error loading animation file: ${path}`));
});
});
}
However this is seemingly not enough as the console log claims:
Error loading camera animation: ProgressEvent {isTrusted: true, lengthComputable: false, loaded: 0, total: 0, type: ‘error’, …}
Any help would be appreciated
I also have the current – disfunctional – code here, with “camerafail.js” being the current – faily attempt
Multiple attempts to add the camera were made.
They all fail at render.
VMD parse for normal (bone based) animation works fine.
calabria psg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.