Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit44fd9e59bd

README.md

Light

Adds a light source to an entity. The entity's world transform determines the light's position (point) or direction (directional). 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, 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), :setKind(lightKind).

kind = "spot" opens a cone along the entity's forward axis, at the engine's default 30° outer and 20° inner half-angles; the SpotLight component is the one that carries the cone angles and the face axis as fields. "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} })