Inspirations

Steam Locomotive in Motion

An apple-green Pacific express steams through a green valley with its Walschaerts valve gear solved live, every rod moving as on the real engine. Exhaust beats follow the wheels; cinematic trackside, close-up and aerial shots; one tap names each part.

Made in Claude Code (Claude subscription) with claude-opus-5.5. The agent wrote code, looked at the preview and fixed it over several iterations. This is not a single-shot result: comparisons on this site show models in one attempt.

Starting prompt

Build "Steam Locomotive in Motion": a cinematic, looping 3D film of a classic express steam locomotive running through a green valley, with its Walschaerts valve gear solved live so that every rod moves exactly as on the real engine. It should look like a railway documentary from the first frame, never like a toy. Single self-contained HTML file; Three.js and its addons from a CDN via an import map are fine; build everything procedurally (canvas textures are fine), no external models, images or sounds.

The train (metres, rail top at y = 0):
- A 4-6-2 Pacific with the proportions of an LNER A3: a tapered boiler on a black smokebox with a domed door, a dart and a number plate; a short chimney with a lip; a long low "banjo" dome; a round-top firebox with brass safety valves and a whistle; a cab with side windows, a cut-out opening and a black roof; handrails along the boiler; a red buffer beam with buffers, a coupling and two white lamps.
- Polished apple-green paint with black-and-white lining on the boiler bands, cab sides, splashers, cylinders and valance; gold shaded numbers on the cab; a curved brass nameplate on the middle splasher; brass fittings and oily steel rods.
- Three pairs of 2.03 m (6 ft 8 in) spoked driving wheels with crescent balance weights, crank bosses and black tyres; a four-wheel bogie, a trailing truck, frames and brake blocks; outside cylinders with piston-valve chests.
- An eight-wheeled lined tender heaped with coal, and four varnished teak coaches with panelled sides, windows, doors and white roofs.

The valve gear, solved every frame:
- Stroke 0.66 m (crank radius 0.33 m), connecting rod 3.2 m, the line of stroke through the driving axle. The crosshead slides between slide bars.
- Coupling rods stay parallel as all three wheels turn together; the right-hand crank leads the left by a quarter turn.
- A return crank on the driving crankpin, 90 degrees from it, drives the eccentric rod. The expansion link pivots on its trunnion, and its foot is found as the intersection of two circles. The die block slides in the curved slot at the reverser setting, carrying the radius rod.
- The combination lever is solved with a small Newton iteration, so that both the radius-rod length and the union-link length to the crosshead drop arm hold exactly; this sets the valve spindle. The lifting link and weighshaft arm follow the reverser.
- Wheels roll without slipping (wheel angle = distance / radius). The reverser starts in full gear and notches up with speed. The cut-off shown on screen is read from the solved gear (when the valve closes the port again), not invented.

Steam and smoke:
- Four exhaust beats per turn of the driving wheels, timed from the crank angle: tall, separate chuffs when starting, a plume lying back over the train at speed. Soft, lit particles slowed by air drag, with a light breeze.
- When steam is shut off, only a thin drifting wisp. At a stand the safety valves feather. Before starting, the whistle blows. Cylinder drain cocks blow white jets sideways from both ends of each cylinder, in time with the strokes, for the first seconds of the start.

The run, which loops:
- The line curves gently along a valley floor between rolling hills, with a river, patchwork fields and hedgerows, woods, grass, ballast and sleepers, telegraph poles with sagging wires, and fences.
- The train runs at about 70 mph, shuts off steam and brakes to a stand at an upper-quadrant semaphore at danger, and stands with its safety valves lifting. Then, after a cut, it starts again from rest in full gear with the cylinder cocks open, accelerates and notches up.

Camera: an automatic cinematic sequence with hard cuts:
- head-on three-quarter;
- low lineside with a long lens as the train approaches, then holding on the coaches as they pass;
- pacing alongside;
- a low close-up of the valve gear, in slow motion at speed;
- an aerial orbit over the valley;
- a view along the boiler from beside the cab;
- a fixed shot at the signal for the stop.
Drag to orbit (following the train), scroll or pinch to zoom; the camera glides back to the sequence a few seconds after the last input. On a portrait phone, step the cameras back.

Interface: a small, elegant caption with the title, the speed in mph, the current shot and a line for the phase and cut-off. Two small buttons: "Next shot" and "Highlight valve gear". Highlighting moves to the close-up and slows time. It colours each part of the motion and names it with a label and leader line that tracks it: cylinder, valve chest, valve spindle, crosshead, connecting rod, coupling rod, return crank, eccentric rod, expansion link, radius rod, combination lever, union link and lifting link. Everything starts automatically and is visibly moving from the first frame. The layout works on a phone.

Rendering: a sky with soft clouds and a warm afternoon sun, soft shadows that follow the train, distance haze, physically based materials with an environment map, and ACES tone mapping. Use subtle bloom only on the sun and the firebox glow. Cap the pixel ratio at 2 and keep it smooth on a laptop.

Engineering rules (the page must work on the first load, with no fixes):
- Use Three.js r170 and only methods that exist on each of its classes. Give every custom ShaderMaterial `fog: false`, and declare every uniform, constant and varying its shaders use.
- Declare each identifier once. Inside one calculation, never reuse a shared scratch vector for two values that are both still needed; use local vectors.
- Guard every animated value against NaN.
- The page runs in a sandboxed iframe without same-origin access: no localStorage, cookies, alerts or network requests besides the CDN.
- Answer with the complete file exactly once, in a single ```html code block: no drafts, partial snippets or notes.

Keep planning brief and write the code. Aim for roughly 1,000 to 1,500 lines, compact and well structured. No black, untextured or placeholder objects anywhere.