Last Stand: a Browser ARPG on Its Own Engine
After the web browser, here is the other big project of the last few months: Last Stand, a 3D wave-survival action RPG that runs in the browser. You can play it (Chrome or Edge, it needs WebGPU), and the code is public on GitHub under the MIT licence.
The game is simple to describe. You pick a hero (mage, warrior or ranger), walk out of a village through a portal, and fight waves of foes on a battleground. After every wave you choose: Bank and leave with what you found, or Continue for better loot. Die, and everything unbanked is gone. You never see what you are carrying until it is banked, only how many items of each rarity. Up to four players can do it together.
The technical side is less simple. Every model, rig, animation, effect and sound is generated in code: there is not one 3D model file in the repository. Since November it draws through its own engine, Bulwark, written in Rust and compiled to WebAssembly over WebGPU. And it is measured more than it is played: the test harness is almost as big as the game.

The warrior in the Thornwood at wave 3, over the shoulder. Everything in the picture (trees, rocks, ferns, the hero, the mossbacks) is made by code at load time. This and the other pictures are the game’s own README screenshots, re-made on the engine on November 29 by npm run lab -- readme.
- By the Numbers
- What Is in the Game
- From Three.js to Our Own Engine
- Architecture
- Nothing Is Modelled by Hand
- Co-op Over Our Own Relay
- How Performance Is Measured
- The Performance Work, at a High Level
- An Outside Contributor: Lucas’s Swarm Work
- What It Means at Scale
- How It Is Built
- What Is Still Open
- Lessons
By the Numbers
The first commit landed on September 22, 2026, titled “Initial release of Last Stand”: 107 files and 13,574 lines. The numbers below are from main today.
| Metric | Value |
|---|---|
| Days since the first commit | 75 |
Commits on main (without merges) |
3,300 (2,522) |
| Merged pull requests | 789 |
| TypeScript files / lines | 2,216 / 402,655 |
JavaScript (.mjs: tools, servers, scripts) |
532 files, 60,478 lines |
The game itself (src/, tests excluded) |
~219,000 lines |
The lab harness (tools/lab) |
~199,000 lines in 1,365 files |
| Lab commands | 180 |
Unit test files / cases (node:test) |
165 / ~1,036 |
AGENTS.md files (one per directory) |
66 |
| 3D model files | 0 |
Engine build (bulwark_bg.wasm) |
1,144,229 bytes |
Lines are counted with git grep -c '' over tracked files, blanks included, without the vendored engine build and the lockfiles.
The line that surprises people is the lab: almost as much code measures the game as makes it. That is on purpose, and most of this article is about why.
| Merged PRs by author | Count |
|---|---|
| VictorZakharov (me) | 618 |
| KenBooks | 160 |
| ShamanicArts (Lucas) | 4 |
| akshvic, marsgpl, andreysgod-cmd | 7 |
Lucas’s four merged PRs undersell his work: most of it went in through my own PRs, which merged his fork’s commits under his name. More on that below.
What Is in the Game

Wardenhollow, the village every run starts from: the fountain, the hall of heroes behind it, the portals beyond.
| Part | What is there |
|---|---|
| Heroes | Mage (arcane, fire, lightning and healing staffs), Warrior (sword and board, dual wield, two-hander, empty hands), Ranger (hold to draw, release to loose, headshots) |
| Battlegrounds | The Crypt (imps, husks, witches, brutes) and the Thornwood (thornlings, mossbacks, sporecallers, bark hulks) |
| Bosses | A boss every 5 waves, three per battleground: Hollow Colossus, the Ossuary Cantor with two Bell-Wardens and the Ossuary Twins in the Crypt; Elder Thornheart, the Rootmother and the Stag of Ash in the Thornwood. A shared kit gives them phases, telegraphs, weak spots and breakable parts |
| Loot | Seven rarities (Common to Ultimate) with random affixes, a stash per hero, and trading between players |
| The village | Houses you walk into (a tavern with a keeper, a library, a shop, a House of Records with boss trophies), duels at a weapons rack, a tutorial, a day and night on your own clock |
| Co-op | Up to four players: revive, spectate, pings, chat, friends, rooms with passwords |
| Saves | Local, or in the cloud with a passkey, Google or a sign-in code |

A party of four in the Crypt at wave 6. The three partners here are stood in on one page for the picture, not four linked games; the real thing goes through the relay described below.
From Three.js to Our Own Engine
Last Stand started on Three.js and WebGL, like most 3D on the web. It moved off it in three steps:
| Step | PR | Merged |
|---|---|---|
| Three’s own WebGPU renderer offered as a trial, WebGL still the default | #331 | Nov 3 |
| Bulwark started as an experiment: plan, cull, lit and shadow passes | Nov 20 | |
| The game drawn by Bulwark alone: WebGPU only, three’s renderers removed | #797 | Nov 23 |
| Three.js removed entirely: scene, maths and UI on Bulwark; IK, foe poses, cloth and world matrices moved to Rust | #975 | Dec 1 |
Why write an engine instead of tuning Three.js? Because the traces players sent kept pointing at things a general-purpose library does on every frame. Three rebuilds every object’s matrix each frame, hidden ones included. It walks the whole scene graph to draw it. It compiles shaders when an object first appears, which on a low-end GPU is a freeze of seconds in the middle of a fight. An engine made for one game can cull, sort and batch the way that game needs, and never compile in the middle of play.
#797 had one bar, in my words in that PR: “all loading bars should be 100% smooth, no freezes anywhere including 0.5sec freezes”. It was measured with an installed Chrome, every cache empty, on an RTX 4070 Ti:
| First visit, cold Chrome | Before | After |
|---|---|---|
| The lobby shown | 25.3 s | 9.2 s |
| The longest hold under the loading screen | 14.0 s | 0.85 s |
| The hero screen’s worst second | 4 fps | 70 fps |
| A return: the longest hold after loading | 10.1 s | 0.19 s |
That is not all the engine’s doing: part of the 25 s was the game’s own (the warrior’s wrist wrap cast rays at his hand for 11 to 14 s a build), fixed the night before. Against Three.js in production the engine opened a cold first visit faster (9.95 s against 13.35 s), but a return was slower (6.81 s against 6.05 s). Both numbers are in the PR. A rewrite is not automatically faster everywhere, and the PR says so.
#975 then took Three.js out entirely. It started from one play report: a party of four at wave 36 of the Crypt ran at 12 frames a second on a laptop with an integrated GPU. The same scene on a lent RTX 3060 laptop, at Very low, compared against main with --ab:
| Party of four, wave 36, Crypt | Before | After |
|---|---|---|
| Median frame, standing | 28.1 ms (36 fps) | 15.3 ms (65 fps) |
| Median frame, casting | 33.6 ms (30 fps) | 18.2 ms (55 fps) |
| Standing, CPU slowed 4× | 113.4 ms | 57.9 ms |
| Draw calls | 925 | 528 |
| Scene objects walked per frame | 12,896 | 16 |
| Triangles | 1.68M | 955k |
On the 4070 Ti the same scene went from 31.6 ms to 11.7 ms. The integrated-GPU laptop that started it was not re-measured; the PR gives its gain as an estimate only.
The engine’s source is a separate, private repository. The game repository holds its build (src/engine/pkg/), stamped with the commit it was built from, and a check fails a pull request that changes the build without the stamp. A second check fails any import of Three.js.
Architecture
Where the work happens. The game decides what happens; Bulwark decides how it is drawn, and runs the code that is hot every frame.
The split is by how often code runs, not by subject:
- The game (TypeScript) owns the rules: input, skills, combat, waves, loot, the bank, co-op, menus. It is plain modules around one typed state object and a typed event bus, with data (
src/data/) kept apart from behaviour (skills registered by name). The same fight modules build for Node too, and that is how the dedicated co-op server runs the game with no browser. - The bridge writes only the scene nodes that changed since the last frame. Data that is large and hot, like the swarm’s positions, is read in place: typed arrays laid over the WASM module’s memory, no copies.
- Bulwark owns everything that runs per object per frame: the crowd simulation, leg and arm IK, foe poses, cloth, world matrices, then culling, sorting and batching look-alike materials into instanced draws. Particles live in a GPU ring buffer moved by one compute pass. The UI panels are laid out by taffy (flexbox) and drawn in one call.
- Pipelines are compiled aside. A draw whose pipeline isn’t ready is skipped for that frame instead of waiting for it, and the number of pipelines made during play is counted and must stay zero. Boot asked for 152 pipelines under the loading screen; after #822, which makes each only when first asked for, it asks for 47.
One rule that sounds odd but came from Chrome: things that follow the world on screen (damage numbers, health bars, name tags) are drawn by the engine, not as DOM elements. DOM elements moved every frame caused 1 to 4 second Skia repaint stalls in Chrome on Windows.
Quality is four levels (High, Medium, Low, Very low) plus Auto, and every setting switches live without a shader change. Auto is the piece I rewrote most often. It aims at 90% of the frame rate the lowest level gets on that screen, never lowers the resolution, judges only steady play and the GPU’s own time, tries the level above once per boot in the village, backs off for 1, 2, 4 and then 8 boots when a trial fails, and never switches in the middle of a wave.
Nothing Is Modelled by Hand

The choice after every wave. The spoils are counted by rarity and stay unseen until banked.
There are no model files. Heroes share one humanoid rig, built and sculpted in code; heads and hands are built in Web Workers and cached across visits. Legs and arms are placed by IK, so a foot stands on a slope and a hand closes round a bow. Skirts and coats are draped as cloth. Trees in the Thornwood are grown by ez-tree (MIT). Sound effects are synthesized in WebAudio, one file per sound. The fire is a fluid simulated once and played back, which took it from 23 MB to 624 KB on the GPU, and its bake step fails if it ever grows past its budget.
The only binaries in the repository are 32 painted skill icons (624 KB of WebP), optional party portraits, four music tracks, five photos used for map colours, the engine build and the README screenshots. Some of the skill icons were painted by Codex’s image generation against my reference icons, and then checked at 48 pixels beside the rest of the set.
Co-op Over Our Own Relay
Co-op launched on September 24 as peer to peer over WebRTC. It did not survive phones: ICE failed behind mobile carrier NAT. Since October 6 every game talks through our own relay, a small Node WebSocket server that holds four players a room, checks the page’s origin, rate-limits each socket and keeps a grace period for reconnects. It runs at wss://ls.wellscoped.dev.
Authority is split so that a slow player hurts only themselves:
- Every game moves and casts for its own hero, and judges its own hero’s hits as its own screen shows them. That keeps combat honest to what you saw, and playable at 300 ms of ping.
- The host simulates the fight: foes, waves, loot, downs. Partners are played back on a timeline.
- A host tab in the background keeps ticking in a worker, so hiding the tab does not freeze the guests.
- An optional dedicated server runs the same fight code in Node and refuses new rooms by measured memory headroom.
The protocol version is a hash of a sorted list of feature lines, one line per PR, instead of one shared number. With several PRs in flight at once, a shared number conflicted in seven rebased PRs. A line of your own merges cleanly.
All of the services (the relay, the dedicated server, cloud saves, performance traces) and a preview of every pull request at pr-N.ls.wellscoped.dev are deployed by Dokci, my own deploy tool for Docker Compose. The game itself is served from GitHub Pages.
How Performance Is Measured
A browser game runs on whatever the player has: a 4080, an integrated Radeon, a Galaxy S25, an Adreno phone. I own few of those. So most of the work is in seeing what happens on hardware I don’t have.
| Tool | What it does |
|---|---|
npm run lab -- <command> |
Boots the real game in Playwright Chrome on the real GPU, deterministically, and measures one thing. 180 commands: perf, draws, pipelines, pace, coop, auto… |
--ab |
Runs the same command on main and on the branch and diffs the numbers and the pictures |
| Canaries | Every lab measure must catch a planted fault (--canary), so a check that passes because it measures nothing gets noticed |
npm run stalls |
Drives a cold, installed Chrome and alternates two builds, to time boots and input lag |
| Player traces | The game always keeps the last minute of frames. When play is slow (1% lows under 30 fps, a stall, a boot over 15 s) it offers to send it, with a short code like ABCD-EFGH, and only with consent |
lab trace <code> |
Reads a player’s trace, so the fix starts from their frame, not from a guess |
| “Profile this spot” | In the pause menu: redraws the frame with each part of the scene removed in turn, timed by GPU timestamps, and names the shader that costs |
| Lent GPUs | Heavy runs go to two lent laptops (an RTX 3060 and a 4080) through Loaner, a small tool of mine that runs jobs on another PC |
The player traces changed how I work more than anything else on this list. “The game is slow” is not something I can fix. A trace that says “the village update took 149.6 ms a frame” is.
The Performance Work, at a High Level
Hundreds of the PRs merged since October 20 are about performance. They fall into a few stories, each started by a player report.
Freezes at boot. Players reported freezes of 5 to 10 seconds while loading, and keys that queued up and fired together afterwards. The causes were many and each was small: shaders compiled whole on the main thread, IndexedDB waits (13.8 s of one boot’s 22 s of map work was waiting on the store), whole villagers built in one task, GPU-process round trips, Chrome compiling a stage again for every pipeline.
| Fix | Measured |
|---|---|
| #276 Maps and programs made ahead | First visit’s lobby 9.1 s → 5.1–5.7 s |
| #935 Each shader stage compiled once | GPU process work to the lobby 40.2 → 20.1 s first visit, 30.4 → 10.1 s return |
| #822 Pipelines made only when first asked for | 152 → 47 under the loading screen |
| #820 A WebGL context left behind, released by hand | A 13 s single task removed from a phone’s 44 s boot |
| #936 Nothing compiled whole in the lobby | Worst hold in the lobby 243 → 63 ms |
Low-end GPUs and phones. An integrated Radeon laptop ran the village at 4.5 to 8 fps, and a WebGPU phone held 60 fps for 11 seconds and then dropped to 31 as it heated up. The answers were triangles and a better Auto. A Very low level came from KenBooks, along with heroes at 22k to 24k triangles instead of 41k to 60k and hands of 612 triangles instead of 12,500 (#544). The village on High went from 2.05M triangles to 533k (#604); my note in that PR was “we need below 1M tris on high”. Auto stopped settling on the wrong level: a Galaxy S25 trace showed 21 to 34 fps for 16 seconds while Auto tried Medium, where Very low held 62 to 74; #1085 tries a level only when the GPU has headroom for it.
Frame pacing and input lag. A 60 Hz monitor next to a 145 Hz one juddered, because the game stepped by the ticks of the wrong screen; KenBooks’ #641 steps by the mean frame interval. Players also noticed that Vsync off showed more fps but “plays slower/sluggish”, so the toggle went and Vsync is always on (#1139). With frames fenced on the GPU, the time from a key press to the GPU finishing its frame went from 87.7 ms to 30.2 ms at the median on a GPU-bound frame (#1134).
Regressions only a player could find. A village at 6 fps turned out to be the game reading saves from localStorage about 860 times a frame (#1207). My test machines had small saves; the player had big ones. The fix reads once and keeps the result, and lab perf now fails on any storage read made per frame.
An Outside Contributor: Lucas’s Swarm Work
In early December an outside contributor, Lucas (ShamanicArts on GitHub), started sending performance work. Everything he sent was about the same problem: what happens when there are a lot of foes on screen.
He started with 17 small PRs in his own fork. I merged most of them as two combined PRs, keeping him as the author of every commit:
- #1105: a GPU minimap, hot DOM loops removed, a hero drawn as one body, foe shadows merged, a flat struct-of-arrays spatial grid, and crowd posing at 30 Hz.
- #1111: pooled damage numbers, a flow-field gradient, a GPU pose bank (dual quaternions), pooled foes without rigs, and a Rust crowd simulation as a sidecar WASM module.
I did not ship his sidecar binary. When I rebuilt it from the source he submitted, the result did not match the binary he sent. I ported the code into Bulwark instead, kept the new paths behind switches, and measured. On the 4070 Ti, Forest wave 36 with 18 times the foes (615 of them): page CPU 21.3 → 6.6 ms, the foes’ update 7.2 → 1.3 ms, the whole frame 27.5 → 13.4 ms standing.
Then came his own PRs:
| PR | What | Result |
|---|---|---|
| #1109 | Damage numbers from one pre-painted digit strip; health bars as a cached track plus a scaled quad, so a change of HP repaints nothing | Merged in 32 minutes. His measure, RX 6600 XT: 90th percentile CPU 27.7 → 24.2 ms |
| #1146 | Every foe killed in view falls as a 16-point Verlet ragdoll again; one killed off screen gets a cheap ballistic body | A correctness fix: pooled foes had been sinking into the floor |
| #1149 | One path for every foe: the four opt-in switches and their double code deleted. The nearest foes keep live skeletal rigs, the rest are instanced draws; the crowd simulation runs in Bulwark from one foe up; navigation reads the flow field in O(1) instead of a 20-step ray walk | Merged. The table below |
| #1154 | Two simplified levels of detail with a dithered band between them; a persistent struct-of-arrays Rust crowd core that steers, separates, hashes, culls and packs instances in one pass | Closed, but landed: I took his commits as they were in #1166 and moved the crate into Bulwark in #1167 (one WASM, 28 KB smaller) |
| #1208 | Effects (telegraphs, shockwaves, rings) as shared instanced pools; 18 skills querying the spatial grid instead of scanning every foe; projectiles pooled | Merged after one review round |
I measured #1149 on a lab scene built for it, --coming mossback --foes N, with every foe in view (4070 Ti, High, 1080p, medians):
| Foes | CPU before | After | Change |
|---|---|---|---|
| 25 | 7.0 ms | 7.1 ms | none |
| 100 | 9.3 / 10.3 ms | 8.9 / 7.9 ms | −4% / −23% |
| 200 | 12.1 / 15.4 ms | 8.1 / 8.2 ms | −33% / −47% |
| 500 | 23.1 ms | 7.2 ms | −69% |
| 1000 | 38.7 ms | 10.4 ms | −73% |
| 2000 | 87.3 ms | 15.4 ms | −82% |
| 4000 | 436 ms | 27.9 ms | −94% |
At 4000 foes the CPU work was 15.6 times smaller: the foes’ stage went from 320 ms to 14.5 ms and placing them in the scene from 65.6 ms to 1.1 ms. The whole frame went from 441 ms to 52.4 ms. Past 2000 the GPU sets the pace, not the CPU. That made the triangle cuts in #1154 the next step: at 4000 mossbacks the frame went 40.2 → 17.8 ms and triangles 18.1M → 6.18M.

A mage in the Crypt. With crowds like this one, only the nearest foes in view keep a live, IK-driven skeleton; the rest are posed from a baked bank on the GPU.
The crowd today has three tiers (src/entities/models/swarmBank.ts):
| Tier | Which foes | How they are drawn |
|---|---|---|
| Live | The 16 nearest in view | A real rig, leg IK, full textured model |
| Mid | The rest, up to about 14–24 m | One instanced draw per kind, posed from a baked dual-quaternion bank |
| Far | Beyond that | A simplified one-bone model; the band between mid and far is dithered by a per-foe hash, so nothing pops |
How the reviews went. Every PR of his got the same treatment as my own: re-measured on my hardware and on the lent laptops, before and after pictures, and an adversarial reviewer given only the pictures. On #1154 the review found four real bugs (rising and dying foes erased every frame, a kind invisible until its far tier was simplified, slam foes that stopped throwing past 150 foes, the host pushing a partner’s hero), six probable ones, and six new foe-count thresholds that broke one of the game’s rules: one path for 1 foe or 1000. He fixed all of it within half an hour. Then he found a bug of mine: main multiplied every crowd texture by a hard-coded 0.8, so the crowd copies came out too pale. I measured to see which of us was right; his matched the real models within 0.05, mine did not. In the PR I called it “a fix, not a regression”.
On #1208 the review found seven issues, including a stale spatial grid that could crash a skill. He fixed them in half an hour, and his fixes were the same as or better than the ones I had made on a local branch. On the RTX 3060 laptop the Crypt with 2000 brutes went from 28.3 to 20.5 ms a frame; on the 4080 laptop, “The gain is real, and larger than claimed”.
Not everything was accepted. #1241 proposed capping Medium’s 3D scene at 2.55 megapixels, aimed at phones. The gain was real, but most of it came from the lower resolution, which the game already offers as an option. A fixed pixel count would also have cut 1440p, ultrawide and 4K screens, and made Medium cheaper than Low, so Auto’s ladder would run backwards. I asked for changes. Three more of his PRs (a baked ground look, a lighter Medium, a faster Dijkstra) are open as I write this.
What It Means at Scale
It’s worth being careful here, because the big numbers above are stress scenes, not the game as played. A real wave tops out at 38 foes standing for a solo hero and 48 for a party of four (maxAlive in src/data/waves.ts). At those sizes, every A/B in these PRs reads “within noise”: 25 mossbacks were 7.0 ms before #1149 and 7.1 ms after.
So what did the swarm work buy? Three things:
- Headroom where it matters. A normal fight is cheap on a 4070 Ti either way, but the same fight on an integrated GPU or a phone is not, and the CPU time saved per foe is saved there too.
- The bosses’ adds and the late waves. Effects, projectiles and skills that used to scan every foe now ask a spatial grid, and the cost of a crowded moment no longer grows with the crowd.
- A game design that is no longer capped by the engine. Before this work, 3,420 foes (ten times wave 36’s crowd) took 478 to 606 ms a frame: about 2 fps. Now 4000 foes take under 18 ms on the 4070 Ti, and 2000 take 12.5 to 13 ms on a 4080 laptop and about 21 ms on a 3060 laptop. A horde mode with thousands of foes went from impossible to a design question.
The trade-off: only the nearest 16 foes are full models. The crowd copies sample real colour and glow maps again since #1166, but not normal and roughness maps. At a distance, in a crowd, in a fight, it does not show. In a still picture it can.
How It Is Built
Like the browser, most of the code was written by AI coding agents (Claude Code and OpenAI Codex), many sessions in parallel, each on its own branch and pull request, while I chose the direction, wrote the rules, reviewed and played the builds. That only works with a lot of structure, and the repository shows it:
- An
AGENTS.mdin every directory, 66 of them, with my own words quoted as rules (of the README’s pictures: “dont make 90% empty room”). A rule I had to repeat once gets written down so I never repeat it again. - Features add files; shared files change by a line of their own. Lists are kept sorted, and a check fails a PR whose list isn’t. Before this,
src/ui/AGENTS.mdalone was edited by 131 PRs in five weeks, and conflicts were the main cost of working in parallel. - Every measure is a lab command, and every lab command must catch its canary. An agent that says “fixed” has to show the number, from a command anyone can run again.
- Pictures in every visual PR, before and after, and an adversarial reviewer that sees only the pictures and the target, never the agent’s opinion.
- Branch rules: a PR lands on
mainas a merge commit, a PR branch with merge commits of its own fails its check, and a code owner approves.
I review and merge. Agents don’t.
What Is Still Open
- A pipeline made mid-fight on some casts (#1225), the one exception to the zero-late-pipelines rule.
- Resizing the window live drops the game under 20 fps (#1236).
- Cold-load freezes on some machines are tracked in #535; the worst are gone, not all.
- No WebGL fallback. WebGPU only means Firefox and Safari users without WebGPU can’t play. That was a deliberate trade for one code path that is fast.
- Several phone results are lab emulations, not measured on the phone itself; the PRs say which.
Lessons
- Measure on the player’s hardware, or as close as you can get. The consented trace was worth more than any profiler I ran myself; it found a 6 fps village my machines never showed.
- A rewrite is not automatically faster. The engine made a cold first visit faster and a return visit slower. Measure both and write both down.
- Make the hot path one path. Four opt-in switches with two code paths each were four bugs waiting. Deleting them made the code smaller and the review possible.
- Review outside work like your own, and credit it the same way. Re-measure it, rebuild its binaries, keep its authorship, and say so when the contributor is right and you were wrong.
- Big numbers need their conditions next to them. 15.6 times faster at 4000 foes and no change at 25 are both true. The second is the game people play today.
The code, the PRs and every number above are public: github.com/VictorZakharov/last-stand.