The pack
beams3d
function beams3d(opts: Beams3dOptions = {}): Pack<{ beams: Beams3dApi }>
The beams-3d pack: visible shafts of light from spot lights, one instanced draw. Requires a 3D world and
render-3d, whose depth the shafts dissolve against so they never cut through the world.
Types
Beam
interface Beam
A live beam. Its look (length, cone, color, intensity) can be read and set at any time; on a beam that
follows a light, reading a field it has not set gives the light's current value, and setting one makes it the
beam's own. Its pose (x, y, z, dir, pitch) is settable on a beam from at, so a lighthouse can sweep
one by turning dir; a following beam's pose is its light's, and setting it is an error in dev (move or aim
the light instead) and ignored in production. A non-finite number is the same error.
length: number— How far the shaft reaches, world units. Live.cone: number— Half-angle of the cone, radians. Live.color: string— Colour, CSS. Live.intensity: number— Additive core strength. Live.x: number— Lamp world x. Live on a beam fromat; the light's x on a following beam.y: number— Lamp world y. Live on a beam fromat; the light's y on a following beam.z: number— Lamp world z. Live on a beam fromat; the light's z on a following beam.dir: number— Aim yaw, radians, 0 toward +z. Live on a beam fromat; the light'slight3d.diron a following beam.pitch: number— Aim pitch, radians, positive down. Live on a beam fromat; the light'slight3d.pitchon a following beam.readonly light: Handle | null— The light it follows, or null for a beam fromat.kill(): void— Remove it now. Further writes to it are ignored.readonly alive: boolean— True until killed, or until the light it follows dies.
BeamPose
interface BeamPose
Where a hand-placed beam's lamp is and where it points: what at takes on top of a BeamSpec.
x: number— Lamp position, world x.y: number— Lamp position, world y (up).z: number— Lamp position, world z.dir: number— Aim yaw, radians, as a lighting-3d light'slight3d.dir: 0 points +z.pitch: number— Aim pitch, radians, aslight3d.pitch: positive points down,Math.PI / 2straight down.
Beams3dApi
interface Beams3dApi
game.beams.
add(light: Handle, spec?: BeamSpec): Beam— Give a SPOT light (from lighting-3d'sgame.lights.addwith acone) a visible shaft. It follows the light's position, aim, cone, reach and colour every frame, except whatspecsets, and dies with the light. It is not drawn while the light is off, at zero intensity or not a spot (a point light, cone 0). A handle with nolight3d(lighting-3d not composed) throws in dev.at(spec: BeamSpec & BeamPose): Beam— A shaft that follows nothing, placed and aimed by hand; move or sweep it through the returnedBeam.strength: number— A multiplier over every beam. Default thestrengthoption. Live.soft: number— How far ahead of a solid a shaft dissolves, world units, at least 0.01. Live.enabled: boolean— Whether the pass draws. Live.readonly count: number— Beams alive now (killed ones and those whose light died are dropped every step, drawn or not).readonly drawn: number— Beams drawn last frame: 0 headless, while disabled, or with no visible beam.
Beams3dOptions
interface Beams3dOptions
Manifest options.
soft?: number— How far ahead of a solid a shaft starts to dissolve, world units; at least 0.01. Default 1.5.strength?: number— A multiplier over every beam's own intensity. Default 1.enabled?: boolean— Whether the pass draws at all. Default true.
BeamSpec
interface BeamSpec
How one beam looks. On a beam that follows a light, every field left out FOLLOWS the light, read every frame;
a field given (or set later on the Beam) is the beam's own from then on.
length?: number— How far the shaft reaches from the lamp, world units. Default: the light'sradius(20 for a beam fromat).cone?: number— Half-angle of the cone, RADIANS (lighting-3d'slights.addtakes degrees; itslight3d.coneis radians, as this is). Capped just under 90°. Default: the light's cone (0.4 for a beam fromat).intensity?: number— Additive core strength, 0 upward; 0.5 reads as a clear shaft in haze. Default 0.5.color?: string— Colour, any CSS colour. Default: the light'slight3d.color('#ffeecc'for a beam fromat).


