# @ferret/clothing: API (continued)

### DressedCloth

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

```ts
interface DressedCloth
```

the result: what the trims, the seam textures and the skin transfer read (the old `DressedGarment`, with the sewing's welds and edges)

- `name: string`
- `positions: Float32Array`
- `normals: Float32Array`
- `flat: Float32Array` — flat panel coordinates, metres (x across the panel, y along the grain)
- `indices: Uint32Array`
- `panelOf: Uint16Array` — the panel of each vertex (index into `panels`)
- `panels: Panel[]`
- `meshes: { mesh: PanelMesh; offset: number }[]` — per panel: its mesh (flat outline, edge vertices) with the vertex offset into this garment
- `garment: Garment`
- `edgeVerts: Map<string, number[]>` — the vertices along a panel edge, by `panel.edge` (global indices)
- `weld: Uint32Array` — per vertex: the smallest vertex index at its place (welded vertices share it)
- `groups: number[][]`
- `seamGap: number` — the widest gap of the seams just before they were sewn shut, metres (from the sewing)
- `stats: { frames: number; contacts: number; restedFrames: number; maxSpeed: number; pinned: number; startedInside: number }`

### DressedGarment

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

```ts
interface DressedGarment
```

Dressing: the panels of a garment are meshed, wrapped round the body where they belong, sewn (the seams close step by
step, then the paired edge vertices are welded) and left to settle under gravity against the body and the garments dressed before.

- `name: string`
- `positions: Float32Array`
- `normals: Float32Array`
- `flat: Float32Array` — flat panel coordinates, metres (x across the panel, y along the grain)
- `indices: Uint32Array`
- `panelOf: Uint16Array` — the panel of each vertex (index into `panels`)
- `panels: Panel[]`
- `meshes: { mesh: PanelMesh; offset: number }[]` — per panel: its mesh (flat outline, edge vertices) with the vertex offset into this garment
- `garment: Garment`

### DressOptions

*interface* · `packages/clothing/src/dress.ts:50`

```ts
interface DressOptions
```

- `frames?: number` — frames of 1/60 s of the settle (default 240)
- `substeps?: number` — substeps per frame (default 8)
- `self?: boolean` — collision of the cloth with itself (default true)
- `ramp?: number` — frames over which gravity grows from nothing to full (default 20)
- `release?: number` — the part of the run, at its end, with the pins released (default 0.15): what rests there is the result
- `clearance?: number` — extra distance kept from the body, metres (hair under a cap; adds to `cloth.clearance`)
- `log?: (s: string) => void` — progress
- `onFrame?: (frame: number, positions: Float32Array) => void` — called with the cloth's positions (per vertex) every `every` frames, to look at the run
- `every?: number`
- `maxSpeed?: number` — speed limit of the cloth while it settles, m/s (default 2)
- `pull?: number` — the fitted pull toward the body, m/s at its strongest (default 0.15)

### DressRequest

*interface* · `packages/clothing/src/service.ts:40`

```ts
interface DressRequest
```

- `entity: string` — the entity whose skinned mesh is the body (its first skinned mesh, or `mesh` by name)
- `mesh?: string`
- `garments: { block: string; style?: Record<string, unknown> }[]`
- `fabrics: Record<string, FabricSpec>`
- `h?: number` — triangle size and frames of the drape
- `frames?: number`
- `hide?: boolean` — leave the covered body triangles out (default true)
- `maxTex?: number` — texture side limit

### DressStyle

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

```ts
interface DressStyle
```

- `cut?: DressCut`
- `fitting?: Fitting`
- `under?: Under` — the layers worn under it (thicknesses in metres or garments): the cut is wider by the room they take
- `length?: number | HemName` — hem: a name, or metres below the waist (default 'knee')
- `sleeves?: SleeveLength`
- `neckline?: Neckline`
- `flare?: number` — A-line: how much wider the hem is than the hip on each half panel, metres (default 0.16)
- `fabric?: string`
- `layer?: number`

### FabricSpec

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

```ts
interface FabricSpec
```

- `weave: Weave`
- `color: [number, number, number]` — linear RGB 0..1
- `weft?: [number, number, number]` — colour of the weft threads (denim: indigo warp, pale weft; the twill shows the weft on the other face); other weaves ignore it
- `wales?: number` — corduroy: wales per metre (default 700 = 1.4 mm period); velvet: pile sheen strength 0..1 (default 0.6)
- `pile?: number`
- `heather?: [number, number, number]` — second fibre colour mixed in (heathered wool), and how much
- `heatherAmount?: number`
- `period?: number` — thread / stitch period, metres: twill wale 0.0008, knit stitch width 0.0036, rib 2 x 2
- `roughness?: number`
- `depth?: number` — relief depth of the weave, metres
- `wear?: number` — how worn: lighter, smoother on raised parts, fuzz
- `yoke?: { panels: string[]; above: number; pattern: 'ladder' | 'moss' | 'ridges' }` — a knitted yoke pattern above this panel y on the panels listed (the guernsey's patterned chest)
- `thread?: [number, number, number]` — thread of the stitching
- `sheen?: [number, number, number]` — sheen (wool fuzz) colour and roughness for KHR_materials_sheen
- `sheenRoughness?: number`

### FolderIO

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

```ts
interface FolderIO
```

the file operations of a folder (Node's fs in the tools, a platform file API in a game); `read` gives undefined when the file is not there

- `read(name: string): Promise<Uint8Array | undefined>`
- `write(name: string, bytes: Uint8Array): Promise<void>`
- `list(): Promise<string[]>`
- `remove(name: string): Promise<void>`

### Garment

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

```ts
interface Garment
```

- `name: string`
- `panels: Panel[]`
- `seams: Seam[]`
- `tacks?: Tack[]`
- `hold?: { panel: string; edge: string; ease?: number; free?: boolean }[]` — `free`: the edge is only kept from sliding down once sewn (it may close its seams freely), instead of pinned to the body
- `hems?: { panel: string; edge: string }[]` — edges that are hemmed (stitched turn-ups)
- `cloth?: ClothProps` — cloth behaviour
- `h?: number` — triangle size for this garment (small things: a cap, a kerchief), metres
- `over?: [string, string, number?][]` — panels lying over other panels of this garment (a front buttoned over the other, a lapel over its front): [upper, lower, gap metres]
- `layer?: number` — the order of dressing: lower layers first; a layer collides with all garments dressed before it
- `support?: Support` — how the garment is held (every block states it)
- `seatGirth?: number` — girth at the seat (a lower garment): the old way to cut upper garments over it; the new way is the `under` option of every block (OLD-SWITCHES.md)
- `trims?: TrimSpec[]` — trims (buttons, eyelets ...) placed on the dressed cloth
- `folds?: { axis: [number, number, number][]; amp: number; n: number; twist?: number; from?: number; ramp?: number }[]` — [OLD DRAPE ONLY, OLD-SWITCHES.md] hanging folds of a garment with more cloth than the body needs (wide trouser legs), put in after the settle (a field over the 3D position, so the two sides of a seam move alike): vertical creases round an axis, outward and inward by about `amp`, growing toward the free end

### GlovePart

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

```ts
interface GlovePart
```

- `name: string`
- `pos: number[]`
- `nrm: number[]`
- `uv: number[]`
- `idx: number[]`
- `material: 'leather' | 'knit' | 'cloth'`

### Gloves

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

```ts
interface Gloves
```

a glove is a shaped shell on the hand: it is held by the hand (the fingers and the wrist), nothing is pinned or sewn on the pattern, and a gauntlet's cuff is stiff

- `parts: GlovePart[]`
- `support: Support`

### GloveStyle

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

```ts
interface GloveStyle
```

Gloves, built like the boots round a last taken from the body: a cuff and palm lofted through cross sections of the
hand and forearm, with a finger for each digit (a tube along the digit's joint chain, wide as the digit's own vertices, ending in a round
tip), or one mitten pocket for the four fingers and a thumb. Digits are found from the skeleton, not from names: the children of the hand
joint are its metacarpals and the thumb; each digit follows its farthest child to the tip. Sizes come from the body's skin weights: the
vertices a digit's joints own. Parts are meshes in metres in the body's frame, one per glove and side, a mirror pair for a pair.

- `kind?: 'glove' | 'mitten'` — 'glove' (a finger each) or 'mitten' (the four fingers together, the thumb apart)
- `cuff?: 'wrist' | 'gauntlet' | 'elbow' | number` — cuff length up the forearm from the wrist: a name or metres (default 'wrist' 0.05)
- `room?: number` — room round the hand, metres (default 0.004: a close leather glove; 0.012 a knitted one)
- `flare?: number` — the cuff flares at its top by this much round the radius, metres (default 0 for 'wrist', 0.012 for longer cuffs)
- `material?: 'leather' | 'knit' | 'cloth'`
- `side?: 1 | -1` — only one hand: 1 left, -1 right (default both)

### HemSpec

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

```ts
interface HemSpec
```

Hems: the lower edge of the body: a plain stitched hem (straight or curved up at the sides like a shirt-tail), or a
welt, a band of rib or of the cloth sewn under the body (a sweatshirt, a guernsey, a bomber), with side vents or closed.

- `trim?: 'plain' | 'rib' | 'band'` — plain: a turned hem; rib: a rib welt; band: a welt of the main cloth
- `height?: number` — height of a welt (default 0.06)
- `shape?: 'straight' | 'curved'` — a plain hem's shape: straight, or curved up at the sides by `rise` (a shirt-tail)
- `rise?: number`
- `vents?: boolean` — a welt left open at the sides (the guernsey's vents)

### HoodSpec

*interface* · `packages/clothing/src/parts/hood.ts:12`

```ts
interface HoodSpec
```

A hood: two side panels joined along the crown seam (a long curve from the back of the neck over the head to the
forehead), the face opening hemmed, the neck edge sewn round the neck ring. The panels start flat behind the head (up) or hanging down
the back (down) and the seams carry them round; the cloth settles on the head or on the shoulders.

- `up?: boolean` — the hood up over the head (default false: it hangs down the back)
- `ease?: number` — ease over the head, metres (default 0.045)
- `deeper?: number` — extra length of the face opening and crown (a deeper hood), metres

### JacketStyle

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

```ts
interface JacketStyle
```

A tailored jacket, the double-breasted reefer by default: two backs with a centre seam, two fronts with the
double-breasted extension, lapels turned back along the roll line (separate panels sewn on the roll line as a hinge, lying over the
fronts), a collar of a stand and a fall turned down over it, set-in sleeves with a crown drafted to the armhole's length, the left front
buttoned over the right (tacks at the buttons), flapped pockets.

- `fitting?: Fitting` — how close the cut is (default 'loose': a jacket is worn over a shirt and a waistcoat); the ease over the chest follows from it and grows with the layers under
- `under?: Under` — the layers worn under it: thicknesses (metres) or garments (default a shirt and a waistcoat)
- `chestEase?: number` — an explicit ease over the chest (in all), metres, instead of the rule's
- `hemBelowCrotch?: number` — length: the hem this far below the crotch (default 0.0)
- `extension?: number` — half the overlap of a double-breasted front past the centre (default 0.085); 0.02 for single-breasted
- `buttonRows?: number` — buttons: rows (default 3), distance of each column from the centre front (default 0.065)
- `buttonX?: number`
- `lapel?: number` — lapel width at its point, collar stand and fall heights
- `stand?: number`
- `fall?: number`
- `pockets?: boolean`
- `fabric?: string`
- `lining?: string`
- `layer?: number`

### JerseyStyle

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

```ts
interface JerseyStyle
```

A knitted jersey, the fisherman's guernsey by default: a body as a front and a back (drop shoulders, a straight
armhole), sleeves tapering to the wrist, rib welts at the hem left open at the sides (the guernsey's vents), rib cuffs and a rib stand
collar. Sizes from the chest, neck, upper arm, wrist and arm length, with the ease of the style.

- `fitting?: Fitting` — how close the cut is (default 'fitted': a knit is cut close and stretches); the ease follows from it and grows with the layers under
- `under?: Under` — the layers worn under it (thicknesses in metres or garments; default a shirt)
- `chestEase?: number` — an explicit ease over the chest, metres in all, instead of the rule's
- `length?: number` — body length below the shoulder point, metres (default to the top of the seat)
- `welt?: number` — rib heights: hem welt, cuffs, collar
- `cuff?: number`
- `collar?: number`
- `vents?: boolean` — vents: the welts are not sewn at the sides
- `fabric?: string`
- `rib?: string`
- `layer?: number`

### KerchiefStyle

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

```ts
interface KerchiefStyle
```

A neckerchief: a long folded strip round the neck over the collar, its ends crossing at the front and hanging, knotted where they cross.

- `length?: number`
- `width?: number`
- `fabric?: string`
- `layer?: number`

### LayerBelow

*interface* · `packages/clothing/src/dress.ts:48`

```ts
interface LayerBelow
```

a rigid or cloth surface the garment lies over (a layer dressed before, boots): positions and triangles

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

### LegBlockStyle

*interface* · `packages/clothing/src/blocks/shorts.ts:12`

```ts
interface LegBlockStyle
```

Shorts and the leg block they share with breeches: the four-panel trouser draft (front crotch extension seat/16, back
seat/8, the back rise raised and slanted) with the hem at any height of the leg: the leg's width at each height comes from the body (the
thigh girth where the hem falls) plus the ease and flare of the style. The trousers block itself is untouched.

- `fitting?: Fitting` — how close the cut is (default 'comfortable'): the seat's ease follows from it and grows with the layers under; an explicit `seatEase` replaces the rule's
- `under?: Under` — the layers worn under it (thicknesses in metres or garments)
- `seatEase?: number`
- `waistEase?: number`
- `rise?: number` — waist line above the natural waist, metres
- `hemY: number` — hem height above the floor, metres
- `hemC: number` — finished girth at the hem, metres
- `thighFlare?: number` — extra girth at the thigh (over the seat's share), the flare of riding breeches; a leg is `hemC` at the hem, `kneeC` at the knee when the hem is below it
- `kneeC?: number`
- `band?: number` — a band round the hem: its height and a hem band cut as a separate strip (knee band, cuff)
- `fabric?: string`
- `layer?: number`
- `name: string`
- `cloth?: Garment['cloth']`

### MapEntry

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

```ts
interface MapEntry
```

what the game records for a character and an outfit: the content key of the dressed outfit and the fit (plain JSON the maker chooses: raise, scale, body key ...)

- `key: string`
- `fit: Record<string, unknown>`

### Measurements

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

```ts
interface Measurements
```

- `neck: number` — girths (metres round the body)
- `chest: number`
- `waist: number`
- `seat: number`
- `thigh: number`
- `knee: number`
- `calf: number`
- `ankle: number`
- `upperarm: number`
- `elbow: number`
- `wrist: number`
- `head: number`
- `floorY: number` — heights above the floor
- `neckY: number`
- `chestY: number`
- `waistY: number`
- `seatY: number`
- `crotchY: number`
- `kneeY: number`
- `ankleY: number`
- `headBandY: number`
- `bootTopY?: number` — world height of the top of the boots the figure wears (set by the dressing tool when there are boots): trousers end just over it
- `underGirth?: number` — girth at the seat of a garment worn under the one being cut (baggy trousers under a shirt): a hem cannot be narrower than what it hangs over
- `shoulderHalf: number` — half the distance between the shoulder points (the outer ends of the shoulders)
- `armLength: number` — shoulder point to wrist along the arm
- `chestDepth: number` — front-to-back depth at the chest and at the seat
- `seatDepth: number`
- `chestZ: number` — z of the body's centre at the chest, waist and seat
- `waistZ: number`
- `seatZ: number`
- `armDir: { l: V3; r: V3 }` — the arm's direction from the shoulder (A-pose), per side

### MotionCollider

*interface* · `packages/clothing/src/motion.ts:81`

```ts
interface MotionCollider
```

a surface a garment may not enter that is not the body: a garment under it (its positions are read each frame)

- `positions(): ArrayLike<number>`
- `indices: Uint32Array`

### MotionOptions

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

```ts
interface MotionOptions
```

- `skin?: ClothSkin` — skin weights of the garment's vertices (default: taken from the body, `transferSkin`)
- `driven?: ArrayLike<number>` — vertices that follow the skin rigidly (an explicit list wins over `support`)
- `supports?: ArrayLike<number>` — the garment's vertices that are held (waistband, shoulder line): the driven part is the cloth within `rigid` metres of them along the cloth
- `support?: SupportKind | { kind: SupportKind }` — how the garment is held (Garment.support.kind when the garment has one): 'fitted' follows the skin everywhere, 'hung' and 'waist' hold at the supports and let the rest fall, 'free' holds nothing but the supports
- `rigid?: number` — distance from the supports that stays rigid, and the width of the band where the cloth goes from rigid to free (metres)
- `band?: number`
- `density?: number` — surface density kg/m2
- `stretch?: number` — compliance of stretch and of bending (m/N); the garment's own `cloth` properties are used when it has them
- `bend?: number`
- `damping?: number`
- `gravity?: number`
- `thickness?: number`
- `friction?: number`
- `substeps?: number` — substeps per frame at full detail (default 6)
- `budget?: number` — work budget per frame in link solves (links x substeps); fewer substeps are taken when the garment is big (default unlimited)
- `maxStretch?: number` — no edge stretches past this ratio of its length at rest (default 1.1)
- `reach?: number` — contact search distance round a vertex (metres, default 0.06)
- `under?: MotionCollider[]` — layers under this garment
- `fadeTime?: number` — seconds a change between skinned only and simulated takes to blend (default 0.5)

### MotionRequest

*interface* · `packages/clothing/src/motion.ts:345`

```ts
interface MotionRequest
```

- `entity: string` — the entity whose skinned mesh is the body
- `garments?: string[]` — the dressed garments to move (default: all the entity has under `clothing.dress`)
- `options?: MotionOptions`

### NeckDraft

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

```ts
interface NeckDraft
```

- `kind: NonNullable<CollarSpec['kind']>`
- `frontNeck: V2[]` — the front half's neck edge from (nw, yN) to `end`, the back neck depth
- `end: V2`
- `backDrop: number`
- `roll?: (e: number, yB: number) => V2[]` — a lapel's roll line from `end` to (-e, yB)
- `lapel: boolean`
- `build: (ring: NeckRing, e: number, yB: number) => Piece` — the panels on the neck ring, given the ring and the front's extension
- `buttonTop: number` — the front buttons start this far below the neck end

### NeckEdge

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

```ts
interface NeckEdge
```

one edge of the neck ring (the body's neck edges, and a raglan sleeve's, in order round the neck)

- `panel: string`
- `edge: string`
- `len: number`
- `rev: boolean`

### NeckRing

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

```ts
interface NeckRing
```

from the centre front on the figure's right, round the back, to the centre front on its left: front_r [sleeve_r] back_r back_l [sleeve_l] front_l

- `edges: NeckEdge[]`
- `front?: { x: number; drop: number }` — where the front neck edges end: their distance from the centre front and how far below the neck point

### NounSpec

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

```ts
interface NounSpec
```

- `word: string` — the phrase that names the block
- `implies?: Record<string, string | number | boolean>` — options this noun implies ("overcoat" is a coat that is knee long)
- `fabric?: string` — the fabric this noun implies ("jeans" are denim)

### OptionSpec

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

```ts
interface OptionSpec
```

Block registry: every garment block by name, its style options with their allowed values, the words (English
and Russian) that name it and that set its options, and what it is made of when nothing is said. The description parser
(`describe.ts`) works off this registry only, so a block needs no code to be describable: lanes that add blocks register the name here.

Word lists are written in the normal form of `normalize`: lower case, `ё` as `е`, hyphens as spaces ("single breasted", "a line").
An English word also matches its plural (`s`, `es`); a Russian word is a stem and matches every word that starts with it.
A phrase is words separated by spaces; a value's phrases are tried longest first, so "short sleeves" is not read as "short".
A phrase that starts with `~` is a weak default: it counts only when nothing else set the option.

- `type: 'enum' | 'number' | 'boolean' | 'string'`
- `values?: string[]` — enum: the allowed values
- `min?: number` — number: the range and the unit
- `max?: number`
- `unit?: string`
- `description: string`
- `words?: Record<string, string[]>` — enum: phrases that set each value (see above); `$long` as a value means the block's `longLength`

### OutfitInput

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

```ts
interface OutfitInput
```

What makes a dressed outfit. `options` is everything else the dressing reads (triangle size, frames, hide, texture size, boots, colliders ...).

- `body: ClothingBody`
- `garments: Garment[]`
- `fabrics?: Record<string, unknown>`
- `options?: Record<string, unknown>`

### OutfitRecord

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

```ts
interface OutfitRecord
```

- `format: number`
- `key: string` — the content key this record was made for
- `core: number` — the core version it was dressed by
- `garments: CachedGarment[]`
- `trims: CachedMesh[]`
- `boots: CachedMesh[]`
- `hidden: CachedHidden[]`
- `anims: CachedAnim[]`
- `meta: Record<string, unknown>` — whatever the maker keeps with it (the body's key, raise, outfit name ...): plain JSON

### PackageFiles

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

```ts
interface PackageFiles
```

the part of a Ferret package source (`PackageSource` of

- `list(): string[]`
- `has(path: string): boolean`
- `read(path: string): Promise<Uint8Array>`

### Panel

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

```ts
interface Panel
```

- `name: string`
- `edges: PanelEdge[]`
- `place: Placement`
- `fabric?: string` — the fabric this panel is cut from (a key of the garment's fabrics)
- `stiff?: number` — a stiffer panel (interfaced collar, cap peak): bending multiplier
- `grain?: number` — the grain: the angle (radians) from the panel's y axis to the warp (the lengthwise threads; for a knit, the wales). 0 = the panel's y is along the warp (a body panel), pi/2 = the warp runs along x (a band cut lengthwise), pi/4 = a bias cut (a strip that drapes and stretches round a curve). Default 0.

### PanelEdge

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

```ts
interface PanelEdge
```

- `name: string`
- `pts: V2[]` — points from the corner where this edge starts to the corner where the next one starts (the last point is that next corner)

### PanelMesh

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

```ts
interface PanelMesh
```

- `panel: Panel`
- `uv: Float64Array` — flat positions (metres)
- `tris: Uint32Array`
- `edgeVerts: Map<string, number[]>` — per edge name: the boundary vertex indices along it, from its start to its end (corners included)
- `boundary: number[]` — boundary vertices (in order round the outline)

### Piece

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

```ts
interface Piece
```

Parts: the pieces of an upper garment that can be swapped for one another. Every part emits a `Piece` (panels, seams,
tacks, trims ...) given the `UpperCtx`: the body's frame and the garment's own dimensions (the hem, the girth at every height, the neck,
the armhole). `composeUpper` (compose.ts) puts the chosen parts together into a `Garment`.

- `panels: Panel[]`
- `seams: Seam[]`
- `tacks: Tack[]`
- `trims: TrimSpec[]`
- `over: [string, string, number?][]`
- `hems: { panel: string; edge: string }[]`
- `hold: NonNullable<Garment['hold']>`

### PinnedLine

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

```ts
interface PinnedLine
```

a line of the pattern that is put on the body's matching line and held there: panel and edge names, and what line of the body it belongs to

- `panel: string`
- `edge: string`
- `role: 'shoulder' | 'neck' | 'collar' | 'waist' | 'closure' | 'band' | 'cuff' | 'brim' | 'hem'`

### Placement

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

```ts
interface Placement
```

where a panel is put round the body before it is sewn: wrapped on a tube along `axis` (see drape.ts)

- `plane?: { origin: [number, number, number]; u: [number, number, number]; v: [number, number, number] }` — a flat start instead of a tube: panel point (x, y) at origin + u x + v y (a cap's crown above the head)
- `axis: [number, number, number][]` — the tube's axis, top to bottom (panel y = 0 at `axis[0]`, growing toward the last point)
- `radius: number[]` — distance from the axis at each axis point, metres
- `angle: number | number[]` — angle round the axis (radians, 0 = front +z, +pi/2 = the figure's left, +x) where panel x = `x0` lies; one per axis point to turn along it
- `x0?: number | number[]` — panel x that sits at `angle` (default: the middle of the panel); one per axis point to shift along it
- `y0?: number` — panel y of the axis start (default: the panel's top)
- `ref?: [number, number, number]` — the direction angle 0 points to (made perpendicular to the axis; default +z, the front): +y for a sleeve, whose angle 0 is the top of the arm
- `dir?: 1 | -1` — +1: panel x grows with the angle; -1: against it
- `anchors?: { at: V2; to: [number, number, number]; reach?: number }[]` — flat points that must start at given places (an armhole running round the front of the arm root): the tube placement is bent to them, each anchor moving the cloth within `reach` metres of it (flat distance), fading out
- `lift?: number` — extra distance outward (layers lying over others: a lapel, a collar fall), metres
- `ripple?: { amp: number; n: number; twist?: number; from?: number }` — [OLD DRAPE ONLY, OLD-SWITCHES.md] folds seeded in the start shape of a garment with more cloth than the body needs (wide trousers): the radius varies as `amp` sin(n angle + twist s), growing from 0 at `from` metres along the axis over 15 cm; the settle keeps part of it as folds

### PocketSpec

*interface* · `packages/clothing/src/parts/pockets.ts:11`

```ts
interface PocketSpec
```

- `kind: PocketKind`
- `at?: 'hip' | 'chest'` — hip (default) or chest (the wearer's left)
- `width?: number` — size of the patch or flap (defaults by kind)
- `height?: number`
- `y?: number` — the pocket's top edge, world height (default by place)
- `x?: number` — its inner edge, metres from the centre front

### PoseSource

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

```ts
interface PoseSource
```

a body pose by time: skinning matrices (16 per joint, Babylon's layout, see motion.ts) at `t` seconds

- `duration: number`
- `loop: boolean`
- `jointCount: number`
- `pose(t: number, out: Float32Array): void`

### RigHint

*interface* · `packages/clothing/src/rig.ts:28`

```ts
interface RigHint
```

- `scheme?: RigScheme` — force a family ('geometry' skips the names altogether)
- `noGeometry?: boolean` — do not fill what the names left out from the geometry of the tree

### RigMap

*interface* · `packages/clothing/src/rig.ts:35`

```ts
interface RigMap
```

- `scheme: RigScheme`
- `roles: Partial<Record<BoneRole, number>>` — joint index per role (only the roles that were found)
- `spine: number[]` — the spine chain from the pelvis up (joint indices; may be empty)
- `source: Partial<Record<BoneRole, RigSource>>` — where each role came from
- `missing: BoneRole[]` — the roles that were not found

### RigOverride

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

```ts
interface RigOverride
```

what the caller may give by hand: roles to joints, and the spine chain (bottom to top)

- `roles?: Partial<Record<BoneRole, JointRef>>`
- `spine?: JointRef[]`

### Seam

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

```ts
interface Seam
```

- `a: SeamSide`
- `b: SeamSide`
- `hinge?: boolean` — a seam that folds flat (a collar's fall over its stand, a lapel over the front): no bending across it
- `stage?: number` — sewing order: seams of stage 0 close first, then 1 ... (a sleeve goes in after the body is sewn up)
- `topstitch?: boolean` — stitched as topstitching (visible lines)

### SeamSide

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

```ts
interface SeamSide
```

- `panel: string`
- `edge: string`
- `reverse?: boolean`

### SewnGarment

*interface* · `packages/clothing/src/sew.ts:65`

```ts
interface SewnGarment
```

- `name: string`
- `positions: Float32Array`
- `normals: Float32Array`
- `flat: Float32Array` — flat panel coordinates, metres (x across the panel, y along the grain): the UVs at the cloth's real scale
- `indices: Uint32Array`
- `panelOf: Uint16Array` — the panel of each vertex (index into `panels`)
- `panels: Panel[]`
- `meshes: { mesh: PanelMesh; offset: number }[]` — per panel: its mesh (flat outline, edge vertices) with the vertex offset into this garment
- `garment: Garment`
- `weld: Uint32Array` — per vertex: the smallest vertex index at its place (itself when it is alone); welded vertices share it
- `groups: number[][]` — groups of two or more vertices that are one node (seams, corners)
- `edgeVerts: Map<string, number[]>` — the vertices along a panel edge, from its start to its end (global indices), by `panel.edge`
- `seams: SewnSeam[]`
- `supports: SewnSupport[]`
- `hold?: HoldKind` — how the garment is held (the pattern's ; undefined for a pattern that does not say) and the zones held differently, with the vertices of their panels
- `zones: { kind: HoldKind; verts: number[] }[]`
- `stiff: SewnStiff[]` — the stiff pieces of the pattern (), with their vertices
- `stages: string[][]` — the order the seams were closed in: per stage the names of its seams
- `stats: { maxGapBeforeWeld: number; maxStretch: number; frames: number }`

### SewnSeam

*interface* · `packages/clothing/src/sew.ts:49`

```ts
interface SewnSeam
```

- `name: string`
- `a: string`
- `b: string`
- `stage: number`
- `pairs: [number, number][]` — the paired vertices (global indices), a side first
- `gap: number` — the widest gap between the two sides just before they were welded, metres

### SewnStiff

*interface* · `packages/clothing/src/sew.ts:63`

```ts
interface SewnStiff
```

a piece (or a strip of one) cut with an interlining: the vertices that are stiff and the factor on the fabric's bending stiffness

- `panel: string`
- `what: string`
- `bend: number`
- `verts: number[]`

### SewnSupport

*interface* · `packages/clothing/src/sew.ts:60`

```ts
interface SewnSupport
```

a pinned line of the sewn garment: its role, how the garment as a whole is held, and the vertices along the edge (global indices, start to end)

- `name: string`
- `role: string`
- `verts: number[]`
- `kind?: HoldKind`

### SewOptions

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

```ts
interface SewOptions
```

- `h?: number` — triangle size, metres (the garment's own `h` first; default 0.012)
- `frames?: number` — frames of 1/60 s per stage (default 40)
- `substeps?: number`
- `passes?: number` — passes over all the links per substep (default 4)
- `seamPasses?: number` — extra passes over the seam links of the stage per substep (default 6): corners where several pieces meet close tighter
- `tackComp?: number` — compliance of a tack (default 1e-2: a stitch gives under the pull of a piece that lies a few centimetres from where its partner is)
- `relaxFrames?: number` — frames of relaxation of the closed cloth before the tacks (default half of `frames`)
- `relaxPasses?: number`
- `relaxForm?: number`
- `settleFrames?: number`
- `settlePasses?: number`
- `settleForm?: number`
- `supports?: SupportSpec[]` — supports the pattern does not give itself (see `supportsOf`)
- `onStage?: (stage: number, positions: Float32Array) => void` — called with the positions of every vertex at the start of the sewing (stage -1) and after each stage (to look at the run)
- `log?: (s: string) => void` — progress

### ShortsStyle

*interface* · `packages/clothing/src/blocks/shorts.ts:121`

```ts
interface ShortsStyle
```

Shorts: the leg block with the hem at a given inseam length (default 0.2 m below the crotch), a little wider than the thigh there

- `length?: number | 'brief' | 'short' | 'bermuda'` — inseam: crotch to hem, metres, or a name
- `fitting?: Fitting`
- `under?: Under`
- `seatEase?: number`
- `waistEase?: number`
- `rise?: number`
- `hemEase?: number` — extra girth at the hem over the thigh's, metres (default 0.1)
- `fabric?: string`
- `layer?: number`

### SkirtStyle

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

```ts
interface SkirtStyle
```

- `kind?: SkirtKind`
- `waist?: 'natural' | 'high' | 'low' | number` — where the waistband sits: 'natural', 'high' (6 cm up), 'low' (half way to the hip), or metres above (+) or below (-) the natural waist
- `length?: number | HemName` — length from the waist line to the hem in metres, or a name (default by kind)
- `fitting?: Fitting`
- `under?: Under` — the layers worn under it (thicknesses in metres or garments): the hip is cut wider by the room they take
- `taper?: number` — straight: the hem is narrower than the hip by this much on each half panel (a pencil skirt; default 0.01)
- `flare?: number` — A-line: the hem is wider than the hip by this much on each half panel (default 0.13)
- `pleats?: number` — pleated, kilt: pleat count per half panel, and the fullness (fabric width over the hip width; default 1.65 for both; kilt: the back only; fabric over 1.8 times the hip is too much for tucks to carry)
- `fullness?: number`
- `circle?: 'full' | 'three-quarter' | 'half'` — circle: how much of the circle the skirt is cut from (default 'full')
- `vent?: number` — a vent at the centre back from the hem up, metres (default 0; a straight skirt 0.15 when it reaches below the knee)
- `fabric?: string`
- `layer?: number`

### SleeveDraft

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

```ts
interface SleeveDraft
```

- `kind: 'set-in' | 'raglan' | 'drop' | 'kimono' | 'none'`
- `yA: number` — armhole depth and the shoulder end, relative to ctx.base
- `sw: number`
- `yS: number`
- `F: V2[]` — the armhole edges: the front's (left panel coordinates) from the side up, the back's (left coordinates) from the top down
- `B: V2[]`
- `shoulder: boolean` — a shoulder seam joins front and back (false: raglan, the sleeve covers the shoulder)
- `neckTop?: number` — raglan: the length of the sleeve's own neck edge
- `anchors: (back: boolean, sx: 1 | -1) => Anchor[]`
- `build: () => Piece`

### SleeveSpec

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

```ts
interface SleeveSpec
```

Sleeves: set-in (a crown drafted to the armhole), raglan (the sleeve runs up to the neck, no shoulder seam), drop
shoulder (a straight armhole low on the arm), kimono (a very low, wide armhole: the shoulder runs on down the arm), none (the armhole is
only hemmed). Any length from a cap to the wrist, with a band or rib cuff or a plain hem.

- `kind?: 'set-in' | 'raglan' | 'drop' | 'kimono' | 'none' | 'short'`
- `length?: UpperSleeveLength` — long (to the wrist), three-quarter, elbow, short, cap, or metres from the shoulder joint along the arm
- `cuff?: 'none' | 'band' | 'rib'`
- `cuffHeight?: number`
- `ease?: number` — ease over the upper arm, metres in all (an explicit value replaces the cutting rule: by fitting and layers, see `upperEases`)
- `endEase?: number` — ease of the sleeve's end over the arm there, metres in all (default: the rule, by the cuff)
- `shoulderPad?: number` — a set-in shoulder's width past the shoulder point (shoulder pads), metres
- `gather?: number` — cuff gathering: the sleeve end is this many times as wide as the band (band cuffs only, default 1.15)

### StaticOptions

*interface* · `packages/clothing/src/collide.ts:225`

```ts
interface StaticOptions
```

- `friction?: number` — friction of the cloth on this surface (default: the world's)
- `solid?: boolean` — a closed surface wound outward (the body): what is found inside it is pushed out. A layer of cloth is not solid: it holds from the side the cloth came from.

### StiffPiece

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

```ts
interface StiffPiece
```

a piece cut with an interlining (canvas, fusing, board): its bending stiffness is the fabric's times `bend`

- `panel: string`
- `bend: number`
- `what: 'collar stand' | 'collar fall' | 'lapel' | 'waistband' | 'cuff' | 'brim' | 'band' | 'flap' | 'facing' | 'crown' | 'shell' | 'belt'`
- `edge?: string` — a strip of the panel along this edge, `depth` metres deep, instead of the whole panel (a waistband cut in one with the trouser panels)
- `depth?: number`

### StoreBackend

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

```ts
interface StoreBackend
```

where the files of a store live; names are flat (`<key>.fout`, `map.json`)

- `readonly readOnly: boolean`
- `get(name: string): Promise<Uint8Array | undefined>`
- `put(name: string, bytes: Uint8Array): Promise<void>`
- `has(name: string): Promise<boolean>`
- `list(): Promise<string[]>`
- `delete(name: string): Promise<void>`

### Support

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

```ts
interface Support
```

- `kind: HoldKind`
- `pinned: PinnedLine[]` — the lines held where they are put on the body
- `stiff: StiffPiece[]` — the pieces cut stiffer than their fabric (also the `stiff` of those panels)
- `zones?: { kind: HoldKind; panels: string[] }[]` — parts of the garment that are held differently from the whole (a dress: the skirt hangs from the waist seam, the bodice rests): the panels and their kind

### SupportSpec

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

```ts
interface SupportSpec
```

an edge of the garment where it is held when it is put on (the shoulder line, the waistband, the collar stand): the pattern's own pinned lines (), or what  reads from a pattern that has none

- `name: string`
- `role: string` — what the line is: a ('shoulder', 'neck', 'collar', 'waist', 'closure', 'band', 'cuff', 'brim', 'hem') or, for a pattern without , 'hold'
- `panel: string`
- `edge: string`

### SurfaceHit

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

```ts
interface SurfaceHit
```

- `d: number`
- `p: Float64Array`
- `n: Float64Array`
- `t: number`
- `w: Float64Array`

### Tack

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

```ts
interface Tack
```

a point of one panel held at a point of another (a button through its hole): `gap` metres apart along the lower panel's normal

- `a: { panel: string; at: V2 }`
- `b: { panel: string; at: V2 }`
- `gap?: number`

### TextureBakeOptions

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

```ts
interface TextureBakeOptions
```

options of the texture bake (`bakeGarment`); the cloth animation bake has its own, `BakeOptions` of bake.ts

- `maxSize?: number` — texture side limit (default 4096)
- `pxPerMeter?: number` — wanted resolution (default 3000 px/m: 0.33 mm a pixel)
- `stitch?: { length?: number; width?: number; seamOffset?: number; hemOffset?: number; hemRows?: number }` — stitching: seams sewn with a visible topstitch line `offset` metres in from the seam, hems with two rows
- `buttonholes?: { panel: string; at: V2; length: number; angle?: number }[]` — buttonholes in panel coordinates
- `fabrics: Record<string, FabricSpec>` — fabric of each panel by its `fabric` key

### TrimMesh

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

```ts
interface TrimMesh
```

Trims: rigid little parts placed on the dressed cloth at flat points of its panels, riding the cloth there: buttons
(a domed disc with a rim, four holes or a shank, an anchor raised on a brass one), eyelets, a cap's peak. Each is a mesh in the
garment's frame with the cloth vertex it rides (for its skin weights).

- `name: string`
- `kind: string`
- `pos: number[]`
- `nrm: number[]`
- `uv: number[]`
- `idx: number[]`
- `material: string`
- `rides: number`

### TrimSpec

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

```ts
interface TrimSpec
```

- `kind: 'button' | 'eyelet' | 'peak'`
- `panel: string`
- `at: V2` — flat point (a button's centre); for a peak, the middle of the edge it is sewn along
- `size?: number` — a button's diameter; a peak's depth
- `edge?: string` — a peak: the flat edge it is sewn along and its half angle
- `material?: string`

### TrouserStyle

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

```ts
interface TrouserStyle
```

Trousers: four panels, a front and a back for each leg, drafted from the seat, waist, rise, knee and length as a
tailor's block (front crotch extension seat/16, back seat/8, back rise raised and slanted), sewn at the outseams, inseams, the front
crotch and the centre back. The waist edge is turned and stitched (a waistband facing); the hems are turned up.

- `fitting?: Fitting` — how close the cut is (default 'comfortable'); the ease over the seat follows from it and grows with the layers under
- `under?: Under` — the layers worn under it (thicknesses in metres or garments)
- `seatEase?: number` — an explicit ease over the seat, metres in all, instead of the rule's
- `waistEase?: number` — ease over the waist (default 0.03)
- `rise?: number` — waist line above the natural waist, metres (default 0.01: worn high, on braces)
- `knee?: number` — finished width of a leg at the knee and at the hem (circumference), metres; default from the knee girth
- `hem?: number`
- `hemAbove?: number` — hem above the floor, metres (default 0.03)
- `fabric?: string`

### UpdateOptions

*interface* · `packages/clothing/src/collide.ts:239`

```ts
interface UpdateOptions
```

- `tau0?: number` — where this substep lies within the frame (0..1): where a moving surface is at its start and at its end
- `tau1?: number`
- `full?: boolean` — run pass 2 (default true)
- `edges?: boolean` — run pass 3, edge against edge (default: with `full`)
- `mask?: Uint32Array | null` — per particle, bit k set: the particle sees static k (default: all); at most 32 statics
- `out?: ContactSet` — the contacts go here (cleared first); default `world.contacts`

### UpperCtx

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

```ts
interface UpperCtx
```

the dimensions every part reads

- `body: ClothingBody`
- `m: Measurements`
- `U: UpperFrame`
- `figure: BodyFit` — the body's fit descriptors (bust, underbust, childness ...)
- `eases: UpperEases`
- `spec: BodySpec`
- `fab: string`
- `rib: string`
- `base: number` — world height of the panels' y = 0 (the hem, or the top of the welt)
- `yN: number` — heights above `base`: neck point, shoulder point, waist
- `yS: number`
- `yW: number`
- `girth: (y: number) => number` — girth with ease at a height above `base`, metres
- `frontExtra: number` — how much longer the front is than the back at the centre front (the chest and belly stand out), metres
- `halfF: (y: number) => number` — half width of the front and back panels at a height above `base`
- `halfB: (y: number) => number`
- `torsoAxis: V3[]` — the start tube of the torso panels
- `torsoR: number[]`
- `nw: number` — neck half width in the panels
- `rel: (worldY: number) => number`

