# @ferret/humans: API (continued)

### skinFromColour

*function* · `packages/humans/src/commands.ts:88`

```ts
function skinFromColour(c: Rgb, age = 30): { melanin: number; redness: number }
```

The melanin and redness whose skin tone is nearest (linear) to a colour sampled from a picture.

### skinReduce

*function* · `packages/humans/src/materials.ts:141`

```ts
function skinReduce(tier: MaterialTier, mobile: boolean): number
```

Texture size reduction (power of two, see composeSkin's `reduce`) per tier and device: the phone gets one step less detail at the same tier, and a
crowd figure never needs more than a quarter-size sheet (it is a few dozen pixels tall on screen).

### skinToBody

*function* · `packages/humans/src/props.ts:76`

```ts
function skinToBody(kit: BuiltKit, m: Mesh, id: string, mat: PartMaterial, k = 3): BuiltPart
```

Skins a mesh by the weights of the nearest body vertices (the way hair is bound): worn cloth-like pieces then follow the torso and the pelvis.

### skinTone

*function* · `packages/humans/src/skin.ts:53`

```ts
function skinTone(skin: Pick<SkinSpec, 'melanin' | 'redness'>, age = 30): SkinTone
```

Average skin colour of a person. `age` in years: old skin is a little paler in chroma and rougher.

### socketsOf

*function* · `packages/humans/src/props.ts:97`

```ts
function socketsOf(kit: BuiltKit): Record<string, Socket>
```

### splitEyes

*function* · `packages/humans/src/eyes.ts:11`

```ts
function splitEyes(part: Pick<BuiltPart, 'positions' | 'indices'>): EyeSplit
```

### springStep

*function* · `packages/humans/src/hair.ts:111`

```ts
function springStep(points: Float32Array, prev: Float32Array, rest: Float32Array, pin: [number, number, number], dt: number, opts: { gravity?: number; damping?: number; iterations?: number } = {}): { points: Float32Array; prev: Float32Array }
```

Spring chain for long hair and beards (Verlet with length constraints). `points` are 3 floats per node, node 0 is pinned to the head; `prev` is the
previous step; `gravity` m/s², `damping` kept per step. Pure: returns new arrays, so the same inputs give the same motion.

### statureOf

*function* · `packages/humans/src/weights.ts:54`

```ts
function statureOf(pack: ShapePack, w: AxisWeights): number
```

The stature a weight set gives (metres), from the pack's calibration.

### stepChains

*function* · `packages/humans/src/chain.ts:121`

```ts
function stepChains(rig: Rig, kit: BuiltKit, state: ChainState, pose: Pose, dt: number): Pose
```

Advances the chains by `dt` seconds and writes their local rotations into a copy of the pose. Each chain is a pinned Verlet chain with fixed segment lengths
pulled back toward the pose it would have without physics (stiffness) and down by gravity: the root (an animated body joint) drives it, so a tail swings when the
body turns and an ear flicks when the head shakes. Deterministic.

### strandLayer

*function* · `packages/humans/src/coat.ts:96`

```ts
function strandLayer(albedo: Img, layer: number, layers: number, seed = 1, cell = 2): Img
```

A strand layer: the albedo with the alpha cut where the strand is shorter than the layer, root darker. Returns RGBA with alpha 0 / 255.

### styleClip

*function* · `packages/humans/src/motion.ts:252`

```ts
function styleClip(rig: Rig, clip: GaitClip, style: MotionStyle): GaitClip
```

Applies a motion style to a gait clip, returning a new clip (same bones and frames). Every parameter -1..1, 0 = the clip as it is:
`armSwing` and `shoulderRoll` and `hipSway` scale the amplitude of that part's swing about its cycle mean, `energy` scales all swing and `bounce` the pelvis rise
(reduced by `heaviness`), `posture` leans the spine forward when negative and straightens it when positive, `confidence` lifts the head and chest or drops
them, `strideWidth` sets the legs apart, `limp` weakens one leg and drops the pelvis on its side, `load` pulls the arms in and leans forward.
Tempo is not baked here: a brisk person walks faster (`deriveMotion` scales the speeds by it) and the cadence match sets the playback rate for that speed.

### sub

*function* · `packages/humans/src/primitives.ts:13`

```ts
function sub: (a: V3, b: V3) => V3
```

### swingPanel

*function* · `packages/humans/src/loose.ts:131`

```ts
function swingPanel(state: PanelState, goal: Float32Array, rest: Float32Array, rows: number, seg: number, dt: number, opts: { stiffness?: number; damping?: number; iterations?: number } = {}): PanelState
```

One step of a hanging panel. `goal` is the panel posed by the skeleton (skinned, no lag) in the same layout; ring 0 is pinned to it. Each lower ring is pulled to its goal
with spring `stiffness` per second, keeps inertia (`damping` per step) and its ring-to-ring length (`rest`, from the unposed panel) is kept, so a hem trails a moving
leg and swings back. Pure: new arrays, the same inputs give the same motion.

### teethRows

*function* · `packages/humans/src/tongue.ts:13`

```ts
function teethRows(positions: Float32Array, indices: ArrayLike<number>): { upper: number[]; lower: number[] }
```

The two tooth rows of the head4 part (it also holds the shells at the eyes): connected components, by welded position, that sit on the midline and are
wide. Returns the vertex lists of the upper and the lower row (lower = the one with the lower mean height); empty when the part has no teeth.

### tongueBuiltPart

*function* · `packages/humans/src/tongue.ts:72`

```ts
function tongueBuiltPart(shape: TongueShape, joint: number, normals: Float32Array): BuiltPart
```

The tongue as a BuiltPart skinned to the head joint (index `joint`).

### tongueOutDelta

*function* · `packages/humans/src/tongue.ts:64`

```ts
function tongueOutDelta(rest: Float32Array, reach = 0.05): Float32Array
```

The displacement of tongueOut = 1 (metres, 3 per vertex) of a tongue's rest positions: the tip comes forward past the teeth and lifts a little; the root stays.

### torus

*function* · `packages/humans/src/primitives.ts:109`

```ts
function torus(c: V3, axis: V3, R: number, r: number, seg = 24, segr = 8): Mesh
```

A torus (ring) about `axis`: major radius R, minor radius r.

### toSpecColour

*function* · `packages/humans/src/picture.ts:46`

```ts
function toSpecColour: (c: Rgb) => Rgb
```

Linear RGB to the sRGB the spec stores? No: the spec stores linear-ish scene colours as in `colour: Rgb`; this returns them unchanged for clarity.

### toSrgb

*function* · `packages/humans/src/skin.ts:33`

```ts
function toSrgb: (c: number) => number
```

### translate

*function* · `packages/humans/src/primitives.ts:36`

```ts
function translate: (m: Mesh, d: V3) => Mesh
```

### treadmill

*function* · `packages/humans/src/motion.ts:421`

```ts
function treadmill(pack: MotionPack, rig: Rig, clip: GaitClip, speed: number): SlideReport
```

Treadmill test of a body: plays the (styled) gait at the cadence-matched rate while the ground slides back at `speed`, and measures how fast the stance feet move on
the ground, before and after planting them with IK. A foot on the ground does not move: the numbers are the foot sliding.

### tube

*function* · `packages/humans/src/primitives.ts:48`

```ts
function tube(path: V3[], radii: (number | [number, number])[], seg = 10, cap = true): Mesh
```

A tube along a polyline with a radius (or [rx, rz]) per point, `seg` sides, capped at both ends when `cap` is set. Closed at the tip when its last radius is 0.

### turtle

*function* · `packages/humans/src/kit-head.ts:94`

```ts
function turtle(p0: V3, dir: V3, axis: V3, length: number, curve: number, steps = 14, twist = 0): V3[]
```

A turtle path: starts at `p0` going `dir`, bends about `axis` by `curve` radians per metre. Returns the points.

### tuskMesh

*function* · `packages/humans/src/kit-head.ts:142`

```ts
function tuskMesh(len: number, curve: number, x: number, sx: number): Mesh
```

Two tusks rising from the lower jaw (orc, boar).

### typicalStature

*function* · `packages/humans/src/weights.ts:57`

```ts
function typicalStature(age: number, sex: number): number
```

Median stature (metres) by age and sex (0 female .. 1 male), from the WHO/CDC growth medians; a reference for when a text gives an age but no height.

### uniform

*function* · `packages/humans/src/uniforms.ts:59`

```ts
function uniform(id: string): OutfitPiece[]
```

The pieces of a named uniform (a fresh array each time). Throws on an unknown id so a typo is not a silent naked soldier.

### uniformIds

*function* · `packages/humans/src/uniforms.ts:64`

```ts
function uniformIds: () => string[]
```

### validateSpec

*function* · `packages/humans/src/validate.ts:34`

```ts
function validateSpec(spec: HumanSpec, opts: ValidateOptions = {}): Issue[]
```

Checks a spec; returns every problem found (errors make the spec unusable, warnings are reported and the spec still builds).

### variantBytes

*function* · `packages/humans/src/crowd.ts:181`

```ts
function variantBytes: (v: CrowdVariant) => number
```

Memory of a baked variant in bytes (positions and normals as the GPU gets them: float32).

### warpMuzzle

*function* · `packages/humans/src/kit-head.ts:52`

```ts
function warpMuzzle(b: BuiltKit, m: HeadMarks, o: NonNullable<HeadKit['muzzle']>): void
```

Warps the head parts (not the eyes) into a muzzle: the lower face from the chin up to the nose bridge is pushed forward by `length` (the lips and teeth ride with it,
the cheeks stay), pinched in width and flattened in height. Sets `exprGain` so that the jaw opens further on a longer jaw. Returns the new nose tip z.

### weldNormals

*function* · `packages/humans/src/kit-core.ts:153`

```ts
function weldNormals(p: BuiltPart): void
```

Position-welded normals (UV seams and duplicated vertices share a normal): used after a part's positions are changed.

### whiteBalance

*function* · `packages/humans/src/picture.ts:16`

```ts
function whiteBalance(img: Img, white?: Region): Rgb
```

Gray-world white balance of a whole picture: the gain per channel that makes the mean grey. Pass `white` (a region of something known to be white or grey) to use it instead.

### withCap

*function* · `packages/humans/src/hair.ts:38`

```ts
function withCap(data: HumanData, built: BuiltHuman, id: string, p: BuiltPart, lift = 0.005): BuiltPart
```

A solid scalp shell under a simplified style: the skin triangles the style is bound to (two of three vertices), lifted by `lift` metres along their normals and merged
into the style part. Clustered curls leave gaps; the shell keeps the head covered at the crowd tiers.

### worley

*function* · `packages/humans/src/coat.ts:25`

```ts
function worley(x: number, y: number, z: number, s = 0): { f1: number; f2: number; id: number }
```

Worley noise: distance to the nearest and second nearest jittered cell point, and the nearest cell's id (0..1).

## Interfaces

### AttachItem

*interface* · `packages/humans/src/attach.ts:11`

```ts
interface AttachItem
```

Attachments: hair styles, brows, lashes and beards bound to the skin. Each vertex stores its 4 nearest skin vertices (head0 numbering, then
body0) and weights; it moves by the weighted displacement of the BUILT skin (positions minus base), so it follows every shape axis and every expression with
no per-axis data. Joints and skin weights are those of the nearest skin vertex, so a long style follows the neck and shoulders too.

- `id: string`
- `kind: 'hair' | 'brows' | 'lashes' | 'beard' | string`
- `source: string`
- `female: boolean`
- `vertices: number`
- `triangles: number`
- `positions: Float32Array`
- `uv: Float32Array | null`
- `indices: Uint16Array | Uint32Array`
- `bindIdx: Uint32Array` — 4 skin vertices per vertex: head0 index, or head0 vertex count + body0 index
- `bindW: Uint8Array`
- `ranges?: { start: number; count: number; mesh: string; prim: number }[]` — library garments: material ranges (triangle start and count per original primitive) and the body0 triangles the garment hides
- `hidden?: Uint32Array`

### AttachPack

*interface* · `packages/humans/src/attach.ts:20`

```ts
interface AttachPack
```

- `skinParts: string[]`
- `items: Map<string, AttachItem>`

### AxisDef

*interface* · `packages/humans/src/axes.ts:6`

```ts
interface AxisDef
```

The shape axes of a person. Every axis is a number; face and proportion axes are signed, -1..1, 0 = the base figure. The tables are
APPEND-ONLY: the share code (code.ts) refers to an axis by its index here, so reordering or removing one breaks every saved code.

- `id: string`
- `region: string` — the region of the face
- `min: number`
- `max: number`
- `weight: number` — how much the axis changes the front view and the profile; used by faceDistance

### BakedClip

*interface* · `packages/humans/src/crowd.ts:21`

```ts
interface BakedClip
```

Crowds: many different people for little. Each distinct person is a VARIANT: one merged mesh at a crowd tier (body, head, hair and clothes in one
part, colours per vertex), baked into vertex animation for a planted walk cycle, a jog cycle and an idle (positions and normals for every frame). Everybody on screen
is an INSTANCE of a variant: a start position, heading, phase, playback rate (which is also the travel speed, so feet do not slide), scale and a colour tint. The
GPU does the rest (see tools/humans/p10-crowd.mjs for the shader): the CPU cost per frame is one time value. Any instance can be swapped for a full figure when it
comes close (`buildFigure` of the same spec at L0/L1): the variant keeps its spec.

- `name: 'walk' | 'jog' | 'idle'`
- `frames: number`
- `fps: number` — poses per second at rate 1
- `duration: number`
- `speed: number` — travel speed in m/s at rate 1 (0 for idle)
- `positions: Float32Array` — frames x vertices x 3
- `normals: Float32Array` — frames x vertices x 3, unit

### BakeOptions

*interface* · `packages/humans/src/crowd.ts:98`

```ts
interface BakeOptions
```

- `tier?: string` — crowd tier of the geometry: 'L3d' (far) or 'L2d' (near)
- `idleFrames?: number` — frames of the idle clip (subsampled)
- `clips?: ('walk' | 'jog' | 'idle')[]`

### BaseFigure

*interface* · `packages/humans/src/data.ts:24`

```ts
interface BaseFigure
```

- `skeleton: string`
- `joints: BaseJoint[]`
- `parts: Map<string, BasePart>`

### BaseJoint

*interface* · `packages/humans/src/data.ts:23`

```ts
interface BaseJoint
```

- `name: string`
- `parent: number`
- `rest: [number, number, number]`

### BasePart

*interface* · `packages/humans/src/data.ts:11`

```ts
interface BasePart
```

- `id: string`
- `vertices: number`
- `triangles: number`
- `positions: Float32Array`
- `uv: Float32Array | null`
- `indices: Uint16Array | Uint32Array`
- `joints: Uint8Array` — 8 joint indices (into `joints`) per vertex
- `weights: Uint8Array` — 8 weights per vertex, 0..255, summing to 255

### BeakKit

*interface* · `packages/humans/src/kit-core.ts:76`

```ts
interface BeakKit
```

- `length: number`
- `depth: number`
- `hook?: number`
- `width?: number`
- `colour: Rgb`
- `colour2?: Rgb`
- `open?: number`

### BodyRegions

*interface* · `packages/humans/src/garment.ts:87`

```ts
interface BodyRegions
```

The body0 vertices classified by region, with the limb parameter and the measures the templates cut by.

- `group: Uint8Array`
- `t: Float32Array`
- `neckY: number`
- `crotchY: number`
- `waistY: number`
- `soleY: number`
- `ankleY: number`
- `jointPos(name: string): [number, number, number]`

### BodySpec

*interface* · `packages/humans/src/spec.ts:42`

```ts
interface BodySpec
```

- `sex: number` — 0 female .. 1 male, continuous
- `age: number` — years
- `height: number` — metres
- `build?: { /** Heath-Carter ratings [endomorphy, mesomorphy, ectomorphy], 0.5..9 */ somatotype?: [number, number, number]; /** bone breadth, -1 slight .. 1 heavy */ frame?: number; /** -1 gynoid (hips, thighs) .. 1 android (belly, waist) */ fatPattern?: number; /** kg; with height gives BMI */ mass?: number; }` — the high level (5a); resolves to the low level where that is left unset
- `weight?: number` — the low level: -1 emaciated .. 1 obese (0 average). Unset = resolved from `build`.
- `muscle?: number` — the low level: -1 wasted .. 1 very muscular (0 average). Unset = resolved from `build`.
- `proportions: Partial<Record<typeof PROPORTION_AXES[number], number>>`

### BuiltHuman

*interface* · `packages/humans/src/build.ts:47`

```ts
interface BuiltHuman
```

- `tier: string`
- `parts: Map<string, BuiltPart>`
- `joints: { name: string; parent: number; rest: [number, number, number] }[]` — joint names, parents and shaped rest positions (the skeleton follows the shape)
- `weights: AxisWeights`
- `stature: number` — head top to sole, metres, measured on the built geometry
- `predictedStature: number` — what the pack's calibration predicted (the check of `stature`)

### BuiltKit

*interface* · `packages/humans/src/kit-core.ts:25`

```ts
interface BuiltKit extends BuiltHuman
```

- `kit: string`
- `options: KitOptions`
- `extraJoints: number` — number of joints beyond the 87 of the contract
- `chains: ChainInfo[]`
- `sockets: Record<string, Socket>`
- `digitigrade: boolean` — the legs were rebuilt with a hock: the IK of `plantFoot` must aim the ball (see `kitRig`)
- `tierName?: string` — the geometry tier this was built at
- `rigid: boolean` — parts hold one joint per vertex (robots): no skin blending anywhere
- `motion?: Record<string, number>` — the gait style a kit asks for by default (robots snap, giants lumber)
- `hidden: string[]` — parts that are built (clothes and props fit them) but not drawn: the skin under a robot's panels
- `roles: Record<string, string[]>` — the ids of the parts the kit added, by role (for hiding/replacing in a viewer)

### BuiltPart

*interface* · `packages/humans/src/build.ts:24`

```ts
interface BuiltPart
```

The geometry of one part of a built person at one LOD tier.

- `id: string`
- `positions: Float32Array` — 3 floats per vertex, metres, the shaped positions
- `normals: Float32Array` — smooth normals (UV seams are welded)
- `uv: Float32Array | null`
- `indices: Uint16Array | Uint32Array`
- `skinJoints: Uint8Array` — 8 joints and 8 weights per vertex, indices into `joints` of the built person
- `skinWeights: Uint8Array`
- `source: Uint32Array` — the base vertex each built vertex came from (identity at the full tier)
- `material?: PartMaterial` — a material of its own (kit parts, props); absent for skin, hair and garments that the material set colours
- `morphs?: Record<string, Float32Array>` — kit parts that move with an expression (a beak's lower half opens with jawOpen): additive position deltas at weight 1, by ARKit name
- `exprGain?: Float32Array` — per-vertex gain on expression deltas (a kit with a long muzzle opens its jaw further than the base head); absent = 1
- `ranges?: { start: number; count: number; mesh: string; prim: number }[]` — library garments: material ranges over the triangles

### ChainInfo

*interface* · `packages/humans/src/kit-core.ts:15`

```ts
interface ChainInfo
```

- `name: string`
- `kind: 'tail' | 'ear' | 'horn' | 'cloth' | 'feather' | 'tentacle'`
- `joints: number[]` — joint indices from the root outward (the root is an existing body joint)
- `stiffness: number` — spring stiffness 0..1 per step, damping 0..1, gravity m/s^2 along -y, seconds of lag
- `damping: number`
- `gravity: number`
- `side?: 'l' | 'r'`

### ChainState

*interface* · `packages/humans/src/chain.ts:113`

```ts
interface ChainState
```

State of the chain simulation of one kit (positions of every chain particle, current and previous).

- `pos: Float32Array[]`
- `prev: Float32Array[]`
- `started: boolean`

### CoatContext

*interface* · `packages/humans/src/coat.ts:37`

```ts
interface CoatContext
```

The colour of a coat at a point of the body, by pattern. `ctx` carries the measures the patterns use.

- `chestY: number`
- `noseZ: number`
- `chinY: number`
- `pelvisY: number`

### CoatKit

*interface* · `packages/humans/src/kit-core.ts:90`

```ts
interface CoatKit
```

- `kind: 'fur' | 'scales' | 'feathers' | 'plain'`
- `colour: Rgb`
- `colour2?: Rgb`
- `pattern?: string` — fur and feathers: 'plain' | 'tabby' | 'spots' | 'saddle' | 'bicolour' | 'stripes' | 'mane'; scales: 'plain' | 'bands' | 'diamond'
- `length?: number` — fur length in metres
- `bare?: ('face' | 'hands' | 'feet')[]` — where the coat does NOT reach: face front, hands... 'face' | 'hands' | 'feet'
- `tufts?: ('cheeks' | 'chest' | 'neck' | 'tail' | 'ears' | 'arms' | 'legs' | 'back' | 'crown' | 'face')[]` — tufts of cards at the silhouette: where they grow
- `tuftLength?: number`
- `seed?: number`

### CommandHost

*interface* · `packages/humans/src/commands.ts:27`

```ts
interface CommandHost
```

The `humans.*` commands, host-agnostic: a host gives `register(name, description, fn)` (the viewer passes `world.commands.register`, a test passes
a Map) and gets a session of named specs. Every command takes and returns plain JSON (bytes aside), so a person, a test and an agent drive the same things.

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

### ComposeOptions

*interface* · `packages/humans/src/compose.ts:15`

```ts
interface ComposeOptions
```

- `tint: TintMap`
- `zones?: FaceZones` — only for the head sheet
- `skin: SkinSpec`
- `age: number`
- `seed: number`
- `reduce?: number` — output size = tint size / 2^reduce (the mobile tiers use 1)
- `sheet: 'head' | 'body'` — 'head' or 'body': what the sheet is, for the density of the marks

### Condition

*interface* · `packages/humans/src/spec.ts:27`

```ts
interface Condition
```

How worn a garment is, 0..1 each (8a.5).

- `wear?: number`
- `dirt?: number`
- `mud?: number`
- `wet?: number`
- `torn?: number`
- `blood?: number`
- `faded?: number`

### Conflict

*interface* · `packages/humans/src/vocab.ts:116`

```ts
interface Conflict
```

- `axis: string`
- `a: string`
- `b: string`

### CrowdOptions

*interface* · `packages/humans/src/crowd.ts:158`

```ts
interface CrowdOptions
```

- `variants: number`
- `arena?: number`
- `seed?: number`
- `idleShare?: number`
- `jogShare?: number`

### CrowdPerson

*interface* · `packages/humans/src/crowd.ts:133`

```ts
interface CrowdPerson
```

- `variant: number`
- `x: number` — metres in the arena (square, centred), heading in radians (0 = +z)
- `z: number`
- `heading: number`
- `clip: 'walk' | 'jog' | 'idle'`
- `rate: number` — playback rate: also the speed relative to the baked speed (feet do not slide)
- `phase: number` — 0..1 of the cycle at time 0
- `scale: number`
- `tint: Rgb` — multiplies the vertex colours (linear), a slight difference between people sharing a variant

### CrowdPlan

*interface* · `packages/humans/src/crowd.ts:147`

```ts
interface CrowdPlan
```

- `specs: HumanSpec[]`
- `people: CrowdPerson[]`

### CrowdVariant

*interface* · `packages/humans/src/crowd.ts:35`

```ts
interface CrowdVariant
```

- `id: number`
- `spec: HumanSpec`
- `tier: string`
- `vertices: number`
- `triangles: number`
- `indices: Uint16Array | Uint32Array`
- `rest: Float32Array` — rest positions, and 3 bytes of sRGB colour per vertex
- `colours: Uint8Array`
- `clips: BakedClip[]`
- `height: number`
- `radius: number`

### DerivedMotion

*interface* · `packages/humans/src/motion.ts:143`

```ts
interface DerivedMotion
```

- `radius: number` — metres
- `height: number`
- `crouchHeight: number`
- `eyeHeight: number`
- `legLength: number`
- `strideLength: number`
- `mass: number`
- `walkSpeed: number`
- `runSpeed: number`
- `crouchSpeed: number`
- `acceleration: number`
- `braking: number`
- `maxStepHeight: number`
- `jumpVelocity: number`

### Described

*interface* · `packages/humans/src/vocab.ts:117`

```ts
interface Described
```

- `face: FaceSpec`
- `age?: number` — age in years if the text gave one
- `sex?: number` — 0 female .. 1 male if the text said
- `matched: { id: string; text: string; factor: number }[]`
- `conflicts: Conflict[]`
- `unmatched: string[]` — words of the text no descriptor took (so the caller can see what was ignored)

### Descriptor

*interface* · `packages/humans/src/vocab.ts:13`

```ts
interface Descriptor
```

Words to a face. The text is split into words, descriptors are found by longest match (Russian by stem, English by whole word),
an intensity word just before a descriptor scales it, "не"/"not" flips it. Descriptors CONSTRAIN the axes they name; the seed FILLS every other axis, so one
description with different seeds gives different people who all match it. Two descriptors that pull an axis in opposite directions are reported as a conflict.

- `id: string`
- `ru: string[][]`
- `en: string[][]`
- `axes: Record<string, number>` — axis targets (for a composite, the targets of its members, summed and clamped)
- `composite: boolean`
- `group: string`

### DigiOptions

*interface* · `packages/humans/src/digitigrade.ts:11`

```ts
interface DigiOptions
```

Digitigrade legs (dogs, cats, birds, lizardfolk): the same four leg joints of the contract (thigh, calf, foot, ball) in a different rest shape. The knee goes
forward, the "foot" joint becomes the hock behind and above the toes, and the long segment from hock to ball is the metatarsus; the mesh is carried along by
a rigid transform per bone (with the length stretched to fit), the toes keep lying flat. The clips are plantigrade: they are retargeted by local rotations and
the stance foot is planted by `plantFoot` aiming the ball (the rig of `kitRig` takes the leg scale from hip to ball), so the feet do not slide.

- `hock?: number`
- `meta?: number`
- `shank?: number`

### Dist

*interface* · `packages/humans/src/random.ts:50`

```ts
interface Dist
```

A range with an optional normal shape: truncated to min..max; without `sd` it is uniform.

- `min: number`
- `max: number`
- `mean?: number`
- `sd?: number`

### DrapeResult

*interface* · `packages/humans/src/loose.ts:26`

```ts
interface DrapeResult extends GarmentResult
```

- `panel: { first: number; rows: number; seg: number }`

### DrapeSpec

*interface* · `packages/humans/src/loose.ts:14`

```ts
interface DrapeSpec
```

- `kind: DrapeKind`
- `width?: number` — metres, default per kind
- `length?: number`
- `thickness?: number` — cloth thickness over the skin, metres
- `cols?: number` — grid resolution (columns, rows)
- `rows?: number`

### EarKit

*interface* · `packages/humans/src/kit-core.ts:74`

```ts
interface EarKit
```

- `kind: 'pointed' | 'round' | 'long' | 'floppy' | 'elf' | 'bat' | 'jackal' | 'horse'`
- `size: number`
- `height?: number`
- `tilt?: number`
- `back?: number`
- `colour?: Rgb`
- `inner?: Rgb`
- `physics?: boolean`
- `x?: number`

### EyeColours

*interface* · `packages/humans/src/skin.ts:82`

```ts
interface EyeColours
```

- `iris: Rgb`
- `iris2: Rgb`
- `sclera: Rgb`
- `pupil: number`

### EyeSplit

*interface* · `packages/humans/src/eyes.ts:9`

```ts
interface EyeSplit
```

The eyeball part (head1) holds both eyes in one UV layout. To give each eye its own iris (heterochromia) the triangles are split by the side of the
head they sit on: x > 0 is the person's left eye. The vertices stay shared (same positions, uv, skin), only the index lists differ, so a renderer
draws the part twice with two textures (composeEye with second = false / true).

- `left: Uint16Array | Uint32Array`
- `right: Uint16Array | Uint32Array`

### EyesSpec

*interface* · `packages/humans/src/spec.ts:89`

```ts
interface EyesSpec
```

- `iris: Rgb`
- `iris2?: Rgb` — second iris colour for heterochromia; unset = same
- `sclera: number`
- `pupil: number`

### FabricInfo

*interface* · `packages/humans/src/fabric.ts:10`

```ts
interface FabricInfo
```

Fabrics and condition. A fabric is a procedural weave or grain on a tileable square: the colour (solid, stripes, check, tartan, print,
camouflage) times the weave shading, then the condition baked in (wear, dirt, mud, wet, tears, blood, fading). The result is one RGBA tile per garment
(alpha 0 = a tear, for alpha cut-off), reused by every tier, so the frame cost does not grow with the number of details.

- `id: string`
- `roughness: number` — PBR roughness of the clean cloth
- `sheen: number` — velvet/silk sheen 0..1
- `metallic: number` — metalness (mail, plate, gilding)
- `weave: number` — weave period in pixels of a 256 tile and amplitude of the shading 0..1
- `amp: number`
- `thickness: number` — thickness in mm, for the hem and the lift of layers
- `kind: 'plain' | 'twill' | 'knit' | 'leather' | 'felt' | 'mail' | 'plate' | 'sheen' | 'denim' | 'canvas'`

### FabricInput

*interface* · `packages/humans/src/fabric.ts:35`

```ts
interface FabricInput
```

- `fabric: string`
- `colour?: Rgb`
- `pattern?: Pattern`
- `condition?: Condition`
- `seed: number`
- `size?: number`

### FabricTile

*interface* · `packages/humans/src/fabric.ts:36`

```ts
interface FabricTile
```

- `size: number`
- `rgba: Uint8ClampedArray`
- `info: FabricInfo`
- `roughness: number`
- `torn: boolean`

### FaceFitModel

*interface* · `packages/humans/src/fit.ts:35`

```ts
interface FaceFitModel
```

- `vertex: Int32Array` — vertex of head0 for each landmark
- `base: Float64Array` — base positions of the landmarks, 3 per landmark
- `pos: Map<string, Float64Array>` — response at weight +1 and -1 of every face axis, landmarks x 3 per axis (rows: axis, then pos|neg)
- `neg: Map<string, Float64Array>`

### FaceSpec

*interface* · `packages/humans/src/spec.ts:67`

```ts
interface FaceSpec
```

- `words?: string` — the description it was made from; kept for reading and correcting as text, not part of the share code
- `blends: { id: string; w: number }[]` — named base faces, mixed by weight
- `axes: Record<string, number>` — shape axes by id (axes.ts FACE_AXES), signed -1..1; unset = 0
- `asym: number` — 0..1, strength of the seeded asymmetry
- `marks?: Mark[]`

### FaceZones

*interface* · `packages/humans/src/compose.ts:13`

```ts
interface FaceZones
```

Face zones (p4-zones.mjs): a = lips, lids, cheeks, freckle; b = brows, liner (one per channel).

- `a: Img`
- `b: Img`

### FieldRef

*interface* · `packages/humans/src/data.ts:61`

```ts
interface FieldRef
```

One side of one axis of the shape pack, ready to add into a position array.

- `part: string`
- `count: number`
- `scale: number`
- `idx: Uint16Array | Uint32Array`
- `d: Int8Array | Int16Array`

### Figure

*interface* · `packages/humans/src/figure.ts:16`

```ts
interface Figure
```

A complete person of any kit: the kit build (`buildKit`), hair, brows, lashes and beard bound to the kit's own skin (so they follow a muzzle or a restyled head),
and the outfit (words or pieces) generated on the kit body. Hair under a hat is cut by the hat's mask. This is what viewers, proofs and games build.

- `spec: HumanSpec`
- `kit: BuiltKit`
- `attachments: BuiltPart[]`
- `outfit: OutfitBuilt | null`
- `pieces: OutfitPiece[]`

### FigureOptions

*interface* · `packages/humans/src/babylon.ts:22`

```ts
interface FigureOptions
```

The bridge from a spec to the running game. `loadFigure` bakes the glb in memory (`exportGlb`) and loads it through Babylon's glTF loader, so the
figure is what every other model is: a node tree, a skinned mesh set, a skeleton. Its clips are the nine gait clips of the motion pack restyled for this body
(`styleClip`), written as animation groups on the joint nodes, so no clips file has to be loaded and the graph (`locomotionGraph`) plays at the body's own derived
walk and run speeds. Tails and ears are driven by `stepChains` each frame (`ChainDriver`).

- `tier?: string`
- `parent?: BABYLON.TransformNode` — parent of the figure's root node
- `glb?: GlbOptions`
- `name?: string` — a name for the root node

### FitOptions

*interface* · `packages/humans/src/fit.ts:88`

```ts
interface FitOptions
```

- `ridge?: number` — ridge strength: how hard the axes are pulled to the prior (the words); 0.02 is gentle
- `prior?: Record<string, number>` — the prior axes (from a description); the fit changes them only where the picture insists
- `iterations?: number` — landmark names present in the picture (others are ignored); default all that are given

### FitResult

*interface* · `packages/humans/src/fit.ts:97`

```ts
interface FitResult
```

- `axes: Record<string, number>`
- `residual: number` — root-mean-square distance between the fitted face and the picture's landmarks after alignment, in units of the interocular distance
- `similarity: { scale: number; rotation: number; shift: [number, number] }` — scale, rotation (radians) and shift that map the picture onto the head frame

### GaitClip

*interface* · `packages/humans/src/motion.ts:41`

```ts
interface GaitClip
```

- `name: string`
- `duration: number`
- `frames: number`
- `fps: number`
- `rotBones: string[]`
- `posBones: string[]`
- `rot: Float32Array`
- `pos: Float32Array`
- `loop: boolean`
- `ignoreSide?: 'l' | 'r'`

### GaitMeasure

*interface* · `packages/humans/src/motion.ts:306`

```ts
interface GaitMeasure
```

- `speed: number` — m/s the clip travels at on the BASE figure, from the stance feet
- `stance: { l: boolean[]; r: boolean[] }` — stance frames per foot (ball height near its lowest)
- `slide: number` — m/s RMS horizontal speed of the stance feet in the world frame after removing the mean: the clip's own slide

### GarmentResult

*interface* · `packages/humans/src/garment.ts:122`

```ts
interface GarmentResult
```

- `part: BuiltPart`
- `source: GarmentSpec`
- `spec: GarmentSpec & { layer: GarmentLayer }`
- `covers: Uint32Array`
- `panel?: { first: number; rows: number; seg: number }`

### GarmentSpec

*interface* · `packages/humans/src/garment.ts:21`

```ts
interface GarmentSpec
```

- `template: Template`
- `length?: number` — hem of a top: 0 neck .. 1 crotch, above 1 over the thighs (default per template)
- `ease?: number` — extra metres over the layer lift: 0 tight, 0.02 normal, 0.05 loose
- `sleeve?: number` — sleeve as a fraction of the arm from shoulder to wrist: 0 none, 0.5 elbow, 1 wrist
- `legLength?: number` — trouser/skirt length as a fraction of the leg from hip to ankle (1 reaches the ankle)
- `neck?: 'crew' | 'v' | 'open' | 'scoop'` — neck: 'crew' high, 'v' open to the chest, 'open' wide, 'scoop'
- `flare?: number` — skirt flare: metres of radius added at the hem
- `height?: number` — footwear height above the sole in metres (shoe 0.07, ankle boot 0.15, knee boot 0.45)
- `layer?: GarmentLayer`
- `fabric?: string` — fabric id and colour for the material layer; `pattern` for checks, stripes (used by the fabric composer)
- `colour?: [number, number, number]`
- `pattern?: string`

### GlbOptions

*interface* · `packages/humans/src/gltf.ts:41`

```ts
interface GlbOptions
```

- `expressions?: boolean | readonly string[]` — expression targets on the head parts: true = all 51 ARKit shapes, a list = those; false = none
- `skinSheets?: { body?: { rgba: ArrayLike<number>; width: number; height: number }; head?: { rgba: ArrayLike<number>; width: number; height: number } }` — RGBA sheets for the skin ('body' for body0, 'head' for head parts); without them the skin is its flat colour
- `name?: string` — name of the scene

### HairSpec

*interface* · `packages/humans/src/spec.ts:97`

```ts
interface HairSpec
```

- `style: string`
- `melanin: number`
- `redness: number`
- `dye?: Rgb`
- `greying: number`

### HeadKit

*interface* · `packages/humans/src/kit-core.ts:77`

```ts
interface HeadKit
```

- `muzzle?: { length: number; pinch?: number; flat?: number; lift?: number }`
- `nose?: { kind: 'dog' | 'cat' | 'pig' | 'horse' | 'none'; colour?: Rgb; size?: number }`
- `beak?: BeakKit`
- `eyes?: { spread?: number; back?: number; scale?: number; pupil?: 'round' | 'slit' | 'horizontal'; colour?: Rgb }`
- `ears?: EarKit`
- `horns?: HornKit`
- `tusks?: { length: number; curve?: number; colour?: Rgb; x?: number }`
- `crest?: { kind: 'spikes' | 'fin' | 'comb'; height: number; count?: number; colour?: Rgb }`
- `patch?: { side: 'l' | 'r'; colour?: Rgb }` — an eye patch on `side` (Odin)

### HeadMarks

*interface* · `packages/humans/src/kit-head.ts:11`

```ts
interface HeadMarks
```

Heads of kits: a muzzle or beak made by warping the human head (so teeth, tongue, lips and every expression still work, with a gain
for the longer jaw), eyes moved to the side, a nose, ears, horns, tusks and crests as rigid pieces on the head joint (ears also as spring chains, see chain.ts).

- `joint: number`
- `eyeL: V3` — eye centres, nose tip, mouth centre (teeth), chin, top of the skull, back of the skull
- `eyeR: V3`
- `noseTip: V3`
- `mouth: V3`
- `chin: V3`
- `topY: number`
- `backZ: number`
- `browY: number`
- `halfWidth: number` — half width of the skull at the eye line

### HeadwearResult

*interface* · `packages/humans/src/headwear.ts:24`

```ts
interface HeadwearResult
```

- `part: BuiltPart`
- `spec: HeadwearSpec`
- `hairMask: { yCut: number; radius: number }`
- `centre: [number, number, number]`
- `topY: number`

### HeadwearSpec

*interface* · `packages/humans/src/headwear.ts:12`

```ts
interface HeadwearSpec
```

- `template: HeadwearTemplate`
- `crown?: number` — crown height above the brow line, metres (default per template)
- `brim?: number` — brim width in metres (hat, helmet rim); for a peaked cap the width of the peak
- `ease?: number` — clearance over the head, metres
- `strap?: boolean` — a chin strap line is a trim; `strap` adds the strap geometry for helmets

### HitCapsule

*interface* · `packages/humans/src/motion.ts:188`

```ts
interface HitCapsule
```

- `name: string`
- `from: string`
- `to: string`
- `radius: number`
- `extend?: number`

### HornKit

*interface* · `packages/humans/src/kit-core.ts:75`

```ts
interface HornKit
```

- `kind: 'straight' | 'curl' | 'bull' | 'antler' | 'unicorn'`
- `length: number`
- `radius?: number`
- `colour?: Rgb`
- `x?: number`
- `tilt?: number`

### HumanAvatarOptions

*interface* · `packages/humans/src/babylon.ts:112`

```ts
interface HumanAvatarOptions
```

- `mine: () => HumanSpec` — this player's person
- `tier?: string`
- `placed?(copy: Entity, fig: LoadedFigure): void` — called with each remote figure once placed (default: puts an Animator on the copy, fed from its movement)
- `profile?: Parameters<typeof randomHuman>[1]` — the people of players who sent none: a profile (default the uniform one); the same on every machine by name

### HumanData

*interface* · `packages/humans/src/data.ts:122`

```ts
interface HumanData
```

- `base: BaseFigure`
- `shape: ShapePack`
- `lod: LodPack`
- `expr?: ShapePack`
- `attach?: AttachPack`
- `garments?: AttachPack`
- `motion?: MotionPack`

### HumanMaterialInput

*interface* · `packages/humans/src/materials.ts:20`

```ts
interface HumanMaterialInput
```

- `spec: HumanSpec`
- `head: SkinPixels` — composed head and body skin sheets (composeSkin)
- `body: SkinPixels`
- `eyeLeft: Uint8ClampedArray` — composed eyeball sheets, one per eye (composeEye, 512 x 512 RGBA)
- `eyeRight: Uint8ClampedArray`
- `eyeSize: number`
- `micro?: { rgba: Uint8ClampedArray; size: number }` — tileable micro relief tile (composeMicro, RGBA); without it the skin is smooth
- `headSurface?: SkinPixels` — metallic-roughness sheet of the head (composeSurface): G = roughness per zone
- `teethTexture?: BABYLON.BaseTexture` — a teeth picture (decoded by the caller). The Customizer's own teeth atlas has an alpha channel that hides the crowns, so it must be used with its alpha dropped; without a picture the teeth are a plain ivory
- `headNormal?: BABYLON.BaseTexture` — optional Customizer normal/roughness maps (already decoded to textures by the caller)
- `bodyNormal?: BABYLON.BaseTexture`

### HumanMaterials

*interface* · `packages/humans/src/materials.ts:40`

```ts
interface HumanMaterials
```

- `tier: MaterialTier`
- `head: BABYLON.Material`
- `body: BABYLON.Material`
- `eyeLeft: BABYLON.Material`
- `eyeRight: BABYLON.Material`
- `hair: BABYLON.Material`
- `lashes: BABYLON.Material` — brows and beard use `hair`; lashes are always near black
- `teeth: BABYLON.Material`
- `mouth: BABYLON.Material` — the plain mouth lining, for a kit without the teeth atlas. NOTE: in the Customizer head the crowns, gums and palate are ONE part (head5) painted by the teeth atlas, so head4 and head5 both take `teeth`
- `tongue: BABYLON.Material`
- `dispose(): void`

### HumanSpec

*interface* · `packages/humans/src/spec.ts:107`

```ts
interface HumanSpec
```

- `v: 1`
- `seed: number`
- `kit: string` — 'human' or the id of an anthropomorphic kit
- `body: BodySpec`
- `face: FaceSpec`
- `skin: SkinSpec`
- `eyes: EyesSpec`
- `hair: HairSpec`
- `brows: { style: string }`
- `lashes: { style: string }`
- `beard?: { style: string }`
- `outfit: OutfitSpec`
- `motion: MotionStyle`
- `kitOptions?: Record<string, unknown>` — kit parameters: see `KitOptions` in kit.ts; free-form here so the spec does not depend on the kit code. Unset = the kit's defaults.

### HumansSessionOptions

*interface* · `packages/humans/src/commands.ts:29`

```ts
interface HumansSessionOptions
```

- `save?: (name: string, spec: HumanSpec, code: string) => unknown | Promise<unknown>` — persists a spec as a library item (the viewer wires the asset library); absent = `humans.save` keeps it in the session only
- `writeFile?: (path: string, bytes: Uint8Array) => unknown | Promise<unknown>` — writes a baked glb; absent = the bytes are returned
- `render?: (spec: HumanSpec, view: string) => Promise<Img>` — renders a spec to a picture (browser/viewer); lets `humans.compare` compare pixels with pixels
- `sheet?: (specs: HumanSpec[], opts: Record<string, unknown>) => Promise<unknown>` — a picture sheet of figures (viewer)
- `skinSheets?: (spec: HumanSpec) => GlbOptions['skinSheets']` — skin sheets for a spec (browser path), used by `humans.bake`

### Img

*interface* · `packages/humans/src/compose.ts:8`

```ts
interface Img
```

A decoded 8-bit image: 3 (RGB) or 4 (RGBA) channels, row-major, row 0 = v 0 of the UV sheet.

- `width: number`
- `height: number`
- `channels: 3 | 4`
- `data: Uint8Array | Uint8ClampedArray`

### Issue

*interface* · `packages/humans/src/validate.ts:6`

```ts
interface Issue
```

- `level: 'error' | 'warning'`
- `path: string`
- `message: string`

### KitDef

*interface* · `packages/humans/src/kit-core.ts:116`

```ts
interface KitDef
```

A kit: its defaults, and what it is called. The registry lives in kits.ts.

- `id: string`
- `name: string`
- `description: string`
- `defaults: KitOptions`
- `proof?: Partial<HumanSpec>`

### KitOptions

*interface* · `packages/humans/src/kit-core.ts:50`

```ts
interface KitOptions
```

- `stylise?: Partial<Record<StyleAxis, number>>` — proportion exaggeration beyond the realistic limits (STYLE_AXES)
- `axes?: Record<string, number>` — raw shape-pack axes at any weight (beyond the +-1 of the face axes): `{ browRidgeProjection: 1.8 }`
- `head?: HeadKit`
- `tail?: TailKit`
- `legs?: 'plantigrade' | 'digitigrade'` — 'digitigrade': legs with a hock (dogs, cats, birds, lizardfolk); 'plantigrade' (default)
- `coat?: CoatKit` — a coat over the whole skin
- `robot?: RobotKit` — robot / machine body
- `scale?: number` — uniform scale of the whole figure after everything else (giants, small folk); the shape pack's height axis stops at about 2.3 m
- `missing?: { hand?: 'l' | 'r'; eye?: 'l' | 'r' }` — body options: a missing hand or eye (Tyr, Odin)
- `held?: { item: string; hand: 'l' | 'r'; scale?: number }[]` — held and worn things by id (props.ts)
- `worn?: { item: string; scale?: number; colour?: Rgb }[]`
- `motion?: Record<string, number>` — default gait style of the kit (merged under the spec's own motion style)

### LandmarkDef

*interface* · `packages/humans/src/fit.ts:11`

```ts
interface LandmarkDef
```

A face from a photo or a drawing, step 2: fit the face axes to facial landmarks. Step 1 (words) is the vocabulary; step 3 (the agent
comparing picture and render) is a loop of commands. Landmarks come from any detector (MediaPipe Face Mesh indices are named below); this file does the
maths: the base head's landmark vertices, the response of every axis at those vertices, and a regularised least-squares fit with the similarity
(scale, rotation, shift) of the picture solved alongside. Front view fits width and height proportions; a second profile set (z, y) fits depth.

- `name: string`
- `mediapipe: number` — index in the 468-point MediaPipe Face Mesh
- `at: [number, number]` — where to look for the vertex on the base head: x (m, person's left +), y (m), and the vertex is the front-most one nearby

