Three.jsTypeScriptCanvas 2DWeb AudioVitest
Керування
- Move the mouse to aim; the reticle sways with your hand. Press and hold to steady it, then let go while the charge ring is gold. Hold too long and the arm tires
- Touch: put a finger down and drag to aim (the aim moves at half the finger's speed so the finger never hides it), keep it down to steady, lift to throw
- Keyboard: arrow keys move the aim (Shift for fine steps), hold Space or Enter and let go to throw
- 501 double out, best of three legs, three darts a visit. The checkout route shows on a beer mat once a finish is on
- Beat each opponent on the ladder to meet the next; the hand gets shakier up the ladder. Each opponent brings quirks: heckles that jolt the hand, a draft, tight wires, a swinging lamp, people walking past, or a seven-second shot clock on finishes
- Before a match, add hard-mode modifiers or a pint for a bigger prize; every opponent also has a one-off side goal (a 180, a 100+ checkout, a bull finish) that pays extra
- During the opponent's turn, tap or press Space to hurry them along
- Coins buy six dart sets and seven flights behind the bar, each with stat bars for steadiness, accuracy and speed. Progress is kept in this browser
Needs WebGL. Without it the poster is shown. Respects the reduced-motion setting: darts land at once, no camera zoom, slow-motion replay, board shake, dust or drifting light, and the hand sways more slowly. Sound is off until you turn it on. Progress is saved in this browser.
Як це зроблено
Last Orders is a darts game in a pub at closing time, built with Three.js and React. Everything in the room is made in code: no models, no image files, no downloaded textures.
The pub
- The board face is painted on a 2048 px canvas from the regulation geometry (bull 12.7 mm, outer bull 31.8 mm, 8 mm trebles and doubles, 170 mm to the double wire) with sisal speckle, worn patches around the treble 20 and the bull, and the number ring. A second canvas with fibre noise is its bump map.
- The wire spider is real geometry: six steel tori for the rings and 20 instanced radial wires, so the lamp throws their shadows on the sisal. On the tight-wire board the texture and wires are rebuilt from narrower rings.
- The cabinet doors stand open with chalk boards on their inner faces. The score sheet, averages and the checkout route are painted onto those boards with a chalk font, a glow pass and a grain pass, and repainted after every dart.
- The room: oak wainscot and flock wallpaper from canvas textures, a brass lamp (a spot light with soft shadows), two sconces, a shelf with nonic pints (lathe glass, beer and foam), a stoneware bottle and a trophy, a painted pub sign and a high table.
- Dust drifts in the lamp light as additive points. The depth-of-field feel is cheap: a masked CSS backdrop blur softens the edges of the room, out-of-focus bulbs and a near pint are CSS gradients in front of the canvas.
Throwing
- The hand sways with summed sines of unrelated periods plus a breathing cycle of about four seconds. Holding steadies it to about a third in 0.8 s; after 2.2 s the arm tires and the sway grows again. The charge ring marks the gold window.
- On release the dart lands at the reticle plus Gaussian scatter that depends on how steady the hand was and on the dart set. Heavier darts sway and scatter less and fly flatter.
- A draft stretches the sway along one direction and leans the hand with it; a pint adds 35 % sway; a finish on adds pressure (18 %).
- The dart flies a parabola with its point along the velocity, spins, sinks a centimetre into the board, quivers with a damped wobble, and the board knocks back. The camera leans in on the hit; a 180 or a checkout is played again at 22 % speed with a chase camera.
Rules and opponents
- Scoring, 501 double-out visits (busts below zero, on one or on a non-double finish), legs and the checkout table live in
core/ as pure TypeScript with Vitest tests. Checkout routes are searched over every single, double, treble and bull, preferring fewer darts, then the usual doubles (D20, D16, D8) and the big trebles; the bogey numbers have none. - Opponents aim at the same routes a sensible pub player would (T20, the checkout, or a set-up single that leaves a good double) and land with Gaussian error. Six of them form a ladder from 30 mm to 7.5 mm error, with drafts and tight wires higher up.
- Coins come from wins, legs, 180s, ton-plus checkouts, high finishes and winning on a pint, and buy four dart sets and five flights. Progress is kept in
localStorage.
Performance
- One Three.js chunk loaded only on this page. Shaders are compiled before the first frame; the loader leaves after that frame and the fonts used on the chalk boards.
- The low tier uses 1024 px board textures, a plain glass material instead of transmission, fewer dust motes and no CSS blur.
- Rendering stops when the page is hidden or scrolled away. Reduced motion lands darts at once and turns off zoom, replay, shake, dust and drifting light.
Feel and difficulty
- Each throw leaves a short additive streak behind the flights. On impact, a puff of sisal dust bursts from the hole, the camera jolts forward slightly and the board knocks back into the cabinet. A score chip pops at the dart and flies to the thrower's scoreplate. Two or more trebles, doubles or bulls in a row light a "hot hand" streak.
- While the opponent throws, the camera steps back to the side. A tap or Space hurries them: waits shrink to 30 % and the darts fly 2.6 times faster. A new leg starts behind a chalk-cloth wipe across the view.
- The sway grows by 7 % per ladder rung. Opponents bring quirks: heckles (the hand jumps for 0.9 s), a draft, tight wires, a swinging lamp (the spot light moves, so the wire and dart shadows slide), regulars walking past (blurred CSS silhouettes), and a seven-second shot clock on finishes that throws the dart when time runs out. Any quirk an opponent doesn't already bring can be added as a hard modifier for 15 to 30 % more prize money.
- Every opponent has a one-off side goal (win 2-0, a 180, no busts, a 100+ checkout, a bull finish, a 60+ average). Six dart sets and seven flights have stat bars; better flights reduce scatter a little.