foldSet

Lays out the ridges of a draped cloth: count folds spread evenly across spread, each nudged sideways, widened and raised by a seeded amount so no two are alike.

foldSet(opts: {
    count: number
    seed: Expr | number
    spread: Expr | number
    width: Expr | number
    height: Expr | number
    jitter?: number
}): Fold[]

Import noise from shaders/std and use noise.foldSet.

spread is the distance the folds cover across the drape, in the units you will pass as across to drapedFolds (the canvas aspect for a full-width curtain). width and height are the typical ridge size. jitter (0–1, default 0.6) is how far a fold may wander from its even slot. The same seed always gives the same layout. count is a plain number, so drive it from a compile-time prop.

Parameters

NameTypeNotes
opts`{
count: number
seed: Expr \| number
spread: Expr \| number
width: Expr \| number
height: Expr \| number
jitter?: number

}` | |

Example

const folds = foldSet({count: 7, seed: u.seed, spread: aspect, width: u.foldWidth, height: u.foldDepth})

Tip. Call it once, outside any height function: the layout is the same at every tap.

See also

  • drapedFolds — The height of a draped cloth at a point: rounded ridges running along one direction, each rippling and swaying along its length, gathered where the cloth is pinned.

Used by

Satin