Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

prefab.from_geometries (procNode)

A prefab: one root with a child per part drawing it through the native Mesh and Material components, each part keeping its own geometry and material, so a body with wheels and glass is one logical entity. Use it when parts must stay separate meshes with separate materials under one root.

Each child has id 1, 2, ... in part order and hangs under the root. A part that is neither a Geometry nor a record holding one is an error naming its number.

Inputs

  • parts (List<Geometry | Record>). The parts, in the order their child entities are laid out. Each entry is a geometry, whose own material it draws with, or a record { geometry, material?, name? } that gives that one part a material and a name of its own.
  • name (String, default "group"). The root entity's name, and the stem every part that named none takes: <name>_1, <name>_2, ... numbered in part order. An empty string takes "group".

Outputs

  • prefab (Prefab). The root, then one child per part, each record's ecs holding a Mesh row (the geometry) and a Material row (its material).
local car = g.prefab.from_geometries({
    parts = { g.mesh.box({}), { geometry = g.mesh.sphere({}), name = "dome" } },
    name = "car",
})