Build notes
How the particles on this site work
The top of my homepage is about 40,000 dots. They start scattered, pull together into my name, and then every few seconds rearrange into the logos of things I've built.
Every shape has the same number of dots
That's the whole trick. My name and the URL, VisBets, Worthwhile and Rock Buddy logos are each turned into exactly the same number of points. Dot number 512 in my name just flies to wherever dot number 512 is in the next logo. Since the counts always match, any shape can turn into any other one.
To turn a logo into points, I draw it onto an invisible canvas, keep the pixels that are part of the mark, and pick from those at random. For my name I do the same thing with text drawn in the blackletter font.
The graphics card does the moving
The browser only uploads two things: where each dot starts and where it's going. After that, one number goes from 0 to 1 and a small shader works out every dot's position on the GPU:
float t = clamp((uProgress - aRand.x * 0.35) / 0.65, 0.0, 1.0);
vec3 p = mix(aFrom, aTo, smoothstep(0.0, 1.0, t));
p += swirl(p, uTime, aRand) * sin(t * PI);
The aRand.x part gives every dot a slightly different start time, so the shape dissolves instead of sliding over as one block. The sin(t * PI) part adds a swirl that's strongest halfway through and zero at both ends, so shapes are messy in transit and sharp when they land.
Things that bit me
- Light logos on a light page. The VisBets and Worthwhile logos are made for dark backgrounds. When I sample them I turn the greys and whites into ink and keep the brand colors, just darker.
- Sideways photos. My camera saves vertical photos as horizontal pixels plus a "rotate me" note. Browsers respect that note in a normal image but not in WebGL, so I rotate the pixels for real when I export.
- A colon in a folder name.
:separates entries in your PATH, sonpxbroke. The npm scripts call the tools throughnodedirectly.
The TNT
The TNT block in the modpack section is a separate little Three.js scene. The textures are drawn in code as 16×16 pixel grids and scaled up without smoothing, so they stay crisp. Clicking it hides the block and swaps in 64 smaller cubes, each showing its own slice of the texture. They fly out under gravity, then ease back into place.