Animated Thruster - EricEisaman/cs1-ide GitHub Wiki

Animated Thruster


export default (()=>{
  
  document.addEventListener('gameStart',e=>{
      
    const s = document.createElement('a-sphere');
    s.setAttribute('animate','');
    s.setAttribute('shader-frog','name:Thruster_Shader');
    CS1.shaderfrog.Thruster_Shader.uniforms.backgroundColor.value.g = 1;
    CS1.shaderfrog.Thruster_Shader.uniforms.frequency.value = 5;
    s.setAttribute('color','blue');  
    s.setAttribute('scale','1 3 1')
    s.object3D.position.set(0,0,-4);
    CS1.scene.appendChild(s);
     
  });
  
  
  AFRAME.registerComponent('animate', {
    
    
    schema: {
      color: {default: 'red'}
    },

    init: function(){

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


  
})()