fox-lifecycle.js 719 B

1234567891011121314151617181920212223
  1. AFRAME.registerComponent('fox-lifecycle', {
  2. init() {
  3. this.fox = document.querySelector('#fox')
  4. this.listeners = {
  5. startAnimation: this.startAnimation.bind(this),
  6. }
  7. this.fox.addEventListener('start-animation', this.listeners.startAnimation)
  8. },
  9. startAnimation() {
  10. this.fox.setAttribute('visible', 'true')
  11. this.fox.setAttribute('animation-mixer', {
  12. clip: 'Animation',
  13. loop: 'once',
  14. clampWhenFinished: true,
  15. })
  16. this.fox.addEventListener('animation-finished', () => {
  17. this.fox.setAttribute('visible', 'false')
  18. this.fox.removeAttribute('animation-mixer')
  19. })
  20. },
  21. })