Jump to content
Search Community

Async action during onUpdate

Klaas test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

I am using GSAP with Sketchfab (webgl 3d models). This works great! I have got one scenario that I need some help with. I'm using the onUpdate callback of my timeline to manipulate the 3D model and camera. This also includes making a render of the 3D model. The renderer returns a promise as it takes a little bit of time. 

I'd like the timeline to wait for the promise to resolve before continuing with the timeline. As if I'm stepping through the animation, frame by frame. Is this possible?

In the codepen I've substituted the rendering of a Sketchfab model with a setTimeout in a Promise. I hope that illustrates the issue. The example uses a timeout of 200ms. I'd like the timeline to wait for 200ms before stepping through the animation.

See the Pen jOvjZqq by klaasnienhuis (@klaasnienhuis) on CodePen

Link to comment
Share on other sites

Hi @Klaas and welcome to the GreenSock forums!

 

I'm not sure how feasible that is. GSAP ticker is ran 60 times per second so that means that the update callback of a GSAP instance is called on every tick. That would create a bit of a conundrum IMHO since you'll have to pause the timeline on every update, wait for the async code to be completed, then resume the timeline and in the next update (roughly 16  milliseconds later) pause it again. You could set the amount of times the ticker runs but that could create a new set of issues.

 

Since the code you're using generates renders of the model, can you create all the models in on sit and use this approach by @OSUblake?

https://greensock.com/forums/topic/25188-airpods-image-sequence-animation-using-scrolltrigger/?do=findComment&comment=121610

 

Sorry I can't be of more assistance.

Hopefully this helps.

Happy Tweening!

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...