Builtin Library
- ..
- .metadata220 B
- README.md1.9 KB
- init.luau2.2 KB
- set.module
README.md
component.set (procNode)
Give every element of a class the component named component, with the fields given, native or script. Every element carries the same record; a field fed per element comes from an attribute the component declares for it. When the elements stand as entities, one entity per point (or per primitive) carries the component.
The component is checked before anything is written: a name that names no component is refused, naming ecs.describe() (the native components) and asset.list("component") (the script ones), and a field a native component does not declare is refused, naming the fields it does. The record is written as a column under the component's name on class, the fields as they are wired.
Inputs
geometry(Geometry). The elements that carry the component. A copy comes out carrying it.fields(Record, optional). The component's fields by name. Each is a constant, an animated value or a node's output wired in. A field the component does not declare is refused, naming the ones it does.component(String). Default"". The component the elements carry, by name: anecscomponent such as "Mesh", "Material" or "Light", or a.componentsuch as "DecalProjector" or your own.class(one of point, primitive). Default"point". Which elements carry it: one entity per point, or one per primitive.
Outputs
geometry: the geometry with a column named after the component onclass, every element holding the fields record.
Example
local points = g.points.grid({ countX = 4, countZ = 1, spacing = 1 })
local lit = g.component.set({ geometry = points, component = "Light", fields = { intensity = 3 } })
Each of the four points carries Light = { intensity = 3 }. fields = { brightness = 3 } is refused: Light declares no field brightness, and the refusal lists the fields it does declare.