# @ferret/clothing: API (continued)

### UpperDefaults

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

```ts
interface UpperDefaults
```

- `name: string`
- `layer: number`
- `length: UpperHemName | number`
- `fitting: Fitting`
- `kind?: HoldKind` — how it is held; default from the fitting (a loose cut hangs from the shoulders)
- `under: number[]` — what is usually worn under it, radial thicknesses (metres)
- `fit: Fit`
- `flare?: number`
- `cbWaist?: number`
- `backNeckDrop?: number`
- `fabric: string`
- `rib?: string`
- `sleeve: SleeveSpec`
- `collar: CollarSpec`
- `closure: ClosureSpec`
- `pockets: PocketSpec[]`
- `hem: HemSpec`
- `cloth: ClothProps`

### UpperEases

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

```ts
interface UpperEases
```

- `chest: number` — ease over the chest, metres in all
- `upperArm: number` — ease over the upper arm, metres in all
- `end: { plain: number; band: number; rib: number }` — ease of the sleeve's end over the arm there for a plain hem, a band cuff (gathered into the band), a rib cuff
- `setting: number` — the fraction the cap is longer than the armhole
- `armholeDrop: number` — extra depth of the armhole, metres

### UpperFrame

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

```ts
interface UpperFrame
```

where the upper body garments sit: the neck point and shoulder point heights, the arm axes (shoulder point to wrist), the torso's z

- `neckR: number`
- `neckPointY: number`
- `shoulderPointY: number`
- `shoulderX: number`
- `arm: { l: { s: V3; w: V3; d: V3; c: V3; e: V3 }; r: { s: V3; w: V3; d: V3; c: V3; e: V3 } }` — per side: the shoulder point, the wrist point, the unit direction down the arm, and `c`: the arm's own axis start (the shoulder joint)
- `z: number`
- `neckZ: number` — z of the neck's centre at the neck point
- `root: { l: { front: V3; back: V3; pit: V3 }; r: { front: V3; back: V3; pit: V3 } }` — per side: the arm root's front and back (where an armhole passes in front of and behind the arm) and the armpit

### UpperSpec

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

```ts
interface UpperSpec
```

Composing an upper garment from its parts: the body (two backs, two fronts) cut for a fit and a length, a sleeve (it
sets the armhole), a collar (it sets the neckline), a closure (the front edges and the buttons), pockets and a hem.

- `name: string`
- `layer: number`
- `hemY: number` — world height of the lowest edge
- `fitting: Fitting` — how close the cut is (fit.ts): the chest ease comes from it by the rules of `upperEases`, plus the room for what is worn under
- `kind: HoldKind` — how the garment is held: `fitted` rests on the body, `hung` hangs from the shoulders and the collar
- `under?: Under` — the layers worn under it: thicknesses (metres) or garments; the ease grows with them
- `chestEase?: number` — an explicit chest ease (metres in all) instead of the rule's
- `fit?: Fit`
- `flare?: number`
- `cbWaist?: number` — the centre back seam taken in at the waist (default 0.012 when fitted)
- `darts?: boolean` — the bust darts of a fitted cut (default: when the figure's bust asks for them)
- `backNeckDrop?: number`
- `fabric: string`
- `rib?: string`
- `sleeve?: SleeveSpec`
- `collar?: CollarSpec`
- `closure?: ClosureSpec`
- `pockets?: PocketSpec[]`
- `hem?: HemSpec`
- `cloth: ClothProps`

### UpperStyle

*interface* · `packages/clothing/src/parts/style.ts:22`

```ts
interface UpperStyle
```

The style of an upper garment as the commands give it (JSON): every part may be named by a string (`sleeve: 'raglan'`) or given in full
(`sleeve: { kind: 'raglan', length: 'elbow', cuff: 'rib' }`).

- `length?: UpperHemName | number` — the hem: a height name, or metres below the shoulder point
- `fitting?: Fitting` — how close the cut is; the ease over the chest follows from it (see `upperEases`) and grows with the layers under
- `under?: Under` — the layers worn under it, thicknesses in metres or the garments themselves (default: what is usually worn under this kind of garment)
- `ease?: number` — an explicit ease over the chest, metres in all (replaces the rule's)
- `fit?: Fit`
- `flare?: number`
- `sleeve?: SleeveSpec | NonNullable<SleeveSpec['kind']>`
- `collar?: CollarSpec | NonNullable<CollarSpec['kind']>`
- `closure?: ClosureSpec | NonNullable<ClosureSpec['kind']>`
- `pockets?: (PocketSpec | PocketKind)[] | PocketKind | 'none'`
- `hem?: HemSpec | NonNullable<HemSpec['trim']>`
- `fabric?: string`
- `rib?: string`
- `layer?: number`
- `cloth?: ClothProps`

### WeltHalf

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

```ts
interface WeltHalf
```

- `panel: string`
- `x0: number`
- `x1: number`
- `back: boolean`
- `side: 'l' | 'r'`

### WitchHatStyle

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

```ts
interface WitchHatStyle
```

- `height?: number` — height of the cone, metres (0.42..0.48)
- `brim?: number` — width of the brim (0.13..0.2)
- `bend?: number` — how far the tip is bent back from the cone's axis (0.16..0.2)
- `crumple?: number` — crumpledness of the cone, 0..1 (a worn, dented felt)
- `hair?: number` — hair under it, metres (default 0.012)
- `fabric?: string`
- `layer?: number`

## Types

### BlockFn

*type* · `packages/clothing/src/service.ts:33`

```ts
type BlockFn = (body: ClothingBody, m: Measurements, style?: Record<string, unknown>) => Garment
```

Clothes on characters of the world: the blocks by name, an entity's skinned body measured, garments drafted to it,
draped, baked, weighted and put on (meshes skinned to the entity's skeleton; the body's triangles under them hidden). Every step is a
command, so a person, a test and an agent dress a character the same way.

### BoneRole

*type* · `packages/clothing/src/rig.ts:13`

```ts
type BoneRole = CentralRole | `${LimbRole}_${Side}`
```

### CentralRole

*type* · `packages/clothing/src/rig.ts:10`

```ts
type CentralRole = 'pelvis' | 'neck' | 'head'
```

### CoatStyle

*type* · `packages/clothing/src/blocks/coat.ts:11`

```ts
type CoatStyle = UpperStyle
```

An overcoat or greatcoat of heavy melton or serge: a body flaring from the chest, set-in sleeves, notched lapels
with a stand and fall, flap pockets. `length` is the parameter that makes the difference: hip, thigh, knee (overcoat, default), calf
(greatcoat), ankle, or metres below the shoulder point. `closure: 'double'` buttons it double-breasted (the greatcoat).

### DartStyle

*type* · `packages/clothing/src/fit.ts:100`

```ts
type DartStyle = 'fitted' | 'semi' | 'shift' | 'none'
```

### DressCut

*type* · `packages/clothing/src/blocks/dress.ts:16`

```ts
type DressCut = 'fitted' | 'aline' | 'shift'
```

Dresses: a bodice with a bust dart (from the side seam to the bust) and waist darts, over a skirt sewn on at the waist
('fitted': straight skirt, 'aline': flared skirt), or a one-piece 'shift' that hangs from the shoulders with the bust dart only. The
armholes are cut to the shoulder point; sleeves are optional (none, cap, short, elbow, three-quarter, long) and set in. The cut comes
from `bodyFit` and `darts` (fit.ts) whatever the sex or age of the body.

### Dresser

*type* · `packages/clothing/src/cache.ts:451`

```ts
type Dresser = (input: OutfitInput) => OutfitRecord | Promise<OutfitRecord>
```

the function that dresses: the same inputs must give the same record

### Fit

*type* · `packages/clothing/src/parts/ctx.ts:30`

```ts
type Fit = 'fitted' | 'straight' | 'aline'
```

the shape of the body of the garment: it follows the body (fitted), hangs straight from the widest point, or flares to the hem

### Fitting

*type* · `packages/clothing/src/fit.ts:81`

```ts
type Fitting = 'skin' | 'close' | 'fitted' | 'comfortable' | 'loose' | 'oversized'
```

how loose a cut is

### HemName

*type* · `packages/clothing/src/blocks/skirt.ts:15`

```ts
type HemName = 'mini' | 'knee' | 'midi' | 'ankle' | 'floor'
```

hem lengths by name: mini above mid-thigh, knee, midi (mid-calf), ankle, floor

### HoldKind

*type* · `packages/clothing/src/pattern.ts:78`

```ts
type HoldKind = 'fitted' | 'hung' | 'waist' | 'head' | 'hand' | 'foot'
```

How a garment is held on the figure: data from the cut, read by the dressing; nothing in it is per outfit.
- `fitted`: the whole surface rests on what is under it (a T-shirt, a shirt, a bodice, a jersey, a close dress);
- `hung`: the shoulder line and the collar stand hold it, the closure holds the fronts, the rest falls (a coat, a jacket, a cape, a loose shirt);
- `waist`: the waistband holds it, the hips and legs only stop it (a skirt, trousers, shorts, breeches);
- `head`, `hand`, `foot`: a hat on the head, a glove on the hand, a boot on the foot.

### HoodieStyle

*type* · `packages/clothing/src/blocks/hoodie.ts:10`

```ts
type HoodieStyle = UpperStyle & { hood?: { up?: boolean; ease?: number; deeper?: number } }
```

A hooded sweatshirt of fleece: drop shoulders, rib welt and cuffs, a kangaroo pocket, a hood (hanging down the back
by default). `hood: { up: true }` puts it over the head; `closure: 'zip'` makes it a zip-up.

### JointRef

*type* · `packages/clothing/src/rig.ts:25`

```ts
type JointRef = string | number
```

a joint given by name or by index

### LimbRole

*type* · `packages/clothing/src/rig.ts:11`

```ts
type LimbRole = 'clavicle' | 'upperArm' | 'forearm' | 'hand' | 'thigh' | 'calf' | 'foot' | 'ball'
```

### Neckline

*type* · `packages/clothing/src/blocks/dress.ts:17`

```ts
type Neckline = 'round' | 'scoop' | 'vee' | 'square'
```

### PocketKind

*type* · `packages/clothing/src/parts/pockets.ts:10`

```ts
type PocketKind = 'patch' | 'flap' | 'welt' | 'kangaroo'
```

Pockets: patch (a rectangle sewn on three sides), flap (a flap hanging from its top edge over a slit), welt (a narrow
strip over a slit), kangaroo (one big patch across the front with its sides open). They lie on the fronts and are held to them by tacks.

### RigScheme

*type* · `packages/clothing/src/rig.ts:21`

```ts
type RigScheme = 'ue' | 'mixamo' | 'cc' | 'generic' | 'geometry'
```

### RigSource

*type* · `packages/clothing/src/rig.ts:22`

```ts
type RigSource = 'name' | 'geometry' | 'map'
```

### RigV3

*type* · `packages/clothing/src/rig.ts:8`

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

Rigs: the module never reads bone names, it reads bone roles. `mapRig` resolves the roles of a skeleton from the bone
names of Unreal / MetaHuman (also the

### ShirtStyle

*type* · `packages/clothing/src/blocks/shirt.ts:12`

```ts
type ShirtStyle = UpperStyle
```

A shirt or blouse of a light woven cloth: a fitted body with a shirt-tail hem, set-in sleeves with band cuffs, a
collar of a stand and a fall, buttons down the front, a patch pocket on the chest. Any part can be swapped through `UpperStyle`
(`collar: 'stand'`, `sleeve: 'short'`, `closure: 'pullover'` for an over-the-head shirt ...).

### Side

*type* · `packages/clothing/src/rig.ts:12`

```ts
type Side = 'l' | 'r'
```

### SkirtKind

*type* · `packages/clothing/src/blocks/skirt.ts:13`

```ts
type SkirtKind = 'straight' | 'aline' | 'pleated' | 'circle' | 'kilt'
```

Skirts: straight, A-line, pleated, circle and kilt, drafted from the waist, the hip and the length. Each is a front and
two back halves (a centre back seam, with an optional vent) or, for the circle, four sectors. The waist edge is held on the body at the
waist line the style asks for; waist darts (`darts` of fit.ts) take the hip in to the waist; pleats are tucks stitched down to the hip with
the fullness hanging free below.

### SleeveKind

*type* · `packages/clothing/src/blocks/ease.ts:32`

```ts
type SleeveKind = 'set-in' | 'raglan' | 'drop' | 'kimono' | 'none'
```

### SleeveLength

*type* · `packages/clothing/src/blocks/dress.ts:18`

```ts
type SleeveLength = 'none' | 'cap' | 'short' | 'elbow' | 'three-quarter' | 'long'
```

### SupportKind

*type* · `packages/clothing/src/motion.ts:78`

```ts
type SupportKind = 'fitted' | 'hung' | 'waist' | 'free'
```

how a garment is held to the body: by it the driven part of the cloth is chosen

### TexData

*type* · `packages/clothing/src/cache.ts:139`

```ts
type TexData = Uint8Array | { ref: string }
```

a baked texture: PNG bytes, or a reference to a file the game keeps elsewhere (a shared tile)

### TshirtStyle

*type* · `packages/clothing/src/blocks/tshirt.ts:12`

```ts
type TshirtStyle = UpperStyle & { neckline?: 'crew' | 'v' | 'scoop' }
```

A T-shirt of a light jersey knit: short set-in sleeves, a rib neck band, a body that follows the figure a little loosely.
Style: `neckline` crew | v | scoop; `sleeve` (short by default; long, raglan, drop ...); `length` (hem height name or metres below the
shoulder point); `fit`; any other part by `UpperStyle`.

### Under

*type* · `packages/clothing/src/blocks/ease.ts:12`

```ts
type Under = (number | Pick<Garment, 'cloth'>)[]
```

the layers a garment is worn over: the radial thicknesses (metres) or the garments themselves (their cloth thickness is used)

### UpperHemName

*type* · `packages/clothing/src/parts/style.ts:16`

```ts
type UpperHemName = 'waist' | 'hip' | 'crotch' | 'thigh' | 'knee' | 'calf' | 'ankle'
```

named hem heights

### UpperSleeveLength

*type* · `packages/clothing/src/parts/util.ts:39`

```ts
type UpperSleeveLength = 'long' | 'three-quarter' | 'elbow' | 'short' | 'cap' | number
```

### V2

*type* · `packages/clothing/src/pattern.ts:7`

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

Patterns: a garment is cut from flat panels, as a tailor cuts it. A panel's outline is a closed chain of named edges
(polylines in metres, in the panel's own plane: x across, y up along the grain); seams join two edges, hems and folds are edges too. A panel
is meshed into near-equilateral triangles of a chosen size; its flat coordinates stay with every vertex (the cloth's UV at its real scale).

### V3

*type* · `packages/clothing/src/body.ts:8`

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

### WaistcoatStyle

*type* · `packages/clothing/src/blocks/waistcoat.ts:11`

```ts
type WaistcoatStyle = UpperStyle & { vDepth?: number }
```

A waistcoat: sleeveless, fitted, a deep V front buttoned in a single row, welt pockets, ending just below the waist.
`collar: 'shawl'` gives a shawl-collar waistcoat; `closure: 'double'` a double-breasted one; `vDepth` the depth of the V.

### Weave

*type* · `packages/clothing/src/fabric.ts:11`

```ts
type Weave = 'twill' | 'plain' | 'stockinette' | 'rib' | 'leather' | 'felt' | 'flannel' | 'denim' | 'corduroy' | 'velvet' | 'satin' | 'linen'
```

Fabrics: the surface of a cloth made in code at its real thread scale, evaluated in the flat panel coordinates
(metres, y along the grain), so the weave runs along the grain and is the same size on every panel. Each fabric gives a colour, a
height (the relief of threads and stitches, metres) and a roughness at a point; a garment's panels are packed into one texture atlas
and baked with the stitching of its seams and hems drawn where they are sewn.

## Constants

### ALL_ROLES

*const* · `packages/clothing/src/rig.ts:17`

```ts
const ALL_ROLES: readonly BoneRole[]
```

### BLOCK_NAMES

*const* · `packages/clothing/src/catalog.ts:324`

```ts
const BLOCK_NAMES: string[]
```

### BLOCKS

*const* · `packages/clothing/src/service.ts:34`

```ts
const BLOCKS: Record<string, BlockFn>
```

### CATALOG

*const* · `packages/clothing/src/catalog.ts:163`

```ts
const CATALOG: Record<string, BlockSpec>
```

### CENTRAL_ROLES

*const* · `packages/clothing/src/rig.ts:15`

```ts
const CENTRAL_ROLES: readonly CentralRole[]
```

### CLOTHING_CORE_VERSION

*const* · `packages/clothing/src/cache.ts:26`

```ts
const CLOTHING_CORE_VERSION: 1
```

The version of the cloth core (drafting rules aside: the garments are in the key itself). EVERY change that can change a dressed result
bumps it by one: the simulation (`sim.ts`, `drape.ts`, `sew.ts`, `dress.ts`), the collision (`body.ts`), the skin transfer and hidden body
(`transfer.ts`), the baking (`fabric.ts`), the trims and boots (`trims.ts`, `footwear.ts`), and the record layout below. A change that
cannot change a result (a comment, a rename, a test) does not. When unsure, bump: a wrong bump costs a re-dress, a missing one ships stale clothes.

### COLOR_WORDS

*const* · `packages/clothing/src/fabrics.ts:83`

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

colour words to sRGB hex (English words; Russian stems are matched by prefix); a garment's colour in a description

### ESSENTIAL_ROLES

*const* · `packages/clothing/src/rig.ts:19`

```ts
const ESSENTIAL_ROLES: readonly BoneRole[]
```

roles the measurements and the garments cannot do without (the neck, the clavicle, the ball of the foot and the spine have fallbacks)

### FABRICS

*const* · `packages/clothing/src/fabrics.ts:28`

```ts
const FABRICS: Record<string, CatalogFabric>
```

### GARMENT_SETS

*const* · `packages/clothing/src/catalog.ts:317`

```ts
const GARMENT_SETS: { word: string; blocks: string[]; }[]
```

garment sets: one word that is several blocks ("suit": jacket and trousers)

### INTERLINING

*const* · `packages/clothing/src/blocks/ease.ts:80`

```ts
const INTERLINING: Record<"collar stand" | "collar fall" | "lapel" | "waistband" | "cuff" | "brim" | "band" | "flap" | "facing" | "crown" | "shell" | "belt", number> & { steel: number; }
```

Interlining by piece: the bending stiffness of the piece over its fabric's. A shirt collar and a waistband are fused, a lapel is
canvassed, a cuff is turned double, a felt brim is blocked and stiffened, a peak is board.

### LAYER_BULK

*const* · `packages/clothing/src/blocks/ease.ts:22`

```ts
const LAYER_BULK: 0.5
```

layers do not squeeze to nothing, and fold at their seams: a layer takes its thickness and half as much again

### LIMB_ROLES

*const* · `packages/clothing/src/rig.ts:16`

```ts
const LIMB_ROLES: readonly LimbRole[]
```

### OUTFIT_MAP_FORMAT

*const* · `packages/clothing/src/cache.ts:30`

```ts
const OUTFIT_MAP_FORMAT: 1
```

the version of the map file layout

### OUTFIT_RECORD_FORMAT

*const* · `packages/clothing/src/cache.ts:28`

```ts
const OUTFIT_RECORD_FORMAT: 1
```

the version of the record file layout

### WEAVES

*const* · `packages/clothing/src/fabrics.ts:19`

```ts
const WEAVES: Weave[]
```

every weave `bakeGarment` knows

