Make destructible buildings in three.js the way Small Magic does: every piece a box, welds armed from the load they carry, GPU physics. Prompts inside.
To make destructible buildings in three.js, build each building from boxes, make every box a rigid body, weld it to the boxes it touches with a breakable joint, and set each weld's strength from the load it carries while the building stands. Knock out a support and the welds that leaned on it are suddenly overloaded, so the building falls the way a real one does, with no scripted breaks. That is how Small Magic works, the wizard sandbox @BlendiByl made with Claude Fable 5.2. Its hamlet is 2,172 moving pieces (1,948 in four buildings, 224 sods and clods of earth) and 5,000 welds, simulated on the GPU with three-avbd, so it needs a browser with WebGPU.
The Cleave in Small Magic, by @BlendiByl
This article walks through the whole system: how the buildings are laid out, how the welds are made and armed, the solver settings that keep a tall tower standing, how blasts and the Cleave break things, and how thousands of pieces stay cheap. It assumes you know three.js and have a coding agent to hand the prompts to. Small Magic's repo is open on Patch, and its physics folder is Patch's destruction block, which is MIT.
What you need
three.js (Small Magic uses 0.186.1) and a browser with WebGPU: Chrome or Edge 113 or newer, or Patch Desktop. Your renderer can stay WebGL. Small Magic draws its meadow with WebGL, runs the physics on a WebGPU device of its own, and reads every piece's pose back each frame to draw it. Where there is no WebGPU, there is no destruction.
three-avbd by Steven Bobyn (MIT): GPU rigid-body physics with breakable joints, an implementation of Augmented Vertex Block Descent (Giles, Diaz and Yuksel, SIGGRAPH 2025). npm only has it up to 0.3.0, and the code here needs commit cd3ce90 (the 0.4.0 release candidate) and its three-avbd/advanced entry point. Take the copy that comes vendored in the destruction block.
Patch's destruction block (patch/destruction, MIT): the builder, the weld rules and the arming code from Timberfall, Patch's demolition game.
A coding agent and Patch's CLI, pch, to clone the repos and check your game in a browser.
No models or textures. Every piece is a box, drawn in code.
1. Build every building from boxes
Lay each building out the way a mason or a carpenter would, one piece at a time, so it has the structure a real one has. Small Magic's structures.js describes its own method: "stone laid in bond with its corners tied, a timber frame with panels between its posts, purlins from gable to gable with the roof laid on them, boards on joists. Every piece is a box."
A building made of real courses breaks along real joints, so nothing has to be fractured at run time.
Bond the stone. Small Magic lays a square tower in courses 0.5 m high of blocks 1 m long, each course breaking joint with the one below and the corners tied with quoins, so a wall cracks in steps instead of splitting down one seam.
Leave openings as gaps in the courses. The keep is 6 m square and 13 m high, with a door to the south and a window in each wall at two heights.
Split long timbers into segments, so a beam can snap partway along.
Stand it on breakable ground. Each building stands on stone flags footed in a fixed ground box. In the code's words, "Nothing of a building is beyond breaking."
By our count of the 2.2.1 source (its layout code run in Node, without trees), the keep is 776 pieces, the abbey ruin 522, the cottage 390 and the windmill 260.
The keep, the cottage and the windmill, every piece a box. From @Christos_antono's grasp clip
2. Weld each piece to what it touches
Join every pair of touching pieces with a fixed joint at the middle of the patch where they touch. Patch's builder.ts does it for you: two boxes count as touching when their faces are within 0.012 m and they overlap by more than 0.02 m. Turned pieces, such as a rafter, are welded by hand.
Each weld gets a kind from the two pieces it joins (weldKind). The rules are checked in this order, and the first that matches wins:
Order
Pieces
Weld
1
anything on the ground
footing
2
two segments of one member
grain (rivet for steel)
3
glass on anything
putty
4
steel on steel, or steel on anything else
rivet, or bolt
5
stone on stone
stonework
6
two pieces of brick, stone or plaster
mortar
7
brick, stone or plaster on anything else
nogging
8
a board or a tile on anything
nail
9
everything else
joinery
The chimney is tied to its gable by hand with a tie weld. In the hamlet, 3,449 of the 5,000 welds are stonework, 593 nail, 427 nogging, 89 mortar and 28 tie; the rest are timber and footings.
Pieces built overlapping, when one of them was welded by hand, get a spring of no strength (stiffness 1e-6) as well: without it, two pieces overlapping by more than 6 mm burst apart the moment their weld breaks.
prompt for your agent
Clone patch/destruction with pch clone and read src/physics/builder.ts, structure.ts and materials.ts. Add that physics folder to my three.js game, with its vendored three-avbd, keeping their MIT licences. Run the physics on its own WebGPU device and draw the pieces as instanced boxes in my renderer, reading their poses back each frame. Build a stone tower with the builder: a square ring 4 m a side and 0.5 m thick, 12 courses of 0.5 m, blocks 1 m long, each course breaking joint with the one below and the corners bonded, a door 1 m wide through the bottom 3 courses, on stone flags on a fixed ground box. Let the builder weld every touching pair, and log the piece and weld counts and the welds of each kind.
Build the tower with Structure.build so it settles before anything can break: 90 steps of 1/60 s with every weld unbreakable, gravity easing on over the first 30, each weld's load read at steps 60, 75 and 90 and the largest kept, then each weld armed at max(floor, margin x load). Show a loading line until it is armed, then let me click a block to remove it, and log every weld that breaks after that, in order. Run pch check.
If pch (Patch's CLI) isn't installed, install it with curl -fsSL https://patch.gg/install.sh | sh (on Windows, in PowerShell: irm https://patch.gg/install.ps1 | iex), then run pch login.
Check that the tower stands still and that nearly every weld in the log is stonework. The tower in this prompt is smaller than Small Magic's keep (6 m square, 26 courses), so it builds fast.
3. Give each material a weight and a weld rule
Give every material a density and a friction, and every weld kind a margin, a floor, and whether it breaks on a pull. These are Small Magic's, from materials.ts:
Material
Density (t/m³)
Friction
timber
0.65
0.65
board
0.55
0.6
plaster
1.3
0.7
earth
1.5
0.95
brick
1.9
0.75
tile
1.9
0.7
stone
2.4
0.8
glass
2.5
0.4
steel
7.8
0.45
Weld
Margin
Floor
Breaks on a pull
Bends first
stonework
4
60
yes
no
mortar
3
40
yes
no
footing
6
80
yes
no
nail
3
60
yes
no
putty, nogging
2.5
30
yes
no
tie
2.5
2
yes
no
grain
6
90
no
yes, snaps past 0.2 rad
joinery
6
70
no
yes, snaps past 0.26 rad
rivet
3
60
yes
yes, snaps past 1.2 rad
bolt
6
40
no
yes, snaps past 0.7 rad
The margin is how many times its standing load a weld will hold. The floor is a minimum, measured in the lighter piece's own weight (or that weight's moment, for a bend), so a weld that carries almost nothing standing still isn't paper.
A brittle weld lets go on a pull or a bend. A weld that doesn't break on a pull fails only by bending. The plastic ones (grain, joinery, rivet, bolt) yield first: they bend, stay bent, and snap past their limit. So a stone wall shatters, and a timber frame sags, then cracks.
4. Settle with unbreakable welds, then arm each weld from its load
Build the structure with every weld unbreakable, let it stand under gravity, read how much each weld carries, and only then give each weld its strength. This is the step that makes collapse look right. structure.ts does it in 90 steps of 1/60 s:
Gravity eases on over the first 30 steps, so nothing drops onto its welds at full weight.
Each weld's load is read at steps 60, 75 and 90, and the largest is kept.
Each weld is armed with the larger of its floor and its margin times that load, written straight into three-avbd's joint records.
The file says why: "A structure built with breakable welds from the start breaks most of them while its penalties ramp."
Every weld ends up just strong enough for its job. Blow away a post, and the welds beside it now carry far past their margin, so they fail, then the next ones, and the collapse runs along the load paths.
An illustration of how welds are armed, drawn by Patch. The loads are a simple beam model, not the game's solver
Small Magic scales every margin and floor by 0.6 for the hamlet, so its buildings come down more easily than the block's defaults. The destruction block exposes the same scale as its weld strength control, from 0.25 to 4 times.
The prompt in step 2 arms your tower this way. Check that the tower stands, and that pulling blocks out of the bottom courses sets off a run of breaks above them.
5. Use the solver settings that keep a tower standing
Run three-avbd at a fixed 1/60 s step with 12 solver iterations and at most 2 substeps a frame. If you use the destruction block, everything in this step is already done; it's here so you know what not to undo. The count is measured: the code notes that at 10, "a free-standing chimney of 70 courses bounced on its welds until they broke".
Allocate contact storage up front: 40 contacts, 12 pairs and 8 manifolds per body. A standing structure has almost no contacts, since welded pairs don't collide, so the solver would otherwise grow its storage in doublings while everything comes down, each one a hitch.
Patch the adjacency sort. The vendored three-avbd changes one kernel, sortAdjacency, to heap-sort any body's constraint list longer than 32. A body under a heap of rubble, "the ground above all", can have thousands of contacts, and the original insertion sort held up the whole step. Patch's Brickfall found it first.
Nudge freed pieces down. three-avbd's adaptive warm start takes a body's gravity from how it moved last step, so a piece held still by a weld that lets go can hang in mid-air. Patch's code gives each freed piece a downward impulse of 0.15 times its mass.
6. Break it with a blast
Push pieces and cut a few welds, and let the armed welds decide the rest. A blast in ruin.js wakes every building within its radius plus 3 m, then throws each piece in range outward at about power x 12 x f^1.5 m/s, where f falls from 1 at the centre to 0 at the edge. Pieces near the centre (f above 0.42) have their welds cut outright; the rest are only thrown. It throws hard on purpose: "a block low in a wall is pinned by the weight on it, and at under 10 m/s it stops within a hand's breadth."
A puff of dust comes off 30% of the welds that break in stone, brick and plaster, driven from the structure's onBreak callback. Fire, smoke and a shockwave on top of the dust are a separate layer; our guide to ai game vfx makes them from generated flipbooks.
The destruction block's cannonball already breaks things this way. To add a blast of your own, ask your agent for one on right click that wakes every building within its radius plus 3 m, throws the pieces in range outward and cuts the welds where f is above 0.42, starting at radius 4 m and power 1, with dust from 30% of the masonry welds that break. Then ask it for a screenshot after a blast at the foot of the tower.
A blast at the foot of a wall should take out the bottom courses and bring the wall above down after them, not throw the whole wall at once.
An explosion and its crater, from @BlendiByl's post on destroying the meadow
7. Cut it with the Cleave
The Cleave is spell 9: click and time all but stops (it runs at 0.05 speed), drag a line across the view, let go. The cut is the flat sheet through your eye and both ends of the line, so what you drew across on screen is what is cut. It doesn't slice any rigid body:
Every weld whose two pieces lie on opposite sides of the sheet, within 3 m of it, is cut.
A box the sheet crosses stays one whole body, on its own side. "Its body is not cut: it is the whole box still, on its own side. What is seen is cut." The shader discards the part of it past the plane and draws the cut face flat, and its other half is drawn riding on the nearest piece across the line.
Everything above the cut is lifted, from 0.84 m for an upright cut to 2.4 m for a level one, held for a second, then let go tipping.
The lift came from testing: pushed along the cut alone, the top half "went a few centimetres: the stone's friction takes a metre a second at once."
The Cleave cuts welds, not bodies. A diagram drawn by Patch
To make a slice tool of your own, ask your agent to read the cleave function in Small Magic's src/ruin.js (clone it with pch clone blendi/small-magic) and write its own rather than copy it, since that file is under the Patch licence. It should cut the welds across the plane through the camera and both ends of your line, discard each crossed box's part past the plane in the shader instead of splitting any body, and lift the top by up to 2.4 m for a second before letting it fall.
8. Keep only the touched building live
Hold every building fast until something reaches it, and step only what moves. Small Magic's code records the saving on an earlier, larger layout of castle and village, 4,105 pieces: "the physics cost 4.5 ms a frame with every piece live, 1.7 ms with only those of one building live." The hardware isn't stated.
Group pieces into companies: pieces joined by welds that still hold, found with a union-find. A company is a building, what's left of one, or one loose stone.
Freeze them. Every piece of a resting company becomes a fixed body, its welds' loads stored first.
Wake a company whole when a spell reaches it. Half a building woken leaves the other half hanging in the air. Its welds get their stored loads back.
Sleep again after 2.5 s with nothing moving: regroup (what broke apart is now several companies) and freeze.
The same thinking caps spells that grab pieces. The Singularity once took 2,600 pieces and gave them back in one frame, at 33 ms a frame and 200 ms at worst. Now it holds at most 1,000 and gives back 150 a frame.
The Singularity takes the abbey apart, every block its own body. By @BlendiByl
To do the same in your game, ask your agent to group your pieces into companies with a union-find over the welds that still hold, freeze each resting one with its weld loads stored, and wake it whole when a blast or a cut reaches its bounds. Have it show the physics time per frame on screen, then build three towers and check the time drops when two of them are frozen.
9. Let the ground break too
Since version 2.2.0, the ground breaks with the buildings. Under the hamlet, three-avbd's ground is flat boxes, one per square of the meadow's height. Where an explosion digs a crater, Small Magic lowers those squares and lays the hole's shape over them in tilted tiles, big where the ground is even and small where it bends, so stones roll down the side. Earth thrown out is sods and clods (24 and 48), pieces like any other. On the north hill, the Cleave takes the top off, and it slides away in blocks. R puts everything back.
What went wrong
The code records each of these, and each one changed the method:
A tall chimney shook itself apart. At 10 solver iterations, a free-standing chimney of 70 courses bounced on its welds until they broke. Twelve holds it (step 5).
Welds broke before anything touched them. Built breakable from the start, a structure broke most of its welds while the solver's penalties ramped up. Settling first and arming after fixed it (step 4).
A pile of rubble stalled the step. A body under a heap of rubble can have thousands of contacts, and three-avbd's insertion sort held up the whole frame. The heap sort fixed it (step 5).
The Cleave's top half barely moved. Pushed along the cut, it went a few centimetres before friction stopped it, so the Cleave lifts it instead (step 7).
The Singularity hitched for 200 ms. Giving back 2,600 pieces in one frame was too much; now it holds at most 1,000 and gives back 150 a frame (step 8).
Mended welds snapped. Small Magic's time spell rewinds a collapse and re-makes the welds. A re-made weld carries nothing at first, so it is held unbreakable for a moment, with those within two pieces of it, then given its strength back once it has taken its load.
No WebGPU, no ruin. Without WebGPU, the meadow is drawn but nothing breaks. "we're working to get the game more optimised for lower end devices," @rehan_shei wrote on X.
The result
Small Magic 2.2.1 has four buildings of 1,948 pieces, plus 224 sods and clods, held by 5,000 welds, and nine spells in its sandbox to break them. @BlendiByl made the first version "in 1 day" with Claude Fable 5.2: seven spells, "about 1800 physics pieces to destroy and zero 3D models or textures". On November 28, the post adding the Cleave had 1,796,904 impressions and 22,563 likes on X.
Try it
Play Small Magic in the browser or Patch Desktop. Choose sandbox in the menu for the Cleave and the big spells.
Start from the destruction block: a timber barn (about 870 pieces), a water tower, a garden wall and a brick chimney to knock down with cannonballs.
Remix blendi/small-magic with pch remix, run it locally, and read src/spells.js and src/ruin.js. Add a new spell of my own that breaks buildings in a new way (wake what it reaches first, then push pieces or cut welds), give it a key, and test it on the keep. Run pch check, then publish my remix with pch.
Common questions
Can three.js do destruction physics without WebGPU?
Yes, with a CPU physics engine: the three.js examples include convex object breaking with Ammo.js, which splits objects on impact. Small Magic's method needs three-avbd, which runs on WebGPU compute only, and that is what lets it simulate thousands of welded pieces at once.
Should I fracture meshes or build buildings from pieces?
Voronoi fracture, as in three-pinata, splits one mesh into fragments at run time, and its docs suggest 10 to 50. A building made of real pieces with load-armed welds breaks along its courses and joints, and collapses by what held it up.
How many physics pieces can a browser game handle?
On WebGPU, thousands. Small Magic's hamlet has 2,172 pieces that can move, but only the buildings something has reached are live at once (step 8). On an earlier 4,105-piece layout, its code records 4.5 ms of physics a frame with every piece live and 1.7 ms with one building live, on hardware it doesn't name. Separately, three-avbd's voxel destruction demo runs a city of 94,000 bodies.
How do you make a building collapse realistically in a game?
Make each weld's strength come from the building's own loads. Settle it with unbreakable welds, read what each carries, and give each a margin over that load: 4 times for stonework, 6 for timber joinery in Small Magic. Removing a support then overloads the welds that depended on it, and the collapse follows.
Credits
Small Magic was made by @BlendiByl with Claude Fable 5.2. Grasp is by @Christos_antono, and the spell remix by @rehan_shei. The builder, weld rules and arming are Patch's destruction block (@patch_gg), from Timberfall. The physics is three-avbd by Steven Bobyn (MIT), implementing Augmented Vertex Block Descent by Giles, Diaz and Yuksel (SIGGRAPH 2025). Rendering is three.js 0.186.1.