Builtin Library
README.md
sim.force (procNode)
A force a solver applies to its particles at every step, from any Vec3 field evaluated where each particle is then.
As an acceleration the field is added in m/s^2. As a velocity the field is the speed the air moves at, and each
particle is pulled toward it at strength a second. Wire any number into sim.particles' forces; they sum, with the
solver's gravity.
Inputs
field(Field<Vec3>): the Vec3 field the force is: an acceleration, or the velocity particles are pulled toward. It is evaluated over the particles as they stand, so a field that reads the domain it is evaluated over (field.position, field.attribute) reads each particle's ownP,v,age,life,lifetime,seed,size,idandstream. A constant vector works as well.mode(String, default"acceleration"):"acceleration"addsfield * strengthto each particle's acceleration;"velocity"adds(field - v) * strength, pulling the velocity toward the field.strength(Float, default 1): how fast a velocity force closes the difference, per second; an acceleration force is scaled by it.
Outputs
force(Record):{ kind = "sim.force", field, mode, strength }, what sim.particles reads at every step.
Example
local wind = g.sim.force({ field = vector.create(2, 0, 0), mode = "velocity", strength = 0.5 })
local source = g.sim.spawn({ points = g.points.grid({ countX = 1, countZ = 1 }), rate = 60 })
local sim = g.sim.particles({ sources = { source }, forces = { wind } })