Jump to content
Search Community

GSAP + THREEJS + onComplete() causing issue/error and altering previous animation

PraveenV21 test
Moderator Tag

Recommended Posts

Hello,

I am a beginner to threejs and gsap, and in that matter generally speaking of web development I am pretty new. Here I'm trying to essentially after the "rocket" takes off from the platform, zoom in to make a cool effect, and then I want the rocket to move from the top back to the bottom so I can animate it as if it were starting below the screen again. Therefore, I tried the most logical solution which was to just use the onComplete() method after my animation for the rocket taking off ended and accordingly changing the position. However, what I noticed was not only for some reason were the x and z coordinates messed up in the following tween, but also as seen in the video. It would actually alter the original animation somehow, even though it shouldn't have? I have about no clue why this happens, and only happens when I scroll at a rapid pace. I've tried to fix this bug for the past 2 1/2 hours, and just decided to give up and go with a more simple solution. Which would be just to have another model which would be seperate from the one which took off from the platform and below the screen, so no issues would be found. I kinda neglect this solution because it would mean on subsequent tweens I would have to include more and more of the same models and decrease the performance overall. Idk, I might honestly suck at coding and any help or advice would be gladly appreciated. 

-- code of error -- 

  timeline.to(ls.position, {

        z: 10, --> just moves the site inwards for the cool affect
        duration: 10,
        // onComplete: () =>{
        //   rocketModel.position.y = -100;
        //   rocketModel.position.z = 0;

        // }

--> commented out the code which caused this error. 

        

 })

timeline.to(rm.position, 

--> moving it(idk why but the x and z were flipped for some reason with this oncomplete bug??)
    //   {
    //     y: -20,


    //     // z: -40
    //   })

FYI -- I can try to include a codepen, but idk how feasible that will be since my project has so many dependencies. I'll make one if people are actually interested in helping fix this bug. But, if my second solution of j including more models isn't bad practice then I'll j keep it. 

Link to comment
Share on other sites

Hi @PraveenV21 and welcome to the GreenSock forums!

 

Sorry to hear about the troubles, it does sounds frustrating, but it's pretty tough to troubleshoot without a minimal demo - the issue could be caused by CSS, markup, a third party library, your browser, an external script that's totally unrelated to GSAP, etc. Would you please provide a very simple CodePen or CodeSandbox that demonstrates the issue? 

 

Please don't include your whole project. Just some colored <div> elements and the GSAP code is best (avoid frameworks if possible). See if you can recreate the issue with as few dependancies as possible. If not, incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, then at least we have a reduced test case which greatly increases your chances of getting a relevant answer.

 

Here's a starter CodePen that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo

See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen

 

If you're using something like React/Next/Vue/Nuxt or some other framework, you may find StackBlitz easier to use. We have a series of collections with different templates for you to get started on these different frameworks: React/Next/Vue/Nuxt.

 

Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. 

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