Module

Hylograph.Simulation.Consumers

Package
purescript-hylograph-simulation
Repository
afcondon/purescript-hylograph-simulation

The tick consumer for a force simulation: what makes a simulation something hylograph-transitions' Coordinator can tick, beside any transitions it is ticking.

The consumers for transitions themselves (transitionConsumer, transitionGroupConsumer) are in Hylograph.Transition.Consumers, in hylograph-transitions, since 2.0.0: they never needed a simulation.

#simulationConsumer Source

simulationConsumer :: forall row linkRow. Simulation row linkRow -> Number -> Effect Unit -> Milliseconds -> Effect TickResult

A tick function for a force simulation.

The simulation's tick is called on each frame. Converged with the alpha while it is settling, Completed once alpha is below the threshold.

Do not call FE.start on the simulation: the Coordinator owns the frame loop. Call FE.create, FE.setNodes, FE.addForce and so on.

sim <- FE.create FE.defaultConfig
FE.setNodes myNodes sim
FE.addForce (FE.ManyBody "charge" FE.defaultManyBody) sim
C.register coord
  { tick: simulationConsumer sim 0.001 (renderNodes nodes)
  , onComplete: log "Simulation converged"
  }