hostGridProgram
A frame program for a small grid stepped in plain JavaScript: the steps run in order every frame until one returns 'skip'.
hostGridProgram(opts: {clampDt: number; steps: HostStep[]}): (fp: unknown) => void
Import sim from shaders/std and use sim.grids.hostGridProgram.
Hand the result to onBeforeRender.
Use it when the field is small (a 32×32 flow grid) and the arithmetic reads better as loops. Publish the cells with hostFieldTexture in the last step.
Parameters
| Name | Type | Notes |
|---|---|---|
opts | {clampDt: number; steps: HostStep[]} |
Example
onBeforeRender(hostGridProgram({clampDt: 0.016, steps: [hostStep('advect', (f) => advect(f.dt)), hostStep('publish', () => { pack(field.texData); field.upload() })]}))
See also
hostStep— One named step of a JavaScript-stepped grid.hostFieldTexture— The texture a JavaScript-stepped grid is read through.gridSim— A field of cells advanced every frame by an ordered list of stages.