Builtin Library
README.md
elements.entity (procNode)
Make one entity of a graph's own: one element, a point numbered 0, that stands as one entity with a name, a pose, optionally a mesh and its material, and any components. It is how a single hand-placed entity enters a graph, such as a part with a mesh on it or the root of a hierarchy; many elements are made by writing attributes over a whole set of points, never by one of these per element. elements.link parents elements under other elements, building a hierarchy of entities.
Inputs
name(String). Default"". The entity's name: the point'sname. Empty leaves the entity to be named after the output that stands it and the element's id.mesh(Geometry | AssetRef<mesh>, optional). What the entity draws: a geometry, or a reference to a mesh asset. Left out, the entity draws nothing.material(Points | AssetRef<material>, optional). The mesh's material: what a material node answers, or a reference to a material asset. Left out, a geometry's own, else the default material.P(Vec3). Default{ x = 0, y = 0, z = 0 }. Where the entity stands.orient(Vec4). Default{ x = 0, y = 0, z = 0, w = 1 }. How the entity is turned, as a quaternion (x, y, z, w).scale(Vec3). Default{ x = 1, y = 1, z = 1 }. How large the entity is on each axis.components(Record, optional). The components the entity carries, by name, each with its fields:{ Light = { intensity = 2 } }. Each goes throughcomponent.set, which refuses a component or a field that does not exist.
Outputs
geometry: one point carryingP,orient,scaleandid0;namewhen one is given;Mesh = { mesh }andMaterial = { material }when a mesh is given (orMaterialalone when only a material is); and a column per component, holding its fields.
Example
local lamp = g.elements.entity({ name = "Lamp", P = vector.create(0, 3, 0), components = { Light = { intensity = 2 } } })
local crate = g.elements.entity({ name = "Crate", mesh = g.mesh.box({}), scale = vector.create(2, 2, 2) })
lamp is one point named Lamp carrying Light = { intensity = 2 }; crate draws the box with the default material at twice its size.