Builtin Library
README.md
field.attractor
An attractor: a Vec3 field pointing at center with strength, fading linearly to nothing at radius when one is given (radius = 0 pulls equally everywhere). A negative strength repels. Zero at the centre.
Inputs
position(Field<Vec3> | Vec3, optional). Where each element samples the field. Left unwired, it is the position leafg.element.Pof the element the field is evaluated at, whichfield.substitutereplaces.center(Vec3). Default{ x = 0, y = 0, z = 0 }. Where the field points.strength(Float). Default1. The pull, in the units a force is read in. Negative pushes away.radius(Float). Default0. The distance beyond which there is no pull, fading linearly to it. 0 pulls equally everywhere.
Outputs
field: a Vec3 field, the pull at each element.
Example
local points = g.points.grid({ countX = 4, countZ = 1, spacing = 1 })
local out = g.attribute.set({ geometry = points, name = "v", value = g.field.attractor({ center = vector.create(0, 0, 0), strength = 2, radius = 4 }) })
The points at x = -1.5 and 1.5 are pulled toward the centre with 2 * (1 - 1.5 / 4) = 1.25.