HTML5Three.jsWebGLWeb AudioMRAIDPlayable ad
Controls
- Tap or press Space to start running; drag left or right (or hold the arrow keys or A and D) to steer the crowd
- Run through the gate that makes the crowd bigger: blue gates add or multiply, red ones subtract or divide
- The saw and the spinning sweeper take runners that touch them; hug the edge to lose fewer
- The red squad and the Brute trade one runner for one: arrive with at least 48 to win
- The Install button is always on screen and calls the exit API of the chosen network; the end card comes up after the boss fight or at 40 seconds of play
- Pick AppLovin, Unity, Google Ads, Meta or Browser to change the mock SDK the ad runs against
- Rotate switches the phone between portrait and landscape; Hide ad simulates the ad leaving the screen so it pauses and mutes; Backup shows the static image
- The mute button in the corner silences the music and effects; sound starts only after your first touch
Needs WebGL; works in current Chrome, Safari and Firefox on phones and desktops. The ad is one HTML file of about 570 KB with three.js bundled in, no external requests, in a sandboxed frame. Sound needs a tap to start, as every browser requires. Respects the reduced-motion setting: no camera shake or confetti, fewer particles, and the hand hint and end-card animations stand still. The ad-network SDKs on the page are mocks with the real names and call shapes. Crowd Clash is a fictional game made for this example.
Questions
Is Crowd Clash a real game?
No. It is a fictional game made for this example.
How large is the file?
About 570 KB raw and 145 KB gzipped, with no external requests, images, models or audio files.
Can a playable ad use three.js?
Yes. Here three.js is bundled into the single HTML file, which stays well under the common 5 MB limit.
Which networks does the demo simulate?
AppLovin, Unity, Google, Meta and a plain browser, inside a phone on a mock ad network.
How it’s built
A 3D playable ad in the crowd-runner style (maths gates, traps, a squad to crash into, a boss at the end), the format that fills a large share of mobile game ad breaks because it explains itself in one second and asks for one gesture. It is built the way ad networks take playables: one self-contained HTML file that starts when the network says it is ready, is playable at once and ends on an install card. The page runs it inside a phone on a mock ad network, so every rule a network checks is visible while it plays. Crowd Clash is a fictional game made for this example.
The playable
- Source in
src/playables/crowd-clash/, built by node scripts/build-playable.mjs crowd-clash (rolldown bundles game.ts with three.js to one minified script, the styles are inlined) into public/lab/ads/crowd-clash/index.html. About 570 KB raw and 145 KB gzipped, no external request, no image, model or audio file; the backup image (backup.jpg) is captured from the ad itself by node scripts/playable-backup.mjs crowd-clash. npm run ads measures it and checks the playable rules (one file, an exit API, no external requests, a 5 MB limit with 2 MB as the safe size). - Flow: the crowd stands at the start with a swipe hint; the first touch starts the run and the ad clock. Four gate pairs ask one question each (which side makes the crowd bigger for its current size: +10 or ×2 when you have 5?), a saw slides across the track, a red squad of 14 charges and trades runners one for one, a spinning sweeper guards the last stretch, and the Brute waits with 48 HP. A good run reaches about 75 runners and wins with a crowd to spare, a careless one runs out at the squad. The end card comes after the boss fight, after a defeat, or 40 seconds after the first touch, whatever the player is doing. A run lasts about 28 seconds.
- All rules are in
logic.ts (unit-tested): the level, the gate maths and the "bigger side" judge, the sunflower crowd formation that squeezes to fit the track, the trap hit tests, the clash and boss exchange rates, the trap budget (one trap takes at most 30% of a crowd on one pass, so a big crowd is hurt, never wiped out), the stars and the end card line built from what the player actually did. - The world (
scene.ts) is three.js built in code: a runway over a lagoon with islands, palms and clouds, gates with canvas-drawn labels, a toothed saw, a hazard-striped sweeper, spinning coins, and the Brute (horns, brows, belt, spiked shoulders) who pounds while hit, cheers when he wins and topples when he loses. Runners are seven instanced meshes (torso, head, two legs, two arms, a blob shadow) with toon shading, so a crowd of 220 is seven draw calls; each runner's limbs swing from its own phase. Particles and confetti share one instanced pool. - The numbers over the crowd, the squad and the Brute are HTML placed at projected 3D positions, so they stay sharp at any pixel ratio. The crowd's tag fades while a gate is close so it never covers the label being chosen.
- Sound is Web Audio only (
audio.ts): a 128 BPM loop of kick, hats, snare noise and a bass line, plus gate arpeggios, pops, coins, hits, a stomp and win and lose jingles. It starts on the first gesture and has a mute button. - Controls: drag anywhere (relative drag, so the thumb never covers the crowd), the arrow keys or A and D on the focused canvas, Space or Enter to start. Reduced motion: no camera shake or confetti, a third of the particles, a still hand hint and still end-card animations; the game itself still plays, because it is driven by the player.
- Without WebGL the ad skips straight to its end card, which is plain HTML.
Network behaviour
- The ad waits for the SDK: with MRAID it starts on
ready, then on viewable; without an SDK it starts at once. It pauses its frame loop and suspends its audio when viewableChange says false or the tab is hidden, and the ad clock excludes the paused time. - The install button is always on screen (top right, then the end card's Play now) and calls, in this order,
mraid.open(url), ExitApi.exit(), FbPlayableAd.onCTAClick() and finally window.open(clickTag). - It reports what happened to the page around it with
postMessage (ready, first touch, each gate with the count before and after and whether it was the bigger side, trap losses, the clash, the boss fight, the outcome, the end card, install taps, pause and resume). Run alone it simply ignores that.
The preview page
- The mock SDKs (MRAID 3 for AppLovin and Unity,
ExitApi for Google, FbPlayableAd for Meta, clickTag only for a plain browser) and the ad-ops checklist are shared with the Guitar Tuner playable in src/lib/playableHost.ts; model.ts here counts this ad's own events and draws the crowd chart (a step line of the crowd size over the ad clock against the Brute's 48 HP). - Controls: network switch, rotate the phone, Hide ad (tells the ad it is no longer viewable; it also reacts to scrolling out of view), Backup (the static
backup.jpg), Reload. Every exit is reported as a toast instead of leaving the page.
Honest limits
- The SDKs are mocks with the real names and call shapes, not the networks' own code. In production Google's
ExitApi comes from an include on Google's servers, which a self-contained file cannot carry; Meta and Google also have their own size limits and review rules that should be checked before trafficking. The 5 MB limit is the one AppLovin and Unity state in their documents. - The store link is a placeholder search on Google Play, because the game does not exist; a real campaign puts its own link in the clickTag.
- The sound could not be judged by ear in an automated run; frame rate was checked in headless Chromium with GPU, not on a range of real phones.