Visualizations
190 / 500

190 · Simulation

Gastrulation

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).

  • Vertex model
  • Overdamped dynamics
  • Apical constriction
  • Vertex-edge repulsion

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

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.
PreviousSumi-e BrushA bristle-by-bristle ink brush paints bamboo on rice paper that wicks and bleeds. NextPCB AnnealerSimulated annealing places chips on a circuit board, then a maze router lays copper.

Related visualizations

  • Embryo StripesSimulation A fly embryo's gene network paints seven even-skipped stripes, nucleus by nucleus.
  • Self-AssemblyEmergence Lipid membrane patches assemble themselves from a random soup into closed vesicles.
  • Subdivision Surfaces3D Catmull-Clark turns an editable cube cage into a smooth clay creature, live.
  • Growing Neural CellsMachine learning Cells running one tiny learned rule grow a gecko from a single seed and heal its wounds.
  • Differential GrowthGenerative art One closed line grows, buckles and folds into brain coral without ever crossing.
  • Miura FoldMath Miura-ori, Yoshimura and waterbomb sheets fold with exact rigid-origami kinematics.
  • Heart TissueSimulation Spiral waves, arrhythmia and defibrillation in a living sheet of heart muscle.
  • Cell SortingEmergence A Cellular Potts tissue unmixes itself by differential adhesion, on a stained slide.
  • Planet ForgeAstronomy A dusty disk grows rocky worlds, ice giants and gas giants by N-body accretion.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs