Mechanics of the examples
Generated by node tools/docs/mechanics.mjs from examples/*/src; do not edit by hand. A mechanism that a scene needs is looked up here (and in the library) before it is written again.
28 examples, 316 source files, 41818 lines.
Files of one name in several examples (copies)#
Lines are the file's size; "shares" is the percent of lines a copy has in common with the first (largest) one of the group.
| File | Examples (lines, shares with the first) | What it is |
|---|---|---|
airwar | dunkirk (684); dunkirk-war (684, 100%) | The war overhead (PLAN-DUNKIRK E2) on the flight core of the airwar sample (@ferret/physics-vehicles: Aeroplane, Autopilot, Gun, Ballistics, Damageable, FlakBattery). Pure simulation, no Babylon. Raids come in from the land (south-east): Ju 87 B-2 dive-bomber trails, He 111 H and Do 17 Z formations with Bf 109 escorts, and Bf 109 pairs that strafe the mole and the beach. Hurricanes and Spitfires patrol over the sea and meet them. British guns fire from the ground and from the ship. Bombs fall with drag and burst. The aircraft are the real flight model with the spec of spec/spec.json (sourced / estimated marks there). The AI is the airwar sample's, adapted (formation bombers with a bombardier, gunner stations, pursuit with lead and a break after the pass); the dive-bomber controller is new (roll in, dive, release, pull out, leave); the strafing run is new. AI numbers (ranges, cones, timings, raid sizes and rhythm) are game values, estimated. The weather scales the raids: heavy in the calm overcast, a trickle in the storm. Frame: the flight core is NED (north, east, down). The scene here is x east along the beach, y up, z north out to sea: north = +z, east = +x, down = -y. toNED/toScene convert. Nobody loses anything to a bomb in the game itself (it has no fail state): the events say where a bomb fell and the game decides what the men and the ship do. |
sim | airwar/game (629); dunkirk-war (201, 2%); dunkirk (177, 2%) | The raid (PLAN-AIRWAR stages 4 and 6): the pure simulation, no Babylon. Twelve B-17G in a box fly a route to the port, gunners fire at fighters, waves of Bf 109 G-6 attack the bombers or the escort, 88 mm flak shoots over the port, bombs fall and hurt the port's buildings, tanks, ships and cranes; three P-51D escort (the first is the player's, or a bot's when no human flies). One step(dt) advances everything; the renderer reads crafts, bombs, bal.rounds and drains events. Numbers marked "estimated" are mine and to be tuned in stage 7 (the specification does not have them). |
sea | pirate-fort (247); dunkirk (235, 86%); dunkirk-war (231, 82%); titanic-field (187, 33%); airwar/world (53, 3%) | The sea of the pirate-fort sample, taken from the Dunkirk demo's sea (PLAN-DUNKIRK D2): one shader surface, a polar grid that follows the camera (fine under it, coarse far away). The vertex shader sums the Gerstner waves of the weather rung with the shoaling of shore.ts (each amplitude follows the depth under it: Green's law, then held by the depth), adds the swell the mole's faces send back, and the fragment shader shades it: Fresnel against the overcast sky, the sun's glitter, murky Channel colour that goes pale in the shallows, foam where the sum of the waves breaks (the Jacobian of the sideways move, the surf zone by the wave height over the depth), the swash band at the waterline (the water is cut where its surface falls below the sand, so the run-up and the backwash come out of the waves themselves), the foam of the ship's wash from a small texture. sea-model.ts computes the same sums on the CPU, so the ship floats on what is drawn. |
soundscape | dunkirk (463); dunkirk-war (463, 100%) | The sound of the beach, made by the engine's sound module (@ferret/media): nothing is a recording. Every sound is a synth recipe (plain data: noise and oscillators through filters and envelopes) that the AudioService plays on its buses, in the world: the listener is the camera, the loudness falls with the distance (and the air takes the highs of a far sound), and a bang that is far arrives late (the speed of sound). Nothing holds still: every loop is driven by a physics value that moves and by a seeded walk of its own. What is heard: - the sea: its body by the sea state and the wave under the listener; the surf, a break each time a crest of the sea model reaches the shallows near the camera; the slap of the water on the mole's faces and on the hulls when it rises fast against them; the rain; - the crowd: a murmur without voices (bands of noise at the speech formants, each with its own walk) from where the men are thickest, smoother the more men there are, louder and brighter when a bomb falls among them; - the vessels' machinery from their physics: the destroyer's turbines, gearing, screws, boilers and fans by her shaft speed; the paddle steamer's floats and her two-cylinder engine by her wheel's turns; the small craft's petrol/paraffin motors by their speed (the constants in MACHINERY); - the aeroplanes: the player's own engine while he flies (inside the cockpit: through the airframe, with the airflow and the buffet near the stall), the others as far as their real distance lets them be heard, by the shaft speed and the power of the flight model; - the guns (machine guns by the rounds that leave the magazines, the flak's bursts), bombs, crashes and the Stukas' sirens. M mutes. |
vat-crowd | dunkirk (442); dunkirk-war (252, 88%) | The soldiers near the camera drawn on the GPU (the Dunkirk demo's answer to "many full figures"): every figure of the library (full triangle count, full textures: nothing is simplified) is drawn by @ferret/crowd's vertex-animation set, i.e. one thin-instanced draw per mesh of a figure for all the men in that figure, skinned in the vertex shader from a texture of baked bone matrices. NearCrowd (near.ts, ?cpu=1) does the same men with one CPU skeleton and one animation group set per figure; this does not. What a VAT can show is one frame of one baked clip per instance, so everything NearCrowd does by blending groups and by turning bones every frame is baked ahead: - the standing and talking clips, and the sitting and crouching ones, are baked with the micro-motion layer already in them (breath, gaze, the arm gestures of the module's own behaviour, recorded from stepPerson; the hands at rest with their curled fingers): a few variants per clip, each man plays one of them at his own phase; - a change of posture (stand -> crouch -> sit -> lie, poseKeys) is a baked blend clip per neighbouring pair of the chain; the man's frame in it is the weight poseKeys gives; - standing -> walking and walking -> standing are short baked blends (stopping from one of four phases of the stride), the lying man's stir is a baked swing. What cannot survive: a micro-motion that answers the world now (a flinch at a blast, a glance at what just happened) and the gaze/breath on a walking or lying man: the gestures a man makes are the recorded ones, not the live ones. The posture the sim gives (ducking, lying down under fire) is live, as are the walk and its pace. The bake is made once per skeleton (the 87-joint Customizer skeleton: every figure shares one bone-matrix texture when its inverse bind poses are the same) and kept in the persistent cache. A new figure needs nothing but its id in the list. |
flight | dunkirk-war (335); dunkirk (333, 98%) | The flight mode (ported from the airwar sample): C takes the observer's place in a Spitfire I over the same war, with the task of covering the evacuation; the stick is the arrows, the rudder A and D, the throttle W and S, Space fires, T locks a raider, G and F the gear and flaps, V the view (cockpit, chase, outside), * hands the Spitfire to the patrol AI and takes it back (the stick takes over). The aeroplane is the war's own (Air.spawnPlayer: the flight model, the guns and the damage of every aircraft there), so the raiders shoot at it and it shoots at them; this file is the keys, the camera and the messages. No fail state: a lost Spitfire puts the observer back and C scrambles another. |
crowd-sim | dunkirk (328); dunkirk-war (328, 100%) | The soldiers on the beach (PLAN-DUNKIRK D4): a crowd simulation with a small state set per man (wait, queue, walk, wade, board, aboard). Pure: positions, states and counts, no Babylon. The men stand in groups on the beach and the dunes and in the shallows; when the ship is made fast at the berth the nearest are called into a queue of three abreast that climbs the ramp and goes up the mole to the gangway; when the gangway is down the head of the queue walks over it and is counted aboard. A man steers by a few rules: head for the next point of his route, keep a body's width from the others (a spatial hash), stand on what walkHeight says, wade where the water is deep enough to show it. Only the men inside range of the viewer are simulated every step; the far ones are held (the visibility limit pays for the crowd). |
near | dunkirk-war (305); dunkirk (288, 96%) | The near view of the soldiers (PLAN-DUNKIRK D4): the library's own British figures (examples/dynamo-troops: Tommies in battledress, greatcoats and caps, and officers, all on the Customizer's 87-bone skeleton) take the place of the cheap instanced men for the few dozen nearest to the camera. A pool of figures is built once; each frame the nearest men that fit in it are given a figure, which stands or walks with the library's own clips (Idle, Walk_Fwd of cc-clips), at the pace the crowd simulation gives the man. A figure stays with its man while he stays near; the men the pool does not reach, and the whole crowd at a distance, are drawn by FarCrowd (baked pictures of the figures, dots beyond). |
land | forest-squirrel (179); pirate-fort (133, 0%); weather (124, 0%); dunkirk (70, 0%); dunkirk-war (70, 0%) | The shape of the land round the Forest level: the river led on, the description of the relief, the species; no Babylon in here, so the page and the terrain workers (terrain-worker.ts) build the same ground from the same few numbers. |
air-view | dunkirk (279); dunkirk-war (279, 100%) | The war overhead on screen: the library's aircraft (one model per craft, posed from the flight model), propellers turning, smoke trails of hurt aircraft, tracers, bombs in the air, bursts of bombs on sand and sea, flak puffs, crashes. Effects are air-fx.ts (pools of billboards). Model frame of the flight model: nose +X, up +Y, left wing +Z; the scene: x east, y up, z north. The library's aircraft now load with the nose on -X (propellers at -X, fins at +X, as the destroyer's bow): each is turned half round about its up axis to fly nose first. |
decks | dunkirk-war (288); dunkirk (220, 91%) | The people on the decks (PLAN-DUNKIRK D4): the men taken off are seen aboard (packed on the destroyer's decks, in the lifeboat, the yacht's cockpit and the steamer's decks), and every craft has her crew of sailors (a naval officer on the bigger ones) who move about her deck. Where a man can stand is read off the model itself: rays down onto it on a grid, the hits on the main deck band are the places (the tops of the funnels, the guns and the deckhouses are not). The places are in the craft's own frame, so the people go with her as she rolls and steams. The men are drawn as the crowd is (the nearest by the library's figures, the rest by the instanced crowd): this makes them Soldiers with figure set, standing still with the posture AI, the sailors also walking from place to place. |
gun-crews | dunkirk (228); dunkirk-war (228, 99%) | The gun crews: the men at the anti-aircraft guns of the war overhead, the ground batteries and the guards of the mole (the Royal Artillery in battledress and helmet) and the ship's own guns (her sailors). The roles and what each does by what the gun does are gun-crew-logic.ts (pure); this puts the men into the world the way decks.ts does: each is a Soldier with a figure set, standing in the physics (Walkers: the ground, or the ship's deck carried with her), so the near and middle figures, the baked pictures and the dots draw them like any man. The game gives them to the crowd's drawing with the deck people (people). Heights are never set here: a man is put on the ground the physics gives at his station (Walkers.groundAt, or the deck's own place read off the ship's model) and each step he is moved by the physics toward where his work puts him; a man who is not on his feet on the ground (carried off by a swell, the ground gone) is put back at his station. |
flight-hud | dunkirk-war (228); dunkirk (224, 99%) | The Spitfire's displays (the flight mode, flight.ts): a flight panel, the instruments (airspeed, horizon, altimeter, climb, heading), the gunsight with a lead marker on a locked raider, markers on the aircraft in sight and on the destroyer, a plan radar, the radio messages and the mission line. The same displays as the airwar sample's, drawn on a 2-D canvas over the 3-D view; the mission is the evacuation's (the destroyer, the mole, the men) instead of the raid's. |
view-sim | dunkirk (168); dunkirk-war (168, 98%); airwar/game (99, 33%) | The drawing's view of the simulation (PLAN-WORKERS W5): an object shaped like Sim for the view modules (sim.ship.vessel.pos, sim.fleet.boats, sim.air.crafts, sim.crowd.soldiers ...), built from the SimHost's replica. Nothing here is the simulation's own object: the numbers are the last two snapshots interpolated, the rest is what the drawing needs to ask for (commands go to the simulation, which applies them at its next step). The same code serves a worker and the page's own thread. |
forest | airwar/world (203); zeppelin/world (202, 94%) | The forest (copied from examples/zeppelin/src/world/forest.ts for PLAN-AIRWAR stage 3): thin instances of the library's spruce near the camera, a conifer and a broadleaf tree made in code farther out (the library has one spruce and no broadleaf), placed by a hash per cell from the same ground function and forest rules as the terrain colour. No tree ever pops: every tree has a draw distance of its own from its random rank u (the share of trees still drawn at distance d is (900 / d)^2, as the old density rings gave), kept in the alpha of its instance colour, and the shader dissolves it (a dither) over the last fifth of that distance. The near spruce and the far cone of the same tree cross-dissolve at 340 to 420 m. The instance buffers are cut again every 25 m of travel, with a margin. |
hud | airwar/game (196); falcon (101, 1%); showcase/gearbox (100, 0%) | The cockpit's instruments and the battle's displays (PLAN-AIRWAR stages 5 and 6): a flight panel, the gunsight with a lead marker on a locked target, markers on aircraft in sight, a plan radar with the formation and the bandits, the radio messages, and the screens (briefing, pause, result). Drawn on a 2-D canvas over the 3-D view and a few DOM boxes. |
gun-crew-logic | dunkirk (198); dunkirk-war (198, 100%) | The crew of a twin 40 mm anti-aircraft mount, pure (no Babylon): who stands where round the mount and what each man does by what the gun does. gun-crews.ts puts the men into the world (the physics gives their heights) and draws them as the crowd is drawn. The crew of one twin mount, six men (the British Army's single Bofors had a detachment of six; for a twin mount the plausible minimum is the same six, for the numbers are not given in the sources the game has, the roles are): - the layer (elevation) and the trainer (traverse), one each side of the mount, carried round with it as it turns, never leaving it; - two loaders, one to a barrel, behind the breeches, carried round with the mount: they bend to the ready ammunition and rise to feed the four-round clip, one such cycle for each clip a barrel is owed (four rounds fired); - the ammunition number, who stays by the ready rack and, while the guns fire, carries a clip from the rack to a loader and walks back (the loaders in turn); - the gun captain, on the ground beside the mount, who faces the target (the aeroplane) while the guns are engaged and the gun's forward while they are not. A man of them takes cover when a bomb or a strafing run is near (the posture AI's cover: down to a crouch or flat) and gets up slowly after it, whatever he was doing. |
sound | airwar/game (135); pirate-fort/duel (125, 6%); forest-squirrel (81, 20%); showcase (45, 0%) | The raid's sound, made by the engine's sound module (@ferret/media; nothing is a recording, as examples/dunkirk-war/src/soundscape.ts): every sound is a synth recipe the AudioService plays in the world: the listener is the camera, the loudness falls with the distance (the air takes the highs of a far sound) and a far bang arrives late (the speed of sound). Heard: the engines of the aeroplanes (the player's own, inside the cockpit through the airframe with the airflow and the buffet at the stall; the others as far as their real distance lets them be heard, by the shaft speed and the power of the flight model), the guns by the rounds that leave the magazines, flak bursts, bombs, hits, crashes, the sea and the wind at low height. M mutes. |
sky | dunkirk (123); dunkirk-war (122, 98%); titanic-field (87, 31%); airwar/world (42, 0%); weather (4, 0%) | The sky of the Dunkirk demo (PLAN-DUNKIRK D3): one dome that follows the camera, a vertical gradient from the haze at the horizon to the zenith, a layer of overcast cloud (two layers of noise clouds on planes at 1.7 and 6.2 km, puffy with a lit side and a dark base, gaps open with a lower cover, drifting with the wind), the sun's glow through the overcast, and the haze below the horizon. The light and the haze come from the weather rung (weather.ts); the rest of the scene is lit by the same numbers. |
levels | pirate-fort/duel (279); showcase (96, 0%) | |
ship | dunkirk (180); dunkirk-war (180, 100%) | The destroyer of the Dunkirk demo: a Fletcher-class hull as a Vessel of @ferret/physics-vehicles (PLAN-DUNKIRK D4, D4b), with two shafts, two rudders that feel the propeller wash, the troop load as a tank of the vessel, and the hull's resistance from HullResistance (Reynolds friction, wave making, appendages, the added resistance of the sea, windage). No Babylon. Particulars: Fletcher class, waterline 112.5 m (110.0 m at the design draft; length overall 114.7), beam 12.1 m, 2,924 t (full load, without troops) at 5.2 m, 60,000 shp on two shafts (the class's 35 knots), propellers of 3.8 m. They are the published figures of the class as remembered, not measured off the model; see README for what is estimated. The hull's lines (plan, keel, sections) are an estimate fitted to the displacement. Body frame: x starboard, y up, z bow; the origin on the design waterline amidships. |
docking | dunkirk (170); dunkirk-war (170, 100%) | Docking at the mole (PLAN-DUNKIRK D4): the berth reading, the contact of the hull with the mole's fenders and with the sea bed, and the mooring lines. No Babylon: the ship is a Vessel of @ferret/physics-vehicles (body frame x starboard, y up, z bow) and every force goes in through applyForce. A touch is a soft contact, never a fail state: the fenders give (a spring that stiffens with the squeeze), the ship is pushed off and loses speed, a scrape drags along the face; a hard hit sets impact for the sound, the spray and the pause of boarding. The lines are springs that only pull when taut; they part at the limit of the weather rung (the ship surges off, the gangway lifts, the soldiers wait). |
fleet | dunkirk-war (177); dunkirk (157, 98%) | The small craft of Dunkirk (PLAN-DUNKIRK E1): lifeboats come in to the beach, a yacht and a paddle steamer lie against the mole's west face; each takes a part of the men who wait on the beach, then backs off and goes out to sea. They are not physics bodies (the player's ship is the only one): they follow a path at a speed that falls off toward the berth, bob on the sea model, and the men walk to them through the crowd (Crowd.ferry). Sizes are the library models' (lifeboat 10.82 x 3.12 m draught 0.70 m, yacht 15.84 x 3.81 m draught 1.52 m, steamer 61.2 x 7.3 m draught 1.69 m: their READMEs). Capacities per visit, speeds and the rhythm of arrivals are game values (estimated): the real Sundowner once brought 130 men and the Princess Elizabeth lifted 1,673 in all. |
math | conics (195); pirate-fort/duel (137, 0%) | The mathematics of the conic-sections scene, with no engine in it (so a unit test checks it). The double cone has its apex at the origin and its axis along y: x² + z² = k²·y², k = tan α (α = the half-angle). The cutting plane is n·p = d with the unit normal n = (sin θ, cos θ, 0) turned about the axis by the spin ψ: θ (tilt) = the angle between the plane and a plane perpendicular to the axis (0 = a circle's plane, 90° = parallel to the axis), d (dist) = the signed distance from the apex to the plane, ψ (spin) = a turn about the axis; it never changes the curve (the cone is round), only the view. Inside the plane take the axes e_u = (cos θ, −sin θ, 0) and e_w = (0, 0, 1) and the point p = d·n + u·e_u + w·e_w. Put p into the cone's equation and it becomes A·u² + B·u + w² + C = 0, A = cos²θ − k² sin²θ, B = 2 d sinθ cosθ (1 + k²), C = d² (sin²θ − k² cos²θ), so the sign of A decides the curve (A > 0 ellipse, A = 0 parabola, A < 0 hyperbola) and completing the square gives the standard form: ellipse / hyperbola: a = /d/·k / /A/, b = /d/·k / √/A/, e = sinθ·√(1 + k²) = sinθ / cos α (the same number for both), parabola: w² = 4p·x with p = /d/·k / 2. |
scenery | fight (167); forest-squirrel (159, 40%) | The land and the sky of the duel, made by the landscape and weather modules: a @ferret/terrain landscape (a flat clearing in the middle, rolling forest floor over the field, lakes, a wall of ridged mountains beyond the field's edge that nobody can enter), plants and stones scattered by its biomes, and a @ferret/weather service that owns the wind, the clouds (@ferret/clouds), the rain, the lightning, the fog and the light of the hour. Nothing is modelled by hand: the height, the water, the colours and the plants all come from the landscape. |
authored | airwar/world (206); zeppelin/world (117, 40%) | The Channel (PLAN-AIRWAR stage 3): a strip of sea 34 km wide between the English shore in the north (z < 0) and the French shore in the south, procedural and deterministic. Metres; x east, z toward France (the raid flies +z), y up, the sea at y = 0. Pure functions: the ground height (the sea bed is below 0), the coast lines, the town's site, and the colour of the ground. The terrain chunks, the town and the scatter of trees read the same groundHeight. The geography is made up: it stands for the Channel, it is not a map of a real stretch of coast. |
plan | pirate-fort/duel (80); home-interior (78, 0%); apartment (76, 0%); wabi-sabi (76, 0%) | |
dunkirk-program | dunkirk-war (147); dunkirk (146, 99%) | The war on the beach as a SimProgram (PLAN-WORKERS W5): Sim (the sea, the ship, the crowd, the fleet, the air war) behind the SimHost, in a worker or in the page. It steps at 60 Hz: the world at 20 Hz (every third step) as before, the air war at its own 30 Hz, or at 60 Hz while someone flies. The drawing sends commands (the camera's place, the stick, a new loop, a raid called) and reads snapshots; no object of this file's side is visible to it. No Babylon in here, so it runs in a Web Worker. |
mole | dunkirk (135); dunkirk-war (135, 100%) | The mole (PLAN-DUNKIRK D1): a timber walkway on piles running out from the dunes to deep water, like the East Mole at Dunkirk. 5 m wide, its deck 4.2 m over the mean sea level, a continuous face of piles with rubbing strakes and rubber fenders on each side, a ramp from the sand, bollards every 12 m, a few lamps; the piles go down to the bed (thin instances, one mesh), the rest is one merged mesh with vertex colours and one deck mesh with a plank texture. The gangway is a separate board that follows the ship. |
beach | dunkirk (131); dunkirk-war (131, 100%) | The beach of the Dunkirk demo (PLAN-DUNKIRK D1): a heightfield made from shore.ts in chunks around the camera (fine near, coarse far, a skirt on each chunk so the different resolutions never show a crack), one sand material whose layers come from the height, the tide and noise: dry sand, wet sand that darkens and glosses along the waterline, shingle at the high-water line, marram grass on the dunes, ripples in the sand. Nothing is built beyond what the visibility reaches. |
air-fx | dunkirk (130); dunkirk-war (130, 100%) | Effects for the raid (PLAN-AIRWAR stage 6): puffs of smoke and fire as two pools of billboards (one solid-particle system each, alpha and additive), flak bursts, bomb explosions, burning targets, smoke trails of hurt aeroplanes, tracers as one line system and the bombs in the air as instances of one mesh. Everything takes scene coordinates (x, y up, z); the tracers and the bombs come in NED from the simulation. |
far-crowd | dunkirk-war (122); dunkirk (118, 94%) | The soldiers beyond the figures (PLAN-DUNKIRK D4): every man the near and the middle rings have not taken is drawn as a baked picture of the library's own figure in his pose (@ferret/perspective: the figure rendered from 8 x 8 directions in each pose, made at build time by tools/perspective/bake-characters.mjs; walking has the frames of a stride), and as a dot when he is only a few pixels. Nothing in the scene is a stand-in: the same Tommy, officer or sailor, at every size. One impostor set per figure and pose (a draw call each, all the men of that kind and pose at once); the men are given pooled nodes, the sets read their matrices. Only the men in the camera's view are given nodes. The picture and the dot are chosen by the size on the screen. |
wrecks-view | dunkirk (120); dunkirk-war (120, 100%) | The abandoned lorries and guns on screen, drawn by the engine's perspective module (@ferret/perspective, PLAN-PERSPECTIVE): each wreck is an entity of the world with a Perspective ladder: the library's model (bedford-qld, qf-25pdr: one loaded copy with its parts merged, drawn as an instance per wreck, long side along +z, centred, wheels on the sand), the library's baked impostor, the module's point; the rungs are the item's measured thresholds (impostor.thresholds, tools/perspective/thresholds.mjs) and the module picks by the size on the screen and cross-fades. The burnt ones are a second copy in darkened materials, and their impostor is baked at the start from that copy with the library's bake options. Nothing shows until all is in. |
wrecks | dunkirk (117); dunkirk-war (117, 100%) | What the BEF left on the beach (PLAN-DUNKIRK D4): Bedford lorries run onto the sand and abandoned, some nose-down in a soft patch or burnt out, a line of them driven into the shallows end to end as a lorry pier (Bray-Dunes and La Panne, 1940), and 25-pounders left where they were last fired, some spiked and slewed. Pure layout and obstacles (no Babylon): the same wrecks from the same seed; the crowd walks round them (clear), the view puts a library model on each. |
controls | fight (83); apartment (37, 38%); home-interior (37, 38%); school-outside (37, 38%); wabi-sabi (37, 38%) | |
details | zeppelin (113); airwar/world (105, 0%) | Details of the zeppelin (PLAN-ZEPPELIN 14.2a): the windows of the control car, the cowl louvres, radiator, exhaust and spinner of the four engine cars, the blur disc of each propeller and the navigation lights. Generated in code and parented to the ship's body frame (x right, y up, z bow), so they move with the physics pose. Only Babylon here. |
shore | dunkirk (107); dunkirk-war (107, 100%) | The shore of the Dunkirk demo as one function of position and time (PLAN-DUNKIRK D1 and D2): the same for every peer, no Babylon. The ground mesh, the water shader, the soldiers and the ship all read it, so the water meets the sand exactly and a soldier stands on what is drawn. World: x runs along the beach (east), z out to sea (north), y up; the mean sea level is y = 0 and the mean waterline is z = 0 (meandering by a few metres). The beach is 2 km long (x -1000..1000), very flat (1:80 on the foreshore, 1:150 out to a bar and a trough, steepening to deep water), with dunes behind it. The mole is a timber walkway on piles from the dunes at x = 0 out to z = 1040: its east face is the berth. |
fx | falcon (154); airwar/game (42, 4%) | Effects: laser bolts (instances of two glowing capsules), fire and smoke (solid-particle billboards, the pool idea of the airwar demo), explosion flashes (a few pooled point lights), loose TIE wings tumbling away, missile trails and the hyperspace streaks. |
look | zeppelin (118); school-outside (35, 0%); apartment (13, 0%); home-interior (13, 0%); wabi-sabi (13, 0%); weather (4, 0%) | The look of the zeppelin demo (PLAN-ZEPPELIN 14.2): the sky and its environment, the silver cover with its seams and lettering, the sun and the shadow of the ship, and the clouds. Only Babylon here, no physics. Everything is generated: there is no texture file. |
vr | atomics (128); conics (57, 3%) | |
weather | dunkirk (81); dunkirk-war (81, 100%); airwar/world (18, 0%) | The weather ladder of the Dunkirk demo (PLAN-DUNKIRK D4): six presets from a calm overcast day to a storm, each a bundle of the wind, the sea it raises, the cloud, the rain, the visibility and the light. The sea is the difficulty: each loop of the game takes the next rung. Pure data and functions, no Babylon. The sea state follows the wind by the Pierson-Moskowitz spectrum of @ferret/waves, cut down by FETCH: the Channel is narrow, so the sea there never grows to the fully developed one the formula gives (a 22 m/s gale would make Hs 10 m). With FETCH = 0.7 the storm rung raises Hs about 5 m, the "4 to 6 m" of the plan. |
ships | airwar/world (90); falcon (88, 0%) | Allied destroyers at sea (PLAN-AIRWAR stage 3): two Fletcher-class ships (the library model fletcher, examples/fletcher) steam in column round a racetrack in the Channel off the port, 10 m/s (about 19 knots: a patrol speed, estimated), and leave a wake. The pose is a pure function of time (destroyerPose), so the battle can later read where they are (they are friendly; they will fire on the German fighters). |
wakes | dunkirk (89); dunkirk-war (89, 100%) | The tracks the vessels leave on the sea (the destroyer and every small craft): the engine's ShipWake (@ferret/levels, the picture of the long wake of the flight simulation: a white core that spreads and thins, and the two arms of the Kelvin wedge), laid along the path the vessel actually took. A simulated vessel is not a function of time, so each keeps its path here with the length travelled and the time, and ShipWake is answered by DISTANCE astern: a row of the track d metres behind the stern is the point d metres back along the path (straight back along the heading where the path is not yet that long). So the track starts at the stern, however slowly the vessel goes, and never lies under the hull. The track fades with the AGE of the water it lies on: foam decays and the turbulence spreads (the profile of wakeProfile gives the width and the first thinning; each row is also multiplied by exp(-age / T), T about a minute for the core and two for the faint arms). A ship that stops leaves a wake that dies away behind her over minutes; a long track ends in nothing. |
input | falcon (98); airwar/game (78, 2%) | The controls: the mouse (the ship turns toward the cursor, left button fires, right button a missile, the wheel is the throttle), the keyboard, a gamepad and touch (the left half of the screen is a stick, holding the right half fires, a tap there launches a missile). |
daynight | airwar (87); zeppelin (87, 100%) | Day and night (PLAN-ZEPPELIN 14.2b): one game day is 120 s of game time, the day (sunrise to sunset) twice as long as the night: phase p in 0..1, the sun is up for p < 2/3 (80 s) and the moon for the rest (40 s). The clock reads 06:00 at sunrise and 22:00 at sunset (the day takes 16 h). sunState is pure; Sky owns the sun, the moon and the stars (billboards and a star dome that follow the camera). |
autopilot | dunkirk (80); dunkirk-war (80, 100%) | The destroyer's autopilot (PLAN-DUNKIRK D4): it brings the ship down an approach line to the berth (bow to the beach), slows to a crawl and lies alongside; to leave it backs off the berth and takes the ship out to sea. It steers with the ship's own controls (the telegraph and the helm), so it is as good as the sea lets it be. It is an assist and is marked so in the HUD; the player takes the ship back with a key. Pure: it reads a state and returns the two controls. |
fleet-view | dunkirk-war (77); dunkirk (76, 98%) | The small craft on screen: one library model per craft (lifeboat, yacht, paddle steamer), posed from Fleet, with the propeller or the paddle wheels turning. Model frame as the ship's: bow +X, starboard -Z in the scene. |
war-fx | airwar/game (72); dunkirk-war (69, 51%) | The raid's effects, made by the engine's effects module (@ferret/vfx, as examples/dunkirk-war/src/war-fx.ts): bombs bursting on the land (a crater, a fountain of earth, a dark column) and in the water (a crown and a jet of spray), flak bursts, hits, a crashed aeroplane that burns where it fell, a hurt aeroplane that smokes and an aeroplane on fire that flames, both following it, and the port's targets that burn. The simulation says what happened (events); this class only draws it. Positions are scene coordinates (x east, y up, z north). |
litter-view | dunkirk (64); dunkirk-war (64, 100%) | The litter on screen: one small mesh per kind, drawn as thin instances, in the library's own materials (packing-case wood, pine planks, rusted and painted drum steel, tin, khaki cloth, helmet steel), tinted to the army's colours where they were painted. Shown only when all is in. |
litter | dunkirk (64); dunkirk-war (64, 100%) | What else the army left on the sand (PLAN-DUNKIRK D4), as it was in 1940: wooden ammunition boxes (the .303 SAA box) and packing cases, loose planks and duckboards, 40-gallon oil drums standing and on their sides, the four-gallon petrol "flimsies", kitbags and haversacks, steel helmets. Most of it round the wrecks, along the columns' tracks to the mole and at the back of the beach; a line of planks and drums at the tide mark. Pure layout (no Babylon): the same litter from the same seed. |
level | greybox (80); npc (48, 24%) | |
sim-spec | dunkirk (43); dunkirk-war (43, 100%); airwar/game (26, 33%) | What the drawing may read from the simulation (PLAN-WORKERS W5): the snapshot spec shared by the simulation's end (dunkirk-program.ts, in a worker or in the page) and the drawing's end (view-sim.ts). A field that is not here cannot be seen by a view module: Replica is made with the audit on in the tests and ?audit and reports any read of a property that is not declared. The lists below are what tests and the TypeScript checker (D:\temp\reads.mjs-style) found the view modules read. |
deck-water | dunkirk (55); dunkirk-war (55, 100%) | Green water and spray for the destroyer (PLAN-TERRAIN T12): DeckWater and Spray of @ferret/waves on the Fletcher's weather deck. The ship's body frame is x starboard, z bow; the deck grid of DeckWater is along x (bow positive) and across z, so the points and the gravity are swapped here. No Babylon. |
landscape | airwar/world (56); zeppelin/world (43, 7%) | The land of the Channel as a @ferret/terrain Landscape made from a description. The authored shape (the two coasts, the sea bed, the chalk cliffs, the plain and the hills, the plain graded to the river: authored.ts) goes in as height grids, like a scan or an Unreal export: a coarse one over the whole world, a fine strip along the English cliffs and a fine one over the port, where the basins and the apron are cut. The fine grain of the fields comes from noise operations, the channel of the river from a river operation, the sea from the sea level. The ground height, the colours (biomes), the water of the river and the chunks the camera sees all come from the landscape; everything that stands on the ground (trees, houses, the flight physics) asks groundHeight, which is the landscape's relief. |
dom | airwar (15); dunkirk (15, 100%); dunkirk-war (15, 100%); falcon (15, 100%); zeppelin (15, 100%) | |
hotspots | apartment (31); wabi-sabi (25, 80%); home-interior (19, 88%) | |
sea-model | dunkirk (32); dunkirk-war (32, 100%) | The sea's height as the ship and the crowd read it (PLAN-DUNKIRK D2): the Gerstner field of @ferret/waves with the shoaling of shore.ts (the amplitude of each wave follows the depth under it) plus the swell the mole's faces send back. The water shader (sea.ts) computes the same sums, so what is drawn is what the ship floats on. |
air-weapons | dunkirk (25); dunkirk-war (25, 100%) | The guns and the aircraft of the air war: spec/weapons.json and spec/spec.json read into the forms of @ferret/physics-vehicles (readWeapons knows only the airwar sample's three guns, so the 1940 rifle-calibre guns are read here). |
dunes | dunkirk (25); dunkirk-war (25, 100%) | The dunes' plants by the engine's terrain module (@ferret/terrain): marram grass in tufts and clumps, sea buckthorn and creeping shrubs on the dunes behind the beach, none below the reach of the spring tides. The ground the module scatters on is the landscape's (land.ts, made from the beach's own bed, the one the sea, the crowd and the craft use); the module's ScatterView places and draws the plants (a pure function of seed and cell, thin instances). |
figures | dunkirk (22); dunkirk-war (22, 33%) | The one list of the figures the soldiers are drawn with (near, middle, far pictures, decks). A new model is one more line here: its library id (without '-lod1'), its role (which men it stands for), its kit (what is on head and back: a man is never drawn with a figure of another kit), how many of it the CPU pool holds, and whether the far pictures are baked for it (one per kit family is enough: far marks the family's picture, the others are drawn as it). |
height | airwar/world (14); zeppelin/world (10, 40%) | The ground of the Channel. Everything the world is made of (authored.ts: the coast lines, the port, the river, the farm and forest amounts) is re-exported here; the ground height itself is the relief of the landscape (landscape.ts), which the terrain view draws. |
sim-worker | airwar (7); dunkirk (7, 33%); dunkirk-war (7, 33%) | The simulation's worker (tools/build.mjs bundles this next to main.js as sim-worker.js): no Babylon in here. |
By example#
airwar#
32 files, 4109 lines. Engine packages: clouds, core, game, levels, media, perspective, physics-vehicles, player, terrain, vfx, weather, xr.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
daynight.ts | 87 | DAY_SECONDS, DAY_SHARE, SunState, sunState, Sky | Day and night (PLAN-ZEPPELIN 14.2b): one game day is 120 s of game time, the day (sunrise to sunset) twice as long as the night: phase p in 0..1, the sun is up for p < 2/3 (80 s) and the moon for the rest (40 s). The clock reads 06:00 at sunrise and 22:00 at sunset (the day takes 16 h). sunState is pure; Sky owns the sun, the moon and the stars (billboards and a star dome that follow the camera). | |
dom.ts | 15 | ui, $, assets, loadContainer, BUILD | core | |
game/fx.ts | 42 | Effects | The raid's shots and bombs on screen: the tracers as one line system and the bombs in the air as instances of one mesh (the engine's effects module draws everything that bursts, burns and smokes: war-fx.ts). The tracers and the bombs come in NED from the simulation. | |
game/game.ts | 310 | Raid | core, media, perspective | The playable raid (PLAN-AIRWAR stage 6): the simulation at a fixed step, the aeroplanes drawn from it, the effects from its events, the cameras (cockpit, chase, lead bomber), the controls and the screens. Raid.frame(dt) is called once per rendered frame and returns where the camera is, so the world can follow it. |
game/hud.ts | 196 | Hud | The cockpit's instruments and the battle's displays (PLAN-AIRWAR stages 5 and 6): a flight panel, the gunsight with a lead marker on a locked target, markers on aircraft in sight, a plan radar with the formation and the bandits, the radio messages, and the screens (briefing, pause, result). Drawn on a 2-D canvas over the 3-D view and a few DOM boxes. | |
game/input.ts | 78 | Command, Input | physics-vehicles | The player's controls (PLAN-AIRWAR stage 6): keyboard (stick on the arrows, up = nose up, pedals on A and D, throttle on W and S), a gamepad, and the buttons of the game. Keys move a stick value toward full deflection and back to the middle, so a short tap is a small input. |
game/models.ts | 94 | Eye, Models, AircraftView | levels, perspective | The aeroplanes on screen (PLAN-AIRWAR stage 6): the three library models loaded once and instanced per craft, posed from the simulation each frame, with the propellers turning, the gear shown only when it is down and the parts that were shot off hidden. The loader's root is made upright (see fixRoot), so inside the holder the nose is on +X, up on +Y and the left wing on +z. |
game/program.ts | 89 | RaidProgram | core, physics-vehicles | The raid as a SimProgram (the SimHost's program, as examples/dunkirk-war/src/dunkirk-program.ts): Sim stepped at 60 Hz behind the host, in a worker or in the page. The drawing sends commands (the stick, take another aeroplane, the autopilot) and reads snapshots; no object of this file's side is visible to it. No Babylon in here. |
game/sim-spec.ts | 26 | KINDS, TEAMS, PLANE_STATUS, SIM_SPEC | core | What the drawing may read from the raid's simulation (the snapshot spec, as examples/dunkirk-war/src/sim-spec.ts): shared by the simulation's end (program.ts, in a worker or in the page) and the drawing's end (view-sim.ts). A field that is not here cannot be seen by the drawing; ?audit reports any read of one that is not declared. |
game/sim.ts | 629 | Vec3, Kind, Team, WEAPONS, toNED, toScene, portN, portE, PortTarget, Slot, Craft, SimEvent, Bomb, BOMBS_PER_B17, FORMATION, SimOptions, Summary, Sim | physics-vehicles, weather | The raid (PLAN-AIRWAR stages 4 and 6): the pure simulation, no Babylon. Twelve B-17G in a box fly a route to the port, gunners fire at fighters, waves of Bf 109 G-6 attack the bombers or the escort, 88 mm flak shoots over the port, bombs fall and hurt the port's buildings, tanks, ships and cranes; three P-51D escort (the first is the player's, or a bot's when no human flies). One step(dt) advances everything; the renderer reads crafts, bombs, bal.rounds and drains events. Numbers marked "estimated" are mine and to be tuned in stage 7 (the specification does not have them). |
game/sound.ts | 135 | RECIPES, RaidSound | media | The raid's sound, made by the engine's sound module (@ferret/media; nothing is a recording, as examples/dunkirk-war/src/soundscape.ts): every sound is a synth recipe the AudioService plays in the world: the listener is the camera, the loudness falls with the distance (the air takes the highs of a far sound) and a far bang arrives late (the speed of sound). Heard: the engines of the aeroplanes (the player's own, inside the cockpit through the airframe with the airflow and the buffet at the stall; the others as far as their real distance lets them be heard, by the shaft speed and the power of the flight model), the guns by the rounds that leave the magazines, flak bursts, bombs, hits, crashes, the sea and the wind at low height. M mutes. |
game/view-sim.ts | 99 | ViewSimOptions, ViewSim | core, physics-vehicles | The drawing's view of the raid's simulation (as examples/dunkirk-war/src/view-sim.ts): an object shaped like Sim for the view modules (sim.crafts, sim.human, sim.bal.rounds, sim.summary() ...), built from the SimHost's replica. Nothing here is the simulation's own object: the numbers are the last two snapshots interpolated, and what the drawing asks for (the stick, another aeroplane, the autopilot) is a command the simulation applies at its next step. The same code serves a worker and the page's thread. |
game/war-fx.ts | 72 | WarFx | vfx | The raid's effects, made by the engine's effects module (@ferret/vfx, as examples/dunkirk-war/src/war-fx.ts): bombs bursting on the land (a crater, a fountain of earth, a dark column) and in the water (a crown and a jet of spray), flak bursts, hits, a crashed aeroplane that burns where it fell, a hurt aeroplane that smokes and an aeroplane on fire that flames, both following it, and the port's targets that burn. The simulation says what happened (events); this class only draws it. Positions are scene coordinates (x east, y up, z north). |
game-block.ts | 5 | game | What the game is made with (ferret.json "game" of the package and the page's createGame): it reads the keys and the mouse itself; VR is on (the stage that follows the aeroplane is set by the game). | |
game.ts | 290 | liteFor, install | clouds, game, media, player, terrain, weather, xr | |
main.ts | 9 | |||
sim-worker.ts | 7 | core | The simulation's worker (tools/build.mjs bundles this next to main.js as sim-worker.js): no Babylon in here. | |
world/authored.ts | 206 | SEA, ENGLAND_Z, hash2, noise2, fbm, coastZ, englandZ, PORT, TOWN, RIVER, riverLevel, riverNear, shapeHeight, portHeight, RGB, portDist, farmAmount, forestAmount, groundColour, groundPaint | The Channel (PLAN-AIRWAR stage 3): a strip of sea 34 km wide between the English shore in the north (z < 0) and the French shore in the south, procedural and deterministic. Metres; x east, z toward France (the raid flies +z), y up, the sea at y = 0. Pure functions: the ground height (the sea bed is below 0), the coast lines, the town's site, and the colour of the ground. The terrain chunks, the town and the scatter of trees read the same groundHeight. The geography is made up: it stands for the Channel, it is not a map of a real stretch of coast. | |
world/countryside.ts | 183 | Road, Farm, farmLayout, buildRoads, buildRiver, buildFarms | The country round the port (PLAN-AIRWAR stage 3): the roads that leave the port, their bridges over the river, the river's water, and the farms on the fields. Layout is pure and deterministic (roadLines(), farmLayout()); the meshes are built from it over groundHeight. Everything is invented: it stands for a coast plain in northern France, it is not a map of one. | |
world/details.ts | 105 | Village, villageOf, allVillages, nearVillage, addVillages, addShores | Villages, and the coast's shallows and surf (PLAN-AIRWAR stage 3). Villages are a pure function of the ground (villageOf()): a house cluster in some 3 km cells of farmland, drawn as thin instances of one house mesh. The shallows and the surf are ribbons laid along the two shore lines, which are functions of x. | |
world/forest.ts | 203 | Forest | The forest (copied from examples/zeppelin/src/world/forest.ts for PLAN-AIRWAR stage 3): thin instances of the library's spruce near the camera, a conifer and a broadleaf tree made in code farther out (the library has one spruce and no broadleaf), placed by a hash per cell from the same ground function and forest rules as the terrain colour. No tree ever pops: every tree has a draw distance of its own from its random rank u (the share of trees still drawn at distance d is (900 / d)^2, as the old density rings gave), kept in the alpha of its instance colour, and the shader dissolves it (a dither) over the last fifth of that distance. The near spruce and the far cone of the same tree cross-dissolve at 340 to 420 m. The instance buffers are cut again every 25 m of travel, with a margin. | |
world/height.ts | 14 | landscape, groundHeight | The ground of the Channel. Everything the world is made of (authored.ts: the coast lines, the port, the river, the farm and forest amounts) is re-exported here; the ground height itself is the relief of the landscape (landscape.ts), which the terrain view draws. | |
world/landscape.ts | 56 | buildChannel, warmErosion | terrain | The land of the Channel as a @ferret/terrain Landscape made from a description. The authored shape (the two coasts, the sea bed, the chalk cliffs, the plain and the hills, the plain graded to the river: authored.ts) goes in as height grids, like a scan or an Unreal export: a coarse one over the whole world, a fine strip along the English cliffs and a fine one over the port, where the basins and the apron are cut. The fine grain of the fields comes from noise operations, the channel of the river from a river operation, the sea from the sea level. The ground height, the colours (biomes), the water of the river and the chunks the camera sees all come from the landscape; everything that stands on the ground (trees, houses, the flight physics) asks groundHeight, which is the landscape's relief. |
world/port-mesh.ts | 352 | Geo, PortMeshes, buildPort | The port's meshes, built from the layout (port.ts) with the textures (port-textures.ts): the deck, the quay walls down into the water, buildings with windows and roofs, cargo stacks, tanks, rails and wagons, cranes, ships, the breakwater and a lighthouse. Geometry is merged per material (a few dozen thousand vertices in all); UVs are in metres of the texture's tile, so a window is a window size whatever the building. | |
world/port-textures.ts | 283 | rng, TILE, portTextures, portGroundMap | The port's textures, all drawn here on canvases (no image files): brick and plaster facades with windows, corrugated sheds, roofs, painted steel, ship hulls and superstructure, cargo crates, quay walls, rock, tank plates, a fine grain for the ground, and the baked ground map of the deck (roads, rails, aprons, yards, building plots, the paint on them). Every texture is a tile of a stated size in metres (TILE), so the meshes can map by metres. | |
world/port.ts | 198 | Rect, Surface, BuildingKind, Building, Tank, Stack, Crane, Loco, ShipSpec, Road, Track, Wagon, Chimney, PortLayout, portLayout, onWater | The layout of the target port (PLAN-AIRWAR stage 3): pure and deterministic, no Babylon. Local frame as in height.ts: u east, v inland from the base line; the deck is at PORT.h. The same lists drive the ground texture (port-ground.ts), the meshes (port-mesh.ts) and, later, the bombing targets and damage. The port is invented: it stands for a mid-century European seaport (two basins, transit sheds, a container-less general-cargo yard of crates and drums, a tank farm, a marshalling yard, workshops and a dock town); it is not a plan of a real one. | |
world/sea.ts | 53 | SeaOptions, Sea | levels, weather | The sea of the Channel: the engine's OceanView (@ferret/levels: a polar grid that follows the camera to the horizon, Gerstner waves that shoal over the bed, foam where the crests fold and in the surf, a cube of the sky in the water) with the sea state of the weather module (seaWaves) and the depth of the landscape under it, so the surf runs along both coasts and the shallows of the bay pale. heightAt is the same sea for the physics (a ditched aeroplane, a splash). |
world/ship-paths.ts | 73 | DESTROYERS, destroyerPose, SUBMARINES, submarinePose | The destroyers' and U-boats' courses: pure functions of time, no Babylon (the raid's simulation in its worker reads them, and the drawing). | |
world/ships.ts | 90 | Destroyers, addDestroyers, Submarines, addSubmarines | levels | Allied destroyers at sea (PLAN-AIRWAR stage 3): two Fletcher-class ships (the library model fletcher, examples/fletcher) steam in column round a racetrack in the Channel off the port, 10 m/s (about 19 knots: a patrol speed, estimated), and leave a wake. The pose is a pure function of time (destroyerPose), so the battle can later read where they are (they are friendly; they will fire on the German fighters). |
world/sky.ts | 42 | Vec3, skyColor, skyCube | Sky colour, sky cube and sky dome: copied from examples/zeppelin/src/look.ts (to be moved into a shared module when a third demo needs them). | |
world/trunks.ts | 50 | Curve, sampleCurve, Trunk, trunks, nearestTrunk | The trunk roads out of the port (pure, deterministic): control points 150 m apart with a slow wander, and the Catmull-Rom curve through them sampled every 20 m. Villages snap onto the nearest trunk (details.ts) and the roads' meshes follow the same curves (countryside.ts). | |
world/weather.ts | 18 | Weather, DEFAULT_WEATHER, stateOfWeather, windAt | weather | The sliders of the day (Weather) and what the weather module makes of them: the wind at a height for the flight physics, and the module's state for the clouds and the sea. |
apartment#
7 files, 280 lines. Engine packages: ai, character, core, game, input, platform, player, ui.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
controls.ts | 37 | actions, bindings | input | |
game-block.ts | 7 | game | ||
game.ts | 106 | install | ai, character, platform, player, ui | |
hotspots.ts | 31 | Hotspot, HOTSPOTS, goTo, mountSpots | core | |
look.ts | 13 | applyLook | game | |
main.ts | 10 | |||
plan.ts | 76 | PlanOptions, mountPlan | The floor plan: the level's meshes seen from above (their bounding boxes in x and z, walls dark, low furniture light), a dot for the visitor with the way they face, and a click that takes them there. It needs no data of its own: it is drawn from the scene. |
atomics#
31 files, 3755 lines. Engine packages: core, perspective, physics-atomic, physics-chemistry, player, ui.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
atom-screen.ts | 143 | categoryOf, AtomScreen | ||
commands.ts | 80 | registerEduCommands | ||
commentator.ts | 48 | Commentator | The voice of the lab: plays the recorded comments of lab/commentary.ts (assets/voice/<id>.mp3) one at a time. A comment plays the first time its situation comes up and not again until the page is reloaded; while one is playing, the next waits, and only the latest waiting one is kept (a player who is clicking quickly is not read a backlog). M switches the voice off and on. Leaving a mode stops what is being said. | |
decay-screen.ts | 297 | DecayScreen | ||
game-block.ts | 5 | game | What the game is made with (ferret.json "game" of the package and the page's createGame): the lab has its own camera and input, a deep blue sky, and VR. | |
game.ts | 82 | install | core, player | |
irradiation-screen.ts | 261 | IrradiationScreen | ||
lab/atom-view.ts | 236 | AtomPicture, PARTICLE_COLOURS, PARTICLE_SIZES, electronColour, ElectronHandle, AtomView | physics-atomic | |
lab/atom.ts | 99 | HC_EV_NM, ShellView, Line, Absorption, wavelengthNm, AtomModel, drawnRadius | physics-atomic | |
lab/bonds.ts | 35 | BondKind, BOND_KINDS, BOND_COLOURS, BOND_NAMES, findHydrogenBonds | The kinds of bonds the Matter mode draws (owner, 2026-11-18: different interactions are different colours): the strong chemical bond that shares electrons between atoms (covalent: inside a molecule, in diamond and graphite), the Coulomb attraction between ions (ionic: sodium and chloride in rock salt) and the hydrogen bond (a hydrogen of an O-H or N-H group towards an O or N of another molecule: ice, water, ethanol, the acids). Metals have no pair bonds: their electrons belong to the whole crystal, so no sticks. | |
lab/commentary.ts | 108 | Comment, COMMENTS, COMMENT_IDS, commentText | The spoken commentary of the lab (owner, 2026-11-18): short comments on what is on the screen, in English, recorded in advance by text to speech and played from files (assets/voice/<id>.mp3, one for each id here). A comment is played the first time its situation comes up in a visit to a mode and not again until the page is reloaded (the player may ask for it again by repeating the action). The texts are the source of the recordings: change one and record again, a test checks that every id has a file and that no file is left without an id. Numbers are the ones of the lab's tables (data/). | |
lab/data/elements.ts | 220 | RYDBERG_EV, Block, Subshell, ElementData, SUBSHELL_LETTERS, occupations, FIRST_IONISATION, Edge, xrayEdge, slaterBinding, ELEMENT_TABLE, element, shortConfiguration, xrayLine, KA1_MEASURED | physics-chemistry | The 118 elements of the lab (PLAN-ATOMICS stage E1): name, mass, place in the periodic table, the electron configuration, and the binding energy of every occupied subshell. Each part says where it comes from; nothing is a value seen once. - names and standard atomic weights: @ferret/physics-chemistry (IUPAC), one table for the engine; - the configuration: the Madelung (n + l, n) order of filling with the experimental exceptions of the ground states (NIST Atomic Spectra Database, "Ground levels and ionization energies"; for Z > 103 the predicted ones follow the Madelung rule, which Fricke and Soff's relativistic calculation confirms but for Lr); - X-ray edges K, L1-L3 and M5 (eV): measured values at the anchor elements (X-Ray Data Booklet, LBNL, table 1-1 "Electron binding energies"), between them interpolated in log-log (Moseley: an edge goes as a power of Z), beyond the ends continued by the exponent of the nearest segment; - the first ionisation energy of the elements 1 to 54 and of a few heavier ones: measured (NIST ASD, CRC Handbook "Ionization energies of atoms"); - every other subshell: Slater's rules (J. C. Slater, Phys. Rev. 36, 57, 1930), E = Ry (Z - s)^2 / n*^2: an estimate, flagged model. |
lab/data/isotopes.ts | 68 | YEAR_S, MEV_J, BARN, DecayMode, Fission, Nuclide, NUCLIDES, nuclideOf, decayConstant, decayChain, C14_LIVING_FRACTION | The nuclides of the lab (PLAN-ATOMICS stage E1): the ones that decay (U-235, U-238, Pu-239, C-14, tritium and the daughters they leave) and the ones they leave or are made of. Sources: atomic masses AME2020 (Wang et al., Chin. Phys. C 45, 030003), half-lives and decay modes NUBASE2020 (Kondev et al., Chin. Phys. C 45, 030001), thermal neutron cross sections the Atlas of Neutron Resonances (Mughabghab, 2018) and ENDF/B-VIII.0, fission energy and neutrons per fission the same. A chain ends at the first nuclide the table does not hold; it is shown as "(beyond the table)", never guessed. | |
lab/data/substances.ts | 275 | R_GAS, N_A, ATM, LatticeId, Solid, Liquid, Kind, Substance, SUBSTANCES, substance, vapourPressure, sublimationPressure, meltingTemperature, PhaseName, phaseOf, solidAt, latticeDensity, liquidDensity, gasDensity, densityAt | The substances of the lab with their phase diagrams (PLAN-ATOMICS stage E1, decided: variant A, a table decides the phase from (T, P)). water, iron (bcc), copper (fcc), carbon (graphite and diamond), He, H2, O2, N2, CO2, table salt (rock salt), ethyl alcohol, sulphuric acid, hydrochloric acid Sources: triple and critical points, boiling and melting points, enthalpies of vaporisation and fusion: CRC Handbook of Chemistry and Physics (92nd to 103rd ed.), NIST Chemistry WebBook, IAPWS-95 for water; lattice constants: Wyckoff, Crystal Structures, and the CRC table "Crystal structures and lattice parameters of the elements"; van der Waals constants: CRC "Van der Waals constants for gases"; carbon: Bundy et al., Carbon 34, 141 (1996). A value I am not sure of is marked approx: true and listed in the report to the owner; none is made up to fill a gap. The phase boundaries are smooth curves through the tabled points: the vapour pressure through the triple, the normal boiling and the critical points (the Riedel form ln P = A + B / T + C ln T), or by Clausius-Clapeyron from the normal boiling point and the enthalpy of vaporisation where no critical point is tabled; the sublimation curve by Clausius-Clapeyron from the triple point; the melting curve a straight line of slope dT/dP from the triple point. The diagram is a picture of the physics, not a thermodynamic fit: it holds the tabled points exactly and the shapes between them. | |
lab/decay-lab.ts | 44 | DECAYING, decayPopulation, chainIds, FUEL, FUEL_DENSITY, criticalRadius, chainBall | physics-atomic | |
lab/dynamics.ts | 158 | K_B, MS_TO_APS, Particles, gauss, angularSpeed, GasBox, LiquidBox | physics-atomic | |
lab/index.ts | 21 | The module atoms-and-matter of the asset library (rubric education/atoms-and-matter): everything of the lab that a game can take; the page of the example is only its screens. | ||
lab/irradiation.ts | 229 | IrradiationEvent, ProjectileKind, Beam, PROJECTILES, NUCLEAR_BEAM_CM2, FISSILE, Irradiation | physics-atomic | |
lab/keepout.ts | 54 | Obstacles, pushOut, KeepOut | What the camera cannot enter (owner, 2026-11-18): every element of the picture - the balls (atoms, electrons, nucleons), the rings of orbits and the chemical bonds - is solid to the camera; it goes round them, never into them. The camera is a small ball of radius; a position that is inside an obstacle is pushed out along the shortest way, so the motion slides along the surface. The probability clouds of the Bohr picture are not solid (a cloud is where an electron may be found, not a thing). Obstacles are flat arrays: spheres as x, y, z, r; segments (a bond, a piece of a ring) as x0, y0, z0, x1, y1, z1, r (a capsule). | |
lab/matter-irradiation.ts | 145 | MatterHit, MatterTrack, MatterBeamResult, electronRange, MatterBeam | physics-atomic | |
lab/matter-view.ts | 138 | MatterView | ||
lab/matter.ts | 138 | Form, Facts, MatterSample | physics-atomic | |
lab/modes.ts | 43 | ModeId, ModeInfo, MODES, Place, LabNav | The four modes of the atoms-and-matter lab and the way between them (PLAN-ATOMICS stage E0): a lobby with a card for each mode, and Esc from any mode back to it. Headless: the page draws the cards and the screens; what mode is open and what a key does is here, so a test (and an agent) drives it without a screen. | |
lab/molecules.ts | 81 | V3, MolAtom, Molecule, add, sub, mul, dot, cross, len, unit, ELEMENT_LOOK, MOLECULES, moleculeOf, centre | The molecules of the lab's substances (PLAN-ATOMICS stage E4): atoms with positions in angstroms and the bonds between them, and how an atom is drawn. Geometries are the gas-phase ones (bond lengths and angles from NIST CCCBDB / CRC; water 0.9572 A and 104.52 deg, CO2 1.162 A, H2 0.741, O2 1.208, N2 1.098, HCl 1.275). Ethanol and sulphuric acid are built from heavy-atom skeletons with the hydrogens placed on the tetrahedral directions (marked approx: no conformer search). | |
lab/nucleus-shape.ts | 37 | Nucleons, nuclearRadius, nucleonCluster | physics-atomic | |
lab/structure.ts | 147 | Crystal, crystal | physics-atomic | |
main.ts | 9 | |||
matter-screen.ts | 159 | MatterScreen | ||
nucleus-field.ts | 222 | FieldOptions, Leaver, NucleusField | perspective | |
screens.ts | 45 | Screen, ScreenHost, mountScreens, frameInFreeArea | ||
vr.ts | 128 | setupVr | ui |
conics#
9 files, 985 lines. Engine packages: core, game, player, xr.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
content.ts | 53 | Lesson, COLORS, LESSONS | ||
game-block.ts | 5 | game | What the game is made with (ferret.json "game" of the package and the page's createGame): the scene has its own camera and input, a deep blue sky, and VR. | |
game.ts | 68 | install | core, player | |
main.ts | 9 | |||
math.ts | 195 | ALPHA_DEG, ALPHA, K, HEIGHT, PARABOLA_TILT, DIST_MAX, PlaneState, Kind, Pt2, Vec3, Section, KIND_NAME, DEFAULT_STATE, PRESETS, snap, toWorld, planeFrame, planeFromHand, coneResidual, section, worldSegments, eccentricityAt | The mathematics of the conic-sections scene, with no engine in it (so a unit test checks it). The double cone has its apex at the origin and its axis along y: x² + z² = k²·y², k = tan α (α = the half-angle). The cutting plane is n·p = d with the unit normal n = (sin θ, cos θ, 0) turned about the axis by the spin ψ: θ (tilt) = the angle between the plane and a plane perpendicular to the axis (0 = a circle's plane, 90° = parallel to the axis), d (dist) = the signed distance from the apex to the plane, ψ (spin) = a turn about the axis; it never changes the curve (the cone is round), only the view. Inside the plane take the axes e_u = (cos θ, −sin θ, 0) and e_w = (0, 0, 1) and the point p = d·n + u·e_u + w·e_w. Put p into the cone's equation and it becomes A·u² + B·u + w² + C = 0, A = cos²θ − k² sin²θ, B = 2 d sinθ cosθ (1 + k²), C = d² (sin²θ − k² cos²θ), so the sign of A decides the curve (A > 0 ellipse, A = 0 parabola, A < 0 hyperbola) and completing the square gives the standard form: ellipse / hyperbola: a = /d/·k / /A/, b = /d/·k / √/A/, e = sinθ·√(1 + k²) = sinθ / cos α (the same number for both), parabola: w² = 4p·x with p = /d/·k / 2. | |
scene.ts | 172 | ConicScene | ||
tasks.ts | 126 | Verdict, Task, TASKS | ||
ui.ts | 300 | Model, equationHtml, Ui | ||
vr.ts | 57 | setupVr | game, xr |
crowd#
1 files, 93 lines. Engine packages: assets, crowd, game, levels, perspective.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
main.ts | 93 | assets, crowd, game, levels, perspective |
dunkirk#
44 files, 7180 lines. Engine packages: ai, assets, core, crowd, levels, media, micromotion, perspective, physics, physics-vehicles, player, terrain, view, waves.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
air-fx.ts | 130 | Effects | Effects for the raid (PLAN-AIRWAR stage 6): puffs of smoke and fire as two pools of billboards (one solid-particle system each, alpha and additive), flak bursts, bomb explosions, burning targets, smoke trails of hurt aeroplanes, tracers as one line system and the bombs in the air as instances of one mesh. Everything takes scene coordinates (x, y up, z); the tracers and the bombs come in NED from the simulation. | |
air-view.ts | 279 | Mount, AirView | levels, physics-vehicles | The war overhead on screen: the library's aircraft (one model per craft, posed from the flight model), propellers turning, smoke trails of hurt aircraft, tracers, bombs in the air, bursts of bombs on sand and sea, flak puffs, crashes. Effects are air-fx.ts (pools of billboards). Model frame of the flight model: nose +X, up +Y, left wing +Z; the scene: x east, y up, z north. The library's aircraft now load with the nose on -X (propellers at -X, fins at +X, as the destroyer's bow): each is turned half round about its up axis to fly nose first. |
air-weapons.ts | 25 | Kind, SPEC, WEAPONS, BOFORS | physics-vehicles | The guns and the aircraft of the air war: spec/weapons.json and spec/spec.json read into the forms of @ferret/physics-vehicles (readWeapons knows only the airwar sample's three guns, so the 1940 rifle-calibre guns are read here). |
airwar.ts | 684 | Vec3, Team, toNED, toScene, raidIntensity, NAMES, blastRadius, Slot, Station, Craft, AirEvent, Bomb, Ground, AirOptions, Air | physics-vehicles | The war overhead (PLAN-DUNKIRK E2) on the flight core of the airwar sample (@ferret/physics-vehicles: Aeroplane, Autopilot, Gun, Ballistics, Damageable, FlakBattery). Pure simulation, no Babylon. Raids come in from the land (south-east): Ju 87 B-2 dive-bomber trails, He 111 H and Do 17 Z formations with Bf 109 escorts, and Bf 109 pairs that strafe the mole and the beach. Hurricanes and Spitfires patrol over the sea and meet them. British guns fire from the ground and from the ship. Bombs fall with drag and burst. The aircraft are the real flight model with the spec of spec/spec.json (sourced / estimated marks there). The AI is the airwar sample's, adapted (formation bombers with a bombardier, gunner stations, pursuit with lead and a break after the pass); the dive-bomber controller is new (roll in, dive, release, pull out, leave); the strafing run is new. AI numbers (ranges, cones, timings, raid sizes and rhythm) are game values, estimated. The weather scales the raids: heavy in the calm overcast, a trickle in the storm. Frame: the flight core is NED (north, east, down). The scene here is x east along the beach, y up, z north out to sea: north = +z, east = +x, down = -y. toNED/toScene convert. Nobody loses anything to a bomb in the game itself (it has no fail state): the events say where a bomb fell and the game decides what the men and the ship do. |
autopilot.ts | 80 | PilotState, Controls, wrap, LINE_X, APPROACH, Pilot | The destroyer's autopilot (PLAN-DUNKIRK D4): it brings the ship down an approach line to the berth (bow to the beach), slows to a crawl and lies alongside; to leave it backs off the berth and takes the ship out to sea. It steers with the ship's own controls (the telegraph and the helm), so it is as good as the sea lets it be. It is an assist and is marked so in the HUD; the player takes the ship back with a key. Pure: it reads a state and returns the two controls. | |
beach.ts | 131 | BeachView | The beach of the Dunkirk demo (PLAN-DUNKIRK D1): a heightfield made from shore.ts in chunks around the camera (fine near, coarse far, a skirt on each chunk so the different resolutions never show a crack), one sand material whose layers come from the height, the tide and noise: dry sand, wet sand that darkens and glosses along the waterline, shingle at the high-water line, marram grass on the dunes, ripples in the sand. Nothing is built beyond what the visibility reaches. | |
crowd-sim.ts | 328 | State, SOLDIER_PROFILE, Soldier, rng, WALK, LANES, CrowdOptions, Crowd | ai, micromotion, physics | The soldiers on the beach (PLAN-DUNKIRK D4): a crowd simulation with a small state set per man (wait, queue, walk, wade, board, aboard). Pure: positions, states and counts, no Babylon. The men stand in groups on the beach and the dunes and in the shallows; when the ship is made fast at the berth the nearest are called into a queue of three abreast that climbs the ramp and goes up the mole to the gangway; when the gangway is down the head of the queue walks over it and is counted aboard. A man steers by a few rules: head for the next point of his route, keep a body's width from the others (a spatial hash), stand on what walkHeight says, wade where the water is deep enough to show it. Only the men inside range of the viewer are simulated every step; the far ones are held (the visibility limit pays for the crowd). |
deck-water.ts | 55 | ShipWater | waves | Green water and spray for the destroyer (PLAN-TERRAIN T12): DeckWater and Spray of @ferret/waves on the Fletcher's weather deck. The ship's body frame is x starboard, z bow; the deck grid of DeckWater is along x (bow positive) and across z, so the points and the gravity are swapped here. No Babylon. |
decks.ts | 220 | Decks | ai, micromotion, physics | The people on the decks (PLAN-DUNKIRK D4): the men taken off are seen aboard (packed on the destroyer's decks, in the lifeboat, the yacht's cockpit and the steamer's decks), and every craft has her crew of sailors (a naval officer on the bigger ones) who move about her deck. Where a man can stand is read off the model itself: rays down onto it on a grid, the hits on the main deck band are the places (the tops of the funnels, the guns and the deckhouses are not). The places are in the craft's own frame, so the people go with her as she rolls and steams. The men are drawn as the crowd is (the nearest by the library's figures, the rest by the instanced crowd): this makes them Soldiers with figure set, standing still with the posture AI, the sailors also walking from place to place. |
docking.ts | 170 | SHIP, halfBreadth, BerthReading, BOX, heading, readBerth, ContactState, contactForces, Line, MooringState, Mooring, gangway | physics-vehicles | Docking at the mole (PLAN-DUNKIRK D4): the berth reading, the contact of the hull with the mole's fenders and with the sea bed, and the mooring lines. No Babylon: the ship is a Vessel of @ferret/physics-vehicles (body frame x starboard, y up, z bow) and every force goes in through applyForce. A touch is a soft contact, never a fail state: the fenders give (a spring that stiffens with the squeeze), the ship is pushed off and loses speed, a scrape drags along the face; a hard hit sets impact for the sound, the spray and the pause of boarding. The lines are springs that only pull when taut; they part at the limit of the weather rung (the ship surges off, the gangway lifts, the soldiers wait). |
dom.ts | 15 | ui, $, assets, loadContainer, BUILD | core | |
dunes.ts | 25 | DUNE_SPECIES, DuneView | terrain | The dunes' plants by the engine's terrain module (@ferret/terrain): marram grass in tufts and clumps, sea buckthorn and creeping shrubs on the dunes behind the beach, none below the reach of the spring tides. The ground the module scatters on is the landscape's (land.ts, made from the beach's own bed, the one the sea, the crowd and the craft use); the module's ScatterView places and draws the plants (a pure function of seed and cell, thin instances). |
dunkirk-program.ts | 146 | DunkirkOptions, AdoptedMan, DunkirkProgram | ai, core, physics, physics-vehicles | The war on the beach as a SimProgram (PLAN-WORKERS W5): Sim (the sea, the ship, the crowd, the fleet, the air war) behind the SimHost, in a worker or in the page. It steps at 60 Hz: the world at 20 Hz (every third step) as before, the air war at its own 30 Hz, or at 60 Hz while someone flies. The drawing sends commands (the camera's place, the stick, a new loop, a raid called) and reads snapshots; no object of this file's side is visible to it. No Babylon in here, so it runs in a Web Worker. |
far-crowd.ts | 118 | FAR_FIGURES, FAR_POSES, FarCrowd | ai, levels, perspective | The soldiers beyond the figures (PLAN-DUNKIRK D4): every man the near and the middle rings have not taken is drawn as a baked picture of the library's own figure in his pose (@ferret/perspective: the figure rendered from 8 x 8 directions in each pose, made at build time by tools/perspective/bake-characters.mjs; walking has the frames of a stride), and as a dot when he is only a few pixels. Nothing in the scene is a stand-in: the same Tommy, officer or sailor, at every size. One impostor set per figure and pose (a draw call each, all the men of that kind and pose at once); the men are given pooled nodes, the sets read their matrices. Only the men in the camera's view are given nodes. The picture and the dot are chosen by the size on the screen. |
figures.ts | 22 | Role, FigureDef, FIGURES, byRole, kitOfId | The one list of the figures the soldiers are drawn with (near, middle, far pictures, decks). A new model is one more line here: its library id (without '-lod1'), its role (which men it stands for), its kit (what is on head and back: a man is never drawn with a figure of another kit), how many of it the CPU pool holds, and whether the far pictures are baked for it (one per kit family is enough: far marks the family's picture, the others are drawn as it). | |
fleet-view.ts | 76 | FleetView | core, levels, perspective, view | The small craft on screen: one library model per craft (lifeboat, yacht, paddle steamer), posed from Fleet, with the propeller or the paddle wheels turning. Model frame as the ship's: bow +X, starboard -Z in the scene. |
fleet.ts | 157 | BoatKind, PADDLE, paddleRps, BoatState, BOATS, Boat, FleetOptions, Fleet | The small craft of Dunkirk (PLAN-DUNKIRK E1): lifeboats come in to the beach, a yacht and a paddle steamer lie against the mole's west face; each takes a part of the men who wait on the beach, then backs off and goes out to sea. They are not physics bodies (the player's ship is the only one): they follow a path at a speed that falls off toward the berth, bob on the sea model, and the men walk to them through the crowd (Crowd.ferry). Sizes are the library models' (lifeboat 10.82 x 3.12 m draught 0.70 m, yacht 15.84 x 3.81 m draught 1.52 m, steamer 61.2 x 7.3 m draught 1.69 m: their READMEs). Capacities per visit, speeds and the rhythm of arrivals are game values (estimated): the real Sundowner once brought 130 men and the Princess Elizabeth lifted 1,673 in all. | |
flight-hud.ts | 224 | HELP, GaugeKind, GAUGES, HudState, FlightHud | The Spitfire's displays (the flight mode, flight.ts): a flight panel, the instruments (airspeed, horizon, altimeter, climb, heading), the gunsight with a lead marker on a locked raider, markers on the aircraft in sight and on the destroyer, a plan radar, the radio messages and the mission line. The same displays as the airwar sample's, drawn on a 2-D canvas over the 3-D view; the mission is the evacuation's (the destroyer, the mole, the men) instead of the raid's. | |
flight.ts | 333 | FlightView, FlightHost, Flight | The flight mode (ported from the airwar sample): C takes the observer's place in a Spitfire I over the same war, with the task of covering the evacuation; the stick is the arrows, the rudder A and D, the throttle W and S, Space fires, T locks a raider, G and F the gear and flaps, V the view (cockpit, chase, outside), * hands the Spitfire to the patrol AI and takes it back (the stick takes over). The aeroplane is the war's own (Air.spawnPlayer: the flight model, the guns and the damage of every aircraft there), so the raiders shoot at it and it shoots at them; this file is the keys, the camera and the messages. No fail state: a lost Spitfire puts the observer back and C scrambles another. | |
game-block.ts | 5 | game | What the game is made with (ferret.json "game" of the package and the page's createGame): it reads the keys and the mouse itself; VR is on. | |
game.ts | 516 | liteFor, install | assets, core, levels, media, perspective, physics, player, view | |
gun-crew-logic.ts | 198 | CrewRole, Station, TWIN_40_CREW, Spot, stationPos, fitStations, Mode, CrewMan, MountInput, GRAB, CARRY_SPEED, CLIP, Crew, turnToward | ai | The crew of a twin 40 mm anti-aircraft mount, pure (no Babylon): who stands where round the mount and what each man does by what the gun does. gun-crews.ts puts the men into the world (the physics gives their heights) and draws them as the crowd is drawn. The crew of one twin mount, six men (the British Army's single Bofors had a detachment of six; for a twin mount the plausible minimum is the same six, for the numbers are not given in the sources the game has, the roles are): - the layer (elevation) and the trainer (traverse), one each side of the mount, carried round with it as it turns, never leaving it; - two loaders, one to a barrel, behind the breeches, carried round with the mount: they bend to the ready ammunition and rise to feed the four-round clip, one such cycle for each clip a barrel is owed (four rounds fired); - the ammunition number, who stays by the ready rack and, while the guns fire, carries a clip from the rack to a loader and walks back (the loaders in turn); - the gun captain, on the ground beside the mount, who faces the target (the aeroplane) while the guns are engaged and the gun's forward while they are not. A man of them takes cover when a bomb or a strafing run is near (the posture AI's cover: down to a crouch or flat) and gets up slowly after it, whatever he was doing. |
gun-crews.ts | 228 | GunCrewsOptions, GunCrews | micromotion, physics, physics-vehicles | The gun crews: the men at the anti-aircraft guns of the war overhead, the ground batteries and the guards of the mole (the Royal Artillery in battledress and helmet) and the ship's own guns (her sailors). The roles and what each does by what the gun does are gun-crew-logic.ts (pure); this puts the men into the world the way decks.ts does: each is a Soldier with a figure set, standing in the physics (Walkers: the ground, or the ship's deck carried with her), so the near and middle figures, the baked pictures and the dots draw them like any man. The game gives them to the crowd's drawing with the deck people (people). Heights are never set here: a man is put on the ground the physics gives at his station (Walkers.groundAt, or the deck's own place read off the ship's model) and each step he is moved by the physics toward where his work puts him; a man who is not on his feet on the ground (carried off by a swell, the ground gone) is put back at his station. |
land.ts | 70 | dunkirkGround, LandLook, LandView | levels, terrain | The land of the Dunkirk demo on the engine's terrain module (@ferret/terrain): the beach's own height (bed of shore.ts, the one the sea, the crowd and the craft use) goes in as height grids (a fine one over the beach and the dunes, a coarse one out over the polder and the sea to past the horizon), the biomes are the module's (the coast: beach sand, wet sand, shingle, marram on the dunes; behind it the farmland of the polder), the ground is drawn by TerrainView with the library's photographic ground sets near the camera (GroundTextures) and the dunes' plants by ScatterView (dunes.ts) on the same ground. It replaces the old hand-made sand shader (beach.ts). |
litter-view.ts | 64 | LitterView | levels | The litter on screen: one small mesh per kind, drawn as thin instances, in the library's own materials (packing-case wood, pine planks, rusted and painted drum steel, tin, khaki cloth, helmet steel), tinted to the army's colours where they were painted. Shown only when all is in. |
litter.ts | 64 | LitterKind, Litter, LITTER_SIZE, layoutLitter, LITTER | What else the army left on the sand (PLAN-DUNKIRK D4), as it was in 1940: wooden ammunition boxes (the .303 SAA box) and packing cases, loose planks and duckboards, 40-gallon oil drums standing and on their sides, the four-gallon petrol "flimsies", kitbags and haversacks, steel helmets. Most of it round the wrecks, along the columns' tracks to the mole and at the back of the beach; a line of planks and drums at the tide mark. Pure layout (no Babylon): the same litter from the same seed. | |
main.ts | 10 | |||
mole.ts | 135 | MoleView, Gangway | The mole (PLAN-DUNKIRK D1): a timber walkway on piles running out from the dunes to deep water, like the East Mole at Dunkirk. 5 m wide, its deck 4.2 m over the mean sea level, a continuous face of piles with rubbing strakes and rubber fenders on each side, a ramp from the sand, bollards every 12 m, a few lamps; the piles go down to the bed (thin instances, one mesh), the rest is one merged mesh with vertex colours and one deck mesh with a plank texture. The gangway is a separate board that follows the ship. | |
near.ts | 288 | figureOf, POOL_COUNTS, kitOf, NearCrowd | ai, levels, micromotion | The near view of the soldiers (PLAN-DUNKIRK D4): the library's own British figures (examples/dynamo-troops: Tommies in battledress, greatcoats and caps, and officers, all on the Customizer's 87-bone skeleton) take the place of the cheap instanced men for the few dozen nearest to the camera. A pool of figures is built once; each frame the nearest men that fit in it are given a figure, which stands or walks with the library's own clips (Idle, Walk_Fwd of cc-clips), at the pace the crowd simulation gives the man. A figure stays with its man while he stays near; the men the pool does not reach, and the whole crowd at a distance, are drawn by FarCrowd (baked pictures of the figures, dots beyond). |
sea-model.ts | 32 | SeaModel | waves | The sea's height as the ship and the crowd read it (PLAN-DUNKIRK D2): the Gerstner field of @ferret/waves with the shoaling of shore.ts (the amplitude of each wave follows the depth under it) plus the swell the mole's faces send back. The water shader (sea.ts) computes the same sums, so what is drawn is what the ship floats on. |
sea.ts | 235 | SeaOptions, SeaView | The sea of the Dunkirk demo (PLAN-DUNKIRK D2): one shader surface, a polar grid that follows the camera (fine under it, coarse far away). The vertex shader sums the Gerstner waves of the weather rung with the shoaling of shore.ts (each amplitude follows the depth under it: Green's law, then held by the depth), adds the swell the mole's faces send back, and the fragment shader shades it: Fresnel against the overcast sky, the sun's glitter, murky Channel colour that goes pale in the shallows, foam where the sum of the waves breaks (the Jacobian of the sideways move, the surf zone by the wave height over the depth), the swash band at the waterline (the water is cut where its surface falls below the sand, so the run-up and the backwash come out of the waves themselves), the foam of the ship's wash from a small texture. sea-model.ts computes the same sums on the CPU, so the ship floats on what is drawn. | |
ship.ts | 180 | PROP, RUDDER, CAPACITY, MAN, GM_TARGET, keelDepth, deckLine, hullFill, volumeBelow, fitSection, particulars, ShipOptions, Ship | physics, physics-vehicles | The destroyer of the Dunkirk demo: a Fletcher-class hull as a Vessel of @ferret/physics-vehicles (PLAN-DUNKIRK D4, D4b), with two shafts, two rudders that feel the propeller wash, the troop load as a tank of the vessel, and the hull's resistance from HullResistance (Reynolds friction, wave making, appendages, the added resistance of the sea, windage). No Babylon. Particulars: Fletcher class, waterline 112.5 m (110.0 m at the design draft; length overall 114.7), beam 12.1 m, 2,924 t (full load, without troops) at 5.2 m, 60,000 shp on two shafts (the class's 35 knots), propellers of 3.8 m. They are the published figures of the class as remembered, not measured off the model; see README for what is estimated. The hull's lines (plan, keel, sections) are an estimate fitted to the displacement. Body frame: x starboard, y up, z bow; the origin on the design waterline amidships. |
shore.ts | 107 | BEACH_HALF, MOLE, BERTH, TIDE, DEEP, smoothstep, noise2, fbm, wobble, profile, bed, tide, depthAt, shoalAmplitude, breaking, deckHeight, onMole, walkHeight, FACE_E, reflectionAt, wetness | The shore of the Dunkirk demo as one function of position and time (PLAN-DUNKIRK D1 and D2): the same for every peer, no Babylon. The ground mesh, the water shader, the soldiers and the ship all read it, so the water meets the sand exactly and a soldier stands on what is drawn. World: x runs along the beach (east), z out to sea (north), y up; the mean sea level is y = 0 and the mean waterline is z = 0 (meandering by a few metres). The beach is 2 km long (x -1000..1000), very flat (1:80 on the foreshore, 1:150 out to a bar and a trough, steepening to deep water), with dunes behind it. The mole is a timber walkway on piles from the dunes at x = 0 out to z = 1040: its east face is the berth. | |
sim-spec.ts | 43 | POSTURES, MAN_STATES, BOAT_KINDS, BOAT_STATES, PHASES, CRAFT_KINDS, PLANE_STATUS, FIGURE_IDS, SIM_SPEC | core | What the drawing may read from the simulation (PLAN-WORKERS W5): the snapshot spec shared by the simulation's end (dunkirk-program.ts, in a worker or in the page) and the drawing's end (view-sim.ts). A field that is not here cannot be seen by a view module: Replica is made with the audit on in the tests and ?audit and reports any read of a property that is not declared. The lists below are what tests and the TypeScript checker (D:\temp\reads.mjs-style) found the view modules read. |
sim-worker.ts | 7 | core | The simulation's worker (tools/build.mjs bundles this next to main.js as sim-worker.js): no Babylon in here. | |
sim.ts | 177 | Phase, SimOptions, START, Sim | physics-vehicles | The game's simulation without any drawing (PLAN-DUNKIRK D4): the sea, the ship, the mole's contact, the lines, the crowd, the weather rung and the loop's state machine (approach -> docked -> boarding -> departing -> away -> reset). main.ts draws it; the tests step it by itself. |
sky.ts | 123 | makeCloudTexture, SKY_GLSL, SkyLook, SkyDome | The sky of the Dunkirk demo (PLAN-DUNKIRK D3): one dome that follows the camera, a vertical gradient from the haze at the horizon to the zenith, a layer of overcast cloud (two layers of noise clouds on planes at 1.7 and 6.2 km, puffy with a lit side and a dark base, gaps open with a lower cover, drifting with the wind), the sun's glow through the overcast, and the haze below the horizon. The light and the haze come from the weather rung (weather.ts); the rest of the scene is lit by the same numbers. | |
soundscape.ts | 463 | MACHINERY, Walk, RECIPES, aeroFall, vesselFall, hullRing, motorTone, turbineTone, paddleTone, SoundSources, Soundscape | media | The sound of the beach, made by the engine's sound module (@ferret/media): nothing is a recording. Every sound is a synth recipe (plain data: noise and oscillators through filters and envelopes) that the AudioService plays on its buses, in the world: the listener is the camera, the loudness falls with the distance (and the air takes the highs of a far sound), and a bang that is far arrives late (the speed of sound). Nothing holds still: every loop is driven by a physics value that moves and by a seeded walk of its own. What is heard: - the sea: its body by the sea state and the wave under the listener; the surf, a break each time a crest of the sea model reaches the shallows near the camera; the slap of the water on the mole's faces and on the hulls when it rises fast against them; the rain; - the crowd: a murmur without voices (bands of noise at the speech formants, each with its own walk) from where the men are thickest, smoother the more men there are, louder and brighter when a bomb falls among them; - the vessels' machinery from their physics: the destroyer's turbines, gearing, screws, boilers and fans by her shaft speed; the paddle steamer's floats and her two-cylinder engine by her wheel's turns; the small craft's petrol/paraffin motors by their speed (the constants in MACHINERY); - the aeroplanes: the player's own engine while he flies (inside the cockpit: through the airframe, with the airflow and the buffet near the stall), the others as far as their real distance lets them be heard, by the shaft speed and the power of the flight model; - the guns (machine guns by the rounds that leave the magazines, the flak's bursts), bombs, crashes and the Stukas' sirens. M mutes. |
vat-crowd.ts | 442 | VAT_CLIPS, VatCrowdOptions, VatCrowd | ai, assets, crowd, levels, micromotion, perspective | The soldiers near the camera drawn on the GPU (the Dunkirk demo's answer to "many full figures"): every figure of the library (full triangle count, full textures: nothing is simplified) is drawn by @ferret/crowd's vertex-animation set, i.e. one thin-instanced draw per mesh of a figure for all the men in that figure, skinned in the vertex shader from a texture of baked bone matrices. NearCrowd (near.ts, ?cpu=1) does the same men with one CPU skeleton and one animation group set per figure; this does not. What a VAT can show is one frame of one baked clip per instance, so everything NearCrowd does by blending groups and by turning bones every frame is baked ahead: - the standing and talking clips, and the sitting and crouching ones, are baked with the micro-motion layer already in them (breath, gaze, the arm gestures of the module's own behaviour, recorded from stepPerson; the hands at rest with their curled fingers): a few variants per clip, each man plays one of them at his own phase; - a change of posture (stand -> crouch -> sit -> lie, poseKeys) is a baked blend clip per neighbouring pair of the chain; the man's frame in it is the weight poseKeys gives; - standing -> walking and walking -> standing are short baked blends (stopping from one of four phases of the stride), the lying man's stir is a baked swing. What cannot survive: a micro-motion that answers the world now (a flinch at a blast, a glance at what just happened) and the gaze/breath on a walking or lying man: the gestures a man makes are the recorded ones, not the live ones. The posture the sim gives (ducking, lying down under fire) is live, as are the walk and its pace. The bake is made once per skeleton (the 87-joint Customizer skeleton: every figure shares one bone-matrix texture when its inverse bind poses are the same) and kept in the persistent cache. A new figure needs nothing but its id in the list. |
view-sim.ts | 168 | ViewVessel, ViewShip, ViewFlak, ViewAir, ViewCrowd, ViewSimOptions, ViewSim | core, physics-vehicles | The drawing's view of the simulation (PLAN-WORKERS W5): an object shaped like Sim for the view modules (sim.ship.vessel.pos, sim.fleet.boats, sim.air.crafts, sim.crowd.soldiers ...), built from the SimHost's replica. Nothing here is the simulation's own object: the numbers are the last two snapshots interpolated, the rest is what the drawing needs to ask for (commands go to the simulation, which applies them at its next step). The same code serves a worker and the page's own thread. |
wakes.ts | 89 | Wakes | levels | The tracks the vessels leave on the sea (the destroyer and every small craft): the engine's ShipWake (@ferret/levels, the picture of the long wake of the flight simulation: a white core that spreads and thins, and the two arms of the Kelvin wedge), laid along the path the vessel actually took. A simulated vessel is not a function of time, so each keeps its path here with the length travelled and the time, and ShipWake is answered by DISTANCE astern: a row of the track d metres behind the stern is the point d metres back along the path (straight back along the heading where the path is not yet that long). So the track starts at the stern, however slowly the vessel goes, and never lies under the hull. The track fades with the AGE of the water it lies on: foam decays and the turbulence spreads (the profile of wakeProfile gives the width and the first thinning; each row is also multiplied by exp(-age / T), T about a minute for the core and two for the faint arms). A ship that stops leaves a wake that dies away behind her over minutes; a long track ends in nothing. |
weather.ts | 81 | FETCH, WIND_TO, Weather, LADDER, waveList, significantHeight, peakPeriod, blend, windNow, windVector, fogDensity | waves | The weather ladder of the Dunkirk demo (PLAN-DUNKIRK D4): six presets from a calm overcast day to a storm, each a bundle of the wind, the sea it raises, the cloud, the rain, the visibility and the light. The sea is the difficulty: each loop of the game takes the next rung. Pure data and functions, no Babylon. The sea state follows the wind by the Pierson-Moskowitz spectrum of @ferret/waves, cut down by FETCH: the Channel is narrow, so the sea there never grows to the fully developed one the formula gives (a 22 m/s gale would make Hs 10 m). With FETCH = 0.7 the storm rung raises Hs about 5 m, the "4 to 6 m" of the plan. |
wrecks-view.ts | 120 | perspectiveOf, WrecksView | core, levels, perspective | The abandoned lorries and guns on screen, drawn by the engine's perspective module (@ferret/perspective, PLAN-PERSPECTIVE): each wreck is an entity of the world with a Perspective ladder: the library's model (bedford-qld, qf-25pdr: one loaded copy with its parts merged, drawn as an instance per wreck, long side along +z, centred, wheels on the sand), the library's baked impostor, the module's point; the rungs are the item's measured thresholds (impostor.thresholds, tools/perspective/thresholds.mjs) and the module picks by the size on the screen and cross-fades. The burnt ones are a second copy in darkened materials, and their impostor is baked at the start from that copy with the library's bake options. Nothing shows until all is in. |
wrecks.ts | 117 | WreckKind, Wreck, layoutWrecks, AA_SITES, WRECKS, OBSTACLES, wreckY, clear | What the BEF left on the beach (PLAN-DUNKIRK D4): Bedford lorries run onto the sand and abandoned, some nose-down in a soft patch or burnt out, a line of them driven into the shallows end to end as a lorry pier (Bray-Dunes and La Panne, 1940), and 25-pounders left where they were last fired, some spiked and slewed. Pure layout and obstacles (no Babylon): the same wrecks from the same seed; the crowd walks round them (clear), the view puts a library model on each. |
dunkirk-war#
46 files, 7435 lines. Engine packages: ai, assets, core, crowd, game, levels, media, micromotion, perspective, physics, physics-vehicles, player, terrain, vfx, view, waves.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
air-fx.ts | 130 | Effects | Effects for the raid (PLAN-AIRWAR stage 6): puffs of smoke and fire as two pools of billboards (one solid-particle system each, alpha and additive), flak bursts, bomb explosions, burning targets, smoke trails of hurt aeroplanes, tracers as one line system and the bombs in the air as instances of one mesh. Everything takes scene coordinates (x, y up, z); the tracers and the bombs come in NED from the simulation. | |
air-view.ts | 279 | Mount, AirView | levels, physics-vehicles | The war overhead on screen: the library's aircraft (one model per craft, posed from the flight model), propellers turning, smoke trails of hurt aircraft, tracers, bombs in the air, bursts of bombs on sand and sea, flak puffs, crashes. Effects are air-fx.ts (pools of billboards). Model frame of the flight model: nose +X, up +Y, left wing +Z; the scene: x east, y up, z north. The library's aircraft now load with the nose on -X (propellers at -X, fins at +X, as the destroyer's bow): each is turned half round about its up axis to fly nose first. |
air-weapons.ts | 25 | Kind, SPEC, WEAPONS, BOFORS | physics-vehicles | The guns and the aircraft of the air war: spec/weapons.json and spec/spec.json read into the forms of @ferret/physics-vehicles (readWeapons knows only the airwar sample's three guns, so the 1940 rifle-calibre guns are read here). |
airwar.ts | 684 | Vec3, Team, toNED, toScene, raidIntensity, NAMES, blastRadius, Slot, Station, Craft, AirEvent, Bomb, Ground, AirOptions, Air | physics-vehicles | The war overhead (PLAN-DUNKIRK E2) on the flight core of the airwar sample (@ferret/physics-vehicles: Aeroplane, Autopilot, Gun, Ballistics, Damageable, FlakBattery). Pure simulation, no Babylon. Raids come in from the land (south-east): Ju 87 B-2 dive-bomber trails, He 111 H and Do 17 Z formations with Bf 109 escorts, and Bf 109 pairs that strafe the mole and the beach. Hurricanes and Spitfires patrol over the sea and meet them. British guns fire from the ground and from the ship. Bombs fall with drag and burst. The aircraft are the real flight model with the spec of spec/spec.json (sourced / estimated marks there). The AI is the airwar sample's, adapted (formation bombers with a bombardier, gunner stations, pursuit with lead and a break after the pass); the dive-bomber controller is new (roll in, dive, release, pull out, leave); the strafing run is new. AI numbers (ranges, cones, timings, raid sizes and rhythm) are game values, estimated. The weather scales the raids: heavy in the calm overcast, a trickle in the storm. Frame: the flight core is NED (north, east, down). The scene here is x east along the beach, y up, z north out to sea: north = +z, east = +x, down = -y. toNED/toScene convert. Nobody loses anything to a bomb in the game itself (it has no fail state): the events say where a bomb fell and the game decides what the men and the ship do. |
autopilot.ts | 80 | PilotState, Controls, wrap, LINE_X, APPROACH, Pilot | The destroyer's autopilot (PLAN-DUNKIRK D4): it brings the ship down an approach line to the berth (bow to the beach), slows to a crawl and lies alongside; to leave it backs off the berth and takes the ship out to sea. It steers with the ship's own controls (the telegraph and the helm), so it is as good as the sea lets it be. It is an assist and is marked so in the HUD; the player takes the ship back with a key. Pure: it reads a state and returns the two controls. | |
beach.ts | 131 | BeachView | The beach of the Dunkirk demo (PLAN-DUNKIRK D1): a heightfield made from shore.ts in chunks around the camera (fine near, coarse far, a skirt on each chunk so the different resolutions never show a crack), one sand material whose layers come from the height, the tide and noise: dry sand, wet sand that darkens and glosses along the waterline, shingle at the high-water line, marram grass on the dunes, ripples in the sand. Nothing is built beyond what the visibility reaches. | |
crowd-sim.ts | 328 | State, SOLDIER_PROFILE, Soldier, rng, WALK, LANES, CrowdOptions, Crowd | ai, micromotion, physics | The soldiers on the beach (PLAN-DUNKIRK D4): a crowd simulation with a small state set per man (wait, queue, walk, wade, board, aboard). Pure: positions, states and counts, no Babylon. The men stand in groups on the beach and the dunes and in the shallows; when the ship is made fast at the berth the nearest are called into a queue of three abreast that climbs the ramp and goes up the mole to the gangway; when the gangway is down the head of the queue walks over it and is counted aboard. A man steers by a few rules: head for the next point of his route, keep a body's width from the others (a spatial hash), stand on what walkHeight says, wade where the water is deep enough to show it. Only the men inside range of the viewer are simulated every step; the far ones are held (the visibility limit pays for the crowd). |
deck-water.ts | 55 | ShipWater | waves | Green water and spray for the destroyer (PLAN-TERRAIN T12): DeckWater and Spray of @ferret/waves on the Fletcher's weather deck. The ship's body frame is x starboard, z bow; the deck grid of DeckWater is along x (bow positive) and across z, so the points and the gravity are swapped here. No Babylon. |
decks.ts | 288 | Decks | ai, micromotion, physics | The people on the decks (PLAN-DUNKIRK D4): the men taken off are seen aboard (packed on the destroyer's decks, in the lifeboat, the yacht's cockpit and the steamer's decks), and every craft has her crew of sailors (a naval officer on the bigger ones) who move about her deck. Where a man can stand is read off the model itself: rays down onto it on a grid, the hits on the main deck band are the places (the tops of the funnels, the guns and the deckhouses are not). The places are in the craft's own frame, so the people go with her as she rolls and steams. The men are drawn as the crowd is (the nearest by the library's figures, the rest by the instanced crowd): this makes them Soldiers with figure set, standing still with the posture AI, the sailors also walking from place to place. |
docking.ts | 170 | SHIP, halfBreadth, BerthReading, BOX, heading, readBerth, ContactState, contactForces, Line, MooringState, Mooring, gangway | physics-vehicles | Docking at the mole (PLAN-DUNKIRK D4): the berth reading, the contact of the hull with the mole's fenders and with the sea bed, and the mooring lines. No Babylon: the ship is a Vessel of @ferret/physics-vehicles (body frame x starboard, y up, z bow) and every force goes in through applyForce. A touch is a soft contact, never a fail state: the fenders give (a spring that stiffens with the squeeze), the ship is pushed off and loses speed, a scrape drags along the face; a hard hit sets impact for the sound, the spray and the pause of boarding. The lines are springs that only pull when taut; they part at the limit of the weather rung (the ship surges off, the gangway lifts, the soldiers wait). |
dom.ts | 15 | ui, $, assets, loadContainer, BUILD | core | |
dunes.ts | 25 | DUNE_SPECIES, DuneView | terrain | The dunes' plants by the engine's terrain module (@ferret/terrain): marram grass in tufts and clumps, sea buckthorn and creeping shrubs on the dunes behind the beach, none below the reach of the spring tides. The ground the module scatters on is the landscape's (land.ts, made from the beach's own bed, the one the sea, the crowd and the craft use); the module's ScatterView places and draws the plants (a pure function of seed and cell, thin instances). |
dunkirk-program.ts | 147 | DunkirkOptions, AdoptedMan, DunkirkProgram | ai, core, physics, physics-vehicles | The war on the beach as a SimProgram (PLAN-WORKERS W5): Sim (the sea, the ship, the crowd, the fleet, the air war) behind the SimHost, in a worker or in the page. It steps at 60 Hz: the world at 20 Hz (every third step) as before, the air war at its own 30 Hz, or at 60 Hz while someone flies. The drawing sends commands (the camera's place, the stick, a new loop, a raid called) and reads snapshots; no object of this file's side is visible to it. No Babylon in here, so it runs in a Web Worker. |
far-crowd.ts | 122 | FAR_FIGURES, FAR_POSES, FarCrowd | ai, levels, perspective | The soldiers beyond the figures (PLAN-DUNKIRK D4): every man the near and the middle rings have not taken is drawn as a baked picture of the library's own figure in his pose (@ferret/perspective: the figure rendered from 8 x 8 directions in each pose, made at build time by tools/perspective/bake-characters.mjs; walking has the frames of a stride), and as a dot when he is only a few pixels. Nothing in the scene is a stand-in: the same Tommy, officer or sailor, at every size. One impostor set per figure and pose (a draw call each, all the men of that kind and pose at once); the men are given pooled nodes, the sets read their matrices. Only the men in the camera's view are given nodes. The picture and the dot are chosen by the size on the screen. |
figures.ts | 22 | Role, FigureDef, FIGURES, byRole, kitOfId | The one list of the figures the soldiers are drawn with (near, middle, far pictures, decks). A new model is one more line here: its library id (without '-lod1'), its role (which men it stands for), its kit (what is on head and back: a man is never drawn with a figure of another kit), how many of it the CPU pool holds, and whether the far pictures are baked for it (one per kit family is enough: far marks the family's picture, the others are drawn as it). | |
fleet-view.ts | 77 | FleetView | core, levels, perspective, view | The small craft on screen: one library model per craft (lifeboat, yacht, paddle steamer), posed from Fleet, with the propeller or the paddle wheels turning. Model frame as the ship's: bow +X, starboard -Z in the scene. |
fleet.ts | 177 | BoatKind, PADDLE, paddleRps, BoatState, BOATS, Boat, FleetOptions, Fleet | The small craft of Dunkirk (PLAN-DUNKIRK E1): lifeboats come in to the beach, a yacht and a paddle steamer lie against the mole's west face; each takes a part of the men who wait on the beach, then backs off and goes out to sea. They are not physics bodies (the player's ship is the only one): they follow a path at a speed that falls off toward the berth, bob on the sea model, and the men walk to them through the crowd (Crowd.ferry). Sizes are the library models' (lifeboat 10.82 x 3.12 m draught 0.70 m, yacht 15.84 x 3.81 m draught 1.52 m, steamer 61.2 x 7.3 m draught 1.69 m: their READMEs). Capacities per visit, speeds and the rhythm of arrivals are game values (estimated): the real Sundowner once brought 130 men and the Princess Elizabeth lifted 1,673 in all. | |
flight-hud.ts | 228 | dockedHelp, HELP, GaugeKind, GAUGES, HudState, FlightHud | The Spitfire's displays (the flight mode, flight.ts): a flight panel, the instruments (airspeed, horizon, altimeter, climb, heading), the gunsight with a lead marker on a locked raider, markers on the aircraft in sight and on the destroyer, a plan radar, the radio messages and the mission line. The same displays as the airwar sample's, drawn on a 2-D canvas over the 3-D view; the mission is the evacuation's (the destroyer, the mole, the men) instead of the raid's. | |
flight.ts | 335 | FlightView, FlightHost, Flight | The flight mode (ported from the airwar sample): C takes the observer's place in a Spitfire I over the same war, with the task of covering the evacuation; the stick is the arrows, the rudder A and D, the throttle W and S, Space fires, T locks a raider, G and F the gear and flaps, V the view (cockpit, chase, outside), * hands the Spitfire to the patrol AI and takes it back (the stick takes over). The aeroplane is the war's own (Air.spawnPlayer: the flight model, the guns and the damage of every aircraft there), so the raiders shoot at it and it shoots at them; this file is the keys, the camera and the messages. No fail state: a lost Spitfire puts the observer back and C scrambles another. | |
game-block.ts | 5 | game | What the game is made with (ferret.json "game" of the package and the page's createGame): it reads the keys and the mouse itself; VR is on. | |
game.ts | 625 | liteFor, install | assets, core, crowd, game, levels, media, perspective, physics, player, view | |
gun-crew-logic.ts | 198 | CrewRole, Station, TWIN_40_CREW, Spot, stationPos, fitStations, Mode, CrewMan, MountInput, GRAB, CARRY_SPEED, CLIP, Crew, turnToward | ai | The crew of a twin 40 mm anti-aircraft mount, pure (no Babylon): who stands where round the mount and what each man does by what the gun does. gun-crews.ts puts the men into the world (the physics gives their heights) and draws them as the crowd is drawn. The crew of one twin mount, six men (the British Army's single Bofors had a detachment of six; for a twin mount the plausible minimum is the same six, for the numbers are not given in the sources the game has, the roles are): - the layer (elevation) and the trainer (traverse), one each side of the mount, carried round with it as it turns, never leaving it; - two loaders, one to a barrel, behind the breeches, carried round with the mount: they bend to the ready ammunition and rise to feed the four-round clip, one such cycle for each clip a barrel is owed (four rounds fired); - the ammunition number, who stays by the ready rack and, while the guns fire, carries a clip from the rack to a loader and walks back (the loaders in turn); - the gun captain, on the ground beside the mount, who faces the target (the aeroplane) while the guns are engaged and the gun's forward while they are not. A man of them takes cover when a bomb or a strafing run is near (the posture AI's cover: down to a crouch or flat) and gets up slowly after it, whatever he was doing. |
gun-crews.ts | 228 | GunCrewsOptions, GunCrews | micromotion, physics, physics-vehicles | The gun crews: the men at the anti-aircraft guns of the war overhead, the ground batteries and the guards of the mole (the Royal Artillery in battledress and helmet) and the ship's own guns (her sailors). The roles and what each does by what the gun does are gun-crew-logic.ts (pure); this puts the men into the world the way decks.ts does: each is a Soldier with a figure set, standing in the physics (Walkers: the ground, or the ship's deck carried with her), so the near and middle figures, the baked pictures and the dots draw them like any man. The game gives them to the crowd's drawing with the deck people (people). Heights are never set here: a man is put on the ground the physics gives at his station (Walkers.groundAt, or the deck's own place read off the ship's model) and each step he is moved by the physics toward where his work puts him; a man who is not on his feet on the ground (carried off by a swell, the ground gone) is put back at his station. |
intro.ts | 131 | NARRATION, NARRATION_SECONDS, INTRO_SECONDS, cues, introPose, Intro | media | The opening title: the narration (synthesised once by the engine's speech module, assets/narration.mp3) with its subtitles, over a slow far view of the beach, the mole and the destroyer. The camera never comes close: it keeps well over a hundred metres from everything. Sound needs a user action, so the title waits for a click or a key first. The narration ends with the invitation to press C, which makes the player a Spitfire pilot; C (or Esc) ends the title at any time. |
land.ts | 70 | dunkirkGround, LandLook, LandView | levels, terrain | The land of the Dunkirk demo on the engine's terrain module (@ferret/terrain): the beach's own height (bed of shore.ts, the one the sea, the crowd and the craft use) goes in as height grids (a fine one over the beach and the dunes, a coarse one out over the polder and the sea to past the horizon), the biomes are the module's (the coast: beach sand, wet sand, shingle, marram on the dunes; behind it the farmland of the polder), the ground is drawn by TerrainView with the library's photographic ground sets near the camera (GroundTextures) and the dunes' plants by ScatterView (dunes.ts) on the same ground. It replaces the old hand-made sand shader (beach.ts). |
litter-view.ts | 64 | LitterView | levels | The litter on screen: one small mesh per kind, drawn as thin instances, in the library's own materials (packing-case wood, pine planks, rusted and painted drum steel, tin, khaki cloth, helmet steel), tinted to the army's colours where they were painted. Shown only when all is in. |
litter.ts | 64 | LitterKind, Litter, LITTER_SIZE, layoutLitter, LITTER | What else the army left on the sand (PLAN-DUNKIRK D4), as it was in 1940: wooden ammunition boxes (the .303 SAA box) and packing cases, loose planks and duckboards, 40-gallon oil drums standing and on their sides, the four-gallon petrol "flimsies", kitbags and haversacks, steel helmets. Most of it round the wrecks, along the columns' tracks to the mole and at the back of the beach; a line of planks and drums at the tide mark. Pure layout (no Babylon): the same litter from the same seed. | |
main.ts | 10 | |||
mole.ts | 135 | MoleView, Gangway | The mole (PLAN-DUNKIRK D1): a timber walkway on piles running out from the dunes to deep water, like the East Mole at Dunkirk. 5 m wide, its deck 4.2 m over the mean sea level, a continuous face of piles with rubbing strakes and rubber fenders on each side, a ramp from the sand, bollards every 12 m, a few lamps; the piles go down to the bed (thin instances, one mesh), the rest is one merged mesh with vertex colours and one deck mesh with a plank texture. The gangway is a separate board that follows the ship. | |
near.ts | 305 | figureOf, POOL_COUNTS, kitOf, NearCrowd | ai, levels, micromotion | The near view of the soldiers (PLAN-DUNKIRK D4): the library's own British figures (examples/dynamo-troops: Tommies in battledress, greatcoats and caps, and officers, all on the Customizer's 87-bone skeleton) take the place of the cheap instanced men for the few dozen nearest to the camera. A pool of figures is built once; each frame the nearest men that fit in it are given a figure, which stands or walks with the library's own clips (Idle, Walk_Fwd of cc-clips), at the pace the crowd simulation gives the man. A figure stays with its man while he stays near; the men the pool does not reach, and the whole crowd at a distance, are drawn by FarCrowd (baked pictures of the figures, dots beyond). |
sea-model.ts | 32 | SeaModel | waves | The sea's height as the ship and the crowd read it (PLAN-DUNKIRK D2): the Gerstner field of @ferret/waves with the shoaling of shore.ts (the amplitude of each wave follows the depth under it) plus the swell the mole's faces send back. The water shader (sea.ts) computes the same sums, so what is drawn is what the ship floats on. |
sea.ts | 231 | SeaOptions, SeaView | The sea of the Dunkirk demo (PLAN-DUNKIRK D2): one shader surface, a polar grid that follows the camera (fine under it, coarse far away). The vertex shader sums the Gerstner waves of the weather rung with the shoaling of shore.ts (each amplitude follows the depth under it: Green's law, then held by the depth), adds the swell the mole's faces send back, and the fragment shader shades it: Fresnel against the overcast sky, the sun's glitter, murky Channel colour that goes pale in the shallows, foam where the sum of the waves breaks (the Jacobian of the sideways move, the surf zone by the wave height over the depth), the swash band at the waterline (the water is cut where its surface falls below the sand, so the run-up and the backwash come out of the waves themselves), the foam of the ship's wash from a small texture. sea-model.ts computes the same sums on the CPU, so the ship floats on what is drawn. | |
ship.ts | 180 | PROP, RUDDER, CAPACITY, MAN, GM_TARGET, keelDepth, deckLine, hullFill, volumeBelow, fitSection, particulars, ShipOptions, Ship | physics, physics-vehicles | The destroyer of the Dunkirk demo: a Fletcher-class hull as a Vessel of @ferret/physics-vehicles (PLAN-DUNKIRK D4, D4b), with two shafts, two rudders that feel the propeller wash, the troop load as a tank of the vessel, and the hull's resistance from HullResistance (Reynolds friction, wave making, appendages, the added resistance of the sea, windage). No Babylon. Particulars: Fletcher class, waterline 112.5 m (110.0 m at the design draft; length overall 114.7), beam 12.1 m, 2,924 t (full load, without troops) at 5.2 m, 60,000 shp on two shafts (the class's 35 knots), propellers of 3.8 m. They are the published figures of the class as remembered, not measured off the model; see README for what is estimated. The hull's lines (plan, keel, sections) are an estimate fitted to the displacement. Body frame: x starboard, y up, z bow; the origin on the design waterline amidships. |
shore.ts | 107 | BEACH_HALF, MOLE, BERTH, TIDE, DEEP, smoothstep, noise2, fbm, wobble, profile, bed, tide, depthAt, shoalAmplitude, breaking, deckHeight, onMole, walkHeight, FACE_E, reflectionAt, wetness | The shore of the Dunkirk demo as one function of position and time (PLAN-DUNKIRK D1 and D2): the same for every peer, no Babylon. The ground mesh, the water shader, the soldiers and the ship all read it, so the water meets the sand exactly and a soldier stands on what is drawn. World: x runs along the beach (east), z out to sea (north), y up; the mean sea level is y = 0 and the mean waterline is z = 0 (meandering by a few metres). The beach is 2 km long (x -1000..1000), very flat (1:80 on the foreshore, 1:150 out to a bar and a trough, steepening to deep water), with dunes behind it. The mole is a timber walkway on piles from the dunes at x = 0 out to z = 1040: its east face is the berth. | |
sim-spec.ts | 43 | POSTURES, MAN_STATES, BOAT_KINDS, BOAT_STATES, PHASES, CRAFT_KINDS, PLANE_STATUS, FIGURE_IDS, SIM_SPEC | core | What the drawing may read from the simulation (PLAN-WORKERS W5): the snapshot spec shared by the simulation's end (dunkirk-program.ts, in a worker or in the page) and the drawing's end (view-sim.ts). A field that is not here cannot be seen by a view module: Replica is made with the audit on in the tests and ?audit and reports any read of a property that is not declared. The lists below are what tests and the TypeScript checker (D:\temp\reads.mjs-style) found the view modules read. |
sim-worker.ts | 7 | core | The simulation's worker (tools/build.mjs bundles this next to main.js as sim-worker.js): no Babylon in here. | |
sim.ts | 201 | Phase, SimOptions, START, Sim | core, physics-vehicles | The game's simulation without any drawing (PLAN-DUNKIRK D4): the sea, the ship, the mole's contact, the lines, the crowd, the weather rung and the loop's state machine (approach -> docked -> boarding -> departing -> away -> reset). main.ts draws it; the tests step it by itself. |
sky.ts | 122 | makeCloudTexture, SKY_GLSL, SkyLook, SkyDome | The sky of the Dunkirk demo (PLAN-DUNKIRK D3): one dome that follows the camera, a vertical gradient from the haze at the horizon to the zenith, a layer of overcast cloud (two layers of noise clouds on planes at 1.7 and 6.2 km, puffy with a lit side and a dark base, gaps open with a lower cover, drifting with the wind), the sun's glow through the overcast, and the haze below the horizon. The light and the haze come from the weather rung (weather.ts); the rest of the scene is lit by the same numbers. | |
soundscape.ts | 463 | MACHINERY, Walk, RECIPES, aeroFall, vesselFall, hullRing, motorTone, turbineTone, paddleTone, SoundSources, Soundscape | media | The sound of the beach, made by the engine's sound module (@ferret/media): nothing is a recording. Every sound is a synth recipe (plain data: noise and oscillators through filters and envelopes) that the AudioService plays on its buses, in the world: the listener is the camera, the loudness falls with the distance (and the air takes the highs of a far sound), and a bang that is far arrives late (the speed of sound). Nothing holds still: every loop is driven by a physics value that moves and by a seeded walk of its own. What is heard: - the sea: its body by the sea state and the wave under the listener; the surf, a break each time a crest of the sea model reaches the shallows near the camera; the slap of the water on the mole's faces and on the hulls when it rises fast against them; the rain; - the crowd: a murmur without voices (bands of noise at the speech formants, each with its own walk) from where the men are thickest, smoother the more men there are, louder and brighter when a bomb falls among them; - the vessels' machinery from their physics: the destroyer's turbines, gearing, screws, boilers and fans by her shaft speed; the paddle steamer's floats and her two-cylinder engine by her wheel's turns; the small craft's petrol/paraffin motors by their speed (the constants in MACHINERY); - the aeroplanes: the player's own engine while he flies (inside the cockpit: through the airframe, with the airflow and the buffet near the stall), the others as far as their real distance lets them be heard, by the shaft speed and the power of the flight model; - the guns (machine guns by the rounds that leave the magazines, the flak's bursts), bombs, crashes and the Stukas' sirens. M mutes. |
vat-crowd.ts | 252 | VAT_CLIPS, shippedName, VatCrowdOptions, VatCrowd | ai, assets, crowd, levels, perspective | The soldiers near the camera drawn on the GPU (the Dunkirk demo's answer to "many full figures"): every figure of the library (full triangle count, full textures: nothing is simplified) is drawn by @ferret/crowd's vertex-animation set, i.e. one thin-instanced draw per mesh of a figure for all the men in that figure, skinned in the vertex shader from a texture of baked bone matrices. NearCrowd (near.ts, ?cpu=1) does the same men with one CPU skeleton and one animation group set per figure; this does not. What a VAT can show is one frame of one baked clip per instance, so everything NearCrowd does by blending groups and by turning bones every frame is baked ahead: - the standing and talking clips, and the sitting and crouching ones, are baked with the micro-motion layer already in them (breath, gaze, the arm gestures of the module's own behaviour, recorded from stepPerson; the hands at rest with their curled fingers): a few variants per clip, each man plays one of them at his own phase; - a change of posture (stand -> crouch -> sit -> lie, poseKeys) is a baked blend clip per neighbouring pair of the chain; the man's frame in it is the weight poseKeys gives; - standing -> walking and walking -> standing are short baked blends (stopping from one of four phases of the stride), the lying man's stir is a baked swing. What cannot survive: a micro-motion that answers the world now (a flinch at a blast, a glance at what just happened) and the gaze/breath on a walking or lying man: the gestures a man makes are the recorded ones, not the live ones. The posture the sim gives (ducking, lying down under fire) is live, as are the walk and its pace. The bake is made once per skeleton (the 87-joint Customizer skeleton: every figure shares one bone-matrix texture when its inverse bind poses are the same) and kept in the persistent cache. A new figure needs nothing but its id in the list. |
view-sim.ts | 168 | ViewVessel, ViewShip, ViewFlak, ViewAir, ViewCrowd, ViewSimOptions, ViewSim | core, physics-vehicles | The drawing's view of the simulation (PLAN-WORKERS W5): an object shaped like Sim for the view modules (sim.ship.vessel.pos, sim.fleet.boats, sim.air.crafts, sim.crowd.soldiers ...), built from the SimHost's replica. Nothing here is the simulation's own object: the numbers are the last two snapshots interpolated, the rest is what the drawing needs to ask for (commands go to the simulation, which applies them at its next step). The same code serves a worker and the page's own thread. |
wakes.ts | 89 | Wakes | levels | The tracks the vessels leave on the sea (the destroyer and every small craft): the engine's ShipWake (@ferret/levels, the picture of the long wake of the flight simulation: a white core that spreads and thins, and the two arms of the Kelvin wedge), laid along the path the vessel actually took. A simulated vessel is not a function of time, so each keeps its path here with the length travelled and the time, and ShipWake is answered by DISTANCE astern: a row of the track d metres behind the stern is the point d metres back along the path (straight back along the heading where the path is not yet that long). So the track starts at the stern, however slowly the vessel goes, and never lies under the hull. The track fades with the AGE of the water it lies on: foam decays and the turbulence spreads (the profile of wakeProfile gives the width and the first thinning; each row is also multiplied by exp(-age / T), T about a minute for the core and two for the faint arms). A ship that stops leaves a wake that dies away behind her over minutes; a long track ends in nothing. |
war-fx.ts | 69 | WarFx | vfx | The war's effects, made by the engine's effects module (@ferret/vfx): a bomb bursting on the land (a crater, a fountain of earth, a dark column) or in the water (a crown and a jet of spray), a shot-down aeroplane that burns where it falls on the beach and throws up a splash where it falls into the sea, a boat that goes down, and the fire of a hit on the destroyer (which follows the ship). The simulation says what happened (events with scene positions, x east, y up, z north); this class only draws it. |
weather.ts | 81 | FETCH, WIND_TO, Weather, LADDER, waveList, significantHeight, peakPeriod, blend, windNow, windVector, fogDensity | waves | The weather ladder of the Dunkirk demo (PLAN-DUNKIRK D4): six presets from a calm overcast day to a storm, each a bundle of the wind, the sea it raises, the cloud, the rain, the visibility and the light. The sea is the difficulty: each loop of the game takes the next rung. Pure data and functions, no Babylon. The sea state follows the wind by the Pierson-Moskowitz spectrum of @ferret/waves, cut down by FETCH: the Channel is narrow, so the sea there never grows to the fully developed one the formula gives (a 22 m/s gale would make Hs 10 m). With FETCH = 0.7 the storm rung raises Hs about 5 m, the "4 to 6 m" of the plan. |
wrecks-view.ts | 120 | perspectiveOf, WrecksView | core, levels, perspective | The abandoned lorries and guns on screen, drawn by the engine's perspective module (@ferret/perspective, PLAN-PERSPECTIVE): each wreck is an entity of the world with a Perspective ladder: the library's model (bedford-qld, qf-25pdr: one loaded copy with its parts merged, drawn as an instance per wreck, long side along +z, centred, wheels on the sand), the library's baked impostor, the module's point; the rungs are the item's measured thresholds (impostor.thresholds, tools/perspective/thresholds.mjs) and the module picks by the size on the screen and cross-fades. The burnt ones are a second copy in darkened materials, and their impostor is baked at the start from that copy with the library's bake options. Nothing shows until all is in. |
wrecks.ts | 117 | WreckKind, Wreck, layoutWrecks, AA_SITES, WRECKS, OBSTACLES, wreckY, clear | What the BEF left on the beach (PLAN-DUNKIRK D4): Bedford lorries run onto the sand and abandoned, some nose-down in a soft patch or burnt out, a line of them driven into the shallows end to end as a lorry pier (Bray-Dunes and La Panne, 1940), and 25-pounders left where they were last fired, some spiked and slewed. Pure layout and obstacles (no Babylon): the same wrecks from the same seed; the crowd walks round them (clear), the view puts a library model on each. |
falcon#
11 files, 1239 lines. Engine packages: core, media, player, xr.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
audio.ts | 53 | Sfx | media | |
battle.ts | 360 | Tie, Phase, CamMode, Battle, lookRotation | media | The fight: the Falcon flown by the player, TIE fighters in waves with a simple pursuit AI (lead, fire in bursts, overshoot and break, come round again), laser bolts, homing missiles, the asteroids to hit, shields and hull, the cameras (chase, far chase, fly-by), a slow-motion beat on the last kill of a wave and the jump to lightspeed. Babylon's frame: left-handed, y up; a ship's nose is the holder's +Z. |
dom.ts | 15 | ui, $, assets, loadContainer, BUILD | core | |
fx.ts | 154 | Bolt, Effects | Effects: laser bolts (instances of two glowing capsules), fire and smoke (solid-particle billboards, the pool idea of the airwar demo), explosion flashes (a few pooled point lights), loose TIE wings tumbling away, missile trails and the hyperspace streaks. | |
game-block.ts | 5 | game | What the game is made with (ferret.json "game" of the package and the page's createGame): it reads the mouse and keys itself, on a black sky; in a headset the controllers steer (game.ts). | |
game.ts | 156 | liteFor, install | media, player, xr | |
hud.ts | 101 | Hud | The HUD in the page (DOM over the canvas): shields and hull, score, wave and kills, speed and missiles, the gun sight, the steering cursor, the target's bracket with its range and lead point, markers on the other fighters and arrows to those off screen, the radar, messages, the damage vignette. | |
input.ts | 98 | Edge, Controls | The controls: the mouse (the ship turns toward the cursor, left button fires, right button a missile, the wheel is the throttle), the keyboard, a gamepad and touch (the left half of the screen is a stick, holding the right half fires, a tap there launches a missile). | |
main.ts | 13 | |||
ships.ts | 88 | ShipModels, FalconView, TieView | The ships on screen: the Falcon (the library model, the desktop or the phone tier) and the TIEs (one container, instanced per fighter). Each ship hangs under a holder whose local +Z is its nose and +Y its top; the loader's root is turned so the models (nose +X in the glb) face +Z. | |
space.ts | 196 | V3, SUN_DIR, PLANET_DIR, Space, glowTexture | The space around the fight: the star sphere (the generator's equirectangular starfield), a small cube of the same light for the PBR reflections, a ringed gas giant and the sun far away (drawn first, in rendering group 0, following the camera), a lens flare, and an asteroid field the ships fly through. |
fight#
13 files, 1947 lines. Engine packages: animation, clouds, combat, core, editor, flow, game, input, levels, media, player, terrain, weather.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
aerial.ts | 466 | LookAccumulator, DRAGON_START, DragonBody, RiderBody, FireBreath, DragonPlayer, RiderCamera, FollowTarget, ObserverCamera, AerialOptions, startAerial | animation, combat, core, input | D7 in the scene (plans/demo_fight.md): the Dragon in the air with Kira on it, its fire, the player as the rider (first person on Kira's head) or as a free observer (third person), and the ending: when a fighter has fallen the Dragon lands by its AI on the field, Kira gets off and stands beside the winner, then the fight begins again. The numbers of the flight are in dragon.ts; this file turns them into poses (the fly clips blended by the turn and the climb), particles and cameras. |
clip-panel.ts | 191 | PanelBody, mountClipPanel | animation, core, editor | |
clock.ts | 4 | clock | The demo's time: the observer's slow motion and pause scale it. The fight, the Dragon and the animations all take their steps from it. | |
controls.ts | 83 | actions, bindings, Role, bindingsFor | input | |
dragon.ts | 303 | ROOT_FLY, LAND_DIST, LAND_TIME, TAKEOFF_TIME, FIRE_TIME, FLY_START_HEIGHT, DragonCommand, DRAGON, DragonObstacles, DragonMode, headingTo, Dragon, inFireCone, DragonAiContext, DragonAI | D7 (plans/demo_fight.md): the Dragon. Plain numbers, no Babylon: an arcade flight model (Dragon), the commands that drive it (DragonCommand: the player's input or DragonAI give the same), the fire cone, and the ground / landing / take-off modes whose motion the clips carry. src/aerial.ts puts it in the scene. Frame: the scene's (left-handed, y up). Heading h: the forward direction is (sin h, 0, cos h); turning right raises it. y is the height of the root bone (the clips of the fly set carry it 17 m up; the node of the model is put at y - ROOT_FLY). | |
fight.ts | 143 | FightOptions, startFight | animation, combat, core, input, levels | D5 in the scene (plans/demo_fight.md): the Viking and the Knight fight by the rules of @ferret/combat, both on its AI, on their real bones. The clip timings come from the library's clip set items, the capsules and the weapons from src/bodies; the reach of each attack is measured on the body. |
game-block.ts | 6 | game | ||
game.ts | 276 | install | animation, combat, game, input, levels, media, player | |
main.ts | 10 | |||
moves.ts | 73 | timings, knightMoves, vikingMoves, clipsOf, STARTS | combat | The two fighters' move sets (plans/demo_fight.md, D5): which clip is which move, what each attack costs and does, how fast they move. Clip names are the clips' own (a game finds them in its bound groups by that name, with or without the clip set's prefix); their timings come from where the clips are (the library's clip set items, or the clip files in Node), so the rules follow the clips. |
obstacles.ts | 119 | Hit, TreeObstacles | terrain | What the Dragon can strike: the trees the landscape scatters. scatterCell is a pure function of (ground, species, cell, seed), so asking it again gives the very trees that ScatterView draws (same cells of 40 m, same seed), and each tree's solid is read from the generated mesh of its own variant (the width of the crown at each height), so the collision is the drawn shape and not a guess of it. No Babylon and no clock: plain numbers, the same on every peer. |
player.ts | 106 | HEAVY_HOLD, BUFFER, FighterPlayer, HEAD_LAYERS, ALL_LAYERS, hideHeadFromOwnCamera, FirstPersonCamera | combat, core, input | D6 (plans/demo_fight.md): the player as a fighter. FighterPlayer turns the input actions into the same FighterCommand the AI gives (it reads the actions at the fixed rate and keeps the edges until the frame takes them); FirstPersonCamera puts the camera on the fighter's head bone, stabilised, looking where the player looks. |
scenery.ts | 167 | FIELD, CLEARING, landscape, heightAt, SPECIES, Scenery, SceneryOptions, buildScenery | clouds, core, flow, terrain, weather | The land and the sky of the duel, made by the landscape and weather modules: a @ferret/terrain landscape (a flat clearing in the middle, rolling forest floor over the field, lakes, a wall of ridged mountains beyond the field's edge that nobody can enter), plants and stones scattered by its biomes, and a @ferret/weather service that owns the wind, the clouds (@ferret/clouds), the rain, the lightning, the fog and the light of the hour. Nothing is modelled by hand: the height, the water, the colours and the plants all come from the landscape. |
forest-squirrel#
9 files, 1052 lines. Engine packages: assets, clouds, core, destruction, flow, game, levels, media, physics, physics-liquids, physics-response, player, terrain, vfx, weather.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
build-stamp.ts | 6 | showBuild | core | |
game-block.ts | 6 | game | ||
game.ts | 530 | install | assets, core, destruction, flow, game, levels, media, physics, physics-liquids, physics-response, player, vfx | The demo of PLAN-PHYSICS-RESPONSE R11: the Forest level of the virtual school (a copy of the port of Unreal's Demo_Map, assets/levels/Demo_Map) flown over on the Flying Squirrel of the library. The level lies in the middle of a landscape of the engine (src/scenery.ts): its river is the engine's water, led on into the hills and into a lake, the sky, clouds and light are the weather module's, and a ring of mountains higher than the scene's ceiling closes the zone. The Squirrel's propulsors publish jets into the flow field; the foliage and the grass read the flow map; over water its air cushion dents the surface, the air escaping under the skirt tears spray off it and makes foam, in a window of height-field water that follows the craft. Controls are the actions every sample of Ferret binds (examples/_shared/controls): move forward and sideways, turn yaw, jump climbs, crouch descends, run is a faster flight, view changes the camera. |
kernels.ts | 8 | terrain | The sample's kernels (PLAN-SCHEDULER): its land is made in the engine's workers by this maker, the same land the page makes (the river is code, so the ground is not plain data). Imported by main.ts and bundled into ferret-worker.js by tools/build.mjs. No Babylon in here. | |
land.ts | 179 | Pt, V3, HALF, FOOT, CEILING, LevelGround, LevelRiver, RiverLine, leadRiver, RiverIndex, marshCenter, describeLand, SPECIES, LandInit, makeLand | terrain | The shape of the land round the Forest level: the river led on, the description of the relief, the species; no Babylon in here, so the page and the terrain workers (terrain-worker.ts) build the same ground from the same few numbers. |
main.ts | 9 | |||
scenery.ts | 159 | Scenery, SceneryOptions, buildScenery | clouds, core, terrain, weather | The world round the Forest level, made by the landscape and weather modules of the engine (as the duel's in examples/fight and the airship's zone): a @ferret/terrain landscape in which the level lies at the middle (its own ground is copied into the relief, so the land runs on from its edges), the level's river led on upstream out of the hills and downstream into a lake, all of it drawn and flowing as the engine's water; rolling forest round it; and a closed ring of mountains on the border of the zone, higher everywhere than the craft's ceiling, so nobody leaves (as round the airship's zone). The sky, the clouds, the fog and the light of the hour are the weather module's. Nothing is modelled by hand: heights, water, colours and plants come from the description. |
solids.ts | 74 | Solids | The solid trunks and rocks of the scene, for a craft that flies among them: every thin instance of a tree, a stump or a rock (the level's forest and the landscape's scatter) is a vertical cylinder, its radius the widest the mesh is near its foot, its height the mesh's, both times the instance's scale. Crowns are not solid: they bend (the foliage's wind). Babylon does not collide thin instances, so the cylinders are kept here in a grid of cells and asked by position. | |
sound.ts | 81 | RECIPES, SquirrelSoundState, SquirrelSound | media | The Squirrel's sound, made by the engine's sound module (@ferret/media; nothing is a recording, as examples/airwar/src/game/sound.ts): every sound is a synth recipe the AudioService plays: the lift rotor's beat by its turns, the four ducted fans' whine by how hard the craft is moving, the wind by the speed through the air (and the height), the spray's hiss where the skirt tears the water, the rustle of leaves in the wash, and a thud when the hull meets a trunk or a wall. M mutes. |
greybox#
2 files, 200 lines. Engine packages: animation, character, game, interaction, levels, physics.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
level.ts | 80 | buildGreybox | game, physics | |
main.ts | 120 | animation, character, game, interaction, levels |
home-interior#
7 files, 277 lines. Engine packages: ai, character, core, game, input, platform, player, ui.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
controls.ts | 37 | actions, bindings | input | |
game-block.ts | 7 | game | ||
game.ts | 113 | install | ai, character, platform, player, ui | |
hotspots.ts | 19 | Hotspot, HOTSPOTS, goTo, mountSpots | core | |
look.ts | 13 | applyLook | game | |
main.ts | 10 | |||
plan.ts | 78 | PlanOptions, mountPlan | The floor plan: the level's meshes seen from above (their bounding boxes in x and z, walls dark, low furniture light), a dot for the visitor with the way they face, and a click that takes them there. It needs no data of its own: it is drawn from the scene. |
item-showcase#
2 files, 88 lines. Engine packages: assets, levels, player.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
game-block.ts | 5 | game | What the game is made with (ferret.json "game" of the package and the page's createGame): its own orbit camera and input, a pale sky, VR. | |
game.ts | 83 | install | assets, levels, player |
library#
1 files, 114 lines. Engine packages: animation, assets, game, levels, platform.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
main.ts | 114 | animation, assets, game, levels, platform |
morph#
1 files, 165 lines. Engine packages: assets, game, levels, morph, motion.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
main.ts | 165 | assets, game, levels, morph, motion |
npc#
2 files, 144 lines. Engine packages: ai, animation, character, game, physics, transform.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
level.ts | 48 | buildYard | game, physics | |
main.ts | 96 | ai, animation, character, game, physics, transform |
people#
1 files, 64 lines. Engine packages: animation, character, game, humans.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
main.ts | 64 | animation, character, game, humans |
physics#
1 files, 209 lines. Engine packages: character, game, interaction, physics, physics-electric, physics-explosions, physics-friction, physics-fx, physics-havok, physics-heat, physics-impact, physics-links, physics-liquids, physics-mechanisms, physics-media, physics-nuclear, physics-strength, physics-terrain, physics-vehicles.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
main.ts | 209 | character, game, interaction, physics, physics-electric, physics-explosions, physics-friction, physics-fx, physics-havok, physics-heat, physics-impact, physics-links, physics-liquids, physics-mechanisms, physics-media, physics-nuclear, physics-strength, physics-terrain, physics-vehicles |
pirate-fort#
28 files, 6059 lines. Engine packages: assets, clouds, core, game, levels, media, motion, platform, terrain, vfx, view, waves, weather.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
duel/chart.ts | 197 | Chart | ||
duel/deckmap.ts | 170 | Solid, DeckMap | The corvette's decks for walking on them (the owner: the world is free, the student walks the deck): the ship's own geometry laid on a grid of 0.25 m in the ship's frame (bow +Z, up +Y, metres from the keel), built once when the ship is loaded. Each cell keeps its floors (the heights of the surfaces facing up: the weather deck, a gangway, a rail's cap, the deck under the poop) and its solid spans (the heights where something stands in it: a bulkhead, a rail, a mast, a gun, a ceiling's beam). Things of the game that stand on the deck (the chart table, the posts, the mortar) are added as solids. | |
duel/demo.ts | 379 | Demo | ||
duel/gauges.ts | 72 | Gauges | ||
duel/instruments.ts | 352 | Station, Instruments | ||
duel/level1.ts | 107 | Phase, RoundPlan, Level1 | ||
duel/levels.ts | 279 | LevelCard, LEVELS, Landmark, LANDMARKS, Round1, LevelSpec, LEVEL1, stationOf, BALL_SPEED, PLAN_ORIGIN, toPlan, fromPlan, planOf, STICK, GUN_MAX_ELEVATION, rangeTable, readTable, LEVEL2, GLASS_MINUTES, LOG_SPEED, runSpeed, LEVEL3, YARD_TARGETS, MORTAR_MIN, BOMB_DRAG, LEVEL4, L5_DRIFT, L5_ROLL, L5_GUNS_LAID, runTable, L5_LEAD_IN, L5_RUN_ON, leewayOf, LEVEL5, LEVEL_SPECS | ||
duel/math.ts | 137 | P2, G, norm360, bearing, dist, dirOf, along, angleBetween, fixByBearings, elevationFor, heightAt, vertexOf, timeTo, Flight, fly, heightAtTan, tangentsFor, leadAngle, rollPhase | The math of the duel (PLAN-PIRATE-FORT stage P1): pure functions, no engine. The instruments, the gun and the checks of the game use them; the tests run them. Conventions. Places are (x, z) in metres, north is +z, east is +x. A bearing (azimuth) is in degrees from north towards east, 0 <= b < 360, the way a compass reads it and the way the ship's headings are counted in sailing.ts (there in radians). Heights are metres above the sea. | |
duel/plan.ts | 80 | DeserterPlan | ||
duel/reckoner.ts | 144 | ReckonerKeys, Reckoner, fmt | ||
duel/scene1.ts | 1106 | DuelDeps, QUARTERDECK, DuelScene | ||
duel/section.ts | 77 | SectionData, paintSection | ||
duel/sound.ts | 125 | VoiceLine, VOICE_LINES, DuelSound, SFX | media, vfx | |
duel/spyglass.ts | 192 | Spyglass | ||
duel/stick.ts | 80 | GunnerStick | ||
duel/tools.ts | 254 | ChartTools | ||
duel/underway.ts | 104 | Underway | ||
duel/units.ts | 44 | Units, YARD, UnitSystem, UNITS, toRange, fromRange, fmtRange, fmtHeight, fmtBearing | Units of the game (PLAN-PIRATE-FORT section 1): yards and feet by default, metres when switched. The scene is in metres inside; only what is shown and what the student sets goes through here. Each system has its own chart scale and its own round numbers for the tasks. | |
duel/walker.ts | 188 | DeckWalker | view | |
duel/worldui.ts | 204 | UiHit, UiHandler, unlitMaterial, Board, faceTowards, loadBitmap, drawPaper, FONT, fitText, Button, WorldUi | The game's interface lives in the world (PLAN-PIRATE-FORT section 1, VR is required): boards with text and pictures, buttons, the chart, the lobby's cards are meshes, and they are used the same way on a screen and in a headset. On a screen the mouse points (a click is a press and release without dragging, so the mouse look keeps working); in a headset the right controller's laser points and the trigger clicks. Only meshes added here are picked. | |
fort.ts | 286 | FORT_PARAMS, FortMark, GunSpot, FortInfo, buildFort | levels | |
island.ts | 150 | FORT, FORT_HALF, DITCH, BAY, PIER, ANCHORAGE, RIVER_POINTS, FALL, RIVER_LEN, riverBed, riverNear, PEAK, islandHeight, GRID, DEEP, islandGround, ground0, ground, pierShoreZ, BED, bakeBed | terrain | |
land.ts | 133 | LandLook, SPECIES, paintGround, LOWER_SLOPE, keepOut, LandView | levels, terrain | The island as a TerrainView with the library's photographic ground sets near the camera (the pattern of the Dunkirk demo's land.ts). |
lobby.ts | 89 | Lobby | ||
main.ts | 572 | assets, clouds, core, game, levels, media, motion, platform, vfx, view, waves, weather | ||
pier.ts | 63 | PierInfo, buildPier | levels | |
sailing.ts | 228 | wrap, fromHeading, forward, SailGroup, SailDef, SAILS, TOTAL_CANVAS, WIND_LIMITS, sailLevel, setSails, NO_GO, HULL_SPEED, ShipParams, SHIP, Ship, Course, AutopilotOptions, Autopilot, rudderFor | Sailing: how the seventy-four moves under its sails in the weather's wind, and an autopilot that steers it to a place and sets or furls the sails by the strength of the wind. Pure functions and small classes, no engine: the scene reads them (main.ts), the tests run them (test/sailing.test.ts). Conventions. A heading is an angle from +Z towards +X (the ship's bow is +Z, so the unit vector ahead is (sin h, cos h) in (x, z)). The wind is the vector the air moves along, (x, z), m/s, as the weather gives it; the direction it comes FROM, as a heading, is fromHeading(w). An angle to the wind is measured from the direction the wind comes from: 0 is straight into it, 180 straight before it; positive to the right of that line (starboard tack when the wind is on the right). The thrust is the one of a square rig: the apparent wind (the true wind less the ship's own motion) blows on the set canvas with a force coefficient that is zero while the apparent wind is nearer the bow than about 35 degrees (the sails are aback), grows over the beam, is greatest on a broad reach and falls on a run (the sails shade each other). Resistance is the hull's friction and wave making and rises steeply towards the hull speed. The side force heels the ship and drives it to leeward a little. | |
sea.ts | 247 | SeaOptions, SeaView | The sea of the pirate-fort sample, taken from the Dunkirk demo's sea (PLAN-DUNKIRK D2): one shader surface, a polar grid that follows the camera (fine under it, coarse far away). The vertex shader sums the Gerstner waves of the weather rung with the shoaling of shore.ts (each amplitude follows the depth under it: Green's law, then held by the depth), adds the swell the mole's faces send back, and the fragment shader shades it: Fresnel against the overcast sky, the sun's glitter, murky Channel colour that goes pale in the shallows, foam where the sum of the waves breaks (the Jacobian of the sideways move, the surf zone by the wave height over the depth), the swash band at the waterline (the water is cut where its surface falls below the sand, so the run-up and the backwash come out of the waves themselves), the foam of the ship's wash from a small texture. sea-model.ts computes the same sums on the CPU, so the ship floats on what is drawn. |
player-test#
1 files, 16 lines. Engine packages: player.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
main.ts | 16 | player |
response#
1 files, 127 lines. Engine packages: assets, flow, game, levels, physics-fx, physics-liquids, physics-response, platform, vfx.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
main.ts | 127 | assets, flow, game, levels, physics-fx, physics-liquids, physics-response, platform, vfx | The test scene of PLAN-PHYSICS-RESPONSE (R0): a flat field, a crate and the Flying Squirrel of the library hovering over it at ?h=<metres> (default 3), its propulsors published as flow sources, the flow map under it. window.ferretResponse gives the numbers to checks and shots. Not a game: no controls beyond the orbit camera. |
school-outside#
8 files, 429 lines. Engine packages: ai, character, core, game, input, interaction, levels, media, platform, player, ui.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
behaviours/index.ts | 15 | installSchoolBehaviours | core | |
behaviours/school-door.ts | 197 | SchoolDoorParams, SchoolDoor | character, core, interaction, levels | |
behaviours/school-web-view.ts | 48 | SchoolWebViewParams, SchoolWebView | core, media | |
controls.ts | 37 | actions, bindings | input | |
game-block.ts | 7 | game | ||
game.ts | 80 | install | ai, character, interaction, media, platform, player, ui | |
look.ts | 35 | Tier, applyLook | game | |
main.ts | 10 |
showcase#
10 files, 1182 lines. Engine packages: animation, character, core, game, input, interaction, levels, media, net, physics-mechanisms, platform, ui, view, zones.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
backend.ts | 79 | joinBackend | core, game, net, ui, zones | |
gearbox/hud.ts | 100 | GearboxHud | ||
gearbox/pose.ts | 33 | Vec3, specToGltf, TOP_GROUP, turnsAboutCentre, rotateAbout | How the gearbox view turns a glTF node, as pure functions (the view and the orbit test share them). The machine (spec.json, drivetrain.json, nodeAngles()) speaks in the spec's axes: Blender's, Z up. The glTF nodes the loader keeps are in glTF's axes, Y up: (x, y, z) -> (x, z, -y). A group directly under the Gearbox node has its origin on its axis (the naming contract), so it turns about its origin. A part inside a group (a planet of the differential) has its origin where the group's is, not on its own axis: it turns about its own centre, and its angle is relative to the group it rides in. | |
gearbox/rig.ts | 168 | Pedals, RigOptions, GearboxRig, followPedals, BENCH, moves, headless, scriptedDrive | physics-mechanisms | |
gearbox/scenes.ts | 205 | gearboxActions, gearboxBindings, GearboxHooks, GearboxScene, gearboxLevels | game, input, levels | |
gearbox/view.ts | 236 | ViewOptions, GearboxView | view | |
levels.ts | 96 | showcaseLevels, BOARD_HTML | game, interaction, levels, media, zones | |
main.ts | 169 | animation, character, game, interaction, levels, media, platform, ui, zones | ||
multiplayer.ts | 51 | joinNet | animation, core, game, interaction, levels, net | |
sound.ts | 45 | wavUrl, wind, hum, blip, testStream | Sounds made at run time, so the sample needs no audio files: a PCM WAV as a data URL. |
titanic-field#
13 files, 1433 lines. Engine packages: assets, core, levels, player, terrain, waves.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
bergs.ts | 296 | Built, buildBerg, buildPan, BergView | The icebergs and the broken ice, as geometry. - A berg is built the way calved glacier ice looks: an irregular outline with bays and spurs; sheer walls whose height changes round the berg (one side tall, the other low and sloping back); the walls CHISELLED by planes at two scales (3-d Voronoi cells, each cell cuts the surface with its own tilted plane), which gives the flat fracture faces with sharp arrises of real bergs, then fluted vertically; a rugged rim; a snow top rising to ridges and a peak; a keel under the water whose depth follows the floating (the freeboard is about one ninth of the whole height). The mesh is dense (up to ~100 k triangles for the biggest). - A cavity term is baked per vertex (the vertex against its smoothed neighbourhood): clefts darken and go blue, arrises catch the light. - The broken ice: 28 variants of slabs (pans with snow, chipped and wave-rounded edges) and shards (tilted bergy bits), thousands of instances, the nearest bobbing on the swell. | |
camera.ts | 31 | PhotoCameraOptions, photoCamera | A camera that behaves like a photographic one, for scenes whose shaders write linear HDR radiance: Babylon's DefaultRenderingPipeline with ACES tone mapping and an exposure, bloom of what is brighter than white (the moon, glints), animated film grain, a vignette, a touch of lens fringing, a little sharpening and 4x MSAA. Every value can be given; the defaults are the moonlit night of the Titanic field. | |
field-scene.ts | 111 | NightFieldOptions, NightField, createNightField | terrain | The whole field in one call: a moonlit night on the North Atlantic with the ice of 14 April 1912, ready for a game to put its ship and people on. createNightField(scene, camera) builds the night sky, the physically based sea with its mirror and sky probe, the pack (the terrain module's floes in the ice shader), the icebergs (built in the background, nearest first) and the broken ice, the moon's shadow and the sea smoke; update(dt) each frame moves the waves, the floating ice, the shadow square and the mist. The camera's photographic pipeline is photoCamera (camera.ts), the game's to add. World: x east, z north, y up, the still sea at y = 0. |
field.ts | 111 | SEED, PACK, LANE, START, fieldSpec, ICE_ZONE, BergSpec, bergs, nightSea, moonAt, PanSpec, pans | terrain, waves | The playing field of "Titanic": the layout of the sea, the ice field and the icebergs, as data and pure functions (no drawing), so a test and the game read the same field. World: x east, z north (the lane the ship will steam along), y up, the still sea at y = 0. The open sea lies to the south and in the middle; the ice field (pack ice of floes with leads and pressure ridges, made by the terrain module's floes) lies across the north, with its edge ragged by noise; icebergs of every size are scattered by the size law (many small, few large) over the sea and the pack, and a few named ones stand where the game wants them. |
game-block.ts | 5 | game | What the game is made with (ferret.json "game" of the package and the page's createGame): the field has its own camera and input, and VR. | |
game.ts | 139 | install | assets, core, levels, player, terrain, waves | |
glsl.ts | 73 | NOISE_GLSL, SHADOW_GLSL, MIST_GLSL, MIST_UNIFORMS, SHADOW_UNIFORMS, Night, setNight | GLSL shared by every shader of the field. All of them write LINEAR radiance (HDR, may exceed 1); the camera's rendering pipeline does the ACES tone mapping, the bloom of the moon and the glints, the film grain and the vignette, so the sea, the ice and the sky go through one exposure as a photograph does. - noise: value noise and fbm in 2 and 3 dimensions; - the moon's shadow: a depth map rendered from the moon (shadow.ts), sampled with a Poisson PCF; - the mist: exponential height fog over the water (sea smoke), thickened and thinned by drifting 3-d noise, lit by the moon with a forward-scattering phase. | |
ice-material.ts | 198 | bergMaterial, iceFieldMaterial, nightOn | What the ice looks like by moonlight, in linear HDR. One lighting model for the bergs, the broken ice and the pack: - albedo: snow (0.85) on what faces up, glacier ice (blue, 0.35..0.55) on the faces, old ice with grey bands of sediment, the blue deepening into clefts; - the moon: Lambert with the moon's shadow (shadow.ts) and a soft wrap, a GGX gloss on the wet, smooth ice faces, sparkles in the snow crystals; - subsurface light: ice is translucent, so light that enters a lit face comes out of shaded faces and clefts deep blue; thin edges glow when the moon is behind them; - the sky's ambient, darkened by the cavity term baked into the mesh (concave = occluded) and by the shadow; - the waterline: wet dark ice, a wave-cut notch, a lace of foam and slush that moves with the swell; under the water the ice goes green-blue and then black; - the surface detail: normal noise in the berg's own frame at three scales, stretched vertically on the faces (meltwater runnels and fluting). mirrorPass drops what is under the water when the sea's mirror is drawn. | |
library.ts | 111 | LibMesh, LibModel, libraryModels | terrain | The field's elements as library models (no drawing, no engine): every iceberg kind, the broken ice and a square of the pack, as plain triangle meshes with normals, a baked colour per vertex (linear: snow, glacier ice, blue clefts, the wet waterline, the keel under the water) and the cavity term the ice shader reads. tools/export-assets.mjs writes them as glb files into ../assets, and the asset library takes them from there (tools/asset-lib/ids.json ferretModels). The geometry is the same code the field draws (bergs.ts, the terrain module), so a model in the library is the berg of the game. Frame: y up, metres, the still water at y = 0 (the part below is the keel), the berg's middle at x = z = 0. |
main.ts | 9 | |||
sea.ts | 187 | SeaOptions, detailWaves, SeaView, SeaModel | waves | The open sea of the Titanic field: the sea of the Dunkirk demo (a polar grid that follows the camera, the Gerstner waves of @ferret/waves summed in the vertex shader, the same sums on the CPU for what floats) made physically based for a night in linear HDR: - the surface slope is the long waves plus a spectrum of 32 short wind waves (0.12 to 9 m) summed per pixel; a wave shorter than the pixel's footprint is not drawn but its slope variance goes into the roughness, so the moon's path is a spray of sharp sparkles at the bow and a broad soft column far away, as in a photograph; - the moon's specular is GGX with the moon's angular size, Fresnel of water (F0 = 0.02); - what the water mirrors: the sky (a floating-point probe of the dome) and, through a planar mirror, the bergs and the pack, shaken by the ripples and blurred by the roughness; - the body of the deep North Atlantic at night is almost black; a little light comes back up through the crests; - foam: where the sum of the waves folds and where the water washes the ice; the mist (glsl.ts) over all of it. |
shadow.ts | 75 | MoonShadow | The moon's shadow: a depth map of the bergs and the broken ice seen from the moon (an orthographic camera along the moonlight), 4096 texels over a square that follows the observer, so a berg shades its own clefts, the slabs at its foot and the pack behind it. The ice shaders read it with SHADOW_GLSL (glsl.ts). The depth written here is the same expression the readers compute from shadowMatrix, so no engine depth convention is involved. | |
sky.ts | 87 | SkyDome | The night sky of the Titanic field, in linear HDR (the pipeline tone-maps it with everything else): a clear, cold sky (the night of 14 April had no cloud and no wind). The colour runs from the faint airglow at the horizon to the black-blue zenith; stars of four magnitude classes, sharp points bright enough to bloom; the Milky Way as a faint, dusty band with dark lanes; the moon as a disc thousands of times brighter than the sky, with its maria, and a faint aureole of the air round it; the sea smoke thickening towards the horizon (the same mist as on the water). The sea mirrors this dome through a floating-point probe. |
vfx#
1 files, 170 lines. Engine packages: game, media, vfx.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
main.ts | 170 | game, media, vfx |
wabi-sabi#
7 files, 274 lines. Engine packages: ai, character, core, game, input, platform, player, ui.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
controls.ts | 37 | actions, bindings | input | |
game-block.ts | 7 | game | ||
game.ts | 106 | install | ai, character, platform, player, ui | |
hotspots.ts | 25 | Hotspot, HOTSPOTS, goTo, mountSpots | core | |
look.ts | 13 | applyLook | game | |
main.ts | 10 | |||
plan.ts | 76 | PlanOptions, mountPlan | The floor plan: the level's meshes seen from above (their bounding boxes in x and z, walls dark, low furniture light), a dot for the visitor with the way they face, and a click that takes them there. It needs no data of its own: it is drawn from the scene. |
weather#
4 files, 482 lines. Engine packages: animation, assets, character, clouds, core, flow, game, levels, physics, physics-friction, physics-gravity, physics-media, physics-vehicles, platform, terrain, weather.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
land.ts | 124 | BEACH_Z, headland, RIVER_Z, riverZ, RIVER_W, landscape, ground, grassy, buildLand | levels, terrain | |
look.ts | 4 | moved to examples/_shared: the airwar and zeppelin samples use the same look of the sky | ||
main.ts | 350 | animation, assets, character, clouds, core, flow, game, levels, physics, physics-friction, physics-gravity, physics-media, physics-vehicles, platform, terrain, weather | ||
sky.ts | 4 | moved to examples/_shared: the airwar and zeppelin samples use the same sky dome |
zeppelin#
23 files, 2310 lines. Engine packages: animation, clouds, core, levels, physics-vehicles, player, terrain, weather, xr.
| File | Lines | Exports | Engine | What it is |
|---|---|---|---|---|
daynight.ts | 87 | DAY_SECONDS, DAY_SHARE, SunState, sunState, Sky | Day and night (PLAN-ZEPPELIN 14.2b): one game day is 120 s of game time, the day (sunrise to sunset) twice as long as the night: phase p in 0..1, the sun is up for p < 2/3 (80 s) and the moon for the rest (40 s). The clock reads 06:00 at sunrise and 22:00 at sunset (the day takes 16 h). sunState is pure; Sky owns the sun, the moon and the stars (billboards and a star dome that follow the camera). | |
details.ts | 113 | Details, addDetails | physics-vehicles | Details of the zeppelin (PLAN-ZEPPELIN 14.2a): the windows of the control car, the cowl louvres, radiator, exhaust and spinner of the four engine cars, the blur disc of each propeller and the navigation lights. Generated in code and parented to the ship's body frame (x right, y up, z bow), so they move with the physics pose. Only Babylon here. |
dom.ts | 15 | ui, $, assets, loadContainer, BUILD | core | |
fighters-ai.ts | 59 | Plane, Orbit, Aim, Brief, Keepout, Limits, LIMITS, nearestOnSegment, stepPlane | The flying of the escort fighters (pure: no Babylon). A plane is a point with a heading, a pitch, a bank and a speed; the pilot gives it an orbit about a moving centre or an aim point, and the plane banks into its turns (the turn rate is g tan(bank) / v, so a plane at 75 m/s and 45 degrees of bank turns in a 570 m circle), climbs and dives within limits, and keeps a floor of height over the ground ahead of it and a distance from the airship's hull. | |
game-block.ts | 5 | game | What the game is made with (ferret.json "game" of the package and the page's createGame): it reads the keys and the mouse itself; VR is on (the stage that follows the ship is set by the game). | |
game.ts | 527 | liteFor, install | clouds, physics-vehicles, player, terrain, weather, xr | |
look.ts | 118 | Vec3, skyColor, skyCube, skyDome, coverUVs, CoverSpec, coverMaterial | The look of the zeppelin demo (PLAN-ZEPPELIN 14.2): the sky and its environment, the silver cover with its seams and lettering, the sun and the shadow of the ship, and the clouds. Only Babylon here, no physics. Everything is generated: there is no texture file. | |
main.ts | 14 | |||
world/airfield/config.ts | 16 | SITE, RUNWAY, TAXI, FIELD, SPOTS | ||
world/airfield/geo.ts | 94 | V3, RGB, WHITE, Geo, Frame, box, cylinder, pipe, post, mix3, rnd | Small geometry builder for the airfield's own constructions (pavements, buildings, fences): vertices in world metres, UVs in metres over the texture's tile (so a brick is a brick on every wall), one Geo per material, merged into one mesh each. Frame places local coordinates (x along the building's width, z along its depth, y up) in the world with a yaw. | |
world/airfield/index.ts | 18 | buildAirfield | levels | |
world/airfield/layout.ts | 65 | Rect, rect, FILLET, PAVED, Hangar, HANGARS, TOWER, FUEL, NISSEN, Parked, PARKED, R22_SPOT, PERIMETER, ROAD, CAR_STOP, WALK, EDGE_STEP, inRect, onPavement | ||
world/airfield/mats.ts | 45 | TILE, Mats, decalMaterial | levels | |
world/airfield/surfaces.ts | 190 | Surfaces, buildSurfaces | ||
world/airfield/textures.ts | 150 | asphaltTexture, slabOverlay, tarmacOverlay, corrugationNormal, sandbagTexture, chainLinkTexture, paintTexture, numeralTexture, laneTexture, blobTexture | ||
world/animals.ts | 217 | Animals | animation | The herds (PLAN-ZEPPELIN 14.3): cattle, sheep and goats in herds and now and then a lone horse, all characters of the asset library (copied by checks/export_animals.py). Herds are placed by a hash per 1 km cell from the biome rules (cattle and sheep on meadow and fields, goats on the high slopes, horses rare and single), spawned when the ship is within about 1.2 km and under 700 m above the ground, at most 40 animals at once, and wander slowly; near the ship's engines low down they run away. Each model is loaded once, on demand, and cloned with its skeleton. |
world/authored.ts | 117 | HALF, SEA, hash2, noise2, fbm, Lake, AIRFIELD, LAKES, farmAmount, forestAmount, RGB, airfieldDist, groundColour, groundPaint | The zone (PLAN-ZEPPELIN 14.3): a square of 100 x 100 km centred on the origin, procedural and deterministic (no data files). Pure functions: the lakes, the airfield, and how much of the ground is farm and forest. The ground itself is a landscape of @ferret/terrain (landscape.ts); the terrain view, the ground physics, the scatter of trees and the animals all read it through groundHeight (height.ts). | |
world/buildings.ts | 68 | Buildings, addBuildings | The buildings below (PLAN-ZEPPELIN 14.3): the fortress cut from the School Outside level (assets/buildings/castle.glb, made by checks/export_castle.py): its real walls, towers and keeps with their textures, laid out as in that level. One copy by the strip, more on open ground (world/sites.ts). | |
world/fighters.ts | 106 | ShipState, Fighters | Twelve Mitsubishi A6M5 Zero fighters of the asset library (a6m5-zero: the model and its gear clips), flown by a small pilot AI (fighters-ai.ts) as three flights of four about the airship: each flight circles it at its own radius, height and sense, and now and then one flight makes a pass along the ship. The gear is drawn up (the library's retraction clips, played once from the start), the propeller turns with the bone of the model. | |
world/forest.ts | 202 | Forest | The forest (PLAN-ZEPPELIN 14.3): thin instances of the library's spruce near the camera, a conifer and a broadleaf tree made in code farther out (the library has one spruce and no broadleaf), placed by a hash per cell from the same ground function and forest rules as the terrain colour. No tree ever pops: every tree has a draw distance of its own from its random rank u (the share of trees still drawn at distance d is (900 / d)^2, as the old density rings gave), kept in the alpha of its instance colour, and the shader dissolves it (a dither) over the last fifth of that distance. The near spruce and the far cone of the same tree cross-dissolve at 340 to 420 m. The instance buffers are cut again every 25 m of travel, with a margin. | |
world/height.ts | 10 | landscape, groundHeight | ||
world/landscape.ts | 43 | buildZone | terrain | The zone as a @ferret/terrain Landscape made from a description: a rolling plain of 150 to 450 m (noise), the lakes (pond: a bowl with a water level of its own and a ragged shore), the flat of the airfield, and a closed ring of mountains in the outer 12 km (ridged noise along a mask on the border) with crests bent by a warp of the domain (the erosion of so wide a ring is too slow to make while flying; at 30 km in the haze it would not show). The heights, the water, the biomes and the colours all come from it. |
world/sites.ts | 31 | Site, CASTLE_CENTRE, SITES | Where the fortresses stand (pure, deterministic): one beside the airfield's strip and a handful on level, open ground farther out. The forest keeps clear of them, the buildings module puts the library's castle on them. |