Builtin Library
- ..
- .metadata164 B
- README.md4.4 KB
- bursts.module
- init.luau7.0 KB
README.md
sim.spawn (procNode)
A spawn description for a solver: particles born on a set of points at a rate and in bursts, with a starting velocity,
a lifetime, a size and the name of the stream they belong to. It owns no particles; wire it into sim.particles'
sources, which takes any number of them and reads each at every step.
Every number or vector point attribute the points carry (not P, N, id, v, age, life, lifetime,
seed, size, stream, alive or slot) rides in rows as stamp_<name>, and sim.particles stamps it onto each
particle born at the point.
rateis births a second, animatable;perMeteris births for every metre the points travel, so a trail behind a mover has the same density at any speed and frame rate, a source that stands still births nothing by it, and the births of a single jump are bounded by the solver's capacity. The two add.- The steps between two presents are born where the points stood at each step's time, so a stream from a fast mover is a continuous line rather than a clump at each present.
burstsis a list of births all at once. An entry is{ x = time, y = count }, or a record oftime,count(a number, or{ x = fewest, y = most }for a different number at each firing;minCountandmaxCountsay the same),cycles(how many times it fires, default 1),interval(seconds between firings) andprobability(the share of firings kept, default 1). Times are in simulation seconds. An entry carrying any other key is refused, naming it.
Inputs
points(Points): where particles are born: each birth picks one of these points.rate(Float, default 20, min 0): particles born per second of simulation time, spread over the points. Animatable; the solver reads it at each of its steps.perMeter(Float, default 0, min 0): particles born for every metre the points travel, summed over the points. The distance is measured between one present and the next, for the points that keep theirid(or, with none, their place in the set), plus the length of anymovedattribute the points carry. Animatable.bursts(List<Record>, optional): extra births all at once, as above.lifetime(Vec2, default (1, 2)): how long a particle lives in seconds, drawn between x and y for each one.velocity(Vec3, default (0, 1, 0)): the velocity every particle is born with.jitter(Float, default 0, min 0): a random velocity up to this length added at birth, in any direction.speed(Vec2, default (0, 0)): a speed drawn between x and y for each particle, taken along the Vec3 point attributealongnames and added tovelocity.along(String, default"N"): the Vec3 point attributespeedis taken along, read at each particle's birth point. Aspeedother than zero needs the points to carry it, and the cook refuses points that do not.size(Vec2, default (0.1, 0.1)): a particle's size, drawn between x and y for each one.stream(String, default"main"): the name of the stream this source's particles belong to; sim.particles gives each particle the index of its source asstreamand lists the names in its detaillabels.stream.seed(Float, default 0): which of the possible sequences of births this source makes.order(String, default"random"):"random"draws one point for every birth;"inTurn"takes the points one after another.
Outputs
source(Record): what sim.particles reads:kind("sim.spawn"),points,rows(the points as the solver reads them:Pwhere they stand,Athe directionalongnames,Manymovedattribute,Ieach point'sidor place, each zero where the points carry none, andstamp_<name>for each attribute stamped onto the particles),rate,perMeter,bursts(the firings the entries state, each{ x = time, y = count }),lifetime,velocity,jitter,speed,along,size,stream,seedandinTurn.
Example
local emitter = g.points.grid({ countX = 1, countZ = 1, y = 1 })
local source = g.sim.spawn({
points = emitter,
rate = 30,
bursts = { { time = 0, count = 50 } },
lifetime = { x = 1, y = 2 },
velocity = vector.create(0, 3, 0),
jitter = 1,
stream = "sparks",
})
local sim = g.sim.particles({ sources = { source }, gravity = vector.create(0, -9.8, 0) })