I'm trying to define a recursive function with arguments using "requestAnimationFrame".
animate(frameElapsed,points,canvas){
console.log("test");
if(frameElapsed<points.length-1){
requestAnimationFrame(this.animate(frameElapsed+1,points,canvas));
}
...
}
When I do this, i get the error "Argument of type 'void' is not assignable to parameter of type 'FrameRequestCallback'. So I tried to define an anonymous function that calls animate to solve this problem.
animate(frameElapsed,points,canvas){
console.log("test");
if(frameElapsed<points.length-1){
requestAnimationFrame(function() {
this.animate(frameElapsed+1,points,canevas);
});
}
...
}
Then, I get "ERROR TypeError: Cannot read property 'animate' of undefined" in my web console. I can't manage to solve this problem.
Is there a way to pass arguments to af function called back by requestAnimationFrame ?
Thank you for your help !