Pixel Cube Avatar
- group .........
- 3D and WebGL scenes
- source ........
- https://ui.aryank.space/components/pixel-cube-avatar
- markdown ......
- /lab/pixel-cube-avatar.md
- human .........
- /lab/pixel-cube-avatar
── WHAT_IT_IS ────────────────────────────────────────────────────────────────────────────────
A wireframe cube rasterized onto a 17 by 17 pixel grid with RGB channel separation. Twelve edges are projected through a two-axis rotation and drawn with an integer Bresenham line into three 8-bit channel buffers; the red and blue passes sit a few degrees off green and scale slightly apart, so the wireframe splits into chromatic fringes, and each frame blends the last one back in so motion smears a decaying trail. It idles still, spins on hover, follows a drag, coasts on release, and returns on a randomized spring to whichever of two rest poses is nearer. A click fires a multi-turn tumble with a decaying sine wobble on top. Canvas 2D and one rAF loop, no dependencies.
── BEHAVIOUR ────────────────────────────────────────────────────────────────────────────────
* The grid stays 17 by 17 at every size
Resolution is what makes it read as pixels, so size scales the block each cell draws rather than adding cells. A larger avatar is the same 289-cell simulation with bigger squares.
* Chroma reacts to speed, not to a clock
The red and blue passes are offset by a fixed 13 degrees plus a term driven by how fast the cube actually turned this frame, clamped to 0.4 radians. Standing still it is nearly clean; thrown hard it tears into full RGB.
* The trail is a max blend, not alpha
Each frame keeps the brighter of the new edge and 90 percent of the previous one per channel, so the smear decays without ever muddying the live wireframe underneath it.
* Two rest poses, nearest one wins
On release it measures the angular distance to both head-on orientations and springs to the closer one, with the spring frequency softened the further it has to travel, so a long throw settles slowly and a nudge snaps back.