FERRETGame engine over Babylon.js
Ferret

@ferret/physics-response

142 exports · source in packages/physics-response/src

Classes

AirCushion class

class AirCushion
readonly 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): voidwhere the craft is, which way it points (yaw: forward = (sin, cos)) and the force the cushion carries, N
get area(): numberthe footprint's area, m2
get pressure(): numberthe pressure of the air under the craft above the outside air, Pa
get escape(): numberthe 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): numberthe 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 BedWash
readonly size: number
readonly cell: number
origin: [number, number]
readonly height: number
readonly dh: Float64Arraythe 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): numberthe 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 FlakePool
readonly 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): numberthe 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 FlowMap
readonly size: number
readonly cell: number
readonly lowHeight: number
readonly highHeight: number
readonly publisher: string
readonly deflect: number
readonly data: Float32Arraythe grid: size*size cells of FLOW_MAP_CHANNELS floats, row z, column x
originX: numberthe world x, z of the grid's corner (cell 0,0) as of the last update
originZ: number
active: booleantrue when the last update found any motion at all: the draw code may skip the map when it is false
peak: numberthe fastest speed in the map (m/s) at the last update
version: numberincremented at every update: a texture uploads when it changed
constructor(o: FlowMapOptions = {})
get extent(): numberthe width of the covered square, metres
update(field: FlowField, cx: number, cz: number, t: number, stride = 1): voidfill 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 FlowMapService

the 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 GroundWash
readonly size: number
readonly cell: number
origin: [number, number]
readonly height: number
readonly dh: Float64Arraythe change of the ground's height this step, m (positive: deposit), per cell, row z
readonly flux: Float64Arraythe 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: numberthe 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): numberthe 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 PhysicsResponseService

The 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): numberthe multiplier of a source: 0 when it is off
material(name: string)
responseOf(m: MaterialInfo & { response?: ResponseBlock | false }): ResponseBlock | falsethe 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'>): booleanraise 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 PropulsorSet
readonly 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(): voidPublish the jets of every propulsor as they are now. Call once a step, after the actuators have run.
dispose(): voidtake every source of the set out of the field

packages/physics-response/src/propulsors.ts:57

ResponseBudget class

class ResponseBudget
readonly name: "response-budget"
constructor(private o: ResponseBudgetOptions = {})
get mapEvery(): numberrun the map's raster every this many frames
get mapStride(): numberask the field at every this many cells of the map each way (FlowMap.update stride)
get waterStride(): numberask the field at every this many cells of the water's grid and fill the rest by the nearest
get groundEvery(): numberstep the ground wash every this many frames
get flakeShare(): numberthe 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 SprayEmitter
constructor(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 WaterResponseMap
readonly size: number
readonly cell: number
originX: number
originZ: number
readonly data: Float32Array
active: boolean
version: number
readonly rings: RingFieldthe 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: numberthe clock of the rings (s), advanced by update
constructor(readonly surface: WaterSurface, o: WaterResponseOptions = {})
update(dt = 0, wind?: WindOver): voidcopy 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 WaterResponseService

the 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): number

bed 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): ResponseBlock

the 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): number

the 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): number

the 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) => number

the 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) => number

the 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) => number

packages/physics-response/src/laws/slender.ts:17

capillaryHold function

function capillaryHold: (wet: number, gap?: number, gamma?: number) => number

the 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) => number

the 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) => number

the 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) => number

the 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 | false

the 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) => number

the 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) => number

drop 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

floatShare function

function floatShare: (rho0: number, rho?: number) => number

the share of a float of density rho0 below the surface: rho0 / rho (it floats while that is below 1)

packages/physics-response/src/laws/bed.ts:37

flutterFrequency function

function flutterFrequency: (v: number, d: number, st?: number) => number

the 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) => number

the 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) => number

the 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) => number

the 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) => number

the 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): ImpactResult

packages/physics-response/src/impact.ts:11

isbashSpeed function

function isbashSpeed: (D: number, rhoS?: number, rho?: number, C?: number) => number

the 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): number

the 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): number

Martin'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) => number

the 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): number

the 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[]) => SurfaceQuery

The nearest of several surface queries.

packages/physics-response/src/surface.ts:27

orbitalSpeed function

function orbitalSpeed: (a: number, k: number, depth?: number) => number

the 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) => number

packages/physics-response/src/laws/liquid.ts:24

planeSurface function

function planeSurface(y: number, kind: SurfaceHit['kind'] = 'ground', material?: string): SurfaceQuery

A 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) => number

the 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) => number

the 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) => number

the 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) => number

the 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): number

the 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): number

the 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) => number

the 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): number

the 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): number

drag 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) => number

the 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): number

the 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): MaterialInfo

a 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): number

the 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 = {}): number

the 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) => number

packages/physics-response/src/laws/liquid.ts:31

stokesSettling function

function stokesSettling: (d: number, rhoP: number, rho?: number, nu?: number) => number

the 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) => boolean

does 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) => number

the 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): number

Bagnold'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 | undefined

The 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) => number

the 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) => number

the 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): void

something 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) => number

a 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) => number

the 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) => number

the 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) => number

the 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) => number

the 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 BedCell
u: [number, number]
depth: number
grains: BedGrains | null

packages/physics-response/src/bedwash.ts:9

BedGrains interface

interface BedGrains
d50: number
density?: number
cohesion?: number
porosity?: number

packages/physics-response/src/bedwash.ts:8

BedWashOptions interface

interface BedWashOptions
size: number
cell: number
origin: [number, number]
height?: number

packages/physics-response/src/bedwash.ts:10

CushionOptions interface

interface CushionOptions
halfX: numberhalf-sizes of the skirt's footprint along the craft's right and forward axes, m
halfZ: number
corner?: numberradius of the footprint's rounded corners, m (default a fifth of the smaller half-size)
gap?: numberthe height of the gap the air leaves through, m (default 0.05)
rho?: numberair density, kg/m3 (default 1.225)
cd?: numberdischarge coefficient of the gap (default 0.6, a sharp-edged orifice)
edge?: numberm 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 DisturbableSurface
disturb(x: number, z: number, volume: number, radius?: number): void

packages/physics-response/src/impact.ts:7

DustEvent interface

interface DustEvent
at: [number, number]
mass: number

packages/physics-response/src/ground.ts:11

Flake interface

interface Flake
x: 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 FlakeKind
sigma: number
mu?: number
thickness?: number
density?: number
size?: number

packages/physics-response/src/flakes.ts:9

FlakeWorld interface

interface FlakeWorld
air(x: number, y: number, z: number, t: number): [number, number, number]the air velocity at a point, m/s
ground(x: number, z: number): numberthe ground height at x, z
solid?(x: number, y: number, z: number): booleantrue 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 FlowMapOptions
size?: numbercells per side (default 64)
cell?: numbermetres per cell (default 1)
lowHeight?: numberheight above the ground of the low layer (default 0.4 m)
highHeight?: numberheight above the ground of the high layer (default 3 m)
ground?: (x: number, z: number) => numberthe ground height at x, z (default flat zero)
publisher?: stringthe publisher whose sources the map shows (default 'physics-response')
deflect?: numbera 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 ForcedSurface
level: number
forcing(fn: ((x: number, z: number) => [number, number, number]) | null): void

packages/physics-response/src/water.ts:24

GroundCell interface

interface GroundCell
u: [number, number]
grains: GroundGrains | null

packages/physics-response/src/ground.ts:9

GroundGrains interface

interface GroundGrains
d50: number
density: number
bulk?: number
wet?: number
cohesive?: boolean

packages/physics-response/src/ground.ts:8

GroundWashOptions interface

interface GroundWashOptions
size: number
cell: number
origin: [number, number]
height?: number

packages/physics-response/src/ground.ts:10

HotJet interface

interface HotJet
exitVelocity: number
exitDiameter: number
hitDistance: number | null
excess: number

packages/physics-response/src/melt.ts:6

Impact interface

interface Impact
x: number
z: number
mass: number
speed: number
diameter: number

packages/physics-response/src/impact.ts:8

ImpactResult interface

interface ImpactResult
energy: number
craterRadius: number
craterVolume: number
columnHeight: number
splash: { mass: number; speed: number; energy: number }

packages/physics-response/src/impact.ts:9

LiftOff interface

interface LiftOff
sigma: number
mu?: number
wet?: number
cl?: number
cd?: number

packages/physics-response/src/laws/flakes.ts:18

MaterialInfo interface

interface MaterialInfo

what 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?: numbera grain size, m (soil, sand, gravel) and the share of fines 0..1
fines?: number
cohesion?: number
wet?: number
diameter?: numbera 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 PropulsorInit
id: string
def: ModelPropulsor
pose: () => PropulsorPosewhere it is now and which way it throws (the node's world transform applied to the model's position and axis)
thrust?: () => number | undefinedthe 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 PropulsorPose
position: V3
axis: V3

packages/physics-response/src/propulsors.ts:14

PropulsorSetOptions interface

interface PropulsorSetOptions
group: stringthe prefix of the names of the sources it publishes (one per model instance)
weight?: () => numberthe weight of the whole model, N (mass x g), for the hover fallback
surface?: SurfaceQuery
scale?: numberthe multiplier of every jet of this set (the game's override); 0 switches them all off
onGroundEffect?: (id: string, extra: V3, at: V3) => voida 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 PropulsorState
id: string
thrust: number
fromActuator: boolean
exitVelocity: numberthe exit velocity and diameter of the jet, m/s and m
exitDiameter: number
hitDistance: number | nullthe surface the jet meets: its distance, or null
groundEffect: number

packages/physics-response/src/propulsors.ts:34

ResponseBlock interface

interface ResponseBlock
class: 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 ResponseClassDef
name: ResponseClassName
summary: string
defaults: Record<string, number | string | boolean>the parameters with their defaults
onset(block: ResponseBlock): numberthe 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 RestingBody
mass: number
area: number
cd: number
mu: number
height: number
width: number

packages/physics-response/src/laws/rigid.ts:4

SoilLike interface

interface SoilLike

the 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 SpeciesLike

the 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 SprayEvent
at: [number, number, number]
energy: number

packages/physics-response/src/spray.ts:8

SprayLaw interface

interface SprayLaw
onset?: numberonset of spray, m/s (default 7)
eta?: numbershare of the air's momentum flux that goes into the water it throws (default 0.3)
elevation?: numberangle the drops rise at, rad, and its spread (default 0.45, 0.25)
elevationSpread?: number
parcelsPerMetre?: numberparcels per metre of line per second at the onset speed doubled (the drawing's resolution, not the physics: the volume is the same)
life?: numberthe longest a parcel lives, s (default 3)

packages/physics-response/src/spray-droplets.ts:17

SprayOptions interface

interface SprayOptions
onset?: numberthe speed where spray starts (default 7 m/s, Monahan)
rate?: numberevents per second per square metre at 10 m/s above the onset (default 0.1)
cell?: numberthe cell area of one sample, m2
cap?: numberat most this many events per update (default 8)
seed?: number

packages/physics-response/src/spray.ts:9

SpraySample interface

interface SpraySample
x: number
z: number
speed: number
y: number

packages/physics-response/src/spray.ts:7

SurfaceHit interface

interface SurfaceHit

What 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: numberdistance along the ray, m
point: V3the point and the normal out of the surface
normal: V3
kind: 'ground' | 'water' | 'body'
material?: stringthe 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 WaterForcingOptions
height?: numberthe height above the water where the air is read (default 0.3 m)
level?: (x: number, z: number) => numberthe water level at x, z (default the surface's level)
publisher?: stringonly 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?: number0 switches the air's action on the water off
cushion?: AirCushionan 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 WaterResponseOptions
foamFrom?: numberheight above rest (m) from which the surface shows foam (default 0.04)
foamFull?: numberheight above rest (m) at which the foam is full (default 0.14)
whitecapOnset?: numberair speed over the water (m/s) from which foam is made, as the onset of spray (default 7, Monahan)
foamLife?: numberseconds 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 ResponseEvents

packages/physics-response/src/registry.ts:91

SurfaceQuery type

type SurfaceQuery = (from: V3, dir: V3, maxDistance: number) => SurfaceHit | null

The 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) => number

the 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.1

packages/physics-response/src/laws/granular.ts:6

BAGNOLD_REF_GRAIN const

const BAGNOLD_REF_GRAIN: 0.00025

packages/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: 4

channels per cell: low.x, low.z, high.x, high.z

packages/physics-response/src/flowmap.ts:26

G const

const G: 9.80665

packages/physics-response/src/laws/constants.ts:3

GRAVITY const

const GRAVITY: 9.80665

packages/physics-response/src/propulsors.ts:12

INTERPARTICLE_FORCE const

const INTERPARTICLE_FORCE: 0.000165

packages/physics-response/src/laws/granular.ts:7

K_AIR const

const K_AIR: 0.0257

packages/physics-response/src/laws/constants.ts:11

KAPPA const

const KAPPA: 0.4

packages/physics-response/src/laws/constants.ts:4

LATENT_FUSION const

const LATENT_FUSION: 334000

packages/physics-response/src/laws/constants.ts:12

NU_AIR const

const NU_AIR: 0.0000146

packages/physics-response/src/laws/constants.ts:7

NU_WATER const

const NU_WATER: 0.00000114

packages/physics-response/src/laws/constants.ts:8

PLATE_CD const

const PLATE_CD: 1.17

packages/physics-response/src/laws/flakes.ts:7

PR_AIR const

const PR_AIR: 0.71

packages/physics-response/src/laws/constants.ts:10

RHO_AIR const

const RHO_AIR: 1.225

packages/physics-response/src/laws/constants.ts:5

RHO_SAND const

const RHO_SAND: 2650

packages/physics-response/src/laws/bed.ts:6

RHO_WATER const

const RHO_WATER: 1000

packages/physics-response/src/laws/constants.ts:6

SPRAY_ONSET const

const SPRAY_ONSET: 7

the 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.072

packages/physics-response/src/laws/constants.ts:9

TUMBLE_I const

const TUMBLE_I: 1

the 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