There are many ways to do that, but at the very least we have to prevent the spheres from following their peers too regularly and thus resulting in an overall regular motion. So sphere 2 follows sphere 1, sphere 3 follows sphere 2, and so on. Then we make each next sphere’s movement to be a function of its previous sphere. It moves in a regular circular path with time(ignore offset for now): // the first blob has a regular circular path (x y positions are calculated using the parametric function for a circle) first_( offset.x + s(elapsed * 2.0), offset.y + Math.sin(elapsed * 2.0), offset.z + Math.sin(elapsed * 2.0) ) No lighting is needed as we’re only using MeshBasicMaterial.Ĭreating the spheres is the easy part, but making the pseudo-random animation is a bit harder.įirstly, we have a “seed” sphere, which is the first sphere in the array of spheres, to act as a motion guide to all subsequent spheres. Fog is also added to create an illusion of depth to the scene. Create a bunch of spheres of various sizes, and then use easing and trigonometric functions to help animate a Brownian-like motion. I improved it and added stats and gui controls. Most of the code and idea is originally from this cool codepen: by Victor Vergara □□♂️, which I found a while back and bookmarked.
0 Comments
Leave a Reply. |