Strange event listener behaviour on AnimationMixer, bug?

Hi,

I’ve faced with strange behaviour on AnimationMixer event listener - I can’t identify/remove event listener after mixer.addEventListener(‘finished’,function(e){…}); … call of mixer.hasEventListener(‘finished’) after adding returns false (same as inside of function(e){…}), but if print mixer via console.log there is _listeners and uuid the same when adding and trying to identify/remove. What is this an issue? It seems there is a bug here… revision 117.

You can take , for instance, webgl_skinning_simple.html example and add the following lines:

mixer = new THREE.AnimationMixer( gltf.scene );
mixer.addEventListener('loop',function(e) { console.log('fin'); console.log(this.hasEventListener('loop')); this.removeEventListener('loop'); });
console.log('has:');
console.log(mixer.hasEventListener('loop'));
mixer.clipAction( gltf.animations[ 0 ] ).play();

console output for hasEventListener will be always false and loop will never removed.

This is no valid usage of the method. Both hasEventListener() and removeEventListener() have two mandatory parameters. That’s because you can add an arbitrary amount of event listeners to a single event.

1 Like

Thank you :))… :man_facepalming: