Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/flo-bit/shapecraft. flo-bit.dev/shapecraft
Something went wrong. Try again.
1.3 kB · 58 lines
MDX
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859# Modifiers
Modifiers come in two patterns:
**Warp functions** — return a `WarpFn`, used with `mesh.warp(fn)`:
```tsimport { twist, bend, taper } from 'shapecraft'```
**Mesh-in mesh-out** — take and return a Mesh directly:
```tsimport { smooth } from 'shapecraft'```
## twist
Rotate vertices around an axis proportional to their position along that axis.
```tsmesh.warp(twist({ amount: 2 })) // twist around Y (default)mesh.warp(twist({ axis: 'x', amount: 1.5 }))```
Higher `amount` = more twist. Works best on geometry with enough segments along the twist axis.
## bend
Curve geometry along an axis.
```tsmesh.warp(bend({ amount: 1 })) // bend around Ymesh.warp(bend({ axis: 'z', amount: 2 }))```
## taper
Scale vertices perpendicular to an axis based on a curve function.
```ts// Linear taper: full size at y=0, half at y=1mesh.warp(taper({ curve: (t) => 1 - t * 0.5 }))
// Custom curve along X axismesh.warp(taper({ axis: 'x', curve: (t) => Math.cos(t * Math.PI) }))```
The curve receives the raw coordinate value along the axis.
## smooth
Laplacian smoothing — moves each vertex toward the average of its neighbors.
```tsconst smoothed = smooth(mesh) // 1 iterationconst verySmooth = smooth(mesh, 5) // 5 iterations```