example/graph.js
function step ({tick}) {
  setFBO({ framebuffer: FIELDS[0] }, () => {
    regl.clear({ color: [0, 0, 0, 1] })
    splatMouse()
    splatVerts({
      vertexState: VERTEX_STATE[(tick + 1) % 2]
    })
  })
  for (let i = 0; i < 2 * BLUR_PASSES; ++i) {
    blurPass({
      dest: FIELDS[(i + 1) % 2],
      src: FIELDS[i % 2],
      axis: (i % 2)
    })
  }
  gradPass({
    dest: FIELDS[1],
    src: FIELDS[0]
  })
  applySpringForces({
    dest: VERTEX_STATE[(tick + 1) % 2],
    src: VERTEX_STATE[tick % 2]
  })
  integrateVerts({
    dest: VERTEX_STATE[tick % 2],
    src: VERTEX_STATE[(tick + 1) % 2],
    field: FIELDS[1]
  })
}
function step ({tick}) {
  setFBO({ framebuffer: FIELDS[0] }, () => {
    regl.clear({ color: [0, 0, 0, 1] })
    splatMouse()
    splatVerts({
      vertexState: VERTEX_STATE[(tick + 1) % 2]
    })
  })
  for (let i = 0; i < 2 * BLUR_PASSES; ++i) {
    blurPass({
      dest: FIELDS[(i + 1) % 2],
      src: FIELDS[i % 2],
      axis: (i % 2)
    })
  }
  gradPass({
    dest: FIELDS[1],
    src: FIELDS[0]
  })
  applySpringForces({
    dest: VERTEX_STATE[(tick + 1) % 2],
    src: VERTEX_STATE[tick % 2]
  })
  integrateVerts({
    dest: VERTEX_STATE[tick % 2],
    src: VERTEX_STATE[(tick + 1) % 2],
    field: FIELDS[1]
  })
}
function step ( { tick } ) { setFBO ( { framebuffer : FIELDS [ 0 ] } , ( ) => { regl . clear ( { color : [ 0 , 0 , 0 , 1 ] } ) splatMouse ( ) splatVerts ( { vertexState : VERTEX_STATE [ ( tick + 1 ) % 2 ] } ) } ) for ( let i = 0 ; i < 2 * BLUR_PASSES ; ++ i ) { blurPass ( { dest : FIELDS [ ( i + 1 ) % 2 ] , src : FIELDS [ i % 2 ] , axis : ( i % 2 ) } ) } gradPass ( { dest : FIELDS [ 1 ] , src : FIELDS [ 0 ] } ) applySpringForces ( { dest : VERTEX_STATE [ ( tick + 1 ) % 2 ] , src : VERTEX_STATE [ tick % 2 ] } ) integrateVerts ( { dest : VERTEX_STATE [ tick % 2 ] , src : VERTEX_STATE [ ( tick + 1 ) % 2 ] , field : FIELDS [ 1 ] } ) }
Main integration loop
Main integration loop