Jump to content
Search Community

animate particles movement using Three.js with a mouse move event

SeanPatrick test
Moderator Tag

Go to solution Solved by Cassie,

Recommended Posts

Hi there,

 

could you please teach me how to use Gsap to animate the particles movement with a mouse move event, using Three.js?

 

I searched the internet and only found a few complicated projects like the attached file. But, it's hard to find an easier example using GSAP. Is it possible to move such a great number of particles with Gsap?

 

Thanks.

Screen Shot 2022-04-28 at 01.00.55.png

Link to comment
Share on other sites

Hi Sean,

 

Animating particles like that is really not something GSAP can really help with you with. Those projects you found are complicated for a reason... that is a very complicated effect that requires a good understanding of WebGL and shaders.

 

 

  • Like 1
Link to comment
Share on other sites

Hi OSUBlake,

 

Thanks for reply.

 

If the flowing effect, like the last one, is impossible to animate with GSAP, how about moving particles randomly, like the attached picture. The function used is quit easy, like Math.random(). Can GSAP animate the moving path, making thousands of particles move smoothly when a mouse event triggered? If possible, is there any example for reference?

 

I just tried this following code. But, it did not respond. 

 

TweenMax.to(IntersectionPoint, 3,  {x: (original_point_x +  Math.random( time ) +100), y: (original_point_y +  Math.random( time ) + 100),z: (original_point_z + Math.random( time ) + 100), ease:Ease.easeOut});

 

Thanks. 

 

 

Screen Shot 2022-04-28 at 10.21.17.png

Link to comment
Share on other sites

Hi OBUBlake,

 

I'm learning about the project (

See the Pen XWNjBdb by sanprieto (@sanprieto) on CodePen

).  Only for particle animation, the code should be positioned at line 183 ~ 275. How could we use GSAP to animate the position movement only? The snippet code as follows. Please correct me, if I get wrong about the code. Thanks. 

 

const t = Math.atan2( dy, dx );
                            px += f * Math.cos( t );
                            py += f * Math.sin( t );

                            pos.setXYZ( i, px, py, pz );
                            pos.needsUpdate = true;

 

      px += ( initX  - px ) * this.data.ease;
                py += ( initY  - py ) * this.data.ease;
                pz += ( initZ  - pz ) * this.data.ease;

                pos.setXYZ( i, px, py, pz );
                pos.needsUpdate = true;

 

 

Link to comment
Share on other sites

  • Solution

Hey there! That's a lot of code.


Maybe this will help give you some context?
 


GSAP can animate anything really, even complex three.js stuff, Blake's point was that there isn't a magic bit of GSAP code that will do all of it for you. The lions share of work will be setup not tweening values.

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