Vehicles: ships, submarines, balloons
Skill ferret-physics-vehicles · download all skills · SKILL.md
When to use#
Anything that floats, dives, flies on gas, or is pushed by a screw or a sail.
The model#
A Vessel (VesselSpec) is one body with parts: hull (cells), tanks, compartments (flood through breach and doors), envelopes, thrusters, surfaces (rudders, foils, sails). Draft = mass / (ρ × waterplane area). stability() gives the metacentric height gm: positive rights itself, negative rolls over.
Steps#
- Size the hull so mass matches displacement; set
coglow. - Add
hullDampingandangularDamping,addedMass0.1–1. - Submarines:
fill/blowtanks; neutral fill =(displacement − dry mass) / tank capacity;crushDepth. - Drive by
vessel.thrust, rudders, sails (sailPolar). - Commands:
vessel.add|info|state|fill|thrust|breach|blow|surface.
Wake and people aboard#
- A ship leaves a track:
ShipWakeof@ferret/levels(a white core that spreads and thins, the two arms of the Kelvin wedge) laid along the path the vessel took. It asks the pose some seconds ago; a simulated vessel keeps a short history of poses and answers from it (seeexamples/dunkirk/src/wakes.ts). Lay the rows by DISTANCE astern from the path history (so the track starts at the stern, never under the hull), put the mesh in rendering group 0 (group 1 clears depth and draws over the pier and men) and fade each row with the age of the water, exp(-age/T) with T about a minute for the core and two for the arms: a stopped ship leaves a wake that dies away in minutes and a long track ends in nothing. The flight sample (examples/airwar/src/world/ships.ts) is the reference look. - People on a vessel's deck are
Walkersstanding on aGridSupportread off her model, with her node as the frame: they are carried as she heaves, rolls and sails, and cannot stand below the deck or walk through a rail (ferret-physics-walkers).
Check afterwards#
Light and loaded drafts follow Archimedes; gm is positive; a breach floods the named compartment.
What usually goes wrong#
- Floats too high or low: mass and hull do not match.
- Rolls over:
gmnegative; lowercog, widen, empty part-filled tanks. - Never settles: no damping.
- Passes through the shore: light kernel or
body: false; use Havok. vessel.breachrefused: unknown compartment name.
Files#
reference/vehicles.md— A vessel is one body with parts: a hull that displaces water, ballast tanks, flooding compartments, gas envelopes, thrusters, rudders and sails. How to build one, drive it and read its stability.reference/api-physics-vehicles.md— every export of@ferret/physics-vehicleswith signature and doc commentreference/api-physics-vehicles-2.md— every export of@ferret/physics-vehicleswith signature and doc commentreference/commands.md— 7 commands of these packages with their argumentsrecipes/water-and-boats.md— Six recipes: tanks that equalise, a U-tube of two liquids, a wave that slows on a beach, a boat that sinks deeper with cargo, a wing that stalls, a ball that curves.