Renderer · interface
AreaLightSource
One rectangular emitter, as a consumer describes it.
Explained in Hello world.
interface AreaLightSourceimport type { AreaLightSource } from '@driftengine/core';In depth
Positions, colours and sizes, and nothing that means anything in one game — the rule
AGENTS.md opens with. right and up are the rectangle's own in-plane axes, and their cross
product is the direction it emits.
Properties
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
z | number | |
r | number | |
g | number | |
b | number | |
rightX | number | In-plane axes. Normalised on the way in, because the form factor assumes unit length. |
rightY | number | |
rightZ | number | |
upX | number | |
upY | number | |
upZ | number | |
halfWidth | number | Half extents along right and up, in metres. |
halfHeight | number | |
twoSidedoptional | boolean | Whether the rectangle emits from both faces. Default false.MoreA window is one-sided and a hanging panel is two-sided, and the difference is visible rather than pedantic: a one-sided light must contribute nothing to a surface behind it, or the wall it is set into is lit by it and reads as glowing. |
castsShadowoptional | boolean | Whether this rectangle is worth a shadow layer at all. Default false, which is the
opposite of what a point light's identically named field defaults to.MoreA point light has cast since before there was a budget to ration, so It also rides |
shadowRangeoptional | number | How far from the rectangle occlusion is tracked, in metres: the shadow map's far plane.MoreRequired when Guessing it would produce one of two failures, both of which read as a renderer bug rather than a missing field: too short and the shadow stops in a straight line partway across the floor, too long and the depth precision spent on the near metres is what a fixture actually needed. A rectangle that declares it casts and names no range is refused with a warning naming the field. |
shadowNearoptional | number | Where casting begins, in metres from the rectangle's plane. Defaults to POINT_SHADOW_NEAR.MoreThe same knob a point light carries and for the same reason: a fixture's own housing sits within centimetres of the emitter, occludes an enormous solid angle from it, and throws that across the floor as a hard square much larger than the housing. Keep it small — it clips every caster, not just the fixture. |
rangeoptional | number | How far the rectangle's light reaches, in metres from its centre: past it the light is zero,
windowed down to it, so a clustered rectangle can be binned into the froxels it reaches and no
others. Read only where the rectangle is shaded through the froxel table — the ones past
maxAreaLights with clusteredLights on; the fixed four light everything they face, as they
always have. Absent, it is where the rectangle's irradiance on its axis falls to a thousandth
of a scene unit, and never inside the rectangle itself. An attenuation radius, in metres. |
barnDoorAngleoptional | number | Barn doors: a flap hinged at each of the rectangle's four edges, standing this many degrees from
its normal. 90, or absent, folds them flat and they hide nothing; smaller closes them, so the
light narrows to the opening they leave — a rectangle at 50° throws a beam rather than filling
its hemisphere. 88° is the usual default, nearly flat.MoreWhat a fragment sees past the doors is the part of the rectangle no door's tip hides, one axis at a time, and the rectangle then shades as that smaller rectangle, its highlight included. Its shadow map is still baked from the whole rectangle's centre. What it gives up: each door is taken as endless along its hinge, so the two axes clip apart and the corner where two doors meet hides a square rather than the mitre two real flaps make. One-sided: a two-sided rectangle's back face has none. |
barnDoorLengthoptional | number | The barn doors' length in metres. Absent, 0.2: the usual default of 20 cm. |