Sixty cars learn to drive the JP Racing track in your browser. Each one is steered by a tiny neural network that starts out as random numbers, and nobody shows them how to drive: the cars that get furthest pass their network on to the next generation, with small random changes. The first generations crash within metres, a car usually reaches the finish within about ten generations, and from there the best time keeps dropping. The leading car shows its seven distance sensors and its network live, and you can run the simulation up to 64 times faster, watch the whole track or start over. The road is read from JP Racing's own 3D track model: a tool I wrote finds the edges of the road surface and walks it from the start gate to the finish gate, 1,137 m in all. The physics, the sensors, the network and the evolution loop are plain JavaScript with no machine-learning library, seeded so that an automated test replays a full run and checks that a car reaches the finish. Drawn with three.js.
Tech Stack
- Three.js
- Neural Networks
- Genetic Algorithm
- Canvas 2D
- Vite
- GitHub Actions
More Projects
Paint Lab
A tray of wet paint in your browser. Pick red, yellow, blue, white or black, drag to pour it, drag fast to stir, and the paints mix the way real paint does: blue and yellow make green, red and yellow make orange, all three make brown. The liquid is a fluid simulation that runs on the graphics card, written in plain WebGL2 with no library: each pixel holds an amount of each of the five paints, not a color, and those amounts flow, swirl and settle. The color of a pixel is then computed with the mixing rule of My Little Lab, my color mixing app for children, which blends pigments instead of averaging screen colors. That is why blue and yellow give green here, and not grey. The amount of paint is also read as a height and lit from one side, which gives the wet shine. When the page opens, three pools are poured and stirred on their own, until you touch the tray.
Path Tracer Studio
A browser app that path-traces glTF models progressively on the GPU, built on Garrett Johnson's three-gpu-pathtracer library. Pick a sample model or drop your own .glb, light it with an HDRI and a key light, orbit around it, and export the converged render as a PNG. I wrote the step that prepares each model first, decoding Draco, expanding quantized vertices and unpacking instanced parts, so real-world files like NASA's ISS model trace correctly, plus a render-scale option and texture budget for weaker GPUs.
WebGL Lab (Shader Gallery)
Eight of Yoichi Kobayashi's shader sketches from ykob/sketch-threejs (MIT), ported from three.js r128 and a gulp build to three.js r187 and Vite: GPU flow fields, a refracting glass, a noise-driven flame, a spring-skinned fire ball and more. I fixed every API the upgrade broke, from WebGL2 shader compilation to skinning and float textures, and redesigned it as a gallery where each sketch explains, from its own code, what its shaders do. The original effects are his; the port, the curation, the write-ups and the interface are mine.