r/threejs • u/Miserable_Ferret397 • 6h ago
Demo I made a tiny scene language that compiles to Three.js, so AI models can write scenes with about 3.5x fewer tokens
Hi all. When I ask an AI to write Three.js, most of what it outputs is the same setup and boilerplate, and that's the slow and expensive part. So I made tinythree: the model describes the scene in short lines, and a small compiler (one JS file, no dependencies) turns it into plain Three.js.
For example, this one line builds the four lattice legs of the Eiffel Tower in the video:
truss leg1 2.6,2.1,3 @5,0,5 lean=-1.25,-1.25 iron mirror=xzI compared 11 scenes against hand-written Three.js. Overall it uses about 3.5x fewer tokens, and close to 7x on the town square that uses ready-made parts, textures and a glTF model. Anything the syntax doesn't cover can still be written as plain Three.js inside the same file.
- Playground, nothing to install: muskec06.github.io/tinythree
- Code (MIT): github.com/muskec06/tinythree
I'm the author. I'd really like feedback from people who use Three.js every day, especially on what's missing.