---
name: ferret-clothing
description: Use to dress any skinned character in Ferret with real clothes (@ferret/clothing): patterns cut by a tailor's rules, sewn off the body, fabric physics, outfit cache and store, cloth in motion and baked per clip, skin weights, textures, boots, commands.
---

# Clothing

## When to use
A character needs clothes that look made: trousers, a knitted jersey, a tailored jacket, a cap, a kerchief, boots. For quick shells over
the old procedural humans use `ferret-humans`; for armour plates, rigid parts.

## The model (the tailor way)
Measure the body, cut the pattern by the rules, sew it off the body, put it on at its supports, add weights and textures, store it, move it.
Each part says in `reference/clothing.md` whether it is built or `status: in progress`; use only what the code has now.
- Cut: `measureBody`, blocks (`trousers`, `jersey`, `jacket`, `shirt`, `tshirt`, `waistcoat`, `coat`, `cloak`, `hoodie`, `skirt`, `dress`, hats ...). Ease by fitting and by layer (`ease`, `upperEases`, `underThickness`: pass `under` to a block), sleeve cap = armhole + setting ease (`settingEase`), darts (`darts`), grain per panel. No per-outfit numbers.
- Held: `Garment.support` (`kind` fitted, hung, waist, head, hand, foot; `pinned` lines; `stiff` pieces).
- Fabric: `fabricPhysics(name)`, `triangleCompliances`, `bendCompliance` (`weave.ts`).
- Sewn: `sewGarment(garment)`: seams in the tailor's order, closed seams welded into one node.
- Put on: `dress.ts` is in progress (plan `plans/PLAN-CLOTHING-TAILOR.md`). Until then `drape(body, garments, { h, frames })` is the OLD way, to be removed: add no switch for an outfit.

## Steps
1. `const body = bodyFromMesh(skinnedMesh)`, `const m = measureBody(body)`.
2. Draft blocks, or words: `describe(text)`; any skeleton: `mapRig`; or your own `Garment`.
3. Dress (`drape` for now), then per garment `transferSkin`, `bakeGarment(d, { fabrics })`, `garmentMesh(...)`; or by command `clothing.dress {entity, garments, fabrics}`, `clothing.list`, `clothing.undress`.
4. Cache: `outfitKey`, `OutfitStore`, `dressCached`; the store lives in the game; `node tools/clothing/store.mjs build|list|verify|pack`. Any change that can change a dressed result bumps `CLOTHING_CORE_VERSION`.
5. Motion: `ClothMotionService`, commands `clothing.motion.start|stop|set|stats|reset` (budget, `near`, `far`); baked: `bakeClip`, `sampleBakedCloth`, stored per clip in the record.

## Check afterwards
Run the regression set `tools/clothing/regress` (`run.mjs`, `compare.mjs`): seam gap under 10 mm, no cloth in the body, no skin or lower layer through, no spikes, three walk frames. One case at a time, low priority, on the RTX.

## What usually goes wrong
- A fault in one outfit: do not add a switch; look at the cut (ease, support), the fabric, the core; then the regression set.
- A garment falls off in motion: it has no support; give the block `support.pinned`.
- The store gives an old result: the core version was not bumped.
- A baked loop jumps: `fps` must divide 60; raise `warmCycles` or `loopBlend`.

## Files

- `reference/clothing.md` — gameplay/clothing.md
- `reference/api-clothing.md` — every export of `@ferret/clothing` with signature and doc comment
- `reference/api-clothing-2.md` — every export of `@ferret/clothing` with signature and doc comment
- `reference/api-clothing-3.md` — every export of `@ferret/clothing` with signature and doc comment
- `reference/api-clothing-4.md` — every export of `@ferret/clothing` with signature and doc comment
- `reference/commands.md` — 12 commands of these packages with their arguments
