• Public
  • Public/Protected
  • All

The visibility Layer which implements dynamic vision, lighting, and fog of war This layer uses an event-driven workflow to perform the minimal required calculation in response to changes.




{PIXI.Container} explored The exploration container which tracks exploration progress


{CanvasVisionContainer} vision The container of current vision exploration





vision: Container

The current vision container which provides line-of-sight for vision sources and field-of-view of light sources.

los: any

The canonical line-of-sight polygon which defines current Token visibility.

visibilityOverlay: Sprite

The optional visibility overlay sprite that should be drawn instead of the unexplored color in the fog of war.

visionModeData: { source: VisionSource; activeLightingOptions: any } = ...

The active vision source data object

Type declaration

lightingVisibility: { illumination: number; background: number; coloration: number; any: boolean } = ...

Define whether each lighting layer is enabled, required, or disabled by this vision mode. The value for each lighting channel is a number in LIGHTING_VISIBILITY

Type declaration

  • illumination: number
  • background: number
  • coloration: number
  • any: boolean
explored: any
filter: any
filters: any[]
filterArea: any
visible: any
options: { name: string } = ...

Options for this layer instance.

Type declaration

  • name: string
interactiveChildren: boolean = false
renderable: boolean
#renderTransform: Matrix = ...

Matrix used for visibility rendering transformation.

#visibilityOverlayDimensions: number[]

Dimensions of the visibility overlay texture and base texture used for tiling texture into the visibility filter.

#lightsSprite: SpriteMesh

The SpriteMesh which holds a cached texture of lights field of vision. These elements are less likely to change during the course of a game.

#pointSourcesStates: Map<number, any> = ...

Map of the point sources active and updateId states

  • The wasActive
  • The updateId
#initialized: boolean = false
#textureConfiguration: any

The maximum allowable visibility texture size.


  • get initialized(): boolean
  • A status flag for whether the layer initialization workflow has succeeded.

    Returns boolean

  • get tokenVision(): boolean
  • Does the currently viewed Scene support Token field of vision?

    Returns boolean

  • get textureConfiguration(): FogTextureConfiguration
  • The configured options used for the saved fog-of-war texture.

    Returns FogTextureConfiguration

  • get name(): string
  • The canonical name of the CanvasLayer is the name of the constructor that is the immediate child of the defined baseClass for the layer type.


    canvas.lighting.name -> "LightingLayer" canvas.grid.name -> "GridLayer"

    Returns string

  • get hookName(): string
  • The name used by hooks to construct their hook string. Note: You should override this getter if hookName should not return the class constructor name.

    Returns string

  • get layerOptions(): { name: string }
  • Customize behaviors of this CanvasLayer by modifying some behaviors at a class level.

    Returns { name: string }

    • name: string
  • Return a reference to the active instance of this canvas layer

    Returns CanvasLayer


  • initializeSources(): void
  • Initialize all Token vision sources which are present on this layer

    Returns void

  • _draw(options: any): Promise<void>
  • _tearDown(options: any): Promise<void>
  • refresh(): void
  • Update the display of the sight layer. Organize sources into rendering queues and draw lighting containers for each source

    Returns void

  • refreshVisibility(): void
  • Update vision (and fog if necessary)

    Returns void

  • resetExploration(): void
  • Reset the exploration container with the fog sprite

    Returns void

  • restrictVisibility(): void
  • Restrict the visibility of certain canvas assets (like Tokens or DoorControls) based on the visibility polygon These assets should only be displayed if they are visible given the current player's field of view

    Returns void

  • testVisibility(point: Point, [options]?: { tolerance: number; object: any }): boolean
  • Test whether a target point on the Canvas is visible based on the current vision and LOS polygons.


    • point: Point

      The point in space to test, an object with coordinates x and y.

    • [options]: { tolerance: number; object: any } = {}

      Additional options which modify visibility testing.

      • tolerance: number
      • object: any

    Returns boolean

    Whether the point is currently visible.

  • Draw the canvas layer, rendering its internal components and returning a Promise. The Promise resolves to the drawn layer once its contents are successfully rendered.


    • options: any = {}

    Returns Promise<CanvasLayer>

  • Deconstruct data used in the current layer in preparation to re-draw the canvas


    • options: any = {}

    Returns Promise<CanvasLayer>

  • Identify whether there is one singular vision source active (excluding previews).

    Returns VisionSource

    A singular source, or null

  • #configureLightingVisibility(): void
  • Configure the visibility of individual lighting channels based on the currently active vision source(s).

    Returns void

  • #updateLightingPostProcessing(): void
  • Update the lighting according to vision mode options.

    Returns void

  • #updateTintPostProcessing(): void
  • Refresh the tint of the post processing filters.

    Returns void

  • #createExploration(): Container
  • Create the exploration container with its exploration sprite.

    Returns Container

    The newly created exploration container.

  • #createVision(): Container
  • Create the vision container and all its children.

    Returns Container

    The created vision container.

  • #checkLights(): boolean
  • Check if the lightsSprite render texture cache needs to be fully redrawn.

    Returns boolean

    return true if the lights need to be redrawn.

  • #cacheLights(clearTexture: boolean): void
  • Cache into the lightsSprite render texture elements contained into vision.fov.lights Note: A full cache redraw needs the texture to be cleared.


    • clearTexture: boolean

      If the texture need to be cleared before rendering.

    Returns void

  • #drawVisibilityOverlay(): Promise<void>
  • Load the scene fog overlay if provided and attach the fog overlay sprite to this layer.

    Returns Promise<void>

  • Configure the fog texture will all required options. Choose an adaptive fog rendering resolution which downscales the saved fog textures for larger dimension Scenes. It is important that the width and height of the fog texture is evenly divisible by the downscaling resolution.

    Returns VisibilityTextureConfiguration

  • #requireBackgroundShader(visionMode: VisionMode): { DISABLED: number; ENABLED: number; REQUIRED: number }
  • Give the visibility requirement of the lighting background shader.


    • visionMode: VisionMode

      The single Vision Mode active at the moment (if any).

    Returns { DISABLED: number; ENABLED: number; REQUIRED: number }

    • DISABLED: number
    • ENABLED: number
    • REQUIRED: number