Skip to content

API Class Light2D

github-actions[bot] edited this page Dec 2, 2026 · 5 revisions

Class: Light2D

Defined in: src/engine/render/components.ts:56

A 2D light (ADR 0399): lights the layered 2D draws (sprites, tiles, 2D decals, 2D lines, skinned sprites) whose material is Sprite Lit, on its target sorting layers, through one of the project's light blend styles. Global lights fill their layers with a flat colour; point lights (a spot when their angles are under 360°) fall off between two radii; freeform lights fill a polygon with a falloff band outside it; sprite lights are shaped and coloured by a sprite. A 2D light lights no mesh, and a 3D Light no 2D draw.

Extends

Constructors

Constructor

new Light2D(): Light2D;

Returns

Light2D

Inherited from

Component.constructor

Properties

blendStyle

blendStyle: string = "Multiply";

Defined in: src/engine/render/components.ts:60


color

color: Color = Color.white;

Defined in: src/engine/render/components.ts:58


falloff

falloff: number = 0.5;

Defined in: src/engine/render/components.ts:71

Point: the falloff's shape, 0 (linear) to 1 (sharp, most light near the inner radius).


falloffSize

falloffSize: number = 0.5;

Defined in: src/engine/render/components.ts:75

Freeform: how far the light fades out past the polygon, in world units.


height

height: number = 1;

Defined in: src/engine/render/components.ts:85

With normalMaps: the light's height above the sprites' plane, in world units (low: grazing light).


innerAngle

innerAngle: number = 360;

Defined in: src/engine/render/components.ts:67

Point: the full-brightness cone's full angle in degrees, along the node's +Y (360: all round).


innerRadius

innerRadius: number = 0;

Defined in: src/engine/render/components.ts:63

Point: full brightness inside this radius, in world units.


intensity

intensity: number = 1;

Defined in: src/engine/render/components.ts:59


normalMaps

normalMaps: Light2DNormals = "off";

Defined in: src/engine/render/components.ts:83

How it lights lit sprites' normal maps (their sidecar's normalMap, ADR 0414). Off: flat. Fast: by the direction of its layer batch's lights, averaged. Accurate (ADR 0415): per light, for point lights on tiers that allow it (high); elsewhere as fast.


outerAngle

outerAngle: number = 360;

Defined in: src/engine/render/components.ts:69

Point: the cone's full angle in degrees, past which there's no light (360: all round).


outerRadius

outerRadius: number = 3;

Defined in: src/engine/render/components.ts:65

Point: no light past this radius, in world units.


overlap

overlap: Light2DOverlap = "additive";

Defined in: src/engine/render/components.ts:90

How it meets the lights below it (ADR 0415): added to them, or blended over them by its own falloff (an alpha blend light replaces what's under its core). Lights in a texture draw additive first, then alpha blend in scene order.


shadowMask

shadowMask: string[] = [];

Defined in: src/engine/render/components.ts:100


shadows

shadows: boolean = false;

Defined in: src/engine/render/components.ts:97

Shadows from ShadowCaster2Ds (ADR 0413).


shadowSoftness

shadowSoftness: number = 0.3;

Defined in: src/engine/render/components.ts:102

How soft its shadows' edges are, 0 (hard) to 1, on qualities with soft shadows (ADR 0400).


shadowStrength

shadowStrength: number = 1;

Defined in: src/engine/render/components.ts:99

How dark its shadows are, 0 (none) to 1 (no light).


shape

shape: Vector2[];

Defined in: src/engine/render/components.ts:73

Freeform: the lit polygon, in the node's local XY.


sprite

sprite: string = "";

Defined in: src/engine/render/components.ts:77

Sprite: the sprite whose colour and alpha shape the light, at its size (like a SpriteRenderer's).


targetSortingLayers

targetSortingLayers: string[] = [];

Defined in: src/engine/render/components.ts:61


type

type: Light2DType = "point";

Defined in: src/engine/render/components.ts:57


volumeIntensity

volumeIntensity: number = 0;

Defined in: src/engine/render/components.ts:95

A visible glow of the light itself (ADR 0415; 0: none): its shape drawn additively over its target layers' sprites, at this share of its intensity. Not for global lights; unshadowed.

Accessors

enabled

Get Signature

get enabled(): boolean;

Defined in: src/engine/core/Component.ts:63

Returns

boolean

Set Signature

set enabled(value): void;

Defined in: src/engine/core/Component.ts:67

Parameters
value

boolean

Returns

void

Inherited from

Component.enabled


gameObject

Get Signature

get gameObject(): GameObject;

Defined in: src/engine/core/Component.ts:43

Unity-style alias for node.

Returns

GameObject

Inherited from

Component.gameObject


isActiveAndEnabled

Get Signature

get isActiveAndEnabled(): boolean;

Defined in: src/engine/core/Component.ts:74

True when enabled, the node is active in the hierarchy, and the node is in a loaded world.

Returns

boolean

Inherited from

Component.isActiveAndEnabled


node

Get Signature

get node(): GameObject;

Defined in: src/engine/core/Component.ts:38

The node this component is on.

Returns

GameObject

Inherited from

Component.node


owner

Get Signature

get owner(): GameObject;

Defined in: src/engine/core/Component.ts:51

The node this component acts for: the node itself when attached directly, or the parent node when this component lives on a component node (ADR 0009).

Returns

GameObject

Inherited from

Component.owner


time

Get Signature

get time(): Readonly<TimeState>;

Defined in: src/engine/core/Component.ts:99

This component's World's clock (ADR 0032): the same values as Time, but safe to read outside the World's frame too (after an await, say).

Returns

Readonly<TimeState>

Inherited from

Component.time


transform

Get Signature

get transform(): Transform;

Defined in: src/engine/core/Component.ts:57

The Transform of the node this component is on, if it has one.

Returns

Transform

Inherited from

Component.transform


world

Get Signature

get world(): WorldHandle;

Defined in: src/engine/core/Component.ts:88

A handle on this component's World (ADR 0132): the same one Engine.findWorld returns. Load a scene into it, pause, connect or destroy it: this.world.loadScene("scenes/level2.scene.json"). Throws for a World no Engine owns.

Returns

WorldHandle

Inherited from

Component.world

Methods

instantiate()

instantiate(prefabPath, options?): GameObject;

Defined in: src/engine/core/Component.ts:109

Instantiate a prefab in this component's World (ADR 0034), like GameObject.instantiate. Use it in code that may run after an await: by then the frame is over and the current World is the Engine's default one, which may not be this component's. A parent from another World throws.

Parameters

prefabPath

string

options?

InstantiateOptions = {}

Returns

GameObject

Inherited from

Component.instantiate


sampleAt()

static sampleAt(
   point, 
   sortingLayer?, 
   blendStyle?
): Color;

Defined in: src/engine/render/components.ts:110

The light the current World's 2D lights give at point (world units) on sorting layer sortingLayer, through blend style blendStyle (default the first), as linear RGB: every enabled light's colour × intensity × falloff, shadows included, without normal maps (flat). For gameplay, such as how visible a character is; computed on the CPU from the lights' fields, the same rule the light pass draws by. A sprite light counts as its rectangle.

Parameters

point

Vector3 | Vector2

sortingLayer?

string = "Default"

blendStyle?

string

Returns

Color

Clone this wiki locally