Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

instances.pick_by_attribute (procNode)

Stand one of several sources on each point, picked by an integer point attribute: each point's value is rounded to the nearest whole number and read as a 0-based index into sources, a value outside the list landing on its nearest end. Each point's Mesh and variant hold that index, which the points' detail lists as labels.Mesh (instances.variants). Points that carry no such attribute are refused.

Inputs

  • points (Points). The cloud that carries the deciding attribute.
  • sources (List<Geometry>). The variants the attribute indexes into. The first entry is index 0.
  • transform (Transform, optional). Per-instance offset, rotation and scale written onto the points' placement, sampled by point id, whichever variant the attribute chose.
  • attribute (String, default "variant"). The point column that decides each point's variant: a shell class, a height band, a region id, whatever a field or attribute node computed upstream.

Outputs

  • instances (Points). The points carrying Mesh, variant, orient and scale.
local pts = g.attribute.choose({ geometry = g.points.grid({ countX = 4, countZ = 4, spacing = 2 }), name = "kind", weights = { 1, 1 } })
local mixed = g.instances.pick_by_attribute({ points = pts, sources = { g.mesh.box({}), g.mesh.sphere({}) }, attribute = "kind" })