FabricCatalog: the single definition of every material in fabricsMaterials.
`C.build()` writes materials/<id>.material/mat.yaml for each fabric and the
collection's collection.yaml (tags; roughness measured from the baked masks;
textureKB measured from the textures each material binds). Re-runnable: it
overwrites the same files every time. Tool code (it writes files): call it
from a tool, a test or an execute call, never from a component.
Real sizes (1 unit = 1 m). Each repeat holds a whole number of threads,
stitches, tufts, loops or seams, so it tiles exactly:
cotton calico plain weave, 0.5 mm yarn pitch, 128 x 128 yarns -> 64 mm
denim 3/1 twill, 0.5 mm ends and picks, 128 x 128 -> 64 mm
linen plain weave, 0.75 mm pitch, 96 x 96 -> 72 mm
canvas (duck) plain weave, 1.0 mm pitch, 96 x 96 -> 96 mm
burlap open plain weave, 2.5 mm pitch, 48 x 48 -> 120 mm
silk dupioni plain weave, 0.33 mm warp x 0.5 mm slubbed weft -> 64 mm
satin 5-end warp-faced satin, 0.4 mm pitch, 160 x 160 -> 64 mm
tartan 2/2 twill, 1.0 mm pitch, one 128-thread sett -> 128 mm
chunky knit stockinette, 12 mm stitch x 9.6 mm row, 8 x 10 -> 96 mm
cut-pile carpet tufts on about a 4 mm gauge -> 200 mm
loop carpet loops 4 mm across, rows 5 mm, 50 x 40 -> 200 mm
rope four 25 mm three-strand ropes, 100 mm lay -> 100 mm
quilted diamonds 100 mm on the diagonal, 3 x 3 seam pairs -> 300 mm
photo(what: string, across: string) → string
| arg | type | description |
|---|
| what | string | |
| across | string | |
get(id: string) → Entry
The definition of one fabric, or nil.
| arg | type | description |
|---|
| id | string | |
ids( ) → void
Every fabric id, in catalog order.
texRef(name: string) → string
| arg | type | description |
|---|
| name | string | |
hasTexture(name: string) → boolean
| arg | type | description |
|---|
| name | string | |
galleryLayout(list: { any }, minSize: number) → void
The gallery page size and page that show every fabric, and nothing else, on one ring of materialLibraryKit's "all" view, for `list` = Materials.list(). Mirrors the core Gallery's pagination (a category starts a fresh page when the current one is over half full and the category fits on a page of its own). Returns the smallest size from `minSize` up at which the collection shares a page with no other category. After masonryMaterials' MasonryCatalog.galleryLayout (MIT).
| arg | type | description |
|---|
| list | { any } | |
| minSize | number | |
pageAt(size: number) → number
| arg | type | description |
|---|
| size | number | |
materialDoc(s: Entry) → void
The mat.yaml document for one fabric. Every fabric is two-sided (cull none, double_sided), so a sheet shows from both faces, and repeats once per UV unit (the materialLibraryKit convention: `tileSize` says how many metres that is).
writeMaterial(s: Entry) → void
Write materials/<id>.material/mat.yaml for one fabric (creating the asset the first time).
round(x: number, d: number) → number
| arg | type | description |
|---|
| x | number | |
| d | number | |
costWord(kb: number) → string
The texture-cost tag: textures-tiny (under 128 KB), textures-light (under 1.5 MB), textures-medium (under 2.5 MB) or textures-heavy.
| arg | type | description |
|---|
| kb | number | |
finishWord(median: number) → string
The finish tag from the median roughness: glossy (under 0.25), satin (under 0.6) or rough.
| arg | type | description |
|---|
| median | number | |
measureRoughness(id: string) → void
The roughness range (2nd and 98th percentile of the mask's G channel) and median of a fabric's baked <id>_rm texture, or nil when it has none.
| arg | type | description |
|---|
| id | string | |
at(p: number) → number
| arg | type | description |
|---|
| p | number | |
tileWord(t: number) → string
The `tile-<metres>m` tag for a tile size (three decimals at most).
| arg | type | description |
|---|
| t | number | |
lobeWords(s: Entry) → void
The extra lobes a fabric's material turns on, as tags (sheen, anisotropic, fibre, clearcoat, cel-shaded).
mipBytes(size: number) → number
GPU bytes of one square block-compressed texture (1 byte per pixel, BC7 / ASTC 4x4) with its full mip chain.
| arg | type | description |
|---|
| size | number | |
build( ) → void
Write every material and the collection.yaml, measuring roughness from each baked mask and texture memory from what each material binds. Returns { count, path, totalKB }.
writeBoards( ) → number
Write boards/<id>.material for every fabric: its reference picture on the engine's unlit shader, which the showcase hangs beside the fabric. Returns the count.