Light.component
This package holds more than this page lists. See all of its files in its world.
README.md
Light
Adds a light source to an entity. The entity's world transform determines the light's position, and a spot's aim: the cone axis is the entity's world rotation applied to face. A directional or distant light travels along direction. Point light positions are auto-synced from that world transform, so a light on a child entity burns where the entity stands — the position entity.position reports. A point light's intensity is on one scale with the SpotLight component's intensity/brightness: the same number at the same radius/range puts the same light on a surface either kind faces from the same place, and a spot spends it on the cone it opens on rather than all around itself.
Kinds: "point", "spot", "directional" (the scene's sun), "ambient", "distant" (a parallel light beside the sun).
Public fields: kind, colorR/G/B, intensity, radius, directionX/Y/Z, face, angle, innerAngle, castsShadows, lightChannels, mobility. range, color and direction are aliases accepting the composite/renamed forms.
Methods: :setColor(color) (color: {r, g, b} array or {r=, g=, b=} map), :setIntensity(i), :setRadius(r), :setDirection(dir), :setFace(face), :setAngle(deg), :setInnerAngle(deg), :setKind(lightKind).
kind = "spot" opens a cone from the entity's position along its face ("Front" by default: the entity-local -Z that transform.forward reports and entity:lookAt aims; also Back, Left, Right, Top, Bottom), to the angle (outer, default 30) and innerAngle (inner, default 20) half-angles in degrees. These are the SpotLight component's fields, under the same names and with the same meanings. A spot aims by face and its entity's rotation, so a direction written to one is refused: :setDirection raises, an assigned direction keeps the value it held, and both name face. "directional" and "distant" are parallel lights: they arrive from the same direction at every point in the world and no distance attenuates them, so their intensity reads against the sun's rather than against a point light's. The SpotLight README carries the rest of how to balance a mixed point-and-spot rig.
entity(id).component.add("Light", { kind = "point", intensity = 2, radius = 10 })
entity(id).component.add("Light", { kind = "directional", direction = {-0.5, -1, -0.3} })
entity(id).component.add("Light", { kind = "spot", face = "Bottom", angle = 35, innerAngle = 25 })