# @ferret/clothing: API (continued)

### legGirthAt

*function* · `packages/clothing/src/blocks/shorts.ts:34`

```ts
function legGirthAt(body: ClothingBody, m: Measurements, y: number): number
```

the girth of the leg at height y (the thigh and calf cross sections along the leg's axis)

### len2

*function* · `packages/clothing/src/pattern.ts:187`

```ts
function len2: (a: V2, b: V2) => number
```

### lerp3

*function* · `packages/clothing/src/body.ts:33`

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

### limbGirth

*function* · `packages/clothing/src/body.ts:280`

```ts
function limbGirth(body: ClothingBody, a: V3, b: V3, t: number, maxR: number): number
```

girth round a limb: the cross-section perpendicular to the segment a->b at fraction t, only vertices nearer than `maxR` to the axis

### listAnims

*function* · `packages/clothing/src/cache.ts:237`

```ts
function listAnims(rec: OutfitRecord): { clip: string; garment: string }[]
```

### locate

*function* · `packages/clothing/src/trims.ts:14`

```ts
function locate(d: DressedGarment, panel: string, at: V2): { p: V3; n: V3; v: number } | null
```

the dressed position, normal and nearest vertex of a flat point of a panel (barycentric in the panel triangle that holds it)

### makeCtx

*function* · `packages/clothing/src/parts/ctx.ts:124`

```ts
function makeCtx(body: ClothingBody, m: Measurements, spec: BodySpec): UpperCtx
```

### mapRig

*function* · `packages/clothing/src/rig.ts:187`

```ts
function mapRig(jointNames: string[], jointPositions: RigV3[], jointParents?: number[], hint?: RigHint, map?: RigOverride): RigMap
```

Resolves the bone roles of a skeleton (joint names, bind-pose world positions, parent per joint with -1 for a root). Order: the names
(unless `hint.scheme` is 'geometry'), then the geometry of the tree for the roles the names left out (needs `jointParents`), then `map`.
The left side is the +x side: a rig whose names put the left at -x is swapped, so callers can rely on 'l' being at +x.

### mat4Identity

*function* · `packages/clothing/src/motion.ts:30`

```ts
function mat4Identity(out: Float32Array | Float64Array, o = 0): void
```

### mat4InvAffine

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

```ts
function mat4InvAffine(m: ArrayLike<number>, out: Float32Array | Float64Array): boolean
```

the inverse of an affine matrix (rotation, scale, translation)

### mat4Mul

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

```ts
function mat4Mul(a: ArrayLike<number>, ao: number, b: ArrayLike<number>, bo: number, out: Float32Array | Float64Array, oo = 0): void
```

out = a then b (row vectors: p * a * b)

### measureBody

*function* · `packages/clothing/src/body.ts:302`

```ts
function measureBody(body: ClothingBody): Measurements
```

the body's measurements, from its joints (by role, see rig.ts) and cross-sections

### meshPanel

*function* · `packages/clothing/src/pattern.ts:255`

```ts
function meshPanel(panel: Panel, h: number, counts: Map<string, number> = new Map()): PanelMesh
```

Mesh a panel: every edge resampled into `counts.get(edge)` segments (or by `h`), interior points on a triangular lattice of spacing `h`
(none closer than 0.6 h to the outline), Delaunay triangulation (Bowyer-Watson), triangles outside the outline dropped. Deterministic.

### mirrorEdges

*function* · `packages/clothing/src/pattern.ts:234`

```ts
function mirrorEdges(edges: PanelEdge[]): PanelEdge[]
```

mirror a panel's outline in x (a left front from a right one); edge order reversed so the outline keeps its winding

### nativeStyle

*function* · `packages/clothing/src/catalog.ts:360`

```ts
function nativeStyle(block: string, style: Record<string, unknown>): Record<string, unknown>
```

the style in the keys the block function takes: for blocks that exist, closure/pockets/length/fit/collar become the block's own numbers

### neckerchief

*function* · `packages/clothing/src/blocks/headwear.ts:63`

```ts
function neckerchief(body: ClothingBody, m: Measurements, s: KerchiefStyle = {}): Garment
```

### neckJoint

*function* · `packages/clothing/src/body.ts:60`

```ts
function neckJoint(body: ClothingBody): V3
```

the neck joint; a rig without one gets the point half way from the top of the spine (or the pelvis) to the head

### newHit

*function* · `packages/clothing/src/body.ts:223`

```ts
function newHit: () => SurfaceHit
```

### norm

*function* · `packages/clothing/src/body.ts:32`

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

### normalize

*function* · `packages/clothing/src/catalog.ts:329`

```ts
function normalize(s: string): string
```

the normal form of a description: lower case, `ё` as `е`, hyphens and underscores as spaces, one space between words

### notchChain

*function* · `packages/clothing/src/blocks/skirt.ts:63`

```ts
function notchChain(panel: string, tag: string, x0: number, x1: number, y: number, notches: { x: number; intake: number; apexY: number }[]): { edges: PanelEdge[]; pieces: string[]; seams: Seam[] }
```

the waist edge of a panel with notches: the edges (pieces and the two legs of each notch) and the seams that close the notches

### notchedEdge

*function* · `packages/clothing/src/fit.ts:148`

```ts
function notchedEdge(x0: number, x1: number, y: number, notches: { x: number; intake: number; apexY: number }[]): { pieces: V2[][]; legs: [V2, V2, V2][] }
```

A pattern edge with notches (darts) cut into it: the straight edge from x0 to x1 at height y with a notch of `intake` at each x whose apex
lies `apexY` away (up for positive). Returns the straight pieces between the notches and each notch's legs (base a, apex, base b), in the
order along the edge, so a panel's outline can be assembled as piece, leg, leg, piece ...

### outfitKey

*function* · `packages/clothing/src/cache.ts:130`

```ts
function outfitKey(input: OutfitInput): string
```

the content key of an outfit on a body: 64 hex digits. Any change of any input gives another key; the order of object keys does not.

### parseBakedCloth

*function* · `packages/clothing/src/bake.ts:152`

```ts
function parseBakedCloth(bytes: Uint8Array): BakedCloth
```

### parseBoneName

*function* · `packages/clothing/src/rig.ts:52`

```ts
function parseBoneName(raw: string): Parsed
```

strips the namespace / family prefix and splits off the side: 'mixamorig:LeftUpLeg' -> {l, 'upleg'}, 'thigh_l' -> {l, 'thigh'}, 'CC_Base_R_Calf' -> {r, 'calf'}

### pathLength

*function* · `packages/clothing/src/blocks/common.ts:57`

```ts
function pathLength: (p: V3[]) => number
```

### peak

*function* · `packages/clothing/src/trims.ts:54`

```ts
function peak(d: DressedGarment, panel: string, edge: string, o: { depth?: number; half?: number; material?: string } = {}): TrimMesh | null
```

a cap's peak: a stiff curved plate sewn along the front of the band's bottom edge, `depth` deep, tilted down a little, with a rolled edge

### placePoint

*function* · `packages/clothing/src/drape.ts:65`

```ts
function placePoint(panel: Panel, uv: V2, top: number, mid: number): V3
```

the 3D start position of a flat panel point: wrapped on the panel's tube

### pointInPolygon

*function* · `packages/clothing/src/pattern.ts:219`

```ts
function pointInPolygon(p: V2, poly: V2[]): boolean
```

### polyLength

*function* · `packages/clothing/src/pattern.ts:188`

```ts
function polyLength: (p: V2[]) => number
```

### requireRoles

*function* · `packages/clothing/src/rig.ts:240`

```ts
function requireRoles(rig: RigMap, roles: readonly BoneRole[] = ESSENTIAL_ROLES): void
```

throws with the list of roles the garments cannot do without if any is missing

### resample

*function* · `packages/clothing/src/pattern.ts:191`

```ts
function resample(p: V2[], n: number): V2[]
```

points of a polyline at `n + 1` equal arc-length steps (both ends included)

### rigPoint

*function* · `packages/clothing/src/rig.ts:236`

```ts
function rigPoint(rig: RigMap, positions: RigV3[], role: BoneRole): RigV3 | null
```

world position of a role, or null

### roleJoint

*function* · `packages/clothing/src/body.ts:52`

```ts
function roleJoint(body: ClothingBody, role: BoneRole): V3
```

the bind-pose position of the joint that plays `role`; throws if the rig has none

### sameOutfit

*function* · `packages/clothing/src/cache.ts:306`

```ts
function sameOutfit(a: OutfitRecord, b: OutfitRecord): boolean
```

two records are the same when their files are the same bytes

### sampleBakedCloth

*function* · `packages/clothing/src/bake.ts:130`

```ts
function sampleBakedCloth(b: BakedCloth, time: number, rest: ArrayLike<number>, out: Float32Array): Float32Array
```

Play a baked cloth: the bind-pose positions of the garment at `time` seconds into `out` (rest positions with the stored offsets of the
two frames round `time` blended), no simulation. A loop wraps; a clip that does not loop holds its last frame.

### scale

*function* · `packages/clothing/src/body.ts:29`

```ts
function scale: (a: V3, s: number) => V3
```

### seamRank

*function* · `packages/clothing/src/sew.ts:246`

```ts
function seamRank(s: Seam, transverse: boolean): number
```

The rank of a seam in the order of sewing: the garment's own `stage` when it gives one; else by what the seam is. The scale is the one
the blocks use (a seam without a stage is a body seam: 0; a sleeve's underarm seam 0, a sleeve into its armhole 1, a collar or a band 2);
darts come before everything, shoulders before the sides, a hinge (a collar's fall, a lapel's roll) last.

### serializeBakedCloth

*function* · `packages/clothing/src/bake.ts:144`

```ts
function serializeBakedCloth(b: BakedCloth): Uint8Array
```

bytes of a baked cloth: a JSON header (length first), then the active vertices (uint32) and the data (int16)

### setAnim

*function* · `packages/clothing/src/cache.ts:229`

```ts
function setAnim(rec: OutfitRecord, a: CachedAnim): void
```

the baked animation slot: put (replacing the same clip and garment), get, list

### settingEase

*function* · `packages/clothing/src/blocks/ease.ts:39`

```ts
function settingEase(sleeve: SleeveKind, cloth?: ClothProps): number
```

How much longer the cap of a set-in sleeve is than the armhole it goes in (the fraction): the cap is eased in by steaming and a row of
gathering stitches. A knit takes no ease (it stretches), a light woven 2.5 %, a heavy woollen 5 % (it shrinks under the iron); the other
sleeves have no cap to ease: their edge is as long as the armhole.

### sewGarment

*function* · `packages/clothing/src/sew.ts:350`

```ts
function sewGarment(g: Garment, o: SewOptions = {}): SewnGarment
```

sew a garment off the body: its pieces on their form, its seams closed stage by stage, the closed seams welded into nodes

### shirt

*function* · `packages/clothing/src/blocks/shirt.ts:14`

```ts
function shirt(body: ClothingBody, m: Measurements, s: ShirtStyle = {}): Garment
```

### shorts

*function* · `packages/clothing/src/blocks/shorts.ts:131`

```ts
function shorts(body: ClothingBody, m: Measurements, s: ShortsStyle = {}): Garment
```

### shrinkTargets

*function* · `packages/clothing/src/body.ts:340`

```ts
function shrinkTargets(body: ClothingBody): Float32Array | null
```

for every body vertex, the nearest point on the bones it is skinned to (weighted): the body shrinks toward these and keeps its shape

### skinPositions

*function* · `packages/clothing/src/motion.ts:46`

```ts
function skinPositions(positions: ArrayLike<number>, joints: ArrayLike<number>, weights: ArrayLike<number>, mats: ArrayLike<number>, out: Float32Array | Float64Array, only?: ArrayLike<number>): void
```

linear blend skinning of `positions` (the vertices `only` or all) by 4 joints and weights per vertex, into `out`

### skirt

*function* · `packages/clothing/src/blocks/skirt.ts:76`

```ts
function skirt(body: ClothingBody, m: Measurements, s: SkirtStyle = {}): Garment
```

### sleeveReach

*function* · `packages/clothing/src/parts/util.ts:41`

```ts
function sleeveReach(U: UpperFrame, len: UpperSleeveLength): number
```

the sleeve's end along the arm from the shoulder joint, metres (long: to the wrist, a little short as a tailored sleeve is)

### spineJoints

*function* · `packages/clothing/src/body.ts:58`

```ts
function spineJoints(body: ClothingBody): V3[]
```

the spine chain from the pelvis up (may be empty)

### sub

*function* · `packages/clothing/src/body.ts:27`

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

### subPath

*function* · `packages/clothing/src/blocks/common.ts:47`

```ts
function subPath(p: V3[], from: number, to: number): V3[]
```

the part of a polyline between arc lengths `from` and `to` (extended along the last segment past its end)

### supportKindFor

*function* · `packages/clothing/src/blocks/ease.ts:30`

```ts
function supportKindFor: (fitting: Fitting) => "fitted" | "hung"
```

the kind of support a fitting gives a garment that is not hung by its cut: a loose cut hangs from the shoulders, a close one rests on the body

### supportOf

*function* · `packages/clothing/src/blocks/ease.ts:84`

```ts
function supportOf(kind: HoldKind, panels: Panel[], pinned: PinnedLine[], o: { zones?: Support['zones']; what?: Record<string, StiffPiece['what']> } = {}): Support
```

the support of a garment from its panels: the stiffened pieces are the panels whose `stiff` is above 1 (`what` by name unless given)

### supportsOf

*function* · `packages/clothing/src/sew.ts:261`

```ts
function supportsOf(g: Garment, extra: SupportSpec[] = []): SupportSpec[]
```

The supports of a garment: the lines its pattern pins (`Garment.support.pinned`, each with its role) plus `extra`. A pattern that does not
state its `support` (an old or hand-made one) gets the lines it can be read to hold: its held edges, shoulder seams and collar stand.

### topAt

*function* · `packages/clothing/src/blocks/common.ts:5`

```ts
function topAt(body: ClothingBody, x: number, zMax = 0.07): number
```

the top of the body over the shoulder line at |x| (highest vertex within 6 mm of |x|, not further than `zMax` from the body's mid plane)

### transferSkin

*function* · `packages/clothing/src/transfer.ts:12`

```ts
function transferSkin(body: ClothingBody, d: Pick<DressedGarment, 'positions' | 'indices'>, o: { smooth?: number; reach?: number } = {}): ClothSkin
```

### trimRecord

*function* · `packages/clothing/src/cache.ts:222`

```ts
function trimRecord(tr: TrimMesh, garment: string, skin: ClothSkin, o: { texture?: CachedTexture; material?: Record<string, unknown> } = {}): CachedMesh
```

a record mesh from a trim, weighted like the cloth vertex it rides on

### trimsOf

*function* · `packages/clothing/src/trims.ts:80`

```ts
function trimsOf(d: DressedGarment, o: { buttonStyle?: 'horn' | 'brass' } = {}): TrimMesh[]
```

all trims of a dressed garment

### trousers

*function* · `packages/clothing/src/blocks/trousers.ts:32`

```ts
function trousers(body: ClothingBody, m: Measurements, s: TrouserStyle = {}): Garment
```

### tshirt

*function* · `packages/clothing/src/blocks/tshirt.ts:14`

```ts
function tshirt(body: ClothingBody, m: Measurements, s: TshirtStyle = {}): Garment
```

### tuckUnder

*function* · `packages/clothing/src/drape.ts:109`

```ts
function tuckUnder(low: DressedGarment, up: DressedGarment, body: Surface): void
```

A garment dressed over another may leave the one under it standing outside its cloth in places (a shirt through a jacket's sleeve or
hem). Every vertex of the lower garment that lies outside the upper one's cloth, near it and not past its free edges (where the upper
garment is open: a shirt shows in the V of a jacket) is moved in to just under the upper cloth, never nearer the body than `keep`.
Seam-welded vertices move together (same position, same move), and the normals are recomputed.

### underThickness

*function* · `packages/clothing/src/blocks/ease.ts:15`

```ts
function underThickness(under?: Under): number
```

the radial thickness of everything under the garment, metres (a layer's cloth stands `thickness` off the layer below)

### unskinPositions

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

```ts
function unskinPositions(posed: ArrayLike<number>, joints: ArrayLike<number>, weights: ArrayLike<number>, mats: ArrayLike<number>, out: Float32Array | Float64Array, only?: ArrayLike<number>): void
```

The inverse of skinning: the bind-pose position that, skinned by `mats`, lands on `posed`. A mesh drawn with GPU skinning plays a
simulated or baked cloth by having these in its vertex buffer. A vertex whose blended matrix cannot be inverted keeps `posed`.

### upperEases

*function* · `packages/clothing/src/blocks/ease.ts:64`

```ts
function upperEases(o: { fitting: Fitting; kind: HoldKind; fit?: Pick<BodyFit, 'childness'>; t?: number; chest?: number; sleeve?: SleeveKind; cloth?: ClothProps; sleeveless?: boolean }): UpperEases
```

the eases of an upper garment of a fitting, worn over layers of a total thickness `t` (an explicit chest ease replaces the rule's)

### upperFrame

*function* · `packages/clothing/src/blocks/common.ts:23`

```ts
function upperFrame(body: ClothingBody, m: Measurements): UpperFrame
```

### upperPinned

*function* · `packages/clothing/src/blocks/ease.ts:96`

```ts
function upperPinned(panels: Panel[], kind: HoldKind): PinnedLine[]
```

the pinned lines of an upper garment from the panels it has: the shoulder seams, the neck edges (the collar's bottom or the bare neckline), the closure edges of the fronts

### validateFabricSpec

*function* · `packages/clothing/src/describe.ts:261`

```ts
function validateFabricSpec(v: unknown, path: string): DescribeIssue[]
```

the problems of a FabricSpec given as JSON, each naming its field

### validateStyle

*function* · `packages/clothing/src/catalog.ts:342`

```ts
function validateStyle(block: string, style: unknown, path = 'style'): string[]
```

check a style against a block's options; returns one message per problem, each naming the field (`path` + key)

### vertexNormals

*function* · `packages/clothing/src/body.ts:75`

```ts
function vertexNormals(pos: ArrayLike<number>, idx: ArrayLike<number>): Float32Array
```

vertex normals (area weighted)

### waistcoat

*function* · `packages/clothing/src/blocks/waistcoat.ts:13`

```ts
function waistcoat(body: ClothingBody, m: Measurements, s: WaistcoatStyle = {}): Garment
```

### waistLine

*function* · `packages/clothing/src/blocks/skirt.ts:54`

```ts
function waistLine(body: ClothingBody, m: Measurements, w: SkirtStyle['waist'] = 'natural', fit?: BodyFit): { y: number; girth: number }
```

the height of the skirt's top above the floor and its girth there

### waistSupport

*function* · `packages/clothing/src/blocks/ease.ts:107`

```ts
function waistSupport(panels: Panel[], waistEdges: { panel: string; edge: string }[], o: { depth?: number; bend?: number } = {}): Support
```

the support of a waist-held garment (a skirt, trousers, shorts, breeches): the waistband's top edge is pinned at the waist line, and a strip of `depth` below it is stiff (the waistband and its interfacing)

### weltPieces

*function* · `packages/clothing/src/parts/hems.ts:25`

```ts
function weltPieces(ctx: UpperCtx, halves: WeltHalf[], spec: HemSpec, closedFront: boolean): Piece
```

the welt bands under the half panels, joined to their hems, to one another at the sides, the back (and the front when it is closed)

### witchHat

*function* · `packages/clothing/src/blocks/accessories.ts:40`

```ts
function witchHat(body: ClothingBody, m: Measurements, s: WitchHatStyle = {}): Garment
```

A pointed hat: the cone is a circular sector (a developable cone) in two halves sewn up the sides, bent back at the tip with the point curling
down, on a wide brim in two halves; felt with buckram (brim and cone stiff). It sits on the head by the cone's foot.

## Interfaces

### Anchor

*interface* · `packages/clothing/src/parts/sleeves.ts:30`

```ts
interface Anchor
```

- `at: V2`
- `to: V3`
- `reach?: number`

### BakedCloth

*interface* · `packages/clothing/src/bake.ts:27`

```ts
interface BakedCloth
```

- `format: 1`
- `garment: string` — the garment and the clip it was made for (names, as the record keys them)
- `clip: string`
- `fps: number` — frames per second of the stored frames, how many frames, the clip's length in seconds and whether it loops (a loop has `frames` distinct frames, the next after the last is the first)
- `frames: number`
- `duration: number`
- `loop: boolean`
- `vertexCount: number` — vertices of the garment, and the ones stored (ascending)
- `active: Uint32Array`
- `scale: number` — metres per unit of `data`
- `data: Int16Array` — frames x active x 3, the offset of the vertex from its rest position in the bind pose

### BakedGarment

*interface* · `packages/clothing/src/fabric.ts:38`

```ts
interface BakedGarment
```

- `width: number`
- `height: number`
- `albedo: Uint8Array` — RGBA 8 bit, sRGB colour
- `normal: Uint8Array` — RGBA 8 bit, tangent-space normal (y up in the flat panel = v up)
- `orm: Uint8Array` — RGBA 8 bit: R occlusion, G roughness, B metal (glTF ORM)
- `uv: Float32Array` — per vertex atlas UV (v down, glTF)
- `pxPerMeter: number`

### BakeOptions

*interface* · `packages/clothing/src/bake.ts:42`

```ts
interface BakeOptions
```

- `fps?: number` — stored frames per second; it must divide 60 (60, 30, 20, 15, 12, 10; default 30)
- `motion?: MotionOptions` — simulation of the garment (see MotionOptions); the garment's skin, supports and layers under it go here
- `warmCycles?: number` — cycles run before the first stored frame for a looping clip (default 3), and frames the first pose is held for a clip that does not loop (default 60)
- `warmHold?: number`
- `loopBlend?: number` — seconds over which the start of a loop is blended into the continuation of its end, so the loop closes (default 0.3)
- `garmentName?: string` — names for the record
- `clipName?: string`
- `onFrame?: (frame: number, positions: Float32Array, mats: Float32Array) => void` — called for every stored frame with the simulated cloth (positions in the pose, the pose matrices) before it is turned into offsets

### BeanieStyle

*interface* · `packages/clothing/src/blocks/hats.ts:20`

```ts
interface BeanieStyle
```

- `height?: number` — body height above the cuff, metres (default 0.13: a little slouch) and cuff height (default 0.07)
- `cuff?: number`
- `fitted?: number` — how much of the head's girth the knit takes (the knit stretches round the head; default 0.93)
- `hair?: number`
- `fabric?: string`
- `rib?: string`
- `layer?: number`

### BeltStyle

*interface* · `packages/clothing/src/blocks/accessories.ts:148`

```ts
interface BeltStyle
```

- `width?: number` — width of the band, metres (default 0.04)
- `waist?: 'natural' | 'high' | 'low' | number` — where it sits: the natural waist, high or low, or metres above (+) / below (-) it
- `under?: Under` — the layers worn under it (dress, skirt, a wrap: thicknesses in metres or garments): the ring is longer by their room
- `buckle?: boolean` — a buckle at the front (default true)
- `ease?: number` — how loose it is, metres of girth (default 0.01)
- `fabric?: string`
- `layer?: number`

### BlockSpec

*interface* · `packages/clothing/src/catalog.ts:32`

```ts
interface BlockSpec
```

- `name: string`
- `implemented: boolean` — false: registered by name and options, the block itself is being written by another lane
- `description: string`
- `nouns: (string | NounSpec)[]`
- `options: Record<string, OptionSpec>`
- `defaultFabric: string` — the fabric used when a description names none
- `woolAs?: string` — the fabric that "wool" means for this block (default: wool serge)
- `longLength?: string` — what "long" means for this block's `length`
- `native?: (style: Record<string, unknown>) => Record<string, unknown>` — implemented blocks: turns the described options (closure, pockets, length, fit, collar ...) into the keys the block function takes

### BodyFit

*interface* · `packages/clothing/src/fit.ts:10`

```ts
interface BodyFit
```

Fits: descriptors a cut needs beyond `measureBody`, computed from the measurements and the body itself and the same for
any sex or age: the bust (girth, height, apexes), the underbust, the waist and hip lines, the proportions of a child, and the ease a
style asks for. `darts` turns them into the bust and waist darts that shape a bodice or a skirt.

- `height: number` — floor to the top of the head, metres
- `headsTall: number` — heads tall (height over the head's height) and crotch height over height: a child is short, short-legged and big-headed
- `legRatio: number`
- `childness: number` — 0 = adult proportions, 1 = a small child (from height and proportions)
- `child: boolean`
- `bust: number` — the bust: girth at the fullest point, its height, the apexes (x, z) of the left (+x) and right sides, their distance
- `bustY: number`
- `apex: { l: V2; r: V2 }`
- `bustSpan: number`
- `bustProjection: number` — how far the bust stands out in front of the ribs, metres, and the (bust - underbust) girth difference
- `bustDifference: number`
- `underbust: number`
- `underbustY: number`
- `waist: number`
- `waistY: number`
- `highHip: number` — a hand's breadth below the waist: the high hip
- `highHipY: number`
- `hip: number`
- `hipY: number`
- `waistToHip: number` — vertical distance from the waist to the fullest part of the hip
- `neckToBust: number` — neck point to the bust, to the waist (front length)
- `neckToWaist: number`
- `bustToWaist: number` — the shaping a figure has from the bust and the hip down to the waist (metres of girth)
- `hipToWaist: number`

### BodySpec

*interface* · `packages/clothing/src/parts/ctx.ts:32`

```ts
interface BodySpec
```

- `hemY: number` — world height of the lowest edge of the garment (below any welt)
- `ease: number` — ease over the chest, metres in all
- `fit: Fit`
- `flare: number` — extra girth at the hem (aline: from the chest down; fitted: below the seat), metres in all
- `cbWaist: number` — how far the centre back seam is taken in at the waist, metres
- `pad: number` — extra start radius over the body's half depth (the start shape of the old drape only)
- `eases: UpperEases` — the cutting rules' eases for this garment (see `upperEases`): `ease` is its chest ease
- `welt: number` — height of a rib or self band under the body (0: none)
- `fabric: string`
- `rib: string`
- `backNeckDrop: number` — the front's armhole depth below the chest line, metres (set by the sleeve)

### BootPart

*interface* · `packages/clothing/src/footwear.ts:20`

```ts
interface BootPart
```

- `name: string`
- `pos: number[]`
- `nrm: number[]`
- `uv: number[]`
- `idx: number[]`
- `material: 'leather' | 'sole' | 'lace' | 'metal'`

### Boots

*interface* · `packages/clothing/src/footwear.ts:21`

```ts
interface Boots
```

- `parts: BootPart[]`
- `raise: number`

### BootStyle

*interface* · `packages/clothing/src/footwear.ts:9`

```ts
interface BootStyle
```

Footwear on a last: a boot is built round the body's own foot, as a shoemaker builds it round a last taken from the
foot: a sole following the foot's outline with a heel block and a welt, an upper lofted from the sole up over the foot with the room a
foot needs, a shaft round the ankle, a tongue and a laced opening with eyelets and laces. Meshes in metres, in the body's frame.

- `shaft?: number` — shaft height above the floor (default 0.15: an ankle boot)
- `sole?: number` — sole and heel thickness
- `heel?: number`
- `room?: number` — room round the foot
- `eyelets?: number` — eyelets per side

### BreechesStyle

*interface* · `packages/clothing/src/blocks/breeches.ts:13`

```ts
interface BreechesStyle
```

Breeches: the leg block of the shorts cut full over the thigh (`flare`, the riding breeches' wings) and closed on a
band below the knee (`band`), buttoned or laced in life: here a ring sewn to the hem. `length` 'knee' puts the band just under the knee,
'calf' on the calf, or give the height of the band's top above the floor.

- `length?: 'knee' | 'calf' | number`
- `flare?: number` — extra half width at the wings on each seam, metres (default 0.05)
- `band?: number` — band height (default 0.08) and its ease over the leg there (default 0.02)
- `bandEase?: number`
- `fitting?: Fitting`
- `under?: Under`
- `seatEase?: number`
- `waistEase?: number`
- `rise?: number`
- `fabric?: string`
- `layer?: number`

### BrimmedHatStyle

*interface* · `packages/clothing/src/blocks/hats.ts:11`

```ts
interface BrimmedHatStyle
```

Hats beyond the cap: a brimmed hat (a tube crown with a flat top and a stiff brim cut in two halves, the way a felt hat
is blocked) and a beanie (a knitted tube closed at the top, with a rib cuff). Both sit on the hair line round the head (`hair` keeps them
off the scalp). The hood is the upper-garment lane's.

- `crown?: number` — crown height and brim width, metres (defaults 0.1 and 0.06: a trilby)
- `brim?: number`
- `crownOver?: number` — the crown's top is wider than the head by this much (default 0.008)
- `hair?: number` — hair under it, metres (default 0.012)
- `fabric?: string`
- `layer?: number`

### BrodyHelmetStyle

*interface* · `packages/clothing/src/blocks/accessories.ts:83`

```ts
interface BrodyHelmetStyle
```

- `dome?: number` — radius of the dome, metres (default 0.105)
- `brim?: number` — width of the brim measured along the slope (default 0.052) and how far its outer edge hangs below its inner (default 0.034)
- `drop?: number`
- `strap?: boolean` — a chin strap
- `hair?: number`
- `fabric?: string`
- `layer?: number`

### CachedAnim

*interface* · `packages/clothing/src/cache.ts:180`

```ts
interface CachedAnim
```

Baked cloth animation of one garment for one clip (written by the cloth animation bake, read by the game). Three kinds:
- `positions`: `frames` frames of `vertexCount` vertices, x y z each, at `fps`, in `data`;
- `vat`: the same as a vertex animation texture in `data` (RGBA32F, `width` x `height`);
- `baked`: the block of `bakeClip` (`serializeBakedCloth` bytes: the vertices that move, 16-bit offsets from rest) in `bytes`, `data` empty;
  `bakedToAnim` and `animToBaked` (bake.ts) turn it from and to the typed `BakedCloth`. `frames`, `fps` and `vertexCount` are the block's own.

- `clip: string`
- `garment: string`
- `fps: number`
- `frames: number`
- `vertexCount: number`
- `kind: 'positions' | 'vat' | 'baked'`
- `data: Float32Array`
- `width?: number`
- `height?: number`
- `bytes?: Uint8Array` — `kind: 'baked'`: the serialized block

### CachedEdge

*interface* · `packages/clothing/src/cache.ts:142`

```ts
interface CachedEdge
```

- `panel: string`
- `edge: string`
- `verts: Uint32Array`

### CachedGarment

*interface* · `packages/clothing/src/cache.ts:144`

```ts
interface CachedGarment
```

- `name: string`
- `positions: Float32Array`
- `normals: Float32Array`
- `uv: Float32Array`
- `indices: Uint32Array`
- `joints: Uint16Array` — 4 joint indices and 4 weights per vertex (the body's skeleton)
- `weights: Float32Array`
- `panelOf: Uint16Array` — the panel of each vertex, index into `panels`
- `panels: string[]`
- `edges: CachedEdge[]` — the edge vertex lists trims and hems need
- `hems: { panel: string; edge: string }[]`
- `texture?: CachedTexture`
- `material?: Record<string, unknown>` — material parameters (sheen ...), plain JSON

### CachedHidden

*interface* · `packages/clothing/src/cache.ts:171`

```ts
interface CachedHidden
```

the body triangles hidden under the outfit at a level of detail: one byte per triangle, 1 = hidden

- `lod: number`
- `mask: Uint8Array`

### CachedMesh

*interface* · `packages/clothing/src/cache.ts:160`

```ts
interface CachedMesh
```

a trim or a boot part: its own mesh, skinned, with its material

- `name: string`
- `kind: string`
- `pos: Float32Array`
- `nrm: Float32Array`
- `uv: Float32Array`
- `idx: Uint32Array`
- `joints?: Uint16Array`
- `weights?: Float32Array`
- `garment?: string` — the garment it rides on, and the vertex of that garment it follows
- `rides?: number`
- `texture?: CachedTexture`
- `material: Record<string, unknown>`

### CachedTexture

*interface* · `packages/clothing/src/cache.ts:140`

```ts
interface CachedTexture
```

- `width: number`
- `height: number`
- `albedo: TexData`
- `normal: TexData`
- `orm: TexData`

### CapStyle

*interface* · `packages/clothing/src/blocks/headwear.ts:11`

```ts
interface CapStyle
```

A soft peaked cloth cap: a round crown wider than the head (it sags over the band), a band round the head held at the
brow, a stiff peak sewn to the front of the band. `clearance` keeps it off the scalp by the hair's thickness.

- `crownOver?: number` — crown radius over the head's (default 0.035: a full, flat cap)
- `band?: number`
- `peak?: number`
- `hair?: number` — hair under it, metres (default 0.012)
- `fabric?: string`
- `layer?: number`

### CatalogFabric

*interface* · `packages/clothing/src/fabrics.ts:10`

```ts
interface CatalogFabric
```

Fabric catalogue: named fabrics, each a surface (FabricSpec, baked by `bakeGarment`) and the way the cloth behaves
in the drape (ClothProps: density kg/m^2, stretch and bend compliances, half thickness, friction). A description picks a fabric by
name and a colour by word; `fabricFor` makes the pair with that colour.

- `name: string`
- `words: string[]` — words that name this fabric in a description (lower case, English words and Russian stems)
- `spec: FabricSpec`
- `cloth: ClothProps`

### CloakStyle

*interface* · `packages/clothing/src/blocks/cloak.ts:17`

```ts
interface CloakStyle
```

A cloak or cape: a circle of cloth with a hole at the neck, cut in two halves joined down the back, open at the front
and clasped at the neck. It starts flat at the shoulders and falls over them. `length` is how far it hangs below the neck point (a
hem height name, or metres), `spread` the angle of each half (a circle cape 2.8, a capelet 2.0), `collar` none | stand | hood.

- `length?: UpperHemName | number` — the hem: a height name, or metres below the neck point (default 'calf': a cloak; 0.45: a cape)
- `spread?: number` — the angle of each half round the neck, radians (default 2.7; the front stays open by pi minus that on each side)
- `collar?: CollarSpec | 'none' | 'stand' | 'hood'`
- `hood?: HoodSpec`
- `under?: Under` — the layers worn under it (thicknesses in metres or garments): the neck ring is wider by their thickness
- `fabric?: string`
- `layer?: number`

### ClosureDraft

*interface* · `packages/clothing/src/parts/closures.ts:24`

```ts
interface ClosureDraft
```

- `kind: NonNullable<ClosureSpec['kind']>`
- `e: number`
- `edges: (from: V2, lapel: boolean, y0: number) => PanelEdge[]` — the front edges after the neck (and a lapel's roll): from `from` to the hem
- `build: (o: { end: V2; lapel: boolean; yB: number; buttonTop: number }) => Piece`

### ClosureSpec

*interface* · `packages/clothing/src/parts/closures.ts:10`

```ts
interface ClosureSpec
```

Closures: single-breasted (buttons on the centre front, a small overlap), double-breasted (a wide overlap, two columns),
zip (the fronts sewn along the centre front, topstitched), pullover (the fronts sewn along the centre front), wrap (the left front crosses
over the right, held at the waist). The left front lies over the right.

- `kind?: 'single' | 'double' | 'zip' | 'pullover' | 'wrap'`
- `buttons?: number` — number of buttons in a column (default from the length of the front)
- `buttonSize?: number` — button diameter (default 0.012; double-breasted 0.024)
- `extension?: number` — half the overlap past the centre front (default by kind: single 0.03, double 0.085, wrap 0.15)
- `buttonX?: number` — double-breasted: distance of each column from the centre front (default 0.065)
- `lowest?: number` — the lowest button, relative to the hem (default: just under the waist)

### ClothingBody

*interface* · `packages/clothing/src/body.ts:10`

```ts
interface ClothingBody
```

- `positions: Float32Array` — metres, y up, the figure faces +z
- `indices: Uint32Array`
- `joints?: Uint16Array` — per vertex, 4 joint indices and 4 weights
- `weights?: Float32Array`
- `jointNames: string[]` — joint names and world positions in the bind pose (UE/MetaHuman names: pelvis, spine_01..05, neck_01, head, clavicle_l, upperarm_l ...)
- `jointPositions: V3[]`
- `jointParents?: number[]` — parent of each joint (-1 for a root): bones are the segments joint-parent
- `rigHint?: RigHint` — how to read the rig (see rig.ts): a hint for the name matching, and roles given by hand (they win over the names and the geometry)
- `rigMap?: RigOverride`

### ClothProps

*interface* · `packages/clothing/src/pattern.ts:135`

```ts
interface ClothProps
```

- `density?: number` — surface density, kg/m^2 (serge 0.45, jersey knit 0.5, cotton shirting 0.12)
- `stretch?: number` — compliance of stretch (m/N); 0 = inextensible
- `bend?: number` — compliance of bending
- `seamBodyOnly?: boolean` — [OLD DRAPE ONLY, OLD-SWITCHES.md] seam vertices ignore the garments under while the seams close (cloth over baggy cloth)
- `layersAfter?: boolean` — [OLD DRAPE ONLY, OLD-SWITCHES.md] the garments under are not collided with in the settle, only pushed out of afterwards
- `seamFinish?: boolean` — [OLD DRAPE ONLY, OLD-SWITCHES.md] after the seams are welded the cloth is pushed once more out of the garments under it, and bridged over their grooves (the cleft of a seat under a shirt's back seam)
- `underTrim?: number` — [OLD DRAPE ONLY, OLD-SWITCHES.md] metres of the top of this garment left out of what a garment over it collides with (a waistband under a shirt)
- `hemFair?: boolean` — [OLD DRAPE ONLY, OLD-SWITCHES.md] fair the hem across its seams (no V at a seam) and smooth the points where three or more seams meet
- `ridgeSeams?: string` — [OLD DRAPE ONLY, OLD-SWITCHES.md] regular expression on a seam's name (`panelA.edgeA/panelB.edgeB`): a seam that stands out as a ridge (surplus cloth gathered along it) is shaved, with its surroundings
- `bendLong?: number`
- `seamIterations?: number` — [OLD DRAPE ONLY, OLD-SWITCHES.md] extra solver iterations of the seam links per substep (corners where several panels meet close tighter; default 14)
- `frames?: number` — [OLD DRAPE ONLY, OLD-SWITCHES.md] frames of the drape for this garment (overrides the run's): a long run lets a tight, light-seamed garment creep and open at its front edge
- `fair?: number` — [OLD DRAPE ONLY, OLD-SWITCHES.md] rounds of fairing of the finished cloth (default 6; 0 off)
- `shell?: boolean` — [OLD DRAPE ONLY, OLD-SWITCHES.md] drape on the body thickened by the garments under it (one smooth shell), not on their cloth: for outer garments (jacket, coat)
- `layerPush?: boolean` — [OLD DRAPE ONLY, OLD-SWITCHES.md] false: no pushing out of the garments under it at the end (an outer garment that must keep its seams closed; default true)
- `thickness?: number`
- `clearance?: number` — extra distance kept from the body (what the body mesh does not have: hair under a cap), metres
- `friction?: number`

### ClothSkin

*interface* · `packages/clothing/src/transfer.ts:10`

```ts
interface ClothSkin
```

Weights and hidden body. Every cloth vertex takes the skin of the nearest point of the body surface (the three corner
vertices' joints blended by the barycentric weights), then the weights are smoothed along the cloth so a fold does not tear between two
bones; the body triangles that every garment covers well inside its edges are listed, to be left out of the drawn body.

- `joints: Uint16Array`
- `weights: Float32Array`

### CollarSpec

*interface* · `packages/clothing/src/parts/collars.ts:14`

```ts
interface CollarSpec
```

Collars: none (a bare neckline: crew, V or scoop), band (a closed rib or self band on the neckline), stand (a mandarin
collar with open ends), shirt collar (stand and fall), notched and peaked lapels and shawl (lapels turned back on the roll line, a stand
and a fall), hood. A collar gives the shape of the front neckline (and the roll line of a lapel) and, once the body is cut, the panels
that go on the neck ring.

- `kind?: 'none' | 'band' | 'stand' | 'shirt' | 'notched' | 'peaked' | 'shawl' | 'hood'`
- `neckline?: 'crew' | 'v' | 'scoop'` — the bare neckline of none / band / hood
- `depth?: number` — depth of the neckline at the centre front (default by kind)
- `stand?: number` — collar stand and fall heights; a band's height is `stand`
- `fall?: number`
- `lapel?: number` — lapel width at its point
- `gorge?: number` — the gorge (where lapel and collar meet) this far below the neck point (default 0.085)
- `hood?: HoodSpec` — a hood

### Dart

*interface* · `packages/clothing/src/fit.ts:94`

```ts
interface Dart
```

a dart: its base point on the pattern's edge, its apex, and the width it takes in at the base (the legs lie either side of the base)

- `base: V2`
- `apex: V2`
- `intake: number`

### DartPlan

*interface* · `packages/clothing/src/fit.ts:101`

```ts
interface DartPlan
```

- `bust: { sideY: number; apex: V2; intake: number } | null` — the bust dart from the side seam to the apex (pattern coordinates: x from the centre front, y above the waist line); null when the cut needs no bust shaping
- `front: { x: number; length: number; intake: number }[]` — waist darts, from the waist line up: x from the centre line, the length up from the waist, the intake (one per side of the panel)
- `back: { x: number; length: number; intake: number }[]`
- `sideIn: number` — how much each side seam moves in at the waist on each panel (the rest of the shaping), metres
- `total: number` — the girth of shaping to take out in all (bust or hip minus waist, with the eases)

### DescribedGarment

*interface* · `packages/clothing/src/describe.ts:18`

```ts
interface DescribedGarment
```

Description to garments: `describe(text | JSON)` turns "a long single-breasted wool overcoat with notched lapels and
flap pockets" (English, or basic Russian) or the structured form into `{garments: [{block, style}], fabrics}` that `clothing.dress` takes.
The parser works off the registry (`catalog.ts`): the words that name each block and set each option are the registry's, so a block
needs no code to be described. The structured form is validated and every problem names its field.

Text grammar: the garment nouns are found first (adjacent nouns make the first a modifier: "jersey dress", "suit jacket"); the text is
cut into one clause per garment at the last "and" / comma between two nouns (a clause is the adjectives before its noun and the
"with ..." after it); in a clause the fabric is taken first, then the option phrases (longest first), then the colour. A trailing
"all in navy wool" applies to every garment that has no fabric or colour of its own.

- `block: string`
- `style: Record<string, unknown>`

### DescribeIssue

*interface* · `packages/clothing/src/describe.ts:31`

```ts
interface DescribeIssue
```

- `field: string`
- `message: string`

### DescribeOptions

*interface* · `packages/clothing/src/describe.ts:27`

```ts
interface DescribeOptions
```

- `native?: boolean` — turn described options into the keys of blocks that exist (default true); false keeps closure/pockets/length/fit/collar

### Description

*interface* · `packages/clothing/src/describe.ts:19`

```ts
interface Description
```

- `garments: DescribedGarment[]`
- `fabrics: Record<string, FabricSpec>` — key (as in each garment's `style.fabric`) to surface, for `clothing.dress`
- `cloth: Record<string, ClothProps>` — key to cloth behaviour of the catalogue fabric (density, stretch, bend ...), for the drape
- `warnings: string[]`

### Digit

*interface* · `packages/clothing/src/blocks/gloves.ts:31`

```ts
interface Digit
```

one digit of a hand: its joint chain from the base to the tip (the tip is extrapolated) and the vertices it owns

- `joints: number[]`
- `chain: V3[]`
- `radius: number[]`
- `thumb: boolean`

### DrapeOptions

*interface* · `packages/clothing/src/drape.ts:25`

```ts
interface DrapeOptions
```

- `h?: number` — triangle size, metres (default 0.012)
- `frames?: number` — frames of 1/60 s (default 220)
- `substeps?: number`
- `shrink?: number` — how far in the body starts (it grows back to full in the first part of the run), metres
- `snapshot?: number[]` — frames whose cloth positions are handed to `onSnapshot` (to look at the run)
- `onSnapshot?: (garment: string, frame: number, positions: Float32Array, indices: Uint32Array) => void`
- `thin?: number` — how thin the body is while the seams close (its limbs scaled toward the bones; default 0.55)
- `seamIterations?: number` — extra solver iterations of the seam links per substep (default 6): corners where several panels meet close tighter
- `fair?: number` — rounds of fairing of the finished cloth (default 6; 0 off)
- `under?: { positions: ArrayLike<number>; indices: ArrayLike<number> }[]` — rigid things the garments hang over besides the body (boots: a trouser leg falls over the shaft, not through it)
- `log?: (s: string) => void` — progress

