Hi I am trying to play an animation on click so far the Idle animation is playing fine but I can’t seen to get the walking animation to play on a click, what Am I doing wrong?
Snippet:
//Load
var action, model2, mixer2, clock, gltf2;
loader.load('scene.gltf', function(gltf2) {
model2 = gltf2.scene;
gltf2.scene.traverse(function(child) {
if (child.isMesh) {
roughnessMipmapper.generateMipmaps(child.material);
}
});
scene.add(model2);
roughnessMipmapper.dispose();
//Play Idle
mixer2 = new THREE.AnimationMixer( model2 );
action = mixer2.clipAction( gltf2.animations[ 0 ] );
action.play();
});
//Load end
//Click
function onClick() {
if (intersects[0].object.name == 'CharacterOne') {
$('body').css('cursor', 'default');
mixer2 = new THREE.AnimationMixer( model2 );
action = mixer2.clipAction( gltf2.animations[ 1 ] );
action.play();
}
}
Uncaught TypeError: Cannot read property ‘animations’ of undefined
at HTMLCanvasElement.onClick