# @ferret/destruction: API (continued)

### wakePiece

*function* · `packages/destruction/src/debris.ts:156`

```ts
function wakePiece(p: DebrisPiece): boolean
```

wake a sleeping piece (a hit on it); a merged piece is part of the clutter and does not wake

### woodKnots

*function* · `packages/destruction/src/wood.ts:68`

```ts
function woodKnots(seed: number, length: number, density: number): Knot[]
```

the knots of a plank of length L (m) by its seed: positions along it and radii, about `density` per metre. The same seed gives the same knots.

### woodModel

*function* · `packages/destruction/src/wood.ts:127`

```ts
function woodModel: FailureModel
```

### xform

*function* · `packages/destruction/src/branches.ts:239`

```ts
function xform: (m: ArrayLike<number>, p: Vec3) => Vec3
```

column-major 4x4 (Babylon's `m`): a model point to the world

## Interfaces

### AssemblyPart

*interface* · `packages/destruction/src/assembly.ts:20`

```ts
interface AssemblyPart
```

- `part: PartState`
- `at: Vec3`
- `attached: boolean`

### BarGeometry

*interface* · `packages/destruction/src/wood.ts:86`

```ts
interface BarGeometry
```

- `axis: number`
- `loadAxis: number`
- `widthAxis: number`
- `length: number` — m
- `depth: number`
- `width: number`
- `Z: number` — m^3
- `I: number` — m^4

### BarSupports

*interface* · `packages/destruction/src/wood.ts:105`

```ts
interface BarSupports
```

- `s0: number`
- `s1: number`

### BodyBox

*interface* · `packages/destruction/src/branches.ts:234`

```ts
interface BodyBox
```

a body as an upright box: its centre, half sizes (x across, y up, z along) and its yaw about y (world)

- `centre: Vec3`
- `half: Vec3`
- `yaw: number`

### BodyLike

*interface* · `packages/destruction/src/capability.ts:10`

```ts
interface BodyLike
```

the part of a physics `Body` this capability reads

- `kind: string`
- `mass: number`
- `removed: boolean`
- `position: Vec3`
- `orientation: [number, number, number, number]`
- `velocity?: Vec3`

### Branch

*interface* · `packages/destruction/src/branches.ts:27`

```ts
interface Branch
```

- `id: number`
- `parent: number`
- `order: number`
- `nodes: number[]` — the rings of the branch, from its base (on its parent) to its tip
- `length: number`
- `diameter: number` — diameter at the base (m): the median of the rings in the first third, the junction ring left out

### BranchSpring

*interface* · `packages/destruction/src/branches.ts:306`

```ts
interface BranchSpring
```

a bent branch swinging back: x is the deflection at the lever (m, along `dir`), v its speed

- `x: number`
- `v: number`
- `dir: Vec3`
- `omega: number`
- `zeta: number`

### BreakNoise

*interface* · `packages/destruction/src/debris.ts:56`

```ts
interface BreakNoise
```

- `part: string`
- `point: Vec3`
- `seed: number`
- `loudness: number` — 0..1
- `dust: number` — 0..1
- `energy: number` — J
- `level: DebrisLevel`
- `made: number` — pieces made, and the mass of those not made, kg
- `dropped: number`

### BreakRecord

*interface* · `packages/destruction/src/service.ts:69`

```ts
interface BreakRecord
```

what travels to another machine for a break: enough to compute the same outcome (section 8)

- `id: string`
- `part: string`
- `style: string`
- `seed: number`
- `hit: Hit`

### Capability

*interface* · `packages/destruction/src/capability.ts:19`

```ts
interface Capability
```

the shape of a physics `Capability` (@ferret/physics) as this one provides it

- `readonly name: string`
- `readonly phase: 'strength'`
- `readonly order: number`
- `readonly needsBodies: boolean`
- `readonly cost: string`
- `readonly defaults: Record<string, unknown>`
- `enable(host: HostLike): void`
- `disable(): void`
- `step(dt: number, host: HostLike, contacts: readonly ContactLike[]): void`

### CarBlock

*interface* · `packages/destruction/src/autoparts.ts:78`

```ts
interface CarBlock
```

- `name: string`
- `mass: number`
- `assembly: Assembly`
- `chassis: string`
- `layout: CarLayout`
- `regions: Region[]`
- `panes: GlassPane[]`
- `zones: Record<string, CrushZone[]>`
- `wheels: WheelSpec[]`
- `centers: Record<string, Vec3>` — the centre of the chassis box (its mass centre is lower)
- `parts: PartState[]`

### CarLayout

*interface* · `packages/destruction/src/autoparts.ts:71`

```ts
interface CarLayout
```

- `bodyMin: Vec3`
- `bodyMax: Vec3`
- `frontAxle: number` — x of the front and the rear axle, m
- `rearAxle: number`
- `radius: number`
- `track: number`
- `leftSign: number` — the z of the left side (the sign of the front-left wheel's z)
- `frontEnd: number`
- `rearEnd: number`
- `bumperTop: number`
- `cowlX: number`
- `cabinRearX: number`
- `hoodHalf: number`

### CarSpec

*interface* · `packages/destruction/src/autoparts.ts:63`

```ts
interface CarSpec
```

- `name: string`
- `mass?: number` — kg, the whole car; when missing it is the curb weight in `CAR_MASS` for the name (an unknown name without a mass throws)
- `nodes: NodeInfo[]`

### Clutter

*interface* · `packages/destruction/src/debris.ts:82`

```ts
interface Clutter
```

- `group: number`
- `count: number`
- `mass: number`
- `lo: Vec3`
- `hi: Vec3`

### CommandHost

*interface* · `packages/destruction/src/service.ts:33`

```ts
interface CommandHost
```

- `register(name: string, description: string, fn: (args: any) => unknown | Promise<unknown>): void`

### Contact

*interface* · `packages/destruction/src/vehicle.ts:426`

```ts
interface Contact
```

- `normal: Vec3`
- `depth: number`
- `point: Vec3`

### ContactInput

*interface* · `packages/destruction/src/service.ts:74`

```ts
interface ContactInput
```

a contact as the capability gives it: world point, the normal from the other body toward this thing, closing speed, the other's mass (Infinity for the ground)

- `point: Vec3`
- `normal: Vec3`
- `speed: number`
- `slide?: number`
- `impulse?: number`
- `otherMass: number`
- `restitution: number`
- `area?: number`
- `step: number`
- `rigidOther?: boolean` — the other side is a wall, the ground, a fixed or kinematic body: infinite mass and stiffness (all of the hit's energy is this thing's), and the blow is spread over the whole face that meets it

### ContactLike

*interface* · `packages/destruction/src/capability.ts:12`

```ts
interface ContactLike
```

the part of a physics `ContactEvent` it reads: `normal` points from b toward a

- `a: BodyLike`
- `b: BodyLike`
- `point: Vec3`
- `normal: Vec3`
- `impulse: number`
- `speed: number`
- `slide: number`
- `restitution: number`

### ContactOutcome

*interface* · `packages/destruction/src/branches.ts:270`

```ts
interface ContactOutcome
```

- `push: Vec3` — the body's correction (m, world): where it may not go
- `force: Vec3` — the force the branches put on the body (N, world)
- `held: boolean` — whether the body is held (it could not push through): its speed into `hold` (unit) is to be taken away
- `hold: Vec3`
- `bends: { contact: TreeContact; deflection: number }[]` — per contact: how far the branch is bent at its lever (m, along the contact's normal)
- `broke: TreeContact[]` — the contacts whose branch broke

### Controls

*interface* · `packages/destruction/src/vehicle.ts:125`

```ts
interface Controls
```

- `throttle: number`
- `brake: number`
- `steer: number`

### CrushZone

*interface* · `packages/destruction/src/crush.ts:41`

```ts
interface CrushZone
```

- `id: string`
- `axis: Vec3` — unit vector: the direction the zone crumples in, into the part
- `center: Vec3` — centre of the zone in the part's frame, m (where a dent is centred by default is the hit point; this is for hulls and views)
- `width: number` — extent of the zone's face across the axis, m
- `height: number`
- `dMax: number` — maximum depth, m: the zone is bottomed out here
- `area: number` — effective section area, m^2 (the plateau force is yield strength times this)
- `plateau: number` — the plateau force, N
- `curve: CurvePoint[]` — force-depth points from (0, 0) to (dMax, F); piecewise linear, x increasing
- `hardStiffness: number` — N/m: stiffness past dMax, where the zone is a block
- `dentRadius: number` — the dent's default radius on the lattice, m

### CrushZoneInput

*interface* · `packages/destruction/src/crush.ts:54`

```ts
interface CrushZoneInput
```

- `id: string`
- `axis: Vec3`
- `center?: Vec3`
- `width: number`
- `height: number`
- `dMax: number` — maximum depth, m (ignored when a custom `curve` is given: the curve's last depth is `dMax`)
- `thickness: number` — sheet thickness, m; 0 means a solid section (all of width x height carries)
- `yieldStrength: number` — Pa; read from the part's material
- `loadShare?: number` — override of `CRUSH_LOAD_SHARE`
- `curve?: CurvePoint[]` — a custom curve, from (0, 0) (added if missing) with depth increasing
- `dentRadius?: number`

### CurvePoint

*interface* · `packages/destruction/src/crush.ts:39`

```ts
interface CurvePoint
```

- `x: number`
- `f: number`

### DebrisLod

*interface* · `packages/destruction/src/debris.ts:30`

```ts
interface DebrisLod
```

- `near: number`
- `middle: number`

### DebrisPiece

*interface* · `packages/destruction/src/debris.ts:67`

```ts
interface DebrisPiece
```

- `id: number`
- `group: number`
- `spec: PieceSpec`
- `mode: DebrisMode`
- `age: number` — seconds since the break
- `still: number` — seconds below DEBRIS_SLEEP_SPEED
- `asleep: number` — seconds asleep
- `sleeping: boolean`
- `merged: boolean` — joined into its group's clutter: no longer a body
- `scale: number` — 1..0 while fading
- `life: number` — seconds, Infinity for a piece that stays
- `bodyUntil: number` — seconds a body (Infinity: stays a body)
- `gone: boolean`

### DebrisPlan

*interface* · `packages/destruction/src/debris.ts:81`

```ts
interface DebrisPlan
```

- `level: DebrisLevel`
- `pieces: DebrisPiece[]`
- `noise: BreakNoise`

### Deceleration

*interface* · `packages/destruction/src/crush.ts:176`

```ts
interface Deceleration
```

- `depth: number` — the deepest the zone was pushed, m (beyond dMax only by the elastic give of the block)
- `time: number` — time to the deepest point, s
- `peak: number` — the largest deceleration, m/s^2
- `mean: number` — the mean deceleration to the stop, `v0^2 / (2 depth)`, m/s^2
- `bottomed: boolean` — the zone reached dMax and the body was stopped by the block

### DecelerationOptions

*interface* · `packages/destruction/src/crush.ts:183`

```ts
interface DecelerationOptions
```

- `from?: number`
- `strengthScale?: number`
- `dt?: number`

### Destructible

*interface* · `packages/destruction/src/service.ts:51`

```ts
interface Destructible
```

a thing that can break

- `id: string`
- `entity: number` — the number the seeds are made from (a hash of the id unless given)
- `assembly: Assembly`
- `zones: Record<string, CrushZone[]>` — crush zones of each part id
- `models: Record<string, string>` — model names to use for a part id instead of the kind's default
- `vehicle?: Vehicle`
- `frame: { position: Vec3; rotation: Quat }` — where the thing is in the world; the part frame is this one (a vehicle uses its own pose)
- `lod: Lod`
- `ledger: Ledger` — the sum of the ledgers of all the hits taken
- `explained: string` — the last `explain` text
- `last: Record<string, Outcome>` — the last outcome, by part
- `off: string[]` — parts that have come off, once each
- `lastStage: string` — the stage of the last hit
- `seen: boolean` — the viewer can see it (debris levels)

### DestructionCapability

*interface* · `packages/destruction/src/capability.ts:25`

```ts
interface DestructionCapability extends Capability
```

- `bind(id: string, body: Body): void` — the thing `id` of the service rides on this body: its pose is kept current and its contacts are the thing's hits
- `unbind(id: string): void`
- `isBound(id: string): boolean` — the thing rides a body of this capability (its vehicle is not to be stepped again by a view)
- `reset(): void` — forget every binding and start the step count again (a new scene: the seeds of its hits come from the step number, so the same scene gives the same breaks)

### DestructionEvent

*interface* · `packages/destruction/src/types.ts:81`

```ts
interface DestructionEvent
```

- `kind: DestructionEventKind`
- `part: string`
- `point: Vec3`
- `energy: number`
- `seed: number`
- `detail?: string`

### DetachedBody

*interface* · `packages/destruction/src/vehicle.ts:139`

```ts
interface DetachedBody
```

- `id: string`
- `mass: number`
- `size: Vec3`
- `position: Vec3`
- `velocity: Vec3`
- `angular: Vec3`
- `rotation: Quat`

### DiceOptions

*interface* · `packages/destruction/src/fracture.ts:180`

```ts
interface DiceOptions extends Omit<PaneOptions, 'budget' | 'point'>
```

- `cell: number` — the natural cell edge, m (tempered glass: a few thicknesses)

### FallingBranch

*interface* · `packages/destruction/src/branches.ts:321`

```ts
interface FallingBranch
```

a broken branch falling: its pivot's place and speed (world), its turn (axis-angle rate) and attitude (quaternion x, y, z, w)

- `p: Vec3`
- `v: Vec3`
- `q: [number, number, number, number]`
- `w: Vec3`
- `terminal: number`
- `radius: number`
- `resting: boolean`
- `t: number`

### FractureResult

*interface* · `packages/destruction/src/fracture.ts:25`

```ts
interface FractureResult
```

- `pieces: PieceSpec[]`
- `crackArea: number` — the crack area made, m^2
- `fractureEnergy: number` — `crackArea * fractureEnergy`, J
- `count: number` — pieces made

### GlassPane

*interface* · `packages/destruction/src/autoparts.ts:70`

```ts
interface GlassPane
```

- `id: string`
- `kind: GlassKind`
- `thickness: number`
- `size: Vec3`
- `parent: string`

### GrainSplitOptions

*interface* · `packages/destruction/src/fracture.ts:220`

```ts
interface GrainSplitOptions
```

- `size: Vec3` — the box that splits, full size, m
- `center?: Vec3` — its centre in the part frame (default 0)
- `grainAxis: number` — axis index (0 x, 1 y, 2 z) the grain runs along
- `splitAxis: number` — axis index the slabs are stacked along (the cut planes are normal to it; they contain the grain)
- `fractureEnergy: number` — J/m^2
- `mass: number` — kg: the slabs' masses sum to this
- `seed: number`

### GridBlockOptions

*interface* · `packages/destruction/src/fracture.ts:264`

```ts
interface GridBlockOptions
```

- `size: Vec3`
- `center?: Vec3`
- `mass: number` — kg: the cells' masses sum to this
- `budget: number` — J available for new crack surface
- `fractureEnergy: number` — J/m^2
- `seed: number`
- `maxPieces?: number` — most cells (default 12)
- `countScale?: number` — a style's multiplier on the count (default 1)

### Hit

*interface* · `packages/destruction/src/types.ts:51`

```ts
interface Hit
```

one contact turned into the numbers a failure model needs (energy.ts `makeHit`)

- `point: Vec3` — world
- `normal: Vec3` — from the other body toward this part
- `speed: number` — closing speed along the normal, m/s
- `slide: number` — sliding speed along the surface, m/s
- `impulse: number` — the normal impulse over the step, N*s
- `energy: number` — the energy available for damage to THIS part, J (the share its softness takes, energy.ts `splitEnergy`)
- `total: number` — the whole hit's energy before it was split between the two sides, J
- `massA: number`
- `massB: number`
- `area: number` — the contact area on this part, m^2
- `step: number` — the fixed step the hit happened in
- `seed: number` — the seed of this break (rng.ts `breakSeed`)

### HitInput

*interface* · `packages/destruction/src/energy.ts:36`

```ts
interface HitInput
```

- `point: Vec3`
- `normal: Vec3`
- `speed: number` — closing speed along the normal, m/s
- `slide?: number`
- `impulse?: number`
- `massA: number`
- `massB: number`
- `restitution: number` — the restitution the contact was solved with
- `stiffThis?: number` — stiffness of this part's side and of the other side, N/m (`contactStiffness`); equal if missing
- `stiffOther?: number`
- `area: number`
- `step: number`
- `entity: number` — the entity (or body) number, for the seed
- `energyScale?: number` — a style's multiplier on the energy (1: physical)

### HitResult

*interface* · `packages/destruction/src/service.ts:71`

```ts
interface HitResult
```

- `record: BreakRecord`
- `outcome: Outcome`
- `detached: string[]`
- `load: number`
- `pieces: PieceSpec[]`
- `dropped: number`
- `plan: DebrisPlan | null`
- `events: DestructionEvent[]`
- `explain: string`

### HostLike

*interface* · `packages/destruction/src/capability.ts:14`

```ts
interface HostLike
```

the part of the physics host it uses

- `world: { events: { emit(name: string, payload: unknown): void }; commands: { register(name: string, description: string, fn: (args: any) => unknown): void } }`
- `config(name: string): { get<T>(key: string, ctx: object): T }`

### Hull

*interface* · `packages/destruction/src/crush.ts:367`

```ts
interface Hull
```

the bounds of a hull after dents, and where its centre has moved to (part frame)

- `size: Vec3`
- `offset: Vec3`

### Knot

*interface* · `packages/destruction/src/wood.ts:66`

```ts
interface Knot
```

- `pos: number`
- `radius: number`

### Ledger

*interface* · `packages/destruction/src/types.ts:66`

```ts
interface Ledger
```

where the energy of a hit went, J. `input = crush + fracture + kinetic + heat + sound + residual`, within 1e-9 of the input (energy.ts `balanced`)

- `input: number`
- `crush: number`
- `fracture: number`
- `kinetic: number`
- `heat: number`
- `sound: number`
- `residual: number`

### LinkState

*interface* · `packages/destruction/src/types.ts:27`

```ts
interface LinkState
```

- `id: string`
- `to: string | null` — the part this link joins to, or `null` for the world
- `kind: 'weld' | 'bolt' | 'hinge' | 'nail' | 'glue' | 'clip'`
- `holds: number` — the force it holds, N (tensile x area x count)
- `load: number` — the force it has taken over the last step, N
- `broken: boolean`

### MaterialProps

*interface* · `packages/destruction/src/types.ts:16`

```ts
interface MaterialProps
```

the numbers of a substance a failure model reads (SI); material.ts fills the missing ones from the kind's typical substance

- `density: number` — kg/m^3
- `youngModulus: number` — Pa
- `yieldStrength: number` — Pa: where it deforms for good (ductile)
- `tensileStrength: number` — Pa: where it tears or ruptures along its strong direction (brittle: modulus of rupture; fibrous: along the grain)
- `crossStrength: number` — Pa: across the grain (fibrous); equals `tensileStrength` for the rest
- `fractureEnergy: number` — J/m^2: the energy of a new crack surface (brittle, fibrous, crumbly)
- `restitution: number` — 0 sticks, 1 perfectly elastic
- `kineticShare: number` — the share of a hit's energy that fragments carry away as motion (0..1)

### MotionBridgeLike

*interface* · `packages/destruction/src/motion.ts:19`

```ts
interface MotionBridgeLike
```

the part of `MotionBridge` (@ferret/motion) this link uses

- `define(name: string, sig: { args: string[]; min?: number; rest?: string; returns?: string }, fn: (ctx: unknown, ...args: any[]) => unknown): unknown`
- `readonly rt: { deliver(name: string, payload?: unknown): void }`

### NodeInfo

*interface* · `packages/destruction/src/autoparts.ts:59`

```ts
interface NodeInfo
```

what the loader gives for a node of the model: its bounds in the car frame, and for a wheel its hub; `area` is the mesh's surface area (both faces of a thin shell counted, as a mesh has it)

- `name: string`
- `min: Vec3`
- `max: Vec3`
- `origin?: Vec3`
- `area?: number`

### Outcome

*interface* · `packages/destruction/src/types.ts:84`

```ts
interface Outcome
```

what a model returns for one hit on one part

- `ledger: Ledger`
- `damage: Record<string, number>` — the part's `damage` after the hit (the whole record, not a delta)
- `pieces: PieceSpec[]`
- `stage: string` — the stage reached: 'none' | 'dent' | 'star' | 'shards' | 'split' | 'crumble' ... (a model names its own)
- `broken: boolean` — the part is gone (replaced by its pieces)
- `events: DestructionEvent[]`

### PaneOptions

*interface* · `packages/destruction/src/fracture.ts:98`

```ts
interface PaneOptions
```

- `width: number` — pane size in its plane, m
- `height: number`
- `thickness: number` — m
- `mass: number` — kg: the pieces' masses sum to this
- `point: [number, number]` — impact point in the pane's plane, part frame, m
- `budget: number` — J available for new crack surface
- `fractureEnergy: number` — J/m^2
- `seed: number`
- `maxPieces?: number` — most pieces (default 128)
- `countScale?: number` — a style's multiplier on how rich the pattern may be (default 1; the cost may then pass the budget)
- `spread?: number` — 0..1: how irregular the pattern is (0: the physical amount)

### PartInput

*interface* · `packages/destruction/src/part.ts:6`

```ts
interface PartInput
```

- `id: string`
- `substance?: string` — a substance name (`glass-tempered`), or a kind with `material` numbers
- `kind?: MaterialKind`
- `material?: Partial<MaterialProps>`
- `size: Vec3` — full size of the bounds, m
- `thickness?: number` — thickness of a sheet or pane, m (0: solid)
- `mass?: number` — kg; the density times the bounds' volume (times `fill`) when missing
- `fill?: number` — the share of the bounds' volume that is material (a car door is mostly air); 1 for a solid part
- `grain?: Vec3`

### PartState

*interface* · `packages/destruction/src/types.ts:36`

```ts
interface PartState
```

- `id: string`
- `kind: MaterialKind`
- `material: MaterialProps`
- `mass: number` — kg
- `size: Vec3` — full size of the part's bounds, m (x, y, z in the part's own frame)
- `thickness: number` — thickness of a sheet or pane, m (0: solid)
- `grain?: Vec3` — the grain direction in the part's frame (fibrous); a unit vector
- `damage: Record<string, number>` — named damage numbers a model keeps between hits: dent depth, crack stage, accumulated energy...
- `dents?: Float32Array` — the dent lattice (crush): control point offsets, x y z per point, in the part's frame, m
- `links: LinkState[]`
- `broken: boolean`

### PieceSpec

*interface* · `packages/destruction/src/types.ts:70`

```ts
interface PieceSpec
```

a piece that a break makes: a body, an instance or a particle by the level and the budget (debris)

- `shape: PieceShape`
- `vertices?: Float32Array` — a convex piece's vertices in the part's frame (hull, shard, splinter, chunk); absent for a box and dust
- `size: Vec3` — full size of the piece's bounds, m
- `offset: Vec3` — where its centre was in the part's frame, m
- `mass: number` — kg
- `velocity: Vec3` — m/s, the part's own velocity at that point plus the share of the energy that flung it (not included: the part's velocity, the host adds it)
- `angular: Vec3` — rad/s

### PlanOptions

*interface* · `packages/destruction/src/debris.ts:84`

```ts
interface PlanOptions
```

- `level: DebrisLevel`
- `live: number` — live pieces and bodies in the world now
- `liveBodies: number`
- `maxPieces: number`
- `maxBodies: number`
- `energy: number` — J, the hit's energy
- `point: Vec3`
- `part: string`
- `seed: number`
- `group?: number` — a heap the pieces belong to (a window's pieces, a wall's)
- `ctx: StyleContext`
- `firstId?: number` — the first piece id (the world numbers them)

### PlateLoad

*interface* · `packages/destruction/src/glass.ts:63`

```ts
interface PlateLoad
```

- `force: number`
- `stress: number`
- `stiffness: number`

### RayCaster

*interface* · `packages/destruction/src/vehicle.ts:52`

```ts
interface RayCaster
```

the one thing the vehicle asks of the world: a ray cast (the kernel's `rayCast` sits behind it in the engine); `dir` is a unit vector

- `cast(origin: Vec3, dir: Vec3, maxDistance: number): RayHit | null`

### RayHit

*interface* · `packages/destruction/src/vehicle.ts:45`

```ts
interface RayHit
```

- `distance: number` — distance along the ray to the surface, m
- `normal: Vec3` — unit surface normal, pointing away from the ground
- `grip: number` — a scale on the tyre's friction coefficient (1: the tyre's own; ice is under 1)
- `velocity?: Vec3` — velocity of the surface at the hit (a moving platform), m/s; zero if missing

### Region

*interface* · `packages/destruction/src/autoparts.ts:69`

```ts
interface Region
```

- `id: string`
- `min: Vec3`
- `max: Vec3`

### ResolvedStyle

*interface* · `packages/destruction/src/style.ts:25`

```ts
interface ResolvedStyle
```

a resolved style: the context the models read, the view's staging and the replacements

- `ctx: StyleContext`
- `spec: StyleSpec`
- `override: Record<string, string>`
- `squash: boolean`

### ServiceOptions

*interface* · `packages/destruction/src/service.ts:89`

```ts
interface ServiceOptions
```

- `maxPieces?: number`
- `maxBodies?: number`
- `nodesOf?: (asset: string) => NodeInfo[] | undefined` — the node list of a library model by asset name, for `destruction.autoparts {asset}` when the command gives no nodes

### SkelNode

*interface* · `packages/destruction/src/branches.ts:26`

```ts
interface SkelNode
```

a ring of the bark: its centre and radius (model frame), its branch and how far it is along that branch from the branch's base (m)

- `p: Vec3`
- `r: number`
- `branch: number`
- `s: number`
- `parent: number`
- `n: number`

### Stream

*interface* · `packages/destruction/src/rng.ts:13`

```ts
interface Stream
```

- `rs: number`

### StrikeInput

*interface* · `packages/destruction/src/vehicle.ts:140`

```ts
interface StrikeInput
```

- `point: Vec3` — world
- `normal: Vec3`
- `speed: number` — closing speed along the normal, m/s
- `otherMass: number`
- `restitution: number`
- `area?: number`
- `step: number`
- `entity: number`
- `style?: StyleContext`

### StrikeResult

*interface* · `packages/destruction/src/vehicle.ts:146`

```ts
interface StrikeResult
```

- `part: string`
- `ledger: Ledger`
- `stage: string`
- `detached: string[]`
- `events: DestructionEvent[]`
- `load: number`

### StyleContext

*interface* · `packages/destruction/src/types.ts:94`

```ts
interface StyleContext
```

the numbers of the style in force for this hit (style.ts resolves them; `physical` is all ones and `conserve` true)

- `name: string`
- `energyScale: number` — hits count this many times
- `strengthScale: number` — what a part holds is multiplied by this
- `depthScale: number` — dents are this much deeper
- `recover: number` — 0..1: the share of a dent that springs back (rubber)
- `piecesScale: number` — more or fewer pieces
- `sizeSpread: number` — 0..1: how varied the piece sizes are (0: the physical distribution)
- `burstScale: number` — fragments fly this much faster
- `debrisBounce: number` — debris: restitution, seconds alive, gravity scale
- `debrisLife: number`
- `debrisGravity: number`
- `conserve: boolean` — false: the ledger may be broken (a style that says so, shown by `explain`)

### StyleSpec

*interface* · `packages/destruction/src/style.ts:11`

```ts
interface StyleSpec
```

the shape of a style as data (every field optional; a missing one is the physical value)

- `name: string`
- `energy?: { scale?: number; conserve?: boolean }`
- `strength?: { scale?: number }`
- `crush?: { depthScale?: number; recover?: number; squash?: boolean }`
- `fracture?: { piecesScale?: number; sizeSpread?: number; burstScale?: number }`
- `debris?: { bounce?: number; life?: number; gravityScale?: number }`
- `reaction?: { hitStop?: number; timeScale?: [number, number]; shake?: number }` — staging for the view (hit stop, slow motion, shake); the physics does not read it
- `override?: Record<string, string>` — a failure model replaced by name: key is a kind (`brittle`, `fibrous`, `ductile`, `crumbly`, `rigid`) or a part id, value is a registered model name

### StyleZone

*interface* · `packages/destruction/src/style.ts:101`

```ts
interface StyleZone
```

- `id: string`
- `min: Vec3`
- `max: Vec3`
- `style: string`

### ThingBlock

*interface* · `packages/destruction/src/service.ts:78`

```ts
interface ThingBlock
```

the destruction block of a manifest or a command (`destruction.define-thing`): parts, links, crush zones and glass panes of one thing

- `id: string`
- `entity?: number`
- `root: string`
- `lod?: Lod`
- `style?: string`
- `parts: (Omit<PartInput, 'id'> & { id: string; at?: Vec3; glass?: GlassKind; model?: string })[]`
- `links?: { part: string; to: string | null; kind: LinkState['kind']; holds?: number; tensile?: number; area?: number; count?: number }[]`
- `zones?: Record<string, (Omit<CrushZoneInput, 'yieldStrength'> & { yieldStrength?: number })[]>` — by part id; the yield strength is the part's material's unless given

### TreeBreakerOptions

*interface* · `packages/destruction/src/view-trees.ts:52`

```ts
interface TreeBreakerOptions
```

- `ground: (x: number, z: number) => number` — the ground's height (m) at x, z (the broken branches land on it)
- `maxLive?: number` — at most this many trees live as meshes of their own (default 48)
- `maxFallen?: number` — at most this many branches falling or lying (default 40)
- `lie?: number` — seconds a fallen branch lies before it goes (default 40)

### TreeContact

*interface* · `packages/destruction/src/branches.ts:236`

```ts
interface TreeContact
```

one branch of one tree in contact: where (world), how deep the body is in it, along which outward normal (world, unit, from the body), its stiffness and breaking force there

- `branch: number`
- `node: number`
- `point: Vec3`
- `depth: number`
- `normal: Vec3`
- `lever: number`
- `k: number`
- `fBreak: number`

### TreeKind

*interface* · `packages/destruction/src/view-trees.ts:42`

```ts
interface TreeKind
```

- `id: string`
- `skeleton: TreeSkeleton`
- `parts: Part[]`
- `leafy: Set<number>`

### TreeMesh

*interface* · `packages/destruction/src/branches.ts:24`

```ts
interface TreeMesh
```

- `positions: ArrayLike<number>`
- `indices: ArrayLike<number>`

### TreeSkeleton

*interface* · `packages/destruction/src/branches.ts:35`

```ts
interface TreeSkeleton
```

- `nodes: SkelNode[]`
- `branches: Branch[]`
- `vertexBranch: Uint16Array`
- `height: number`
- `foot: Vec3`

### TreeStep

*interface* · `packages/destruction/src/view-trees.ts:62`

```ts
interface TreeStep
```

- `held: boolean`
- `hold: Vec3`
- `push: Vec3`
- `broke: number`
- `touching: number`

### VehicleSpec

*interface* · `packages/destruction/src/vehicle.ts:127`

```ts
interface VehicleSpec
```

- `assembly: Assembly`
- `chassis: string` — the part that carries the rest (its box is the body's hull)
- `wheels: WheelSpec[]`
- `zones?: Record<string, CrushZone[]>` — the crush zones of each part (autoparts), for the shrunk collider
- `model?: FailureModel` — the failure model that turns a hit into damage of a part (`crushModel` of autoparts)
- `driveTorque?: number` — N m at each driven wheel at full throttle; default: a quarter of g x mass x radius over the driven wheels
- `brakeTorque?: number` — N m at each wheel at full brake; default: friction limit of the static load
- `friction?: number` — a ground friction coefficient for the tyres
- `centers?: Record<string, Vec3>` — the centre of a part's BOX in the car frame where it is not the part's centre of mass (the chassis: its mass centre is low, its box is the whole body); default: the part's own place

### VoronoiOptions

*interface* · `packages/destruction/src/fracture.ts:468`

```ts
interface VoronoiOptions
```

- `size: Vec3` — the block, full size, m
- `center?: Vec3` — its centre in the part frame (default 0)
- `mass: number` — kg: the cells' masses sum to this
- `point: Vec3` — the impact point, part frame: cells are denser near it
- `budget: number` — J available for new crack surface
- `fractureEnergy: number` — J/m^2
- `seed: number`
- `maxPieces?: number` — most cells (default 48)
- `countScale?: number` — a style's multiplier on the count (default 1)

### WheelSpec

*interface* · `packages/destruction/src/vehicle.ts:111`

```ts
interface WheelSpec
```

- `id: string` — the wheel's part id in the assembly
- `mount: Vec3` — x and z of the hub in the car frame, m (the height of the suspension top is worked out from the static load: y here is ignored); the ray starts at the top of the suspension and points down the body's -y axis
- `radius: number`
- `width: number`
- `steer: boolean`
- `drive: boolean`

### WheelState

*interface* · `packages/destruction/src/vehicle.ts:117`

```ts
interface WheelState
```

- `spec: WheelSpec`
- `mount: Vec3` — top of the suspension in the car frame: x and z of the spec, and the height at which the spring stands at its static length with the hub on the ground
- `attached: boolean` — false once the wheel has come off: no ray, no force
- `spin: number` — rad/s
- `k: number` — N/m
- `c: number`
- `onGround: boolean`
- `load: number`
- `length: number`

## Types

### DebrisLevel

*type* · `packages/destruction/src/debris.ts:27`

```ts
type DebrisLevel = 'near' | 'middle' | 'far' | 'unseen'
```

### DebrisMode

*type* · `packages/destruction/src/debris.ts:28`

```ts
type DebrisMode = 'body' | 'instance' | 'particle'
```

### DestructionEventKind

*type* · `packages/destruction/src/types.ts:80`

```ts
type DestructionEventKind = 'damage' | 'dent' | 'crack' | 'break' | 'detach' | 'link-break' | 'shatter' | 'splinter' | 'crumble' | 'settle'
```

### FailureModel

*type* · `packages/destruction/src/types.ts:111`

```ts
type FailureModel = (hit: Hit, part: PartState, ctx: StyleContext) => Outcome
```

a failure model: a pure function of the hit, the part and the style; the seed is `hit.seed`. A style may replace a model by name (style.ts).

### GlassKind

*type* · `packages/destruction/src/glass.ts:36`

```ts
type GlassKind = keyof typeof GLASS_KIND
```

### Lod

*type* · `packages/destruction/src/service.ts:36`

```ts
type Lod = 'near' | 'middle' | 'far' | 'unseen'
```

### MaterialKind

*type* · `packages/destruction/src/types.ts:12`

```ts
type MaterialKind = 'brittle' | 'fibrous' | 'ductile' | 'crumbly' | 'rigid'
```

how a material fails: `brittle` (glass, ceramic, stone, ice), `fibrous` (wood), `ductile` (sheet metal, plastic), `crumbly` (brick, plaster, concrete), `rigid` (never fails)

### PieceShape

*type* · `packages/destruction/src/types.ts:68`

```ts
type PieceShape = 'box' | 'hull' | 'shard' | 'splinter' | 'chunk' | 'dust'
```

### Quat

*type* · `packages/destruction/src/types.ts:9`

```ts
type Quat = [number, number, number, number]
```

### Vec3

*type* · `packages/destruction/src/types.ts:8`

```ts
type Vec3 = [number, number, number]
```

## Constants

### ACCESSORY_FILL

*const* · `packages/destruction/src/autoparts.ts:30`

```ts
const ACCESSORY_FILL: 0.02
```

the share of the volume of a small fitted accessory's bounds that is material (a light bar, a speaker)

### ADHESIVE_TENSILE

*const* · `packages/destruction/src/autoparts.ts:46`

```ts
const ADHESIVE_TENSILE: 5000000
```

### AREA_M10

*const* · `packages/destruction/src/autoparts.ts:48`

```ts
const AREA_M10: 0.000058
```

### AREA_M12

*const* · `packages/destruction/src/autoparts.ts:48`

```ts
const AREA_M12: 0.0000843
```

### AREA_M6

*const* · `packages/destruction/src/autoparts.ts:48`

```ts
const AREA_M6: 0.0000201
```

stress areas of ISO metric bolts, m^2

### AREA_M8

*const* · `packages/destruction/src/autoparts.ts:48`

```ts
const AREA_M8: 0.0000366
```

### BARE_TERMINAL

*const* · `packages/destruction/src/branches.ts:41`

```ts
const BARE_TERMINAL: 14
```

### BASE_LIFE

*const* · `packages/destruction/src/debris.ts:45`

```ts
const BASE_LIFE: 8
```

base life of a small piece, seconds, times `ctx.debrisLife` (tuning constant)

### BEAD_WIDTH

*const* · `packages/destruction/src/autoparts.ts:54`

```ts
const BEAD_WIDTH: 0.01
```

the width of the adhesive bead and of the window seal's grip, m

### BIG_BREAK

*const* · `packages/destruction/src/debris.ts:51`

```ts
const BIG_BREAK: 2000
```

a far break makes dust only from this energy, J (tuning constant)

### BODY_SECONDS

*const* · `packages/destruction/src/debris.ts:33`

```ts
const BODY_SECONDS: 1
```

seconds a middle-distance piece stays a body before it becomes an instance

### BOLT_TENSILE

*const* · `packages/destruction/src/autoparts.ts:46`

```ts
const BOLT_TENSILE: 800000000
```

handbook strengths of the fixings, Pa: grade 8.8 bolt, spot-weld nugget (as the sheet's tensile strength is used), polyurethane windscreen adhesive, window channel seal

### BUMP_STOP_FACTOR

*const* · `packages/destruction/src/vehicle.ts:81`

```ts
const BUMP_STOP_FACTOR: 20
```

the bump stop is this many times stiffer than the spring

### BUMPER_DEPTH_FRACTION

*const* · `packages/destruction/src/autoparts.ts:40`

```ts
const BUMPER_DEPTH_FRACTION: 0.25
```

where the bumper starts, as a share of the overhang beyond the axle; its height as a share of the body's height

### BUMPER_HEIGHT_FRACTION

*const* · `packages/destruction/src/autoparts.ts:40`

```ts
const BUMPER_HEIGHT_FRACTION: 0.4
```

### BUMPER_LOAD_SHARE

*const* · `packages/destruction/src/autoparts.ts:34`

```ts
const BUMPER_LOAD_SHARE: 0.05
```

### BUMPER_THICKNESS

*const* · `packages/destruction/src/autoparts.ts:24`

```ts
const BUMPER_THICKNESS: 0.002
```

thickness of a bumper's steel reinforcement beam and cover, m

### CAR_CONTACT_AREA

*const* · `packages/destruction/src/vehicle.ts:105`

```ts
const CAR_CONTACT_AREA: 0.1
```

a hit that was not given an area gets this one on the car, m^2

### CAR_MASS

*const* · `packages/destruction/src/autoparts.ts:61`

```ts
const CAR_MASS: Record<string, number>
```

curb weights of the real models, kg: the 1987 police-package sedan (about 4000 lb) and the 1987 convertible (about 3300 lb); chosen by the lead with the owner's consent (2026-11-12)

### CHASSIS

*const* · `packages/destruction/src/autoparts.ts:56`

```ts
const CHASSIS: "Chassis"
```

### CHASSIS_SECTION

*const* · `packages/destruction/src/autoparts.ts:26`

```ts
const CHASSIS_SECTION: 0.0015
```

effective section thickness of the chassis frame that carries a crush zone, m (rails and fold lines: a modelling constant; the plateau force is yield x this x the load share)

### CHIP_ZONE_DEPTHS

*const* · `packages/destruction/src/wood.ts:56`

```ts
const CHIP_ZONE_DEPTHS: 0.5
```

the length of the chip zone at the break plane, in section depths (tuning constant)

### CHIPS_MAX

*const* · `packages/destruction/src/wood.ts:58`

```ts
const CHIPS_MAX: 12
```

### COM_FRONT_BIAS

*const* · `packages/destruction/src/autoparts.ts:42`

```ts
const COM_FRONT_BIAS: 0.1
```

the centre of mass of the chassis (the structure with the engine and drivetrain): ahead of the middle of the wheelbase by this share of it, at this share of the body's top height

### COM_HEIGHT_RATIO

*const* · `packages/destruction/src/autoparts.ts:42`

```ts
const COM_HEIGHT_RATIO: 0.4
```

### COMPRESSION_RATIO

*const* · `packages/destruction/src/wood.ts:48`

```ts
const COMPRESSION_RATIO: 0.5
```

compressive strength along the grain over the modulus of rupture (clear wood, about one half; tuning constant)

### CRUSH_BOTTOM_FORCE_RATIO

*const* · `packages/destruction/src/crush.ts:24`

```ts
const CRUSH_BOTTOM_FORCE_RATIO: 6
```

the force at `dMax` is this many times the plateau force (the bottomed-out branch is stiff)

### CRUSH_BOTTOM_FRACTION

*const* · `packages/destruction/src/crush.ts:22`

```ts
const CRUSH_BOTTOM_FRACTION: 0.85
```

the plateau ends (the zone starts to bottom out) at this fraction of `dMax`

### CRUSH_DT

*const* · `packages/destruction/src/crush.ts:34`

```ts
const CRUSH_DT: number
```

the fixed step of `decelerationAlong`, s

### CRUSH_HARD_FACTOR

*const* · `packages/destruction/src/crush.ts:26`

```ts
const CRUSH_HARD_FACTOR: 50
```

past `dMax` the zone is a solid block: its stiffness is this many times the slope of the bottoming-out branch

### CRUSH_LOAD_SHARE

*const* · `packages/destruction/src/crush.ts:18`

```ts
const CRUSH_LOAD_SHARE: 0.25
```

share of the section's perimeter that lies in the load path (rails and fold lines rather than skin) when the effective area is built from a sheet thickness: a modelling constant, not a measured one

### CRUSH_ONSET_FRACTION

*const* · `packages/destruction/src/crush.ts:20`

```ts
const CRUSH_ONSET_FRACTION: 0.03
```

the stiff first branch of the default curve ends (the plateau starts) at this fraction of `dMax`

### crushModel

*const* · `packages/destruction/src/crush.ts:363`

```ts
const crushModel: FailureModel
```

the `ductile` failure model with no zones given: a default zone along the hit's normal (`defaultZoneFor`)

### DEBRIS_BOUNCE

*const* · `packages/destruction/src/service.ts:45`

```ts
const DEBRIS_BOUNCE: 0.3
```

### DEBRIS_GRAVITY

*const* · `packages/destruction/src/service.ts:43`

```ts
const DEBRIS_GRAVITY: 9.81
```

the cheap fall of pieces that are not bodies (and of bodies when the host gives no speeds): gravity, m/s^2

### DEBRIS_GROUND_FRICTION

*const* · `packages/destruction/src/service.ts:45`

```ts
const DEBRIS_GROUND_FRICTION: 0.6
```

the share of its speed along the ground that a piece keeps when it lands, and of its vertical speed that it bounces with (before the style's `debrisBounce`)

### DEBRIS_LOD

*const* · `packages/destruction/src/debris.ts:31`

```ts
const DEBRIS_LOD: DebrisLod
```

### DEBRIS_SLEEP_SPEED

*const* · `packages/destruction/src/debris.ts:35`

```ts
const DEBRIS_SLEEP_SPEED: 0.05
```

m/s below which a piece counts as still

### DEBRIS_SLEEP_TIME

*const* · `packages/destruction/src/debris.ts:37`

```ts
const DEBRIS_SLEEP_TIME: 0.5
```

seconds a piece must stay still to sleep

### DEFAULT_MAX_BODIES

*const* · `packages/destruction/src/service.ts:41`

```ts
const DEFAULT_MAX_BODIES: 50
```

bodies alive at once among the pieces (the tier table's `maxShardBodies`): a tuning constant, a quarter of the piece cap

### DEFAULT_MAX_PIECES

*const* · `packages/destruction/src/service.ts:39`

```ts
const DEFAULT_MAX_PIECES: 200
```

pieces alive at once over the world (the tier table's `maxPieces`, as the strength capability's default)

### DENT_DIMS

*const* · `packages/destruction/src/crush.ts:36`

```ts
const DENT_DIMS: [number, number, number]
```

the default dent lattice, points along x, y, z of the part (about 5 x 3 x 3 per panel)

### DENT_MIN_RADIUS_SPACINGS

*const* · `packages/destruction/src/crush.ts:28`

```ts
const DENT_MIN_RADIUS_SPACINGS: 1.5
```

a lattice dent never gets a radius below this many grid spacings, so that it always lands on control points

### DESTRUCTION_EVENTS

*const* · `packages/destruction/src/motion.ts:27`

```ts
const DESTRUCTION_EVENTS: readonly string[]
```

the events of the service delivered to programs: the `destruction:` names the service announces

### DICE_THICKNESSES

*const* · `packages/destruction/src/glass.ts:50`

```ts
const DICE_THICKNESSES: 3
```

a tempered pane dices into cells of this many thicknesses (tuning constant)

### DUST_BUDGET_SHARE

*const* · `packages/destruction/src/stone.ts:39`

```ts
const DUST_BUDGET_SHARE: 0.4
```

the share of the crack budget dust may take (tuning constant)

### DUST_GRAIN

*const* · `packages/destruction/src/stone.ts:37`

```ts
const DUST_GRAIN: 0.0002
```

the size of a dust grain, m (tuning constant)

### DUST_PUFFS

*const* · `packages/destruction/src/stone.ts:41`

```ts
const DUST_PUFFS: 6
```

how many dust puffs the dust of one break is merged into at most

### END_GRAIN_COS

*const* · `packages/destruction/src/wood.ts:42`

```ts
const END_GRAIN_COS: 0.7
```

|n . axis| from which a hit is an end-grain hit

### FADE_TIME

*const* · `packages/destruction/src/debris.ts:47`

```ts
const FADE_TIME: 1.5
```

seconds a fading piece takes to shrink to nothing

### FENDER_LOAD_SHARE

*const* · `packages/destruction/src/autoparts.ts:34`

```ts
const FENDER_LOAD_SHARE: 0.07
```

### FILL_BUMPER

*const* · `packages/destruction/src/autoparts.ts:28`

```ts
const FILL_BUMPER: 2
```

### FILL_DOOR

*const* · `packages/destruction/src/autoparts.ts:28`

```ts
const FILL_DOOR: 4
```

### FILL_FENDER

*const* · `packages/destruction/src/autoparts.ts:28`

```ts
const FILL_FENDER: 1
```

### FILL_HOOD

*const* · `packages/destruction/src/autoparts.ts:28`

```ts
const FILL_HOOD: 2
```

each panel's mass is density x thickness x face area x fill: the fill stands for inner panels, stiffeners and fittings (a hood or door is far more than its skin)

### FILL_SOFT_TOP

*const* · `packages/destruction/src/autoparts.ts:28`

```ts
const FILL_SOFT_TOP: 5
```

### FILL_TRUNK

*const* · `packages/destruction/src/autoparts.ts:28`

```ts
const FILL_TRUNK: 2
```

