Skip to content
Projects

About

An endless cinematic steam train ride from golden hour to dusk, in your browser. three.js on WebGPU, everything made in code. Built by Claude Sonnet Next.

Design & Media

How these counts are measured

Measured star growth

in 24h
Collecting history
in 7 days
Collecting history
in 15 days
Collecting history
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

The Golden Line

An endless steam train ride through European-style countryside, in a browser tab, built in three.js on WebGPU. It starts at golden hour and runs through sunset into dusk, past wheat fields, lakes, rivers, pine forest, tunnels, station towns and a great stone viaduct, while the train's lights come on. The train, the land, the trees, the water, the sky, the steam, the sound and the interface are all made in code. There are no image files, 3D models or audio recordings behind any of it.

Nine shots from the ride: golden hour fields, the carriage, the viaduct, the tunnel exit and dusk

Nine shots from the film, which tools/render-video.mjs draws frame by frame from the running build. Nothing in it is composited and nothing is retouched.

Ride it live MIT license GitHub stars

Buy me a coffee  Sponsor on GitHub

Ride it: https://starknightt.github.io/golden-line/

For a hands-off recording, ?director=1 cuts between the cameras by itself with no interface.

Read the brief it was built from: PROMPT.md. Unedited, with everything that was added during the build.

It needs WebGPU, so use a current Chrome or Edge with a desktop GPU. It was built and measured on an RTX 4060. A loading screen stays up while the world is laid and the shaders compile, about 10 seconds on that card from a local copy. Browsers hold sound until your first click or key.

Running it locally

Open index.html in Chrome or Edge. It is a single self-contained file of about 1.8 MB that runs straight from disk, with three.js bundled in.

To change it:

git clone https://github.com/StarKnightt/golden-line.git
cd golden-line
pnpm install
pnpm dev        # live development server
pnpm build      # rebuilds index.html

GitHub Pages serves the root index.html from master, so a change ships when the rebuilt file is pushed. The build fails if the page references an external script or stylesheet.

The window seat: velvet armchairs, a laid table and the fields going by

Controls

Key or action What it does
C Driver's cab. Press again to go back to the drone view. A small hint on screen says which
D Director mode: cuts between the cameras every few seconds, with no interface
1 to 5 Drone chase, trackside, viaduct, window seat, tunnel exit. Press again to recompose the shot
Drag, or click to capture the mouse Look around (manual mode)
W / S Faster / slower, from a standstill to 130 km/h. It cruises at 65
H or the camera button Photo mode, which hides the interface. Click, tap, H or Esc brings it back
M or the speaker button Sound on and off
? Show the keys again

Manual mode shows the time and weather, the next station and its distance, and the speed. The weather text describes the sky on screen; there is no weather simulation behind it. On a touch screen you can drag to look and use the two buttons, but changing camera or speed needs a keyboard.

URL option Effect
director=1 Starts in director mode
hud=0 No interface
cam=hero Starts on a composed shot: hero, drone, trackside, bridge, interior, tunnel, sunset, dusk, dusk-interior, cab or dusk-cab
time=0..1 Time of day to start at: 0 is golden hour, 1 is blue hour (default 0.1)
dayspeed=2 Makes the day pass faster

The five cameras

The brief called this the most important part.

Key Camera What it does
1 Drone chase Drifts around the engine's front quarter, and climbs until ground and trees no longer hide the train
2 Trackside Sets up low beside the rails near a telegraph pole, widens as the engine arrives and shakes as it passes
3 Viaduct Scouts 36 viewpoints across the valley for one that sees the span, with the train against sky and haze
4 Window seat Two compositions inside the furnished saloon, with the country sliding past
5 Tunnel exit Keyed to distance past the portal, so it holds at any speed. The exposure opens in the dark and closes in the sun

C adds the driver's view. The cab's front windows are two small ports, so the camera does what drivers did and leans out of the left side, looking along the boiler to the line ahead. It sways with the engine and bumps at each rail joint. Director mode does not use it.

Director mode works like a film editor. It picks the next shot early, streams in that stretch of line if it is somewhere else, and cuts once it is ready (or after seven seconds at most). When a viaduct or a tunnel exit is about to come up on its own, it times the cut to that instead.

The viaduct, the train small above a misty valley

What is in it

  • About 23,000 lines of JavaScript across 107 files in src/, blank and comment lines aside.
  • An endless line in seven kinds of country: fields, lake, pine forest, tunnel, viaduct, river and station town. The opening stretch is hand-ordered. After that the order is shuffled from a seed, and every tunnel opens onto a viaduct or a lake.
  • The train: a 4-6-0 express engine in green with working side rods, a six-wheeled tender and five crimson coaches. One coach has a fully furnished saloon. Distant windows on the others are ray-traced into an imaginary one.
  • The railway: ballast, sleepers and rails, the stone viaduct, arched stone and plate-girder river bridges, brick-lined tunnels with cut-stone portals, telegraph wires, fences and farms.
  • Station towns with generated names, each with a platform, station house, signal box, water tower, semaphores, level crossing, gas lamps, houses and a church.
  • Living things: rooks, geese and woodpigeons in the middle distance, and dust in the sunbeams of the coach.

How it works

One line that keeps going

The world is a seeded sequence of set pieces. Web workers build the ground in 200 m chunks, which stream in 2.5 km ahead of the train and 1.1 km behind it. The workers are classic inline ones, so the single file still works from disk. A floating origin jumps forward in 1,024 m steps, and every world-space texture tile divides that distance, so nothing visibly moves when it does.

Grass and trees on the GPU

Each frame a compute pass walks three rings of about 90,000 world-fixed candidate cells, reads what grows under each one and appends the survivors to indirect draw lists. Placement depends only on the cell, so nothing swims, and a camera cut is correct on its first frame. Trees live in one storage buffer and are culled the same way into detailed, merged and impostor levels, with separate caster lists for each shadow cascade. The impostors are the near trees photographed from eight headings at load.

Steam

Puffs are born in world space at the chimney, cylinder cocks and safety valves, so they hang in the air behind the train. Their motion is closed-form in age, which lets a camera cut rebuild 7.2 seconds of history in one step. All of them are one instanced draw. Their atlas is ray-marched on the GPU at load and lit from six directions. Two low-resolution maps of the whole plume, one from the camera and one toward the sun, let it shade as one body and throw its shadow on the land.

Out of the tunnel into the sun

Light, air and water

One sun drives four shadow cascades out to 650 m, with the long shadows of distant hills baked beyond them. The sky, the distance haze, the environment light and the water's sky reflection all call the same atmosphere functions, so far land fades into exactly the colour behind it. The far ridgelines are painted into the sky itself. The frame gets ACES tone mapping, bloom and 4x MSAA. Lakes and rivers share one material. A single half-resolution planar mirror goes to whichever body fills most of the view, and the others reflect the analytic sky.

Time of day

Golden hour, sunset, dusk and blue hour are one keyed track, so sun, sky, haze and lamps always agree. From the default start it takes about seven and a half minutes to reach full dark. After the night has held for a while, the clock rolls back to gold while the camera is inside a tunnel, and the train comes out into a new evening.

Sunset in the fields

Sound without samples

Every sample and echo is computed at load, in a worker, and played through Web Audio. The engine beats four times per turn of its driving wheels. A rail clack is scheduled as each axle crosses a joint. The chime whistle sounds before tunnels, out over viaducts, approaching stations and now and then in open country. Around that are wind, rolling noise, the creak of the carriage, birds that change with the hour and crickets as the light goes.

Performance

Director mode for 150 seconds in headless Chromium at 1920×1080 on an RTX 4060, measured on 29 November 2026 with pnpm perf --seconds 150. These are times between frames, in milliseconds, and headless runs are not locked to a display's refresh rate.

Shot Frames Median 95th 99th Worst Over 20 ms
Drone chase 5,484 7.6 9.6 10.3 16.7 0
Trackside 5,201 6.2 8.2 13.2 19.6 0
Viaduct 3,906 6.9 8.5 10.2 39.2 3
Window seat 4,937 6.0 8.1 13.3 21.2 1
Tunnel exit 2,457 7.0 8.6 10.2 48.8 3
All 21,985 6.8 9.0 11.9 48.8 7

The 99th percentile is inside the 16.7 ms that 60 fps allows. Three frames took longer than 34 ms, and none of the twelve worst fell on a camera cut. GPU time was 4.9 ms at the median and 7.0 ms at the 95th percentile. The run peaked at 400 draw calls and 5.5 million triangles, with 18 cuts. It started at golden hour and reached early sunset, so dusk is not covered by these numbers.

There are no quality tiers. The one automatic adjustment is that high-DPI screens are trimmed toward 2560×1440 worth of pixels, never below 1x scale.

Dusk, with the headlamp lit

What is not good enough yet

An independent critic compared every camera with real photographs in two rounds. The second round found six major problems: three in the tunnel shot (staging, a cartoon-like cab, broken-looking masonry), two in the opening and drone views (thin crop, a flat model-railway look), and a train whose shadow could not be seen. A last round of fixes addressed all six. No critic round ran after it, at the owner's request, so none of those fixes is independently confirmed.

Known differences from the photographs:

  • Steam is softer and less torn. At the tunnel exit, some of it hangs under the arch as a separate cloud.
  • The tunnel exit is a bright golden burst rather than a white-out, with no sun disc in frame.
  • The train's shadow has a readable edge, but not the outline of a locomotive. The opening has two or three long shadow stripes across the wheat.
  • From the drone, the ballast looks smooth and the stubble rows regular.
  • Up close in the cab, the crew look like mannequins.
  • Dusk coach windows are small and dim from a distance, and the trackside sky is bluer than in the references.
  • Thin bright lines on wheels and trim may shimmer in the live ride. The film is supersampled, which reduces this.

It was built and measured in Chromium on Windows. There is no mobile version.

The film

pnpm video renders sonnet-next-train.mp4, a 60-second film, frame by frame from the ride itself, with no screen recording. Each picture is drawn at 3840×2160 and scaled to 1920×1080, while the ride and its shaders advance exactly 1/60 s. It is encoded at 60 fps with NVENC. The soundtrack is rendered offline from the same frames by the live sound engine, then levelled to about -14 LUFS.

The same run writes each shot to segments/ as its own clip and a 4K still of each to stills/. The video files and stills are not in the repository. segments/cut-list.txt has the cut times and shows how to leave shots out without re-encoding. The shot list is in tools/film.json.

Tools

The capture and test tools drive the real build in headless Chromium and refuse to run on anything but an NVIDIA GPU. They were written for Windows. Install their browser once with pnpm exec playwright install chromium.

Command What it does
pnpm check Screenshots from fixed cameras, measured and set beside reference photos, in .world-check/. The photos are not in the repository
pnpm perf --seconds 150 Director-mode frame timing, per shot
pnpm video Renders the film. Needs ffmpeg with NVENC on the PATH
node tools/shot.mjs Quick screenshots; exits with an error on any console error or WebGPU warning

Layout

index.html      the built ride, one self-contained file
src/
  main.js       boot, frame loop, URL options
  world/        the endless line: layout, terrain, track, towns, streaming workers
  render/       renderer and bloom, atmosphere, sun and shadows, time of day, floating origin
  train/        engine, tender, coaches, saloon, cab
  structures/   track, viaduct, bridges, tunnels, station towns, lineside
  vegetation/   GPU grass and wheat, trees and impostors, reeds
  water/        lakes, rivers, the planar mirror
  effects/      steam, birds, dust motes
  camera/       the five cameras, the driver's cab and the director
  audio/        the synthesised soundtrack
  ui/           controls and HUD
  capture/      frame-by-frame film capture
  core/         math, noise, seeded random numbers
tools/          capture, check, timing and film scripts
media/          the pictures on this page

Zero assets

There is no TextureLoader, GLTFLoader, RGBELoader, AudioLoader, fetch, XMLHttpRequest, new Image or createImageBitmap anywhere in src/. The pictures in media/ are output of the ride, not input to it.

How it was built

Claude Sonnet Next built it in Claude Code from the brief in PROMPT.md, using the world-taste skill for art direction. The world is an old passenger train on a single line, under clear skies with high thin cloud and haze in the valleys. The direction was "golden-hour rail", with the dials at realism 9, density 8 and life 7.

The brief asked for a critic loop against real photographs, for up to five rounds. It was stopped after two, at the owner's request, with the results listed above.

Credits

Built with three.js (MIT), Vite and Playwright.

The reference photos were used only as local visual targets while building. They are not part of the ride, and refs/ is not committed or shipped. All are from Wikimedia Commons (licence texts: https://creativecommons.org/licenses/):

Reference Author Licence
Jacobite on Glenfinnan Viaduct 4 Daniel Kraft CC BY-SA 3.0
Steam sunset at Peterborough, Nene Valley Roger Carvell CC BY 3.0
Jacobite on Glenfinnan Viaduct 1 Daniel Kraft CC BY-SA 3.0
Vintage carriage, 3rd class James Petts CC BY-SA 2.0
Tunnel Merten 020 Olbertz CC BY-SA 3.0
Sunset over Glenfinnan Viaduct Tjdenholm CC BY 4.0
Harvest Season Christoph Wurst CC BY-SA 3.0
Baureihe 35.1097 wieczór "120Hz USB type C HDMI cable cord" CC0
60163 Tornado, 22 May 2010 Paul Downey CC BY 2.0
A passenger train crossing Ribblehead Viaduct John Lucas CC BY-SA 2.0

Licence

MIT. See LICENSE.

Built by Prasenjit Nayak (@prasenx).

Explore related projects

Loading…