Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

instances.pick_random (procNode)

Stand one of several sources on each point, dealt by a seeded, weighted draw keyed by the point's own id: each point's Mesh and variant hold its index into the sources, which the points' detail lists as labels.Mesh (instances.variants). One seed deals the same variants on every run, machine and platform.

Inputs

  • points (Points). The cloud the variants are dealt to: one draw per point.
  • sources (List<Geometry>). The variants, in order. A geometry's position here is the variant index each point is assigned, and weights lines up with the same order.
  • transform (Transform, optional). Per-instance offset, rotation and scale written onto the points' placement, sampled by point id and dealt independently of the variant.
  • seed (Float, default 1). Picks which variant each point draws; changing it reshuffles the whole field.
  • weights (List<Float>, optional). How often each source is drawn, relative to each other: { 9, 1 } draws the first source nine times as often as the second. A source whose entry is missing, zero or negative is never drawn; a list that leaves nothing positive deals the sources evenly. Unwired, every source is equally likely.

Outputs

  • instances (Points). The points carrying Mesh, variant, orient and scale.
local forest = g.instances.pick_random({ points = g.points.grid({ countX = 4, countZ = 4, spacing = 2 }), sources = { g.mesh.cone({}), g.mesh.sphere({}) }, weights = { 3, 1 }, seed = 2 })