A vertex-model embryo folds its own gut, purely from cell mechanics.
A cross-section of a sea urchin embryo: 60 epithelial cells, each a quadrilateral with apical, basal and lateral edges, around a fluid-filled blastocoel. Each cell resists changes in area, each edge carries a line tension, the blastocoel keeps its volume, and short-range repulsion lets the sheet fold without passing through itself; vertices slide down the energy gradient with overdamped dynamics, 28 substeps a frame. When the vegetal plate cells contract their apical actomyosin (drawn in red) they become wedges and the plate buckles inward, then secondary mesenchyme cells at the tip send filopodia to the roof and reel the archenteron across the blastocoel until it touches down and the threads retract, while primary mesenchyme cells crawl along the vegetal wall. None of the shapes are keyframed: every fold is a force balance computed live.
Try it. Drag across cells to make them constrict apically (shift-drag or right-drag for basal constriction, which buds the sheet outward instead) and design your own folds. Clear and paint starts from a fresh blastula, Gastrulate replays the embryo's own program, and the sliders set constriction strength and tissue stiffness (arrow keys too; R replays the program and C clears).
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build a 2D vertex model of an embryo folding (gastrulation) with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple:
- Make a ring of 50 cells. Each cell is a quadrilateral with two outer (apical) vertices on a circle of radius 1 and two inner (basal) vertices on a circle of radius 0.75, and neighboring cells share their side edges.
- Give every cell an area energy kappa/2 * (A / A0 - 1)^2, where A0 is its starting area, and give every apical, basal and side edge a line tension (energy = tension * length).
- Compute the force on each vertex as minus the gradient of that energy (the polygon area gradient and the unit vectors along edges are all you need), and move each vertex by force * dt. Use small steps and do 20 or more per frame.
- Add a soft circular wall just outside the ring, and a pressure on the inner ring that keeps the enclosed area (the blastocoel) roughly constant.
- Draw each cell as a filled polygon with a dark outline, plus a small ellipse for the nucleus.
Once that works, make it beautiful:
- Ramp up the apical tension of the 12 cells at the bottom over a few seconds and watch them turn into wedges and fold the sheet inward.
- Add repulsion between each vertex and nearby edges that it does not belong to, so the folded sheet cannot cross itself.
- Use soft pastel colors per cell type, draw the constricting apical edges in red, and let me click cells to toggle their constriction so I can design my own folds.
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as filopodia that pull the tip of the fold across the cavity, basal constriction that buds the sheet outward, or cell division as the tissue grows.