LightSystem. Light

A Light is an EngineObject that contributes a soft additive blob of color to the LightSystem plugin's lightmap.

  • castShadow on a Light means its rays stop at casters when lightSystem.shadows is on, three.js's meaning for a light; a Light's own render() draws nothing so the object meaning never applies to it
  • A light inside a caster is blocked entirely, so the object that holds it, its lamp, a torch, the player carrying it, needs a shadowCore that reaches past it, castShadow = false, or a renderShadow that leaves the light's spot out

Constructor

new Light(pos, radius, coloropt, fadeRangeopt)

Create a light object and add it to the engine object list

Parameters:
NameTypeAttributesDescription
posVector2

World space position

radiusnumber

Total extent of the light in world units

colorColor<optional>

Color of the light; alpha modulates intensity

fadeRangenumber<optional>

Width of the soft edge in world units (defaults to radius)

Example
new Light(vec2(5, 5), 4, rgb(1, 0.5, 0));        // orange light, full soft blob
new Light(vec2(0, 0), 8, rgb(1, 1, 1), 2);       // white core with 2-unit soft halo

Extends

  • EngineObject

Members

fadeRange

Properties
TypeDescription
number

Width of the soft edge in world units

radius

Properties
TypeDescription
number

Total extent of the light in world units

shadowCore

Properties
TypeDescription
number

Radius around the light where casters are left out of its shadow, so the lamp or torch that holds it, or the player carrying it, does not block it; it has to reach past that object's corners, about half its diagonal and a little more, or dark rays run out from them

Methods

render()

Lights are invisible in the main render pass — they only contribute to the lightmap via renderLight().

renderLight()

Draw this light's falloff blob into the lightmap. Called by LightSystemPlugin during its render pass. No-op when the plugin or WebGL is unavailable.