Simple Animate Component - EricEisaman/cs1-ide GitHub Wiki

Simple Animate Component


export default (()=>{
  
  document.addEventListener('gameStart',e=>{
      
    const box = document.createElement('a-box');
    box.setAttribute('animate','');
    box.setAttribute('color','blue');
    CS1.scene.appendChild(box);
     
  });
  
  
  AFRAME.registerComponent('animate', {
    
    
    schema: {
      color: {default: 'red'}
    },

    init: function(){

    },
    
    tick: function(t,dt){
    
      this.el.object3D.position.y = 4 * Math.sin(t/300) + 5;
      
    }
    
    
  });
  


  
})()