# @ferret/physics-fx: API

The render side: glow of hot parts, water meshes, fluid views and lamp lights.

The render side of the physics capabilities: what a temperature, a water surface, a particle liquid and a lamp look like in a Babylon
scene. The capabilities report numbers and own no look; these bindings turn the numbers into a picture and
are what a game uses or replaces with its own. Each returns a `dispose`.

10 exports. Generated from the source (`packages/physics-fx/src`), so it matches the code.

## Functions

### blackbody

*function* · `packages/physics-fx/src/index.ts:8`

```ts
function blackbody(T: number): [number, number, number]
```

Colour of a black body at T kelvin (Tanner Helland's fit of the Planck locus; within a few percent from 1000 K to 40000 K), 0..1.

### flowArrows

*function* · `packages/physics-fx/src/index.ts:115`

```ts
function flowArrows(scene: BABYLON.Scene, samples: () => Array<{ at: [number, number, number]; velocity: [number, number, number] }>, o: { scale?: number; color?: [number, number, number] } = {})
```

The inspector's flow arrows: a line from each grid point along the flow there (length by speed), redrawn every frame.

### fluidView

*function* · `packages/physics-fx/src/index.ts:72`

```ts
function fluidView(scene: BABYLON.Scene, view: () => FluidViewLike, o: { max?: number; color?: [number, number, number]; foam?: [number, number, number]; foamSpeed?: number } = {})
```

A particle liquid as thin instances of one small sphere, a particle each (the liquid's spacing is its size), shaded from a still colour
to a foam colour by speed. Up to `max` particles are drawn.

### glow

*function* · `packages/physics-fx/src/index.ts:29`

```ts
function glow(scene: BABYLON.Scene, mesh: BABYLON.AbstractMesh, temperature: () => number, o: { full?: number; strength?: number } = {})
```

A mesh glows by the temperature of a heat part (a brake disc, a forge's iron, a reactor vessel).

### incandescence

*function* · `packages/physics-fx/src/index.ts:21`

```ts
function incandescence(T: number, full = 1800): number
```

How bright a hot body glows, 0..1: nothing below the Draper point (798 K, where a dull red first shows in the dark), then rising with the
visible part of the radiation, about T⁴ times the share that is visible, normalised to 1 at `full` (a white-hot 1800 K by default).

### lampLight

*function* · `packages/physics-fx/src/index.ts:103`

```ts
function lampLight(scene: BABYLON.Scene, light: BABYLON.Light, lamp: LampLike, o: { rated?: number; intensity?: number } = {})
```

A scene light follows a lamp of the circuit: its colour from the filament's temperature, its intensity from the visible light the
filament gives (`incandescence`, against the lamp's rated temperature, so the rated lamp shines at `intensity`). A dimmed lamp goes red
and dark; a burnt one goes out.

### waterMesh

*function* · `packages/physics-fx/src/index.ts:44`

```ts
function waterMesh(scene: BABYLON.Scene, field: () => SurfaceField, o: { name?: string; material?: BABYLON.Material } = {})
```

A mesh that follows a water surface of L2: a grid of the surface's cells, heights and normals written every frame.

## Interfaces

### FluidViewLike

*interface* · `packages/physics-fx/src/index.ts:66`

```ts
interface FluidViewLike
```

What `particleLiquid().view(name)` returns (L3).

- `count: number`
- `spacing: number`
- `positions: Float32Array`
- `speeds: Float32Array`

### LampLike

*interface* · `packages/physics-fx/src/index.ts:96`

```ts
interface LampLike
```

What a lamp of W reports: its filament temperature and whether it burnt out.

- `T: number`
- `burnt?: boolean`

### SurfaceField

*interface* · `packages/physics-fx/src/index.ts:41`

```ts
interface SurfaceField
```

What `WaterSurface.field()` returns (L2).

- `nx: number`
- `nz: number`
- `dx: number`
- `origin: [number, number] | number[]`
- `heights: Float32Array`
- `normals: Float32Array`

