A notebook-paper glider that stalls, porpoises and circles in thermals for real.
The glider is flown by the textbook equations for airspeed, flight path angle, heading, angle of attack and pitch rate. Lift follows a straight lift slope that blends into flat-plate lift past about 14 degrees, so pulling too hard stalls the wing and the nose drops, while the slow phugoid porpoise falls out of trading height for speed. Thermals rise from sunlit fields as Gaussian updraft columns topped with cumulus, and the autopilot holds its speed, notices lift on the variometer, banks into a circle and centres it by turning less while flying toward stronger lift, then leaves at cloud base for the next one. The countryside is a perspective diorama of field bands receding to the horizon, the plane is a lit 3D mesh, and the trail shows each climb as a rising helix.
Try it. Drag up or down to pitch and sideways to bank, or use the arrow keys or WASD. Pull up too far and the wing stalls; circle in the shimmering columns to climb and see how far you can get. Let go and the autopilot takes over again. R relaunches.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build a side-view glider flight simulator with real aerodynamics, using JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple:
- Model the glider as a point mass in the vertical plane with airspeed V, flight path angle gamma, angle of attack alpha and pitch rate q. Use a mass of 1 kg, wing area 0.26 m^2, chord 0.3 m and air density 1.225.
- Lift coefficient: CL = 0.2 + 5 alpha while attached, blended with a sigmoid around alpha = 0.245 rad (about 14 degrees) into a flat-plate CL = 1.05 sin(2 alpha). Drag: CD = 0.028 + 0.042 CL^2, plus a big separated-flow term past the stall.
- Each step: L and D = 0.5 rho V^2 S C. V' = -D/m - g sin(gamma), gamma' = (L - m g cos(gamma)) / (m V). For pitch, a moment coefficient Cm = 0.08 + elevator - 0.8 alpha - 9 q c / (2V) drives q' = 0.5 rho V^2 S c Cm / I with I = 0.08, and alpha' = q - gamma'. Integrate with four small substeps per frame.
- Draw a pastel sky, a rolling ground line, and the glider as a little triangle rotated by gamma + alpha, with a fading trail.
- Let the mouse's vertical position set the elevator. Pull up too far and it should stall and drop its nose; trim it and it should porpoise gently (the phugoid).
Once it flies, make it beautiful and add soaring:
- Add thermals: columns where the air rises with a Gaussian profile, drawn as shimmering translucent columns with a cumulus cloud on top. Add their updraft to the glider's climb.
- Add a heading and a bank angle so the glider can circle, and an autopilot that circles when its variometer reads lift.
- Show a HUD with height, airspeed, climb rate and distance flown.
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as a perspective 3D paper plane, smarter thermal centring, or a procedurally generated cross-country landscape.