Jump to content
Search Community

set minimum fps force tweends into slow motion 30 fps?

sagispin 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

Are you trying to get a delta time of 0.5, or do you want it to be based on the elapsed time?

 

Here's a simple example of a ticker, which could be adapted to work with GSAP's ticker.

 

var targetFPMS = 60 / 1000;
var maxElapsedMS = 100;
var lastTime = -1;
var elapsedMS = -1;
var deltaTime = 1;
var speed = 1;

requestAnimationFrame(onFrame);

function onFrame(currentTime) {
  
  elapsedMS = currentTime - lastTime;
  
  deltaTime = elapsedMS * targetFPMS * speed;
  
  if (elapsedMS > maxElapsedMS) {
    elapsedMS = maxElapsedMS;
  }
  
  // Do your delta time stuff
    
  lastTime = currentTime;
  
  requestAnimationFrame(onFrame);
}

 

  • Like 3
Link to comment
Share on other sites

@OSUblake
lets say i run a tween that takes a {x:0} to {x:10} in duration 1 second

each tick the tween moves 10 * dt pixels

lets say that dt is now 1/20 in that case it needs to move
10 * 1/30 pixels
and not
10 * 1/20

because i set the limited fps to 30

dt = max(dt,1/30)
am i change this stuff witought going inside the js files of gsap?
 

Link to comment
Share on other sites

Just now, sagispin said:

@OSUblake
lets say i run a tween that takes a {x:0} to {x:10} in duration 1 second

each tick the tween moves 10 * dt pixels

lets say that dt is now 1/20 in that case it needs to move
10 * 1/30 pixels
and not
10 * 1/20

because i set the limited fps to 30

dt = max(dt,1/30)
am i able to change this stuff witought going inside the js files of gsap?
 

 

Link to comment
Share on other sites

OK. I understand what you want now. I think you might be able to do that with the lagSmoothing feature.

https://greensock.com/docs/TweenLite/static.lagSmoothing()

 

And I just saw your deleted post about manually stepping the ticker. @GreenSock that's actually a feature a lot of game developers want. They want their game loop to drive everything. Something worth considering for GSAP v2.

  • Like 3
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...