Reads a particle attribute. Type matches the attribute (see ParticleAttribute).
Reads the engine time uniform (uniforms.time, seconds since pass start).
Reads the per-frame delta-time uniform (uniforms.dt, seconds).
Reads the particle's slot index as an f32 (handy as a per-particle constant).
Reads the emitter origin (world-space, after the GameObject transform). vec3.
Uniform random float in [min, max]. Seed source depends on RandomMode.
Reference to a local variable declared in the same graph.
Branchless selection: returns whenTrue if cond is true, else whenFalse.
Both branches are evaluated; for control-flow use action.if_.
WGSL swizzle: swizzle(v, 'xz'), swizzle(c, 'rgb'), etc.
channels must be 1–4 of [xyzwrgba].
Reads a patch (grid) field value at the world-space point coord (xz used
as the ground plane). Returns f32. Only valid when the surrounding
ParticleGraphConfig declares patchFields — used by the agent-modeling
layer (turtles sensing a pheromone/diffusion grid). field indexes
config.patchFields. filter picks nearest-cell vs bilinear sampling.
Reads a patch field value at a CELL offset (dx, dz) from the current cell.
Only valid in the PATCH (cellular-automaton) context — the per-field
update program of a PatchFieldDef, which runs once per grid cell.
dx/dz are integer cell offsets (0,0 = this cell); they read the
pre-step half so a CA sees a consistent snapshot of its neighborhood.
Neighborhood reduction over the current cell's grid neighbors, for the PATCH
(CA) context. mooreSum / vonNeumannSum sum the 8 / 4 surrounding cells of
field; mooreCountGt counts how many of the 8 Moore neighbors exceed
threshold (the building block for "live neighbors" / "burning neighbors").
Generic neighbor reduction over the agents within radius (the AgentScript
inRadius family), evaluated against the spatial hash. query picks the
reduction: count (f32 number of neighbors), meanPos (vec3 center of mass
— cohesion; self position when none), meanVel (vec3 average velocity —
alignment), sep (vec3 sum of normalized away-vectors — separation). Only
valid in the UPDATE context when the surrounding ParticleGraphConfig
declares spatialHash. XZ ground plane.
nearest returns the offset vec3 to the closest neighbor within radius
(zero when none). coneCount counts neighbors within radius AND inside a
forward vision cone of half-angle coneHalfAngle (radians, about the
heading) — the AgentScript in-cone.
OptionalconeHalfAngle?: numberOptionalbreed?: numberWhen set, restrict the reduction to neighbors of this breed id (color.a) —
the AgentScript breed neighbor query. Only valid with count / nearest.
Reduction over THIS agent's link-neighbors (the AgentScript link-neighbors
family) — read a scalar attribute of every agent this one is linked to and
fold it. count is the degree (number of live link-neighbors); min/max/
sum/mean fold the chosen scalar attr (rotation/alpha/size, the
free per-agent scalar channels). Empty-neighborhood defaults: min +1e30,
max -1e30, sum/mean 0, count 0. UPDATE context only; requires
config.links. The graph-relaxation building block: label propagation /
connected components = min(self, linkReduceMin(label)); Bellman-Ford =
min(self, linkReduceMin(dist) + edgeCost).
Random-access read of ANOTHER agent's attribute by index (idx is an f32
agent index, rounded + clamped to the live range). Reads the particles
storage buffer directly, so it works for any attribute (position is a
vec3, scalars f32). UPDATE context only. The building block for agents that
reference other agents by id — e.g. a traveler reading the world position of
the graph node it's walking toward (linktravel/roads). Reads the live
buffer; point it at agents that don't mutate the read field mid-step (static
graph nodes) to stay race-free.
Read agent idx's link slot slot — the linked agent's index as f32, or
-1 for an empty slot (idx/slot rounded + clamped). Lets an agent read
the adjacency of ANOTHER node (not just its own links), so a traveler can
pick the next node to walk to: linkSlot(node, floor(random*k)). UPDATE
context only; requires config.links.
Read this agent's own scratch-array slot slot (f32; rounded + clamped to
[0, slotsPerAgent)). The per-agent working array declared by
config.scratch. UPDATE context only.
Read ANOTHER agent's scratch slot — scratch[agent][slot] (both rounded +
clamped). Lets an agent read a peer's working array (e.g. copy a better
candidate in tournament local search). UPDATE context only; requires
config.scratch.
Value-producing expression node. Recursive — operators take other
Exprs as inputs. Each node produces a single value whose WGSL type is implied by its kind and inputs; mismatched types surface as WGSL compile errors at pipeline-creation time.