Builtin Library
README.md
geometry.separate
Split a geometry's triangles by a per-primitive mask field or attribute into two geometries: a holds the triangles whose value is strictly above threshold, b the rest, so between them they hold every triangle once. Both keep every point.
The value each triangle is tested by is the mask field when it is wired, else the named primitive attribute, else 0. elements.keep on the primitives runs once for each half, on the device.
Built from: g.compare, elements.keep.
Inputs
geometry(Geometry). Whose triangles are divided. Point and detail attributes carry to both halves as they are; primitive and vertex attributes stay with each half's own triangles.mask(Field, optional). Read once per triangle for which half it joins. Wired, it is what the split reads, andattributeis read only when this is empty.threshold(Float, default 0.5). A triangle goes toawhen its value is strictly above this, and tobotherwise.attribute(String, optional). A primitive attribute on the geometry to read the split from, instead of a wired mask. A name the triangles do not carry is refused.
Outputs
The call answers a record by output name.
a(Geometry). The triangles whose value is strictly abovethreshold.b(Geometry). The rest.
local box = g.mesh.box({})
box.primitive.band = g.element.id * 1.0
local halves = g.geometry.separate({ geometry = box, attribute = "band", threshold = 5.5 })
return { top = halves.a, bottom = halves.b }