Repository navigation
API 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.
new Light2D(): Light2D;Light2D
blendStyle: string = "Multiply";Defined in: src/engine/render/components.ts:60
color: Color = Color.white;Defined in: src/engine/render/components.ts:58
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: 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: 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: 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: number = 0;Defined in: src/engine/render/components.ts:63
Point: full brightness inside this radius, in world units.
intensity: number = 1;Defined in: src/engine/render/components.ts:59
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: 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: number = 3;Defined in: src/engine/render/components.ts:65
Point: no light past this radius, in world units.
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: string[] = [];Defined in: src/engine/render/components.ts:100
shadows: boolean = false;Defined in: src/engine/render/components.ts:97
Shadows from ShadowCaster2Ds (ADR 0413).
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: number = 1;Defined in: src/engine/render/components.ts:99
How dark its shadows are, 0 (none) to 1 (no light).
shape: Vector2[];Defined in: src/engine/render/components.ts:73
Freeform: the lit polygon, in the node's local XY.
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: string[] = [];Defined in: src/engine/render/components.ts:61
type: Light2DType = "point";Defined in: src/engine/render/components.ts:57
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.
get enabled(): boolean;Defined in: src/engine/core/Component.ts:63
boolean
set enabled(value): void;Defined in: src/engine/core/Component.ts:67
boolean
void
get gameObject(): GameObject;Defined in: src/engine/core/Component.ts:43
Unity-style alias for node.
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.
boolean
get node(): GameObject;Defined in: src/engine/core/Component.ts:38
The node this component is on.
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).
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).
Readonly<TimeState>
get transform(): Transform;Defined in: src/engine/core/Component.ts:57
The Transform of the node this component is on, if it has one.
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.
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.
string
InstantiateOptions = {}
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.
string = "Default"
string
This wiki is generated from docs/wiki/ and the myco module's source on every push to master. Change pages there in a pull request: edits made here are not kept.
Basics
Gameplay
Rendering
Audio
- Playing sound
- Why is there no sound?
- Playlists
- Interactive music
- Sound generators
- Spatial audio
- Audio mixer
- Live mixing
- Loudness
- Audio profiler
- Audio takes
Reference