Hello all, I’m trying to load and play a few different animations that my models contain but can’t get it to work, I either get one animation to work or non at all. Following this example: Animation system – three.js docs (threejs.org)
This is what I have
loadModelFile = (fileName, path) => {
return new Promise((resolve) => {
let dracoLoader = new THREE.DRACOLoader();
dracoLoader.setDecoderPath('https://www.gstatic.com/draco/versioned/decoders/1.5.5/');
let loader = new THREE.GLTFLoader();
loader.setDRACOLoader(dracoLoader);
loader.load(`${path}${fileName}`, (gltf) => {
console.info("GLTF file load complete");
const model = gltf.scene;
scene.add(model);
model.scale.set(0.75, 0.75, 0.75);
model.position.set(0, 0.2, 0);
model.rotation.set(0, -0.2, 0);
model.traverse((o) => {
if (o.isMesh) {
o.castShadow = true;
o.receiveShadow = true;
o.frustumCulled = false;
}
});
const mixer = new THREE.AnimationMixer(model);
const clips = model.animations;
clips.forEach(function(clip) {
mixer.clipAction(clip).play();
});
function animate(){
requestAnimationFrame( animate );
delta = clock.getDelta();
if ( mixer ) mixer.update( delta );
If any one can point out what I’m doing wrong I would be very grateful.
Thanks in advance!