Builtin Library
README.md
instances.cull
Keep the instances whose mask field or attribute reads strictly above threshold (or, inverted, the rest). The survivors keep their point attributes, so a culled set realizes as the whole one would have. With nothing to judge by every instance stays, and inverted none does.
The value each instance is judged by is the mask field when it is wired, else the named point attribute. elements.keep on the points does the removal, on the device.
Built from: g.compare, elements.keep.
Inputs
instances(Geometry). The set to thin out: points carrying a Mesh, or any points.mask(Field, optional). The value each instance is judged by. Wired, it outranksattribute.threshold(Float, default 0.5). An instance survives when its value reads strictly above this. Raising it thins the set, lowering it fills it back in.attribute(String, optional). A point attribute on the set to judge by, read whilemaskis unwired. A name the points do not carry is refused.invert(Bool, default false). true keeps the complement: every instance the test dropped.
Outputs
instances(Geometry). The surviving instances, in their order, with every attribute they carried.
local spots = g.points.grid({ countX = 8, countZ = 8, spacing = 2 })
spots.point.keep = g.field.random({ seed = 4 })
local thinned = g.instances.cull({ instances = spots, attribute = "keep", threshold = 0.3 })