@ferret/physics-response
Classes
AirCushion class
class AirCushionreadonly halfX: number | |
readonly halfZ: number | |
readonly corner: number | |
gap: number | |
readonly rho: number | |
readonly cd: number | |
readonly edge: number | |
x: number | |
z: number | |
yaw: number | |
force: number | |
constructor(o: CushionOptions) | |
place(x: number, z: number, yaw: number, force: number): void | where the craft is, which way it points (yaw: forward = (sin, cos)) and the force the cushion carries, N |
get area(): number | the footprint's area, m2 |
get pressure(): number | the pressure of the air under the craft above the outside air, Pa |
get escape(): number | the speed of the air leaving through the gap, m/s |
edgeAt(x: number, z: number): { d: number; nx: number; nz: number } | the signed distance from the footprint's edge (negative inside) and the outward direction there (world x, z) |
perimeter(n: number): Array<{ x: number; z: number; nx: number; nz: number; length: number }> | n points evenly along the skirt's edge, with the outward direction and the length of edge each stands for (world x, z), for the host to place effects on |
pressureAt(x: number, z: number): number | the pressure on the water at x, z, Pa: the cushion's inside the footprint, falling to zero over edge at its border |
airAt(x: number, z: number): [number, number] | the air along the surface outside the skirt at x, z, m/s (zero under the craft): the wall jet of the air that left through the gap |
packages/physics-response/src/cushion.ts:22
BedWash class
class BedWashreadonly size: number | |
readonly cell: number | |
origin: [number, number] | |
readonly height: number | |
readonly dh: Float64Array | the change of the bed's height this step, m |
readonly load: Float64Array | |
readonly theta: Float64Array | |
lost: number | |
constructor(o: BedWashOptions) | |
step(dt: number, at: (x: number, z: number) => BedCell): void | |
netVolume(porosity = 0.4): number | the volume of solid the height changes add up to, m3 (zero while nothing leaves the grid) |
packages/physics-response/src/bedwash.ts:12
FlakePool class
class FlakePoolreadonly flakes: Flake[] | |
constructor(readonly world: FlakeWorld, seed = 1) | |
add(x: number, z: number, kind: FlakeKind, o: { wet?: number; y?: number } = {}): Flake | |
static liftOff(k: FlakeKind, wet = 0): number | the lift-off speed of a flake (the law), m/s along the ground |
static regime(k: FlakeKind) | the regime of a flake's fall |
static terminal(k: FlakeKind) | the terminal velocity of a flake in still air, m/s (positive down) |
step(dt: number, t: number): void |
packages/physics-response/src/flakes.ts:17
FlowMap class
class FlowMapreadonly size: number | |
readonly cell: number | |
readonly lowHeight: number | |
readonly highHeight: number | |
readonly publisher: string | |
readonly deflect: number | |
readonly data: Float32Array | the grid: size*size cells of FLOW_MAP_CHANNELS floats, row z, column x |
originX: number | the world x, z of the grid's corner (cell 0,0) as of the last update |
originZ: number | |
active: boolean | true when the last update found any motion at all: the draw code may skip the map when it is false |
peak: number | the fastest speed in the map (m/s) at the last update |
version: number | incremented at every update: a texture uploads when it changed |
constructor(o: FlowMapOptions = {}) | |
get extent(): number | the width of the covered square, metres |
update(field: FlowField, cx: number, cz: number, t: number, stride = 1): void | fill the grid round (cx, cz) at time t; the origin snaps to whole cells so a static source does not shimmer while the centre moves |
sample(x: number, z: number, heightAboveGround = this.lowHeight): [number, number] | the horizontal velocity of the map at a world point and height above the ground, bilinear in the grid, blended between the layers; zero outside |
packages/physics-response/src/flowmap.ts:28
FlowMapService class
class FlowMapServicethe flow map as a world service named flow-map: the level loader hands it to the foliage-wind plugin of the level it loads
readonly name: "flow-map" | |
constructor(readonly map: FlowMap) |
packages/physics-response/src/flowmap.ts:98
GroundWash class
class GroundWashreadonly size: number | |
readonly cell: number | |
origin: [number, number] | |
readonly height: number | |
readonly dh: Float64Array | the change of the ground's height this step, m (positive: deposit), per cell, row z |
readonly flux: Float64Array | the flux that leaves each cell, kg/m/s, and its friction velocity and threshold (for tests and the inspector) |
readonly ustar: Float64Array | |
readonly threshold: Float64Array | |
lost: number | the mass blown off the grid in all steps so far, kg (the edge cells' outflow) |
constructor(o: GroundWashOptions) | |
step(dt: number, at: (x: number, z: number) => GroundCell): DustEvent[] | one step: fill dh; returns the dust thrown up. at(x, z) gives the air and the grains of a cell. |
netMass(bulk: number): number | the mass the height changes of this step add up to over the grid, kg, with the bulk density given (zero when nothing left the grid) |
packages/physics-response/src/ground.ts:13
PhysicsResponseService class
class PhysicsResponseServiceThe overrides of the game. source(id).set({ on, scale }); material(name).set(block | false); law(class, impl); the events response:* a game may handle and cancel. A game that sets nothing gets the defaults.
readonly name: "physics-response" | |
constructor(private emit?: (name: string, payload: unknown) => void) | |
source(id: string) | |
sourceScale(id: string): number | the multiplier of a source: 0 when it is off |
material(name: string) | |
responseOf(m: MaterialInfo & { response?: ResponseBlock | false }): ResponseBlock | false | the response of a material: the game's block, else the material's own, else the derived one |
law(cls: ResponseClassName, impl: LawImpl): void | |
lawOf(cls: ResponseClassName): LawImpl | undefined | |
on<K extends ResponseEventName>(name: K, fn: (e: ResponseEvents[K]) => void): () => void | |
raise<K extends ResponseEventName>(name: K, e: Omit<ResponseEvents[K], 'cancel'>): boolean | raise an event; returns false when a handler cancelled it (the engine then does not do the default) |
packages/physics-response/src/registry.ts:97
PropulsorSet class
class PropulsorSetreadonly states: Map<string, PropulsorState> | |
scale: number | |
constructor(readonly field: FlowField, private o: PropulsorSetOptions) | |
add(init: PropulsorInit): void | |
remove(id: string): void | |
jetName(id: string) | the name of a propulsor's jet source in the field, and of its wall jet |
wallName(id: string) | |
thrustOf(it: PropulsorInit): { thrust: number; fromActuator: boolean } | the thrust of one propulsor: from the actuator when the physics gives it, else its share of the weight in hover |
update(): void | Publish the jets of every propulsor as they are now. Call once a step, after the actuators have run. |
dispose(): void | take every source of the set out of the field |
packages/physics-response/src/propulsors.ts:57
ResponseBudget class
class ResponseBudgetreadonly name: "response-budget" | |
constructor(private o: ResponseBudgetOptions = {}) | |
get mapEvery(): number | run the map's raster every this many frames |
get mapStride(): number | ask the field at every this many cells of the map each way (FlowMap.update stride) |
get waterStride(): number | ask the field at every this many cells of the water's grid and fill the rest by the nearest |
get groundEvery(): number | step the ground wash every this many frames |
get flakeShare(): number | the share of the flakes stepped each frame, 0..1 (the others keep their place this frame) |
level(id: 'map' | 'water' | 'ground' | 'flakes'): number | |
qualityKnobs(): QualityKnob[] |
packages/physics-response/src/budget.ts:8
SprayEmitter class
class SprayEmitterconstructor(private o: SprayOptions = {}) | |
update(dt: number, samples: SpraySample[]): SprayEvent[] | the events of dt seconds over the samples |
packages/physics-response/src/spray.ts:23
WaterResponseMap class
class WaterResponseMapreadonly size: number | |
readonly cell: number | |
originX: number | |
originZ: number | |
readonly data: Float32Array | |
active: boolean | |
version: number | |
readonly rings: RingField | the centimetre rings of drops and bodies falling in (drawn per pixel by the water shader from these sources; the grid keeps the coarse waves) |
time: number | the clock of the rings (s), advanced by update |
constructor(readonly surface: WaterSurface, o: WaterResponseOptions = {}) | |
update(dt = 0, wind?: WindOver): void | copy the surface into the grid (call after surface.step); the map is inactive while the surface is flat |
packages/physics-response/src/waterview.ts:21
WaterResponseService class
class WaterResponseServicethe water's response map as a world service named water-response
readonly name: "water-response" | |
constructor(readonly map: WaterResponseMap) |
packages/physics-response/src/waterview.ts:70
Functions
airOnWater function
function airOnWater(field: FlowField, surface: ForcedSurface, t: number, o: WaterForcingOptions = {}): (x: number, z: number) => [number, number, number]the forcing function of the air on a water surface at time t, for surface.forcing(...)
packages/physics-response/src/water.ts:27
bedLoad function
function bedLoad(theta: number, thetaC: number, d: number, rhoS = RHO_SAND, rho = RHO_WATER): numberbed load, m2/s of solid volume per metre of width, Meyer-Peter and Muller: q = 8 (theta - theta_c)^1.5 sqrt((s - 1) g d^3)
packages/physics-response/src/laws/bed.ts:24
bedOf function
function bedOf(m: MaterialInfo): ResponseBlockthe bed class of a ground material, for the water side (the same grain as its wind side)
packages/physics-response/src/registry.ts:82
bedShear function
function bedShear(u: number, z: number, d: number, rho = RHO_WATER): numberthe bed shear stress of a flow of speed u at height z over a bed of grain d: tau = rho (kappa u / ln(z / z0))^2, z0 = d / 30
packages/physics-response/src/laws/bed.ts:8
breakingSpeed function
function breakingSpeed(d: number, L: number, strength: number, cd = 1.0, rho = RHO_AIR): numberthe wind speed at which a uniformly loaded round stem (diameter d, length L, drag per length 1/2 rho Cd d v^2) breaks at its root: sigma_u = M c / I with M = w L^2 / 2
packages/physics-response/src/laws/slender.ts:25
cantileverFrequency function
function cantileverFrequency: (L: number, E: number, I: number, massPerLength: number) => numberthe first natural frequency of a cantilever, Hz: (1.875^2 / 2 pi) sqrt(EI / (m' L^4)), m' the mass per length
packages/physics-response/src/laws/slender.ts:19
cantileverTipPoint function
function cantileverTipPoint: (F: number, L: number, E: number, I: number) => numberthe tip deflection of a cantilever of length L: point load at the tip F L^3 / 3EI; uniform load w (N/m) w L^4 / 8EI
packages/physics-response/src/laws/slender.ts:16
cantileverTipUniform function
function cantileverTipUniform: (w: number, L: number, E: number, I: number) => numberpackages/physics-response/src/laws/slender.ts:17
capillaryHold function
function capillaryHold: (wet: number, gap?: number, gamma?: number) => numberthe capillary pressure that holds a wet flake to a surface: 2 gamma / gap, scaled by the wet share (0 dry .. 1 wet)
packages/physics-response/src/laws/flakes.ts:17
columnHeight function
function columnHeight: (v: number, D: number, a?: number) => numberthe height of the Worthington column rising from the closing cavity: H = a D sqrt(Fr) = a v sqrt(D / g), a = 0.5 (a tunable fit of the order of magnitude of the experiments)
packages/physics-response/src/laws/liquid.ts:21
craterRadius function
function craterRadius: (E: number) => numberthe radius of the crater an impact of energy E makes: R = 0.5 (E / rhoW g)^(1/4) (the scaling water.splash uses)
packages/physics-response/src/laws/liquid.ts:17
cushionSpray function
function cushionSpray(c: AirCushion, n: number, water: (x: number, z: number) => number | null, carrier: [number, number, number], law: SprayLaw = {}): DropletEmitter[]The shedding lines of a cushion's skirt over water: n pieces of the edge, each where water(x, z) gives a level (else none), at the escape speed of the cushion through its gap; carrier is the craft's velocity.
packages/physics-response/src/spray-droplets.ts:54
dentDepth function
function dentDepth: (q: number) => numberthe depth of the dent a steady pressure q makes in a still surface: q / (rhoW g)
packages/physics-response/src/laws/liquid.ts:13
deriveResponse function
function deriveResponse(m: MaterialInfo): ResponseBlock | falsethe response a material has when it carries no block: from what it is and its numbers
packages/physics-response/src/registry.ts:63
dimensionlessGrain function
function dimensionlessGrain: (d: number, rhoS?: number, rho?: number, nu?: number) => numberthe dimensionless grain size D* = d (g (s - 1) / nu^2)^(1/3)
packages/physics-response/src/laws/bed.ts:15
dropEnergy function
function dropEnergy: (speed: number) => numberdrop energy at an air speed: half a 0.2 g drop at that speed
packages/physics-response/src/spray.ts:21
fallRegime function
function fallRegime: (massRatio: number) => "flutter" | "tumble"'flutter' (a light, wide plate: side to side), 'tumble' (a heavy one: end over end)
packages/physics-response/src/laws/flakes.ts:15
firstToGo function
function firstToGo: (b: RestingBody, rho?: number) => { speed: number; mode: "slide" | "tip"; }which comes first
packages/physics-response/src/laws/rigid.ts:10
floatDrift function
function floatDrift(current: [number, number], dir: [number, number], a: number, k: number, immersion = 0): [number, number]the drift of a float on a regular wave of amplitude a and wave number k with a current: its velocity is the current plus the Stokes drift at its depth (a float rides the surface, depth 0)
packages/physics-response/src/bedwash.ts:48
flutterFrequency function
function flutterFrequency: (v: number, d: number, st?: number) => numberthe flutter frequency of a leaf or a stem of width d in a flow v: f = St v / d, St = 0.2
packages/physics-response/src/laws/slender.ts:21
frictionVelocity function
function frictionVelocity: (u: number, z: number, z0: number) => numberthe friction velocity of a flow of speed u at height z over a rough surface of roughness length z0: u* = kappa u / ln(z / z0)
packages/physics-response/src/laws/granular.ts:11
grainRoughness function
function grainRoughness: (d: number) => numberthe roughness length of a bed of grains of diameter d: z0 = d / 30 (Nikuradse)
packages/physics-response/src/laws/granular.ts:13
groupSpeed function
function groupSpeed: (k: number) => numberthe group speed d omega / d k: where the rings run
packages/physics-response/src/laws/liquid.ts:26
impactFroude function
function impactFroude: (v: number, D: number) => numberthe Froude number of an impact of a body of diameter D at speed v: Fr = v^2 / (g D)
packages/physics-response/src/laws/liquid.ts:19
impactOnWater function
function impactOnWater(surface: DisturbableSurface, i: Impact): ImpactResultpackages/physics-response/src/impact.ts:11
isbashSpeed function
function isbashSpeed: (D: number, rhoS?: number, rho?: number, C?: number) => numberthe speed a stone of diameter D starts to move at (Isbash): V_c = C sqrt(2 g D (rhoS - rho) / rho), C = 0.86 exposed .. 1.2 embedded
packages/physics-response/src/laws/bed.ts:33
jetFlux function
function jetFlux(j: HotJet, r: number): { h: number; flux: number }the heat transfer coefficient (W/m2/K) and the flux (W/m2) at radius r from the stagnation point; zero when the jet meets no surface
packages/physics-response/src/melt.ts:8
jetHeatTransfer function
function jetHeatTransfer(v: number, D: number, r: number, H: number, k = K_AIR, nu = NU_AIR): numberthe heat transfer coefficient h = Nu k / D, W/m2/K, of a jet of exit speed v and diameter D at the radius r on a surface H away
packages/physics-response/src/laws/heat.ts:12
jetOf function
function jetOf(d: ModelPropulsor, thrust: number): { velocity: number; diameter: number }The jet of a propulsor of thrust T: an open rotor or propeller of disc area A has the induced velocity v_i = sqrt(T / 2 rho A) at the disc and a wake of twice that over half the area (momentum theory); a ducted fan, a nozzle and an exhaust leave at v_e = sqrt(T / rho A_e).
packages/physics-response/src/propulsors.ts:48
liftOffSpeed function
function liftOffSpeed(p: LiftOff, rho = RHO_AIR): { lift: number; slide: number; start: number }the wash speed that lifts a lying piece: 1/2 rho v^2 Cl = sigma g + hold; it slides at 1/2 rho v^2 Cd = mu (sigma g + hold) with Cd for the edge of a plate; the smaller is the speed it starts to move at
packages/physics-response/src/laws/flakes.ts:20
martinNusselt function
function martinNusselt(Re: number, r: number, D: number, H: number, Pr = PR_AIR): numberMartin's correlation, Nu = Pr^0.42 F(Re) G(r/D, H/D) with F = 2 sqrt(Re) sqrt(1 + 0.005 Re^0.55), G = (D/r)(1 - 1.1 D/r) / (1 + 0.1 (H/D - 6) D/r); r the radius from the stagnation point, H the nozzle height; valid 2000 < Re < 400000, 2.5 < r/D < 7.5, 2 < H/D < 12 (used beyond as the same trend)
packages/physics-response/src/laws/heat.ts:6
meltRate function
function meltRate: (h: number, dT: number) => numberthe melt rate of ice or snow at the melting point under a flux h dT, kg/m2/s
packages/physics-response/src/laws/heat.ts:17
moistureFactor function
function moistureFactor(wetPercent: number): numberthe factor wet grains raise the threshold by (Hotta et al.): 1.8 + 0.6 log10(w), w the gravimetric moisture in percent, rising from 1 at dry
packages/physics-response/src/laws/granular.ts:20
nearestSurface function
function nearestSurface: (...qs: SurfaceQuery[]) => SurfaceQueryThe nearest of several surface queries.
packages/physics-response/src/surface.ts:27
orbitalSpeed function
function orbitalSpeed: (a: number, k: number, depth?: number) => numberthe orbital speed at the surface of a deep water wave of amplitude a and wave number k: a omega; and the Stokes drift omega k a^2 (decaying as exp(2 k z) with depth z below the surface)
packages/physics-response/src/laws/liquid.ts:30
phaseSpeed function
function phaseSpeed: (k: number) => numberpackages/physics-response/src/laws/liquid.ts:24
planeSurface function
function planeSurface(y: number, kind: SurfaceHit['kind'] = 'ground', material?: string): SurfaceQueryA horizontal plane as a surface (the still water, a flat floor) for tests and simple scenes.
packages/physics-response/src/surface.ts:18
plateMassRatio function
function plateMassRatio: (rhoS: number, h: number, d: number, rho?: number) => numberthe dimensionless mass of a plate of density rhoS, thickness h, diameter d in a fluid of density rho: I* = rhoS h / (rho d)
packages/physics-response/src/laws/flakes.ts:11
ringWaveNumber function
function ringWaveNumber: (R: number) => numberthe wave number a ring of crater radius R is carried by: k = pi / R
packages/physics-response/src/laws/liquid.ts:28
rootStress function
function rootStress: (M: number, d: number) => numberthe root bending stress of a round stem of diameter d under the moment M: sigma = M (d / 2) / I
packages/physics-response/src/laws/slender.ts:23
roundSecondMoment function
function roundSecondMoment: (d: number) => numberthe second moment of area of a round section of diameter d
packages/physics-response/src/laws/slender.ts:14
saltationFlux function
function saltationFlux(ustar: number, ustarT: number, d: number, rho = RHO_AIR, C = 1.8): numberthe saltation flux, kg per metre of width per second: q = C sqrt(d / D) (rho / g) u*^3 (1 - (u*_t / u*)^2) above the threshold, else 0 (Bagnold; the bracket makes it vanish at the threshold)
packages/physics-response/src/laws/granular.ts:26
settlingVelocity function
function settlingVelocity(d: number, rhoS = RHO_SAND, rho = RHO_WATER, nu = NU_WATER, C1 = 18, C2 = 0.4): numberthe settling velocity of a natural grain (Ferguson and Church 2004): w = (s - 1) g d^2 / (C1 nu + sqrt(0.75 C2 (s - 1) g d^3)), C1 = 18, C2 = 0.4
packages/physics-response/src/laws/bed.ts:28
shields function
function shields: (tau: number, d: number, rhoS?: number, rho?: number) => numberthe Shields parameter of a shear stress: tau / ((rhoS - rho) g d)
packages/physics-response/src/laws/bed.ts:22
shieldsCritical function
function shieldsCritical(d: number, rhoS = RHO_SAND, rho = RHO_WATER, cohesion = 0): numberthe critical Shields parameter (Soulsby and Whitehouse 1997): 0.30 / (1 + 1.2 D*) + 0.055 (1 - exp(-0.020 D*)); cohesion raises it (clay) by the factor 1 + cohesion
packages/physics-response/src/laws/bed.ts:17
slenderDrag function
function slenderDrag(v: number, area: number, cd = 1.0, rho = RHO_AIR, psi = 0, vRef = 1): numberdrag of a slender thing: F = 1/2 rho Cd A v^2, with Vogel's reconfiguration: beyond vRef the drag grows as v^(2+psi) (psi in -1..0; 0: rigid)
packages/physics-response/src/laws/slender.ts:7
slidingSpeed function
function slidingSpeed: (b: RestingBody, rho?: number) => numberthe speed at which the drag passes the friction: 1/2 rho Cd A v^2 = mu m g
packages/physics-response/src/laws/rigid.ts:6
snowMelted function
function snowMelted(j: HotJet, r: number, dt: number, depth: number, rho = 300): numberthe depth of snow (density rho, kg/m3) melted in dt seconds at radius r: flux dt / (rho L), limited by what is there
packages/physics-response/src/melt.ts:14
soilToMaterial function
function soilToMaterial(name: string, s: SoilLike, moisture = 0): MaterialInfoa soil as a ground material: its grains and its glue, at a moisture 0..1 (the gravimetric share is taken as the moisture of the column)
packages/physics-response/src/registry.ts:144
speciesToMaterials function
function speciesToMaterials(s: SpeciesLike): { limb: MaterialInfo; leaf: MaterialInfo | undefined }a tree as the plant material of its crown limbs (a twig of a tenth of the breast diameter) and the flake of its fallen leaves
packages/physics-response/src/registry.ts:150
sprayDiameter function
function sprayDiameter(u: number): numberthe median diameter the drops leave with at air speed u: ligaments twice the Weber-stable size, at most 1.2 mm (the bulk of spray is fine: the big drops of a gale are the tail of the distribution, the log-normal sigma)
packages/physics-response/src/spray-droplets.ts:39
sprayFlux function
function sprayFlux(u: number, delta: number, law: SprayLaw = {}): numberthe volume flux per metre of line (m^3/s/m) of air at speed u over water through a layer delta thick
packages/physics-response/src/spray-droplets.ts:31
stokesDrift function
function stokesDrift: (a: number, k: number, depth?: number) => numberpackages/physics-response/src/laws/liquid.ts:31
stokesSettling function
function stokesSettling: (d: number, rhoP: number, rho?: number, nu?: number) => numberthe settling speed of dust of diameter d by Stokes' law (small grains): w = (rhoP - rho) g d^2 / (18 rho nu)
packages/physics-response/src/laws/granular.ts:31
stoneMoves function
function stoneMoves: (speed: number, D: number, rhoS?: number, C?: number) => booleandoes a flow of this speed move a stone of this diameter (Isbash)?
packages/physics-response/src/bedwash.ts:45
terminalVelocity function
function terminalVelocity: (sigma: number, rho?: number, cd?: number) => numberthe terminal velocity of a plate of mass per area sigma falling flat: v = sqrt(2 sigma g / (rho Cd))
packages/physics-response/src/laws/flakes.ts:9
thresholdFrictionVelocity function
function thresholdFrictionVelocity(d: number, rhoP: number, rho = RHO_AIR, cohesion = false): numberBagnold's threshold friction velocity of grains of diameter d and density rhoP: u*_t = A sqrt((rhoP - rho) / rho g d); with cohesion the interparticle force adds gamma / (rho d) under the root
packages/physics-response/src/laws/granular.ts:15
thrustOfForce function
function thrustOfForce: (force: V3 | undefined, on?: boolean) => number | undefinedThe thrust an actuator state gives: the length of its force. For PropulsorInit.thrust over ActuatorsCapability.state(name).
packages/physics-response/src/propulsors.ts:119
tippingSpeed function
function tippingSpeed: (b: RestingBody, rho?: number) => numberthe speed at which the drag's moment about the downstream bottom edge passes the weight's: F h / 2 = m g w / 2
packages/physics-response/src/laws/rigid.ts:8
waterFrictionVelocity function
function waterFrictionVelocity: (tau: number) => numberthe friction velocity of the water side of a wind-driven surface: sqrt(tau / rhoWater)
packages/physics-response/src/laws/liquid.ts:11
waterImpact function
function waterImpact(map: WaterResponseMap, x: number, z: number, mass: number, speed: number): voidsomething of mass m (kg) at speed v (m/s) fell into the water at x, z now: rings from it
packages/physics-response/src/waterview.ts:67
waterlogged function
function waterlogged: (rho0: number, rhoMax: number, k: number, t: number) => numbera float that takes water: its density after time t, from rho0 toward rhoMax with the rate k (1/s)
packages/physics-response/src/laws/bed.ts:35
waveFrequency function
function waveFrequency: (k: number) => numberthe dispersion of gravity-capillary waves in deep water: omega^2 = g k + (gamma / rho) k^3
packages/physics-response/src/laws/liquid.ts:23
waveOrbit function
function waveOrbit: (a: number, k: number, depth?: number) => numberthe peak orbital speed of the same wave at the surface, m/s: what a float bobs and surges by
packages/physics-response/src/bedwash.ts:53
windDragCoefficient function
function windDragCoefficient: (u10: number) => numberthe drag coefficient of the sea surface by the wind at 10 m (Large and Pond): 1.2e-3 up to 11 m/s, then (0.49 + 0.065 U) e-3
packages/physics-response/src/laws/liquid.ts:7
windSpray function
function windSpray(map: FlowMap, water: (x: number, z: number) => number | null, o: { block?: number; max?: number; delta?: number; skip?: (x: number, z: number) => boolean } & SprayLaw = {}): DropletEmitter[]The shedding lines of the air over water from a flow map's low layer: blocks of block x block cells whose mean speed is over the onset, each a line across the flow; the strongest max are kept. delta is the thickness of the fast layer next to the water (m, default 0.1).
packages/physics-response/src/spray-droplets.ts:70
windStress function
function windStress: (u: number, rho?: number) => numberthe wind stress tau = rho C_D U^2, Pa (signed with the wind)
packages/physics-response/src/laws/liquid.ts:9
Interfaces
BedCell interface
interface BedCellu: [number, number] | |
depth: number | |
grains: BedGrains | null |
packages/physics-response/src/bedwash.ts:9
BedGrains interface
interface BedGrainsd50: number | |
density?: number | |
cohesion?: number | |
porosity?: number |
packages/physics-response/src/bedwash.ts:8
BedWashOptions interface
interface BedWashOptionssize: number | |
cell: number | |
origin: [number, number] | |
height?: number |
packages/physics-response/src/bedwash.ts:10
CushionOptions interface
interface CushionOptionshalfX: number | half-sizes of the skirt's footprint along the craft's right and forward axes, m |
halfZ: number | |
corner?: number | radius of the footprint's rounded corners, m (default a fifth of the smaller half-size) |
gap?: number | the height of the gap the air leaves through, m (default 0.05) |
rho?: number | air density, kg/m3 (default 1.225) |
cd?: number | discharge coefficient of the gap (default 0.6, a sharp-edged orifice) |
edge?: number | m over which the pressure falls to zero at the footprint's edge (default 0.3) |
packages/physics-response/src/cushion.ts:7
DisturbableSurface interface
interface DisturbableSurfacedisturb(x: number, z: number, volume: number, radius?: number): void |
packages/physics-response/src/impact.ts:7
DustEvent interface
interface DustEventat: [number, number] | |
mass: number |
packages/physics-response/src/ground.ts:11
Flake interface
interface Flakex: number | |
y: number | |
z: number | |
vx: number | |
vy: number | |
vz: number | |
kind: FlakeKind | |
wet: number | |
airborne: boolean | |
phase: number | |
age: number |
packages/physics-response/src/flakes.ts:10
FlakeKind interface
interface FlakeKindsigma: number | |
mu?: number | |
thickness?: number | |
density?: number | |
size?: number |
packages/physics-response/src/flakes.ts:9
FlakeWorld interface
interface FlakeWorldair(x: number, y: number, z: number, t: number): [number, number, number] | the air velocity at a point, m/s |
ground(x: number, z: number): number | the ground height at x, z |
solid?(x: number, y: number, z: number): boolean | true where a point is inside a solid (walls, bodies): a flake that enters it stops there |
packages/physics-response/src/flakes.ts:11
FlowMapOptions interface
interface FlowMapOptionssize?: number | cells per side (default 64) |
cell?: number | metres per cell (default 1) |
lowHeight?: number | height above the ground of the low layer (default 0.4 m) |
highHeight?: number | height above the ground of the high layer (default 3 m) |
ground?: (x: number, z: number) => number | the ground height at x, z (default flat zero) |
publisher?: string | the publisher whose sources the map shows (default 'physics-response') |
deflect?: number | a vertical jet that meets the layer's height (a crown, a roof) turns outward along it, at this share of its speed (stagnation-point flow; a wall jet leaves an impinging jet at about half; default 0: off) |
packages/physics-response/src/flowmap.ts:8
ForcedSurface interface
interface ForcedSurfacelevel: number | |
forcing(fn: ((x: number, z: number) => [number, number, number]) | null): void |
packages/physics-response/src/water.ts:24
GroundCell interface
interface GroundCellu: [number, number] | |
grains: GroundGrains | null |
packages/physics-response/src/ground.ts:9
GroundGrains interface
interface GroundGrainsd50: number | |
density: number | |
bulk?: number | |
wet?: number | |
cohesive?: boolean |
packages/physics-response/src/ground.ts:8
GroundWashOptions interface
interface GroundWashOptionssize: number | |
cell: number | |
origin: [number, number] | |
height?: number |
packages/physics-response/src/ground.ts:10
HotJet interface
interface HotJetexitVelocity: number | |
exitDiameter: number | |
hitDistance: number | null | |
excess: number |
packages/physics-response/src/melt.ts:6
Impact interface
interface Impactx: number | |
z: number | |
mass: number | |
speed: number | |
diameter: number |
packages/physics-response/src/impact.ts:8
ImpactResult interface
interface ImpactResultenergy: number | |
craterRadius: number | |
craterVolume: number | |
columnHeight: number | |
splash: { mass: number; speed: number; energy: number } |
packages/physics-response/src/impact.ts:9
LiftOff interface
interface LiftOffsigma: number | |
mu?: number | |
wet?: number | |
cl?: number | |
cd?: number |
packages/physics-response/src/laws/flakes.ts:18
MaterialInfo interface
interface MaterialInfowhat the engine knows of a material or a surface to derive its response from; every field is optional
name?: string | |
surface?: 'ground' | 'water' | 'plant' | 'cloth' | 'flake' | 'rigid' | 'stone' | 'float' | what the thing is: a ground layer, a water surface, a plant, cloth, a loose flake, a rigid body |
density?: number | |
youngs?: number | |
strength?: number | |
d50?: number | a grain size, m (soil, sand, gravel) and the share of fines 0..1 |
fines?: number | |
cohesion?: number | |
wet?: number | |
diameter?: number | a plant's stem or leaf: diameter, length, mass per length or per area |
length?: number | |
sigma?: number |
packages/physics-response/src/registry.ts:10
PropulsorInit interface
interface PropulsorInitid: string | |
def: ModelPropulsor | |
pose: () => PropulsorPose | where it is now and which way it throws (the node's world transform applied to the model's position and axis) |
thrust?: () => number | undefined | the force of the running actuator on the body, N (its length is the thrust); undefined when the physics is not running |
packages/physics-response/src/propulsors.ts:15
PropulsorPose interface
interface PropulsorPosepackages/physics-response/src/propulsors.ts:14
PropulsorSetOptions interface
interface PropulsorSetOptionsgroup: string | the prefix of the names of the sources it publishes (one per model instance) |
weight?: () => number | the weight of the whole model, N (mass x g), for the hover fallback |
surface?: SurfaceQuery | |
scale?: number | the multiplier of every jet of this set (the game's override); 0 switches them all off |
onGroundEffect?: (id: string, extra: V3, at: V3) => void | a force the ground adds to the body that carries a propulsor in ground effect (CPU, feeds the fixed step): the extra thrust along the axis' opposite, N, at the point |
packages/physics-response/src/propulsors.ts:23
PropulsorState interface
interface PropulsorStateid: string | |
thrust: number | |
fromActuator: boolean | |
exitVelocity: number | the exit velocity and diameter of the jet, m/s and m |
exitDiameter: number | |
hitDistance: number | null | the surface the jet meets: its distance, or null |
groundEffect: number |
packages/physics-response/src/propulsors.ts:34
ResponseBlock interface
interface ResponseBlockclass: ResponseClassName | |
[param: string]: unknown |
packages/physics-response/src/registry.ts:20
ResponseBudgetOptions interface
interface ResponseBudgetOptions[k: string]: never |
packages/physics-response/src/budget.ts:7
ResponseClassDef interface
interface ResponseClassDefname: ResponseClassName | |
summary: string | |
defaults: Record<string, number | string | boolean> | the parameters with their defaults |
onset(block: ResponseBlock): number | the speed (m/s) at which a thing of this block first responds to a flow, the number every class can give: a game and a test read it |
packages/physics-response/src/registry.ts:22
ResponseEvents interface
interface ResponseEvents'response:break': { entity?: string; at: [number, number, number]; cause: string; cancel(): void } | |
'response:topple': { entity?: string; at: [number, number, number]; cancel(): void } | |
'response:erode': { at: [number, number, number]; volume: number; cancel(): void } | |
'response:spray': { at: [number, number, number]; energy: number; cancel(): void } |
packages/physics-response/src/registry.ts:85
RestingBody interface
interface RestingBodymass: number | |
area: number | |
cd: number | |
mu: number | |
height: number | |
width: number |
packages/physics-response/src/laws/rigid.ts:4
SoilLike interface
interface SoilLikethe shape of a physics-terrain Soil that the response reads (a structural type: this package does not depend on it)
density: number | |
cohesion: number | |
d50?: number | |
fines?: number | |
grainDensity?: number |
packages/physics-response/src/registry.ts:142
SpeciesLike interface
interface SpeciesLikethe shape of a weather TreeSpecies that the response reads
name: string | |
dbh: number | |
height: number | |
mor: number | |
mod: number | |
leaf: number | |
lma?: number | |
cd: number | |
vogel: number |
packages/physics-response/src/registry.ts:148
SprayEvent interface
interface SprayEventat: [number, number, number] | |
energy: number |
packages/physics-response/src/spray.ts:8
SprayLaw interface
interface SprayLawonset?: number | onset of spray, m/s (default 7) |
eta?: number | share of the air's momentum flux that goes into the water it throws (default 0.3) |
elevation?: number | angle the drops rise at, rad, and its spread (default 0.45, 0.25) |
elevationSpread?: number | |
parcelsPerMetre?: number | parcels per metre of line per second at the onset speed doubled (the drawing's resolution, not the physics: the volume is the same) |
life?: number | the longest a parcel lives, s (default 3) |
packages/physics-response/src/spray-droplets.ts:17
SprayOptions interface
interface SprayOptionsonset?: number | the speed where spray starts (default 7 m/s, Monahan) |
rate?: number | events per second per square metre at 10 m/s above the onset (default 0.1) |
cell?: number | the cell area of one sample, m2 |
cap?: number | at most this many events per update (default 8) |
seed?: number |
packages/physics-response/src/spray.ts:9
SpraySample interface
interface SpraySamplex: number | |
z: number | |
speed: number | |
y: number |
packages/physics-response/src/spray.ts:7
SurfaceHit interface
interface SurfaceHitWhat a ray meets: the ground, the water or a body. kind says what to ask next (the soil, the wave field, the body's material).
distance: number | distance along the ray, m |
point: V3 | the point and the normal out of the surface |
normal: V3 | |
kind: 'ground' | 'water' | 'body' | |
material?: string | the name of the material (a ground layer, water, a body's physical material), for the classes that read it |
packages/physics-response/src/surface.ts:5
WaterForcingOptions interface
interface WaterForcingOptionsheight?: number | the height above the water where the air is read (default 0.3 m) |
level?: (x: number, z: number) => number | the water level at x, z (default the surface's level) |
publisher?: string | only the sources a publisher owns (physics-response: propulsors); default all sources, the weather's wind too |
bounds?: [number, number, number, number] | a box x0, z0, x1, z1 outside which the forcing is zero and the field is not asked |
scale?: number | 0 switches the air's action on the water off |
cushion?: AirCushion | an air cushion of a craft: under its footprint the water takes the cushion's pressure (the air of its rotors goes into the cushion, it does not dent the water on its own); outside, the air that leaves under the skirt adds to the field's |
packages/physics-response/src/water.ts:10
WaterResponseOptions interface
interface WaterResponseOptionsfoamFrom?: number | height above rest (m) from which the surface shows foam (default 0.04) |
foamFull?: number | height above rest (m) at which the foam is full (default 0.14) |
whitecapOnset?: number | air speed over the water (m/s) from which foam is made, as the onset of spray (default 7, Monahan) |
foamLife?: number | seconds in which the foam fades to a third (default 2.5) |
packages/physics-response/src/waterview.ts:7
Types
LawImpl type
type LawImpl = { cpu?: (...a: number[]) => number; wgsl?: string; glsl?: string }packages/physics-response/src/registry.ts:84
ResponseClassName type
type ResponseClassName = typeof RESPONSE_CLASSES[number]packages/physics-response/src/registry.ts:8
ResponseEventName type
type ResponseEventName = keyof ResponseEventspackages/physics-response/src/registry.ts:91
SurfaceQuery type
type SurfaceQuery = (from: V3, dir: V3, maxDistance: number) => SurfaceHit | nullThe question a propulsor asks of the world: the nearest surface along a ray from from in the unit direction dir, within maxDistance, or null. The host answers from the ground query, the water surface and the physics rays.
packages/physics-response/src/surface.ts:15
WindOver type
type WindOver = (x: number, z: number) => numberthe air speed over a cell: what makes foam besides the height of the water
packages/physics-response/src/waterview.ts:19
Constants
BAGNOLD_A const
const BAGNOLD_A: 0.1packages/physics-response/src/laws/granular.ts:6
BAGNOLD_REF_GRAIN const
const BAGNOLD_REF_GRAIN: 0.00025packages/physics-response/src/laws/granular.ts:8
CLASSES const
const CLASSES: Record<"rigid" | "elastic" | "membrane" | "granular" | "flake" | "liquid-surface" | "bed" | "stone" | "floating" | "heat", ResponseClassDef>packages/physics-response/src/registry.ts:33
FLOW_MAP_CHANNELS const
const FLOW_MAP_CHANNELS: 4channels per cell: low.x, low.z, high.x, high.z
packages/physics-response/src/flowmap.ts:26
G const
const G: 9.80665packages/physics-response/src/laws/constants.ts:3
GRAVITY const
const GRAVITY: 9.80665packages/physics-response/src/propulsors.ts:12
INTERPARTICLE_FORCE const
const INTERPARTICLE_FORCE: 0.000165packages/physics-response/src/laws/granular.ts:7
K_AIR const
const K_AIR: 0.0257packages/physics-response/src/laws/constants.ts:11
KAPPA const
const KAPPA: 0.4packages/physics-response/src/laws/constants.ts:4
LATENT_FUSION const
const LATENT_FUSION: 334000packages/physics-response/src/laws/constants.ts:12
NU_AIR const
const NU_AIR: 0.0000146packages/physics-response/src/laws/constants.ts:7
NU_WATER const
const NU_WATER: 0.00000114packages/physics-response/src/laws/constants.ts:8
PLATE_CD const
const PLATE_CD: 1.17packages/physics-response/src/laws/flakes.ts:7
PR_AIR const
const PR_AIR: 0.71packages/physics-response/src/laws/constants.ts:10
RHO_AIR const
const RHO_AIR: 1.225packages/physics-response/src/laws/constants.ts:5
RHO_SAND const
const RHO_SAND: 2650packages/physics-response/src/laws/bed.ts:6
RHO_WATER const
const RHO_WATER: 1000packages/physics-response/src/laws/constants.ts:6
SPRAY_ONSET const
const SPRAY_ONSET: 7the wind speed where whitecaps and spray begin (Monahan): about 7 m/s at 10 m
packages/physics-response/src/laws/liquid.ts:15
SURFACE_TENSION const
const SURFACE_TENSION: 0.072packages/physics-response/src/laws/constants.ts:9
TUMBLE_I const
const TUMBLE_I: 1the order-of-magnitude transition between fluttering and tumbling (Field et al. 1997, Mahadevan et al. 1999): tumbling above this I*
packages/physics-response/src/laws/flakes.ts:13