craftecode / hello-world

My first GitHub repository
0 stars 0 forks source link

Figure out how to have an animation only respond once to being clicked #3

Open craftecode opened 4 years ago

craftecode commented 4 years ago

e.g. if you start a sphere earth spinning on mouseenter and don't want it to restart the animation when you mouseenter again.

For now I'm just going to change the class so that the raycaster no longer identifies the object as clickable using this:

<script>
      //this is only on the heater
  AFRAME.registerComponent('removeclass', {
    schema: {
      class: {default: 'nothing'}
    },

    init: function () {
      var data = this.data;
      var el = this.el;  

      el.addEventListener('click', function () {
        el.setAttribute('class', data.class);
      });

    }
  });
</script>