Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

prefab.from_instances (procNode)

A prefab: a root with one child entity per instance, each drawing the geometry its point's variant names through the native Mesh and Material components, standing at the instance's pose. A child draws with the material input when it is wired, else the material its point wears (instances.set_material, or a Material attribute), else the material its source carries. Use it when each copy must be an entity of its own; prefab.from_population keeps any number of copies as two records.

A point's variant (rounded, held to the sources) picks its geometry, and a point without one draws the first source. A point lacking orient or scale stands unrotated or at scale 1; points.pose composes them from the other instance attributes. A source carrying no material draws with the default material.

Inputs

  • instances (Points). The placement: one child entity per point, standing at the point's P, orient and scale. The record count rises with the instance count, one per point.
  • sources (List<Geometry>, optional). The geometries the points stand, in the order the set was made: the one source of instances.on_points, or the pack given to instances.pick_random or instances.pick_by_attribute, whose variant picks each child's geometry. Unwired, they are the ones the set carries.
  • material (Points | AssetRef<material>, optional). The material every child draws with: what a material node answers, or a reference to a material asset, written asset.resolve("<identity>", "material"). Unwired, each child draws with the material its point wears, else the one its source carries.
  • name (String, default "instances"). The root entity's name, and the stem of every child: <name>_0, <name>_1, ... numbered from 0 in point order. An empty string takes "instances".

Outputs

  • prefab (Prefab). The root (id "0"), then one child per point drawing through the native Mesh and Material components (ids "1", "2", ...).
local spots = g.points.grid({ countX = 2, countZ = 1 })
local crates = g.prefab.from_instances({
    instances = g.instances.on_points({ source = g.mesh.box({}), points = spots }),
    name = "crates",
})