Flow sources
Skill ferret-flow · download all skills · SKILL.md
When to use#
A breeze that gusts, a storm front crossing a valley, a tornado that lifts crates, a river that carries logs, a fan, the lee of a hill, wind in a sail.
The model#
Sources (uniform, front, vortex, jet, shelter, channel, curve) add up to one field flow.at(position, time, medium) for air or water. Every source is a pure function of position and time, so peers agree without replication. Bodies, vessels, the character and the render read the field; it is not a force on a body.
Steps#
- Add a
FlowServiceto the world (@ferret/flow); enablemediafor bodies to feel it. - List sources in the level's
physics.flow, oredit.physics.flow.set { name, kind, ... }. - A liquid current is a source with
medium: "water"; bodies in a liquid medium and a surface'scurrent(waterCurrent(field)) read it. - Limit cost with
reach; move a source withpath+speed; fade it withlevelcurves. - Commands:
flow.at|set|on|off|move,edit.physics.flow.set|remove|list.
Check afterwards#
flow.at at the point returns the expected velocity; a light body reaches the wind speed; a body outside a channel is not moved.
What usually goes wrong#
- Nothing moves: no
FlowService,medianot enabled, or the point is outsidereach. - A channel's
widthis a 3D distance from its line, so a body at another height than the points sees a thinner profile. - A water source with
mediummissing is air (the default). - A character is not pushed:
maxWindAccelis 0.
Flow around bodies (flow box)#
- Use
FlowBox/physics.flowBoxeswhere a body must change the wind: a tower's lee, a roof section, a pier in a river.plane: 'xz'horizontal,'xy'vertical;cellsets the cost (about 1 us per cell per step). forces: 'solved'drives rigid bodies by surface pressure (air boxes only);coefficientskeeps the media drag and uses the box for the wake.- Over
maxCellsthe box coarsens and reportsdegraded;sleepreturns the analytic field;every: nsteps it less often. - 3d boxes are not built; the box refuses
plane: "xyz"with that message.
Files#
reference/flow.md— Wind, fronts, vortices, jets, shelters and channels that add up to one field of moving air and water, a pure function of position and time that bodies, vessels, the character and the render can all read.reference/api-flow.md— every export of@ferret/flowwith signature and doc commentreference/api-flow-solver.md— every export of@ferret/flow-solverwith signature and doc commentreference/api-physics-media.md— every export of@ferret/physics-mediawith signature and doc commentreference/commands.md— 23 commands of these packages with their arguments