Search code examples
javascriptaframe

Aframe repetition of animations?


I am wondering how to repeat animations. I have made this:

  var drip_stage = 0; 

  function Drip(){

    var water = $(".water");//water drop

    water.attr('position', '-4.4 8.45 3.95');// faucet position
    
   //if statements for all stages of water

    if (drip_stage==0){

        water.attr('animation',"property: position; to:-4.1 5.1 3.95; dur: 5000;");

       drip_stage++

    }// other statements

    water.attr('visible','true');

    console.log("repeat");

    setTimeout(Drip, 5000);//repeat



  }

  AFRAME.registerComponent("drip",{

    init: Drip

  });

I am wondering if there is a to repeat the animation but at different times?


Solution

  • Set the loop property to true:

    animation="property: position; from: 0 4.25 -10; to: 0 -2.25 -10; dur: 1000; loop: true"
    

    Glitch illustrating