Skip to main content

LightingSystem

Composite canvas-driven visibility system tracking ambient, darkness, light masks, and ray projected shadow volumes.

Renders via a Canvas graphic on a screen-space ScreenElement named 'lighting'. The raster pipeline per frame: ambient-blended darkness veil → room rect fills/clips → camera frustum cull → per-light destination-out punch (with occluder shadows subtracted) → colored tint passes.

Enabled scene-wide via EngineOptions.lighting, or add an instance manually to a scene's world.

Potentially performance impacting — the overlay is rasterized with the 2D Canvas API and re-uploaded to the GPU every frame.

Known limitations: circle occluder radii scale uniformly with Math.min(scale.x, scale.y) so a non-uniformly scaled occluder won't cast an elliptical shadow, darkness room rects have no independent rotation of their own (though they do rotate along with the camera), and polygon shadow volumes can split at corners when the silhouette edge is not face on to the light.

Hierarchy

Index

Constructors

constructor

Properties

publicreadonlysystemType

systemType: Draw = SystemType.Draw

Determine whether the system is called in the SystemType.Update or the SystemType.Draw phase. Update is first, then Draw.

staticpriority

priority: number = SystemPriority.Highest

System can execute in priority order, by default all systems are priority 0. Lower values indicated higher priority. For a system to execute before all other a lower priority value (-1 for example) must be set. For a system to execute after all other a higher priority value (10 for example) must be set.

Methods

publicinitialize

  • Optionally specify an initialize handler


    Parameters

    Returns void

optionalinheritedpostupdate

  • postupdate(scene: Scene, elapsed: number): void
  • Optionally run a postupdate after the system processes matching entities


    Parameters

    • scene: Scene
    • elapsed: number

      Time in milliseconds since the last frame

    Returns void

optionalinheritedpreupdate

  • preupdate(scene: Scene, elapsed: number): void
  • Optionally run a preupdate before the system processes matching entities


    Parameters

    • scene: Scene
    • elapsed: number

      Time in milliseconds since the last frame

    Returns void

publicupdate

  • update(elapsed: number): void
  • Update all entities that match this system's types


    Parameters

    • elapsed: number

      Time in milliseconds

    Returns void