Skip to content Skip to sidebar Skip to footer

Update Is Not Firing In Aframe Component

I read from the aframe docs that whenever we update the position or any other value the update of the attached component would fire I am just trying to fire the update on every pos

Solution 1:

I think You are confusing a component with an entity. The entity is a container, which behavior and appearance are defined via components.So the update function is firing at the beginning + when you change the component, like via setAttribute('checking','newValue').


You can do Your check either by:

including a listener for the 'componentChanged' event:

this.el.addEventListener('componentChanged',function(e){
       if(e.detail.name==='position'){
          console.log(e.detail.newData);
       }
    });

checking if the position changed on tick, but that seems highly inneficient:

init(){
     this.pos = this.el.getAttribute('position');
   }
   tick: function(){
     if( this.el.getAttribute('position') != this.pos ){
         this.pos = this.el.getAttribute('position');
     }
   }

Post a Comment for "Update Is Not Firing In Aframe Component"