Jump to content
Search Community

TweenMax Ticker Call Tick() from my own RAF call

Steven Sanborn test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

As many games and simulations have their own request for animation frame calls that can be core to rendering obj positions frame by frame, it would be nice if I could call GSAP's from our own request frame function. Ideally everything gets a position in a  single RAF. 

 

For instance I would love to do this:

function animate(){


                requestAnimationFrame(animate);


                TweenMax.ticker._tick(true); //call GSAP rfa manually


                render()
                

}

requestAnimationFrame(animate);
TweenMax.ticker.setManualRequestAnimation = true; //set a flag somehow

//now all tween run off from the user defined RAF 
TweenMax.to(obj1,1, { x:,y:,z:....
TweenMax.to(obj2,1, { x:,y:,z:....

I do realize there is the ticker event that i can listen to, but I dont want run my entire application based off of GSAP's RAF event. This would mean stop my RAF run tween then turn on my RAF in my own, with multiple tweens.    It seems to make sense that GSAP runs off an game animation render loop and not vice versa.

 

Is there a way to do this? 

Link to comment
Share on other sites

I see exactly what you're saying Steven, but that's not something we support at this point mostly because it's something that only a tiny fraction (probably less than 0.1%) of our users might tap into and the rest would rather not pay the file size and API complexity cost. In other words, we'd have to rewire some things internally to offer a feature like this and that'd increase KB size (not significantly, of course, but we try REALLY hard to keep things in the core very tight) and then we'd have to document it and increase the API surface area. 

 

You could hack it by swapping in your own function for the browser's requestAnmationFrame() method I suppose since that's what GSAP taps into under the hood. :)

  • Like 1
Link to comment
Share on other sites

  • 2 years later...
On 4/12/2016 at 21:09, Steven Sanborn said:

Dado que muchos juegos y simulaciones tienen su propia solicitud de llamadas de cuadros de animación que pueden ser fundamentales para representar las posiciones de objetos, cuadro por cuadro, sería bueno si pudiera llamar a GSAP desde nuestra propia función de cuadro de solicitud. Idealmente, todo se posiciona en una sola RAF. 

 

Por ejemplo, me encantaría hacer esto:







                 


                



  


 
 

Me doy cuenta de que hay un evento de teletipo que puedo escuchar, pero no quiero ejecutar toda mi aplicación basada en el evento RAF de GSAP. Esto significaría detener mi interpolación RAF y luego activar mi RAF por mi cuenta, con múltiples interpolaciones. Parece tener sentido que GSAP se ejecute en un bucle de renderizado de animación del juego y no al revés.

 

¿Hay alguna forma de hacer esto? 


Hello Steven Sanborn
did you manage it ?

I need to do the same.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...