recompileWhen

Rebuild when your own test of the old and new value says so, for a threshold crosses cannot express.

recompileWhen(predicate: (prev: any, next: any) => boolean): RecompileRule

Import recompileWhen from shaders/std.

Parameters

NameTypeNotes
predicate(prev: any, next: any) => boolean

Example

blur: {default: 0, recompile: recompileWhen((prev, next) => (prev > 0) !== (next > 0))}

See also

  • crosses — Rebuild the shader only when the prop crosses value, not on every change.

Used by

FlutedGlass, Glass, GridDistortion, ParticleFlow, Surface3D