Klaas Posted April 1, 2023 Share Posted April 1, 2023 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 More sharing options...
Rodrigo Posted April 1, 2023 Share Posted April 1, 2023 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 More sharing options...
Solution GreenSock Posted April 1, 2023 Solution Share Posted April 1, 2023 Nah, you shouldn't have to keep pausing/playing. Here's what I'd do: See the Pen zYJVLNe?editors=1010 by GreenSock (@GreenSock) on CodePen Does that help? Link to comment Share on other sites More sharing options...
Klaas Posted April 2, 2023 Author Share Posted April 2, 2023 @GreenSock that's fantastic. It works great. Thanks a lot. And @Rodrigo thanks for welcoming to the forum. Your reaction speed is impressive. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now