Here’s the code:
loader.load( './models/gltf/Xbot.glb', function ( gltf ) {
const model = gltf.scene;
model.position.set( 0, 0, 0 );
model.traverse( function ( child ) {
if ( child.isMesh ) child.material.envMap = envMap;
} );
scene.add( model );
console.log(gltf)
mixer = new THREE.AnimationMixer( model );
let firstAction = mixer.clipAction(gltf.animations[6]);
let secondAction = mixer.clipAction(gltf.animations[3]);
firstAction.setLoop(THREE.LoopRepeat, 3);
firstAction.play();
mixer.addEventListener('finished', (e) => {
//playNextAction();
console.log(e.action)
firstAction.fadeOut(1);
secondAction.fadeIn(1);
secondAction.play();
console.log("finished")
})