# @ferret/humans: API

People and anthropomorphic characters from a spec: faces from words or a picture, clothes, kits and species, gait clips, crowds, glb bake, the humans.* commands and the viewer.

374 exports. Generated from the source (`packages/humans/src`), so it matches the code.

## Classes

### IdleLife

*class* · `packages/humans/src/expressions.ts:66`

```ts
class IdleLife
```

Idle life: blinks at a seeded rhythm (every 2..6 s, 0.2 s long, sometimes double) and micro-saccades of the gaze (small jumps every 0.4..1.6 s).
A pure function of time: the same seed gives the same weights, so a replay or a client on the network sees the same eyes.

- `constructor(seed: number, horizon = 600)`
- `blink(t: number): number` — Eyelid closure 0..1 at time t (seconds): a fast close, a slower open.
- `saccade(t: number): { yaw: number; pitch: number }` — The small gaze offset (radians) at time t.
- `weights(t: number, gaze = { yaw: 0, pitch: 0 }): ExpressionWeights` — Blink and saccade as expression weights (combine with `blendExpressions`).

### Rng

*class* · `packages/humans/src/random.ts:20`

```ts
class Rng
```

A small seeded generator (sfc32).

- `constructor(seed: number)`
- `next(): number` — 0 <= x < 1
- `range(lo: number, hi: number)`
- `int(n: number)`
- `chance(p: number)`
- `normal(): number` — standard normal (Box-Muller)
- `pick<T>(items: readonly { v: T; w?: number }[]): T`

## Functions

### add

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

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

### addCoat

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

```ts
function addCoat(kit: BuiltKit, coat: CoatKit): void
```

Adds the geometry of a coat: shells on hero tiers, tufts and feathers on hero and mid tiers.

### addEarChains

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

```ts
function addEarChains(b: BuiltKit, k: EarKit): void
```

Ears as spring chains: three joints from the base to the tip, the mesh bound along them (ears that flick and sway).

### addJoint

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

```ts
function addJoint(b: BuiltHuman, name: string, parent: string, at: V3): number
```

Appends a joint (world rest position) under `parent`; returns its index.

### addMissing

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

```ts
function addMissing(kit: BuiltKit, o: { hand?: 'l' | 'r'; eye?: 'l' | 'r' }): void
```

A missing hand (the fingers and palm collapse into a rounded stump on the wrist) and a missing eye (the eyeball is gone, the lids stay).

### addOutfitBundle

*function* · `packages/humans/src/outfit-words.ts:63`

```ts
function addOutfitBundle(id: string, ruStems: string, enWords: string, text: string): void
```

### addPart

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

```ts
function addPart(b: BuiltHuman, part: BuiltPart, role?: string, kit?: BuiltKit): void
```

Adds a part (its id must be unused).

### addProps

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

```ts
function addProps(kit: BuiltKit): void
```

Builds the held and worn items of the kit options.

### addRobot

*function* · `packages/humans/src/rigid.ts:20`

```ts
function addRobot(kit: BuiltKit, o: RobotKit): void
```

### addTail

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

```ts
function addTail(b: BuiltKit, o: TailKit): void
```

Adds a tail: joints, a mesh bound along them, a chain with its spring constants.

### addUniform

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

```ts
function addUniform(id: string, pieces: () => OutfitPiece[]): void
```

### ageWeights

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

```ts
function ageWeights(age: number): { ageBaby: number; ageChild: number; ageOld: number }
```

Weights of the three age axes for an age in years.

### ageWord

*function* · `packages/humans/src/describe.ts:12`

```ts
function ageWord(age: number, sex: number): string
```

### applyExpression

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

```ts
function applyExpression(data: HumanData, built: BuiltHuman, weights: ExpressionWeights): Map<string, Float32Array>
```

The positions of the head parts with the expression applied, as new arrays per part id (the built person is not touched). A tier that is a vertex
subset applies the deltas through `source`.

### assertValid

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

```ts
function assertValid(spec: HumanSpec, opts?: ValidateOptions): Issue[]
```

Throws with every error listed; returns the warnings.

### attachCell

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

```ts
function attachCell: (tier: string) => number
```

The cluster size of a tier by its name ('L2d', 'L2m' and 'L2' all mean the level 2).

### attachIds

*function* · `packages/humans/src/attach.ts:41`

```ts
function attachIds: (pack: AttachPack, kind: string) => string[]
```

Ids of the items of one kind.

### attachmentIds

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

```ts
function attachmentIds(data: HumanData, spec: HumanSpec): string[]
```

The attachment ids a spec asks for: hair style, brows, lashes, beard. 'none' gives nothing; 'default' picks by sex.

### axisWeights

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

```ts
function axisWeights(spec: HumanSpec, pack: ShapePack): AxisWeights
```

The pack's axes a spec asks for, at which signed weights. Axes the pack does not have are ignored (a spec may name future ones).

### bakeVariant

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

```ts
function bakeVariant(data: HumanData, spec: HumanSpec, id: number, opts: BakeOptions = {}): CrowdVariant
```

Builds a variant from a spec: the merged mesh and its baked clips (planted at the person's own walking speed, so every body walks without sliding).

### bindChain

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

```ts
function bindChain(m: Mesh, joints: number[], rest: V3[], id: string, material?: PartMaterial, root?: number): BuiltPart
```

Skin data that binds a mesh along a chain of joints: each vertex takes the two joints whose rest positions bracket its projection on the chain, weighted by
where it falls between them (a tail, an ear or a tentacle bends smoothly). `joints` are indices into the built joint list, `rest` their rest positions.

### bindRigid

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

```ts
function bindRigid(m: Mesh, joint: number, id: string, material?: PartMaterial, opts: { flat?: boolean } = {}): BuiltPart
```

Skin data that binds every vertex of a mesh to one joint.

### blendExpressions

*function* · `packages/humans/src/expressions.ts:47`

```ts
function blendExpressions(...sets: ExpressionWeights[]): ExpressionWeights
```

Blend several weight sets: the largest value of each shape wins (so two emotions do not add into a grimace).

### bodyRegions

*function* · `packages/humans/src/garment.ts:94`

```ts
function bodyRegions(built: BuiltHuman): BodyRegions
```

### box

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

```ts
function box(c: V3, h: V3, forward?: V3): Mesh
```

An axis-aligned or oriented box: centre, half sizes, and an optional `forward` for the local z axis (y stays up when possible).

### buildAttachment

*function* · `packages/humans/src/attach.ts:47`

```ts
function buildAttachment(data: HumanData, built: BuiltHuman, id: string, skinPositions?: Map<string, Float32Array>): BuiltPart | null
```

Builds one attachment on a built person. `built` must hold head0 (and body0 for long hair) at the SAME tier it was built for; the attachment follows the
displacement of those vertices. `skinPositions` overrides the head positions (an expression applied by `applyExpression`), so brows and lashes move with the face.

### buildAttachments

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

```ts
function buildAttachments(data: HumanData, built: BuiltHuman, spec: HumanSpec, skinPositions?: Map<string, Float32Array>): BuiltPart[]
```

All attachments of a spec on a built person, simplified for the tier.

### buildFigure

*function* · `packages/humans/src/figure.ts:18`

```ts
function buildFigure(data: HumanData, spec: HumanSpec, tier = 'full'): Figure
```

### buildGarment

*function* · `packages/humans/src/garment.ts:196`

```ts
function buildGarment(built: BuiltHuman, spec: GarmentSpec, regions?: BodyRegions): GarmentResult | null
```

Builds a garment on the built person. Returns null when the template covers nothing.

### buildHeadKit

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

```ts
function buildHeadKit(b: BuiltKit, o: HeadKit): void
```

Builds the kit head: warps, moves eyes, and adds the rigid pieces. Returns nothing; parts are added to `b`.

### buildHeadwear

*function* · `packages/humans/src/headwear.ts:75`

```ts
function buildHeadwear(built: BuiltHuman, spec: HeadwearSpec): HeadwearResult
```

### buildHuman

*function* · `packages/humans/src/build.ts:106`

```ts
function buildHuman(data: HumanData, spec: HumanSpec | AxisWeights, tier = 'full', parts: readonly string[] = PART_IDS): BuiltHuman
```

Builds a person: the base figure plus the weighted sum of the shape fields, per part and LOD tier. `tier` is a name of the LOD pack
('L0d', 'L1m', ...) or 'full' for all base vertices. Deterministic: the same spec and data give the same numbers on every machine.

### buildKit

*function* · `packages/humans/src/kit.ts:20`

```ts
function buildKit(data: HumanData, spec: HumanSpec, tier = 'full'): BuiltKit
```

Builds a person of a kit: the human build of the spec (with the kit's raw axis weights, which may lie beyond the +-1 of the face axes), the stylised proportions,
the head (muzzle, beak, eyes, ears, horns, tusks, crest, patch), the legs (digitigrade), the tail and ear chains, the coat (fur, scales, feathers), the robot
body, missing limbs, held and worn props. `spec.kit === 'human'` returns the plain build with the kit fields empty.

### buildOutfit

*function* · `packages/humans/src/garment.ts:305`

```ts
function buildOutfit(built: BuiltHuman, specs: GarmentSpec[]): { garments: GarmentResult[]; bodyIndices: Uint16Array | Uint32Array }
```

An outfit: the garments of a person in layer order, and the body0 index list with the covered triangles of opaque layers removed.

### buildOutfitFromPieces

*function* · `packages/humans/src/outfit.ts:39`

```ts
function buildOutfitFromPieces(built: BuiltHuman, pieces: readonly OutfitPiece[], seed: number, tileSize = 256, data?: HumanData): OutfitBuilt
```

The outfit of a spec on a built person: garments in layer order with their fabric tiles, and the body index list without the covered triangles.

### buildTrims

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

```ts
function buildTrims(built: BuiltHuman, garment: GarmentResult, trims: readonly Trim[], regions?: BodyRegions): { trims: TrimResult[]; missing: Trim[] }
```

Builds the trims of one garment. `garment` comes from `buildGarment`; pieces that find no surface in their region are left out (the result says which).

### cadenceRate

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

```ts
function cadenceRate(measure: GaitMeasure, rig: Rig, speed: number): number
```

Playback rate that makes the stance feet of this body move at `speed` m/s: speed / (clip speed on the base figure x leg scale).

### cardImage

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

```ts
function cardImage(kind: 'tuft' | 'feather', size: number, colour: Rgb, tip: Rgb, seed = 1): Img
```

The alpha tile of a card: 'tuft' = a bunch of tapering strands, 'feather' = a vane with a shaft and barbs. RGBA, colour from `colour` (root) to `tip`.

### clamp

*function* · `packages/humans/src/axes.ts:47`

```ts
function clamp: (v: number, lo: number, hi: number) => number
```

### coatAlbedo

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

```ts
function coatAlbedo(kit: BuiltKit, partId: string, size = 1024): Img
```

The albedo of a coated part: the coat colour at every texel, painted by position. Parts without UVs (cards, tails made without UV) cannot be painted: see `uvFromProjection`.

### coatColour

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

```ts
function coatColour(c: CoatKit, ctx: CoatContext, p: V3, n: V3): Rgb
```

### colourDistance

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

```ts
function colourDistance(a: Rgb, b: Rgb): number
```

CIE-like distance between two linear colours (weighted for the eye); 0 identical, about 0.1 a visible difference.

### colourName

*function* · `packages/humans/src/describe.ts:20`

```ts
function colourName(c: readonly [number, number, number]): string
```

### composeEye

*function* · `packages/humans/src/compose.ts:146`

```ts
function composeEye(e: { iris: Rgb; iris2?: Rgb; sclera: number; pupil: number; /** 'slit' (cat, reptile) or 'horizontal' (goat, horse): a kit's pupil */ shape?: 'round' | 'slit' | 'horizontal' }, seed: number, size = 512, second = false): Uint8ClampedArray
```

The eyeball sheet (centre = pupil, like the Customizer's planar eye UVs): sclera that darkens and reddens toward the rim with a seeded network of veins,
an iris with radial fibres, a collarette, a dark limbal ring and a round pupil. `second` picks the iris colour of the second eye (heterochromia).
RGBA, sRGB, size x size.

### composeFabric

*function* · `packages/humans/src/fabric.ts:74`

```ts
function composeFabric(o: FabricInput): FabricTile
```

### composeMicro

*function* · `packages/humans/src/compose.ts:210`

```ts
function composeMicro(o: MicroOptions): Uint8ClampedArray
```

Micro relief of skin as one tileable RGBA tile for Babylon's PBR detail map (R albedo grey, G normal Y, B roughness, A normal X; 128 = flat).
Three layers of one height field: pores (a Worley field of small pits on a torus, so the tile repeats), the skin-line lattice (two crossing families of
shallow furrows, warped by low-frequency noise so it is not a grid) and fine grain. A slow noise modulates the depth over the tile so the relief is not
uniform. Pores come out a little rougher and darker than the plateaus between them. Deterministic: the same seed gives the same tile.

### composeSkin

*function* · `packages/humans/src/compose.ts:37`

```ts
function composeSkin(o: ComposeOptions): Uint8ClampedArray
```

The albedo of one skin sheet for one person: the person's tone times the tint map, then freckles, moles, age spots and makeup (all seeded, so the same
spec gives the same pixels). Returns RGBA, sRGB, 8 bit. Pure arithmetic over arrays: runs in a worker, in node and in the tests alike.

### composeSurface

*function* · `packages/humans/src/compose.ts:267`

```ts
function composeSurface(o: { tint: Img; zones: FaceZones; base: number; reduce?: number }): Uint8ClampedArray
```

Metallic-roughness sheet of the face (glTF layout: G roughness, B metallic = 0, R = 255) from the zones: lips and lids are wet and smooth, cheeks and
forehead drier. `base` is the person's average roughness (skinTone().roughness). Same UV sheet as the albedo; size = tint size / 2^(reduce + 1).

### computeNormals

*function* · `packages/humans/src/build.ts:82`

```ts
function computeNormals(positions: Float32Array, indices: ArrayLike<number>, group: Uint32Array | null): Float32Array
```

Smooth normals of positions over triangles, welded by `group` (indices over the same vertex numbering as positions).

### createHumanMaterials

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

```ts
function createHumanMaterials(scene: BABYLON.Scene, tier: MaterialTier, i: HumanMaterialInput): HumanMaterials
```

### cross

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

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

### crowdMesh

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

```ts
function crowdMesh(F: Figure): { part: BuiltPart; colours: Uint8Array }
```

One merged, vertex-coloured part of a figure built at a crowd tier.

### cylinder

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

```ts
function cylinder: (a: V3, b: V3, ra: number, rb: number, seg?: number, cap?: boolean) => Mesh
```

A frustum (or cylinder, cone) from `a` to `b`.

### decodeHuman

*function* · `packages/humans/src/code.ts:178`

```ts
function decodeHuman(code: string): HumanSpec
```

### defaultHuman

*function* · `packages/humans/src/spec.ts:127`

```ts
function defaultHuman(seed = 0): HumanSpec
```

A neutral adult: every axis at the base figure. Not a typical person, only the origin of the spaces.

### deriveMotion

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

```ts
function deriveMotion(built: BuiltHuman, spec: HumanSpec): DerivedMotion
```

Movement values from the real body: sizes from the built geometry, speeds by the Froude number of the leg (walking about 0.27, running about 2.9: a person
of leg length L walks at sqrt(Fr g L)), mass from BMI and muscle, then age, fat and style (energy) adjust. Everything is a default that a spec can override.

### deriveSeed

*function* · `packages/humans/src/random.ts:8`

```ts
function deriveSeed(seed: number, ...salt: number[]): number
```

32-bit hash used to derive seeds; the same inputs give the same output on every machine.

### describeBack

*function* · `packages/humans/src/vocab.ts:170`

```ts
function describeBack(face: FaceSpec, limit = 10): string[]
```

The face in words again (English ids with intensity): the descriptors whose axes the face matches, strongest first. The agent compares these with the request.

### describeFace

*function* · `packages/humans/src/vocab.ts:134`

```ts
function describeFace(text: string, seed: number, opts: { spread?: number; asym?: number } = {}): Described
```

Face from words. `spread` is the standard deviation of the seeded fill of axes the text does not mention (0 = exactly the average face for the rest).

### describeHuman

*function* · `packages/humans/src/describe.ts:47`

```ts
function describeHuman(spec: HumanSpec): string
```

### describeOutfit

*function* · `packages/humans/src/outfit-words.ts:122`

```ts
function describeOutfit(text: string): OutfitDescribed
```

Clothes from words.

### describeParts

*function* · `packages/humans/src/describe.ts:30`

```ts
function describeParts(spec: HumanSpec): Record<string, string>
```

One sentence per aspect, in a fixed order, as a list; `describeHuman` joins them.

### diffSpecs

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

```ts
function diffSpecs(a: unknown, b: unknown, path = ''): { path: string; from: unknown; to: unknown }[]
```

The changes between two specs as JSON-pointer entries.

### dominantColours

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

```ts
function dominantColours(img: Img, region: Region, k = 3, gain: Rgb = [1, 1, 1], mask?: (r: Rgb) => boolean): { colour: Rgb; share: number }[]
```

Dominant colours of a region (linear RGB, balanced): k-means with farthest-point start, ordered by area. Skips transparent and near-black/white background when `skipBackground`.

### dot

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

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

### drapeCloth

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

```ts
function drapeCloth(built: BuiltHuman, spec: DrapeSpec): DrapeResult
```

### earMesh

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

```ts
function earMesh(k: EarKit): Mesh
```

One ear in local coordinates (base at the origin, pointing +y, wide along x, thin along z), left side; the caller orients and mirrors it.

### ellipsoid

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

```ts
function ellipsoid(c: V3, r: V3, seg = 14, ring = 9, up?: V3): Mesh
```

An ellipsoid: centre, three semi-axes, optionally rotated so that its local y axis points along `up`.

### emotion

*function* · `packages/humans/src/expressions.ts:40`

```ts
function emotion(name: EmotionName, k = 1): ExpressionWeights
```

An emotion at intensity k (0..1.5), as expression weights.

### encodeHuman

*function* · `packages/humans/src/code.ts:103`

```ts
function encodeHuman(s: HumanSpec): string
```

### encodePng

*function* · `packages/humans/src/gltf.ts:21`

```ts
function encodePng(rgba: ArrayLike<number>, width: number, height: number): Uint8Array
```

PNG (RGBA 8 bit) with stored deflate blocks: no compressor needed, so it runs everywhere.

### everydayOutfit

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

```ts
function everydayOutfit(rng: Rng, spec: HumanSpec): HumanSpec['outfit']['pieces']
```

A random everyday outfit as words (colours, a top, a bottom, shoes), read by `describeOutfit`: a profile's `outfit` may use it or bring its own.

### exportGlb

*function* · `packages/humans/src/gltf.ts:79`

```ts
function exportGlb(data: HumanData, F: Figure, opts: GlbOptions = {}): Uint8Array
```

The glb bytes of a figure. `data` supplies the motion pack (the rig) and the expression targets.

### eyeColours

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

```ts
function eyeColours(e: EyesSpec): EyeColours
```

Eye colours (linear sRGB). `sclera` 0..1: 1 = clean white, 0 = yellowed and bloodshot.

### faceDistance

*function* · `packages/humans/src/face.ts:12`

```ts
function faceDistance(a: FaceSpec, b: FaceSpec): number
```

How different two faces look: the weighted root-mean-square difference of the shape axes (weights = how much an axis
changes the front view and the profile), plus the difference of the base-face blends. 0 = the same face. Two faces drawn independently with a
per-axis spread s are about 1.41 * s apart.

### faceFitModel

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

```ts
function faceFitModel(data: HumanData): FaceFitModel
```

The landmark vertices of the base head and the response of every axis there. Computed once per HumanData.

### fatFromBmi

*function* · `packages/humans/src/resolve.ts:27`

```ts
function fatFromBmi(bmi: number): number
```

Provisional: BMI 22 is 0, 16 is -1, 38 is +1.

### fitFaceToLandmarks

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

```ts
function fitFaceToLandmarks(model: FaceFitModel, picture: Record<string, [number, number]>, opts: FitOptions = {}): FitResult
```

Fits face axes to picture landmarks. `picture`: for each landmark name an [x, y] in picture units (x to the person's left, y up; any scale), front view.
Alternates a 2D similarity alignment of the picture onto the current face with a ridge least-squares for the axes (bounded to -1..1).

### fk

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

```ts
function fk(rig: Rig, pose: Pose): World
```

FK: world positions and rotations of every joint.

### flatten

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

```ts
function flatten(m: Mesh): Mesh
```

A flat-shaded copy: every triangle gets its own vertices, for hard-edged parts (boxes, plates, panels).

### frameOf

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

```ts
function frameOf(d: V3): [V3, V3]
```

Two unit vectors perpendicular to `d` (and to each other).

### fromMediaPipe

*function* · `packages/humans/src/fit.ts:163`

```ts
function fromMediaPipe(points: ArrayLike<{ x: number; y: number }>): Record<string, [number, number]>
```

The MediaPipe Face Mesh index of each landmark, for a caller that turns a 468-point result into the `picture` record.

### fromSrgb

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

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

### furCards

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

```ts
function furCards(part: BuiltPart, count: number, length: number, width: number, droop: number, keep: TriMask, seed: number, card: 'tuft' | 'feather', colour: Rgb, id: string): BuiltPart | null
```

Tufts: two crossing quads per tuft at area-weighted random points of the selected triangles, leaning down by `droop`, skinned like the triangle they grow from.

### furShells

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

```ts
function furShells(part: BuiltPart, layers: number, length: number, keep: TriMask, colour: Rgb): BuiltPart[]
```

Shell layers of a skin part: `layers` copies of the selected triangles pushed out along the normals, each a part of its own (`fur-<id>-<k>`), outermost last.

### gazeWeights

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

```ts
function gazeWeights(yaw: number, pitch: number): ExpressionWeights
```

Eye-look shapes for a gaze direction in head space (yaw to the person's right +, pitch up +, radians).

### getPointer

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

```ts
function getPointer(obj: any, ptr: string): unknown
```

### hairColour

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

```ts
function hairColour(h: Pick<HairSpec, 'melanin' | 'redness' | 'greying' | 'dye'>): Rgb
```

Hair colour: eumelanin darkens (L* 80 blond .. 12 black), pheomelanin (redness) adds red-orange; greying mixes toward white-grey.
`dye` replaces the pigment colour. Linear sRGB.

### headFrame

*function* · `packages/humans/src/headwear.ts:29`

```ts
function headFrame(built: BuiltHuman): HeadFrame
```

The head's measures: centre of the skull, top, brow level and the outer radius by height and angle (0 = +z, front).

### headMarks

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

```ts
function headMarks(b: BuiltKit): HeadMarks
```

Landmarks measured on the built head (they follow every face axis and the stylised proportions).

### headScale

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

```ts
function headScale(data: HumanData, built: BuiltHuman): [number, number, number]
```

Per-axis scale of this person's head against the base head: expression deltas are multiplied by it (the re-basing).

### hitCapsules

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

```ts
function hitCapsules(built: BuiltHuman): HitCapsule[]
```

Combat hit capsules (the `CapsuleSpec` of `@ferret/combat`) with radii measured on this body's vertices: the median distance of the vertices each bone drives to its segment.

### hornMesh

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

```ts
function hornMesh(k: HornKit, sx = 1): Mesh
```

### humanAvatarLook

*function* · `packages/humans/src/babylon.ts:126`

```ts
function humanAvatarLook(scene: BABYLON.Scene, data: HumanData, o: HumanAvatarOptions): AvatarLook
```

The avatar look for `Multiplayer`: the look that travels is the spec's share code (a short string), and each machine builds the person from it. A player who sends
none gets a person made from their name, the same on every machine.

### humanLook

*function* · `packages/humans/src/babylon.ts:107`

```ts
async function humanLook(scene: BABYLON.Scene, data: HumanData, spec: HumanSpec, o: FigureOptions = {}): Promise<Look>
```

A `Look` for the transform package: the figure as one profile of a `Transformer` (`profiles.knight = { build: (_e, parent) => look }`).

### itaClass

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

```ts
function itaClass(ita: number): 'very light' | 'light' | 'intermediate' | 'tan' | 'brown' | 'dark'
```

Chardon's classes by ITA.

### jointAt

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

```ts
function jointAt(pack: MotionPack, rig: Rig, clip: GaitClip, joint: string, t: number): [number, number, number]
```

World position of a joint at time t (seconds) of a clip on a rig.

### jointIndex

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

```ts
function jointIndex: (b: BuiltHuman, name: string) => number
```

### jointRest

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

```ts
function jointRest: (b: BuiltHuman, name: string) => V3
```

### kitDef

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

```ts
function kitDef(id: string): KitDef
```

### kitHeadTop

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

```ts
function kitHeadTop: (b: BuiltKit) => number
```

The eye line and brow line of the built head, for hats and crowns of kits.

### kitIds

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

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

### kitRig

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

```ts
function kitRig(pack: MotionPack, kit: BuiltKit): Rig
```

The rig of a kit: the 87-joint rig plus the kit's own joints (identity rest rotation, so they follow their parent until the simulation moves them).

### labToLinear

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

```ts
function labToLinear(L: number, a: number, b: number): Rgb
```

CIELAB (D65) to linear sRGB, unclamped.

### landmarksOf

*function* · `packages/humans/src/fit.ts:79`

```ts
function landmarksOf(model: FaceFitModel, axes: Record<string, number>): Float64Array
```

Landmark positions (metres, 3 per landmark) of a face given as axis values, by the model's linear response (the sparse fields are linear in the weight).

### lathe

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

```ts
function lathe(origin: V3, axis: V3, profile: [number, number][], seg = 20): Mesh
```

A solid of revolution about the line through `origin` along `axis`; `profile` is [height along axis, radius] pairs. Closed at both ends when the radii there are above 0.

### len

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

```ts
function len: (a: V3) => number
```

### lerp3

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

```ts
function lerp3: (a: V3, b: V3, t: number) => V3
```

### linearToLab

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

```ts
function linearToLab(c: Rgb): [number, number, number]
```

Linear sRGB to CIELAB (D65).

### loadFigure

*function* · `packages/humans/src/babylon.ts:80`

```ts
async function loadFigure(scene: BABYLON.Scene, data: HumanData, spec: HumanSpec, o: FigureOptions = {}): Promise<LoadedFigure>
```

### loadHumanData

*function* · `packages/humans/src/data.ts:125`

```ts
async function loadHumanData(get: (name: string) => Promise<ArrayBuffer>): Promise<HumanData>
```

Loads the three assets through any fetcher: `get('humans-shape.json')` and so on.

### makeDigitigrade

*function* · `packages/humans/src/digitigrade.ts:20`

```ts
function makeDigitigrade(b: BuiltKit, o: DigiOptions = {}): void
```

### makeRig

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

```ts
function makeRig(pack: MotionPack, joints: BuiltHuman['joints'], opts: { legScale?: number } = {}): Rig
```

### makeTongue

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

```ts
function makeTongue(lower: Float32Array, rest = 1): TongueShape
```

`lower`: positions of the lower teeth (the person's own).

### mapMesh

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

```ts
function mapMesh: (m: Mesh, f: (p: V3) => V3) => Mesh
```

Applies a function to every vertex.

### maskHair

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

```ts
function maskHair(p: BuiltPart, headwear: { yCut: number; radius?: number }): BuiltPart
```

A hat or helmet hides hair: triangles whose centre is above `yCut` (and inside `radius` of the head axis when given) are dropped.

### material

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

```ts
function material: (colour: Rgb, rest?: Partial<PartMaterial>) => PartMaterial
```

### meanPlainSrgb

*function* · `packages/humans/src/compose.ts:112`

```ts
function meanPlainSrgb(img: Uint8ClampedArray, tint: TintMap, reduce = 0): Rgb
```

Mean sRGB colour of the plain-skin pixels of a composed sheet (for tests and the sheet report).

### measureGait

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

```ts
function measureGait(pack: MotionPack, rig: Rig, clip: GaitClip): GaitMeasure
```

The ground-facing metrics of a gait clip on a rig: travel speed (positive forward, negative backward), the stance frames of each foot and the clip's own slide.
Stance: the ball is near its lowest AND moves along z at the speed the others in that group move at (the median), so the toe-off and heel-strike frames, where the
foot rolls, are not counted. A clip that stays in place (idle) has speed 0 and every frame is stance.

### merge

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

```ts
function merge: (...ms: (Mesh | null | undefined)[]) => Mesh
```

### mergeParts

*function* · `packages/humans/src/garment.ts:234`

```ts
function mergeParts(parts: BuiltPart[], id: string): BuiltPart
```

Concatenates parts into one (same material).

### migrate

*function* · `packages/humans/src/migrate.ts:22`

```ts
function migrate(raw: unknown): HumanSpec
```

### mirrorX

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

```ts
function mirrorX: (m: Mesh) => Mesh
```

Mirrors across x = 0 (left to right); the winding is flipped to keep the faces outward.

### moveEyes

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

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

Eyes to the side of the head (rabbit, horse, bird, lizard): both eyeballs and the lids around them move out and back, optionally larger.

### movementValues

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

```ts
function movementValues(built: BuiltHuman, spec: HumanSpec, overrides: Partial<MovementValues> = {}): MovementValues
```

The CharacterParams a body gets: derived values where the spec has no override (`overrides` wins).

### mul

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

```ts
function mul: (a: V3, k: number) => V3
```

### nearestPair

*function* · `packages/humans/src/face.ts:22`

```ts
function nearestPair(faces: readonly FaceSpec[]): { distance: number; i: number; j: number }
```

The smallest distance between any two faces of a set (Infinity for fewer than two), and the pair that has it.

### newChainState

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

```ts
function newChainState: (kit: BuiltKit) => ChainState
```

### noise3

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

```ts
function noise3(x: number, y: number, z: number, s = 0): number
```

value noise 0..1 at a 3D point

### norm

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

```ts
function norm: (a: V3) => V3
```

### outfitFromPicture

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

```ts
function outfitFromPicture(img: Img, reads: readonly PictureRead[], defaults: { fabric?: string } = {}): OutfitPiece[]
```

Fills the colours and patterns of the read garments from the pixels.

### paintByPosition

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

```ts
function paintByPosition(part: BuiltPart, size: number, fn: (p: V3, n: V3) => Rgb, background: Rgb = [0.5, 0.5, 0.5]): Img
```

Paints a texture by 3D position: every texel of every triangle is evaluated at its interpolated position and normal. `fn` returns linear RGB.

### panelRest

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

```ts
function panelRest(points: Float32Array, rows: number, seg: number): Float32Array
```

Ring-to-ring rest lengths of a panel laid out like the grids above, for `swingPanel`.

### panelStart

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

```ts
function panelStart(goal: Float32Array): PanelState
```

Starts a panel at rest: the points are the posed goal and at rest.

### parseAttach

*function* · `packages/humans/src/attach.ts:24`

```ts
function parseAttach(json: string | object, bin: ArrayBuffer): AttachPack
```

### parseBase

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

```ts
function parseBase(json: string | object, bin: ArrayBuffer): BaseFigure
```

### parseLod

*function* · `packages/humans/src/data.ts:104`

```ts
function parseLod(json: string | object, bin: ArrayBuffer): LodPack
```

### parseMotion

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

```ts
function parseMotion(json: string | object, bin: ArrayBuffer): MotionPack
```

### parseShapePack

*function* · `packages/humans/src/data.ts:74`

```ts
function parseShapePack(json: string | object, bin: ArrayBuffer): ShapePack
```

### patternFromPixels

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

```ts
function patternFromPixels(img: Img, region: Region, gain: Rgb = [1, 1, 1], across = 0.5): { pattern: Pattern; colour: Rgb }
```

A pattern read from a region of cloth: `solid`, `stripes` (periodic along one axis only) or `check` (periodic along both); `scale` is repeats across `across` metres of cloth.

### penetration

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

```ts
function penetration(F: Figure): { checked: number; inside: number; fraction: number; deepest: number }
```

Garment vertices that sit inside the body: nearest body vertex by a hash grid, signed distance along its normal.

### pieceToGarment

*function* · `packages/humans/src/outfit.ts:21`

```ts
function pieceToGarment(p: OutfitPiece): GarmentSpec | null
```

The garment spec of an outfit piece (templates only; library items are bound by the bind tool). Unknown parameter keys are ignored, bad values are dropped.

### placeEars

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

```ts
function placeEars(local: Mesh, base: V3, tilt: number, back: number): { l: Mesh; r: Mesh }
```

Places a local ear (left) on the head and returns the left and right meshes. `tilt` leans it outward, `back` backward.

### planCrowd

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

```ts
function planCrowd(profile: Profile, n: number, opts: CrowdOptions): CrowdPlan
```

Plans a crowd: `variants` different people from the profile (`population`, with its face-distance rule) and `n` instances spread over a square arena. Each instance's
clip, rate, phase, scale and tint come from its own seed; each variant's gait style comes from its spec (the profile's `motionSpread`). Pure of (profile, n, options).

### plantedCycle

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

```ts
function plantedCycle(pack: MotionPack, rig: Rig, clip: GaitClip, speed: number): { poses: Pose[]; fps: number; rate: number; duration: number }
```

One planted cycle of a gait at `speed` m/s: the clip played at the cadence-matched rate with the stance feet held still on the ground (IK), as `treadmill` does,
one pose per clip frame (the middle of three simulated cycles, so the foot states are in their steady cycle). `fps` is the playback rate in poses per second.
The body moves forward by `speed` (m/s) while the poses play: the foot positions in the world are constant during stance.

### plantFeet

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

```ts
function plantFeet(rig: Rig, pose: Pose, targets: Partial<Record<'l' | 'r', [number, number, number]>>): Pose
```

Plants the stance feet of a pose: where a target is farther than the leg can reach, the pelvis is lowered just enough (at most 25 % of the leg) so that it can be
reached, then each leg is bent with plantFoot. targets are world positions of the balls.

### plantFoot

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

```ts
function plantFoot(rig: Rig, pose: Pose, side: 'l' | 'r', target: [number, number, number]): Pose
```

Plants a stance foot with two-bone IK: the pose's leg is bent so the ball stays at `target` (world). `side` 'l' or 'r'. Returns a new pose. The knee bends forward, the foot keeps its world orientation.

### population

*function* · `packages/humans/src/random.ts:187`

```ts
function population(profile: Profile, n: number, seed: number, attempts = 40): Population
```

n different people from one profile. With `minFaceDistance`, a person too close to an earlier one is drawn again (up to `attempts`
times); the result is a pure function of (profile, n, seed).

### poseSkin

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

```ts
function poseSkin(part: BuiltPart, rig: Rig, w: World): Float32Array
```

Linear blend skinning of a built part (8 joints per vertex) to a pose.

### proofIds

*function* · `packages/humans/src/proofs.ts:35`

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

### proofSpec

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

```ts
function proofSpec(id: string): HumanSpec
```

### qaxis

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

```ts
function qaxis: (axis: [number, number, number], angle: number) => Q
```

### qconj

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

```ts
function qconj: (a: ArrayLike<number>) => Q
```

### qfromTo

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

```ts
function qfromTo: (a: [number, number, number], b: [number, number, number]) => Q
```

the rotation taking direction a to direction b (both nonzero)

### qmul

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

```ts
function qmul: (a: ArrayLike<number>, b: ArrayLike<number>) => Q
```

### qnorm

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

```ts
function qnorm: (a: Q) => Q
```

### qrot

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

```ts
function qrot: (q: ArrayLike<number>, v: ArrayLike<number>) => [number, number, number]
```

### qslerp

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

```ts
function qslerp: (a: ArrayLike<number>, b: ArrayLike<number>, t: number) => Q
```

### quantise

*function* · `packages/humans/src/code.ts:237`

```ts
function quantise(s: HumanSpec): HumanSpec
```

What a spec becomes after a trip through the code (the quantised spec); useful for comparing two specs.

### randomHuman

*function* · `packages/humans/src/random.ts:162`

```ts
function randomHuman(seed: number, profile: Profile = UNIFORM_PROFILE): HumanSpec
```

One person from a seed and a profile, the same on every machine. The profile's constraints are hard: the person is drawn again (with
seeds derived from `seed`) until all hold and the spec is valid; if 64 draws fail, it throws with the reasons rather than relax a rule.

### recipe

*function* · `packages/humans/src/kits.ts:44`

```ts
function recipe(id: string): KitOptions
```

### recipeIds

*function* · `packages/humans/src/kits.ts:43`

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

### registerHumansCommands

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

```ts
function registerHumansCommands(host: CommandHost, data: HumanData, opts: HumansSessionOptions = {}): Session
```

Registers the commands on a host and returns the session they work on.

### registerKit

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

```ts
function registerKit(def: KitDef): void
```

### registerProp

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

```ts
function registerProp: (id: string, b: PropBuilder) => void
```

### registerWorn

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

```ts
function registerWorn: (id: string, w: Worn) => void
```

### resolveBody

*function* · `packages/humans/src/resolve.ts:31`

```ts
function resolveBody(spec: HumanSpec): ResolvedBody
```

### resolveKitOptions

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

```ts
function resolveKitOptions(spec: HumanSpec): KitOptions
```

The options of a spec: the kit's defaults, with the spec's own `kitOptions` laid over them (objects merged one level deep, arrays and scalars replaced).

### restPose

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

```ts
function restPose(rig: Rig): Pose
```

### restyle

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

```ts
function restyle(b: BuiltHuman, axes: Partial<Record<StyleAxis, number>>): void
```

The stylised-proportion transform: each joint gets a length factor for the bone from its parent (per axis) and a cross-section factor for the skin it drives, and
every vertex is moved by the weighted sum over its joints (`J'_k + (p - J_k) * section_k`). Works on every part of the built person (skin, hair, garments built
later do not need it: they are made on the result). Afterwards the figure is put back on the ground.

### rotateMesh

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

```ts
function rotateMesh: (m: Mesh, axis: V3, a: number, about?: V3) => Mesh
```

### rotAxis

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

```ts
function rotAxis: (v: V3, axis: V3, a: number) => V3
```

Rotation of a vector about a unit axis by `a` radians (Rodrigues).

### sample

*function* · `packages/humans/src/random.ts:52`

```ts
function sample(rng: Rng, d: Dist): number
```

### samplePose

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

```ts
function samplePose(pack: MotionPack, rig: Rig, clip: GaitClip, t: number): Pose
```

The pose of a gait clip at time `t` seconds (looping), rotations slerped between the 30 fps frames, the pelvis translation scaled by leg length.

### scaleKit

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

```ts
function scaleKit(b: BuiltHuman, k: number): void
```

Uniform scale of the whole built kit about the ground (all parts, joints, stature).

### scaleMesh

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

```ts
function scaleMesh: (m: Mesh, s: V3, about?: V3) => Mesh
```

### setPointer

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

```ts
function setPointer(obj: any, ptr: string, value: unknown): void
```

### simplifyPart

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

```ts
function simplifyPart(p: BuiltPart, cell: number): BuiltPart
```

Cluster simplification: vertices in one grid cell merge (positions and uv averaged, skin of the first), degenerate and duplicate triangles go.

