A fog of war management class which is the singleton canvas.fog instance.

Properties

exploration: FogExploration = null

The FogExploration document which applies to this canvas view

_updated: boolean = false

Track whether we have pending fog updates which have not yet been saved to the database

#initialized: boolean = false

A status flag for whether the layer initialization workflow has succeeded

#refreshCount: number = 0

The fog refresh count. If > to the refresh threshold, the fog texture is saved to database. It is then reinitialized to 0.

#renderTransform: Matrix = ...

Matrix used for fog rendering transformation.

#debouncedSave: Function

A debounced function to save fog of war exploration once a continuous stream of updates has concluded.

#queue: Semaphore = ...

Handling of the concurrency for fog loading, saving and reset.

COMMIT_THRESHOLD: number = 70

Define the number of fog refresh needed before the fog texture is extracted and pushed to the server.

Accessors

  • get sprite(): SpriteMesh
  • The exploration SpriteMesh which holds the fog exploration texture.

    Returns SpriteMesh

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

    Returns FogTextureConfiguration

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

    Returns boolean

  • get fogExploration(): boolean
  • Does the currently viewed Scene support fog of war exploration?

    Returns boolean

Methods

  • Internal

    Create the exploration display object with or without a provided texture.

    Parameters

    • Optional tex: any

      Optional exploration texture.

    Returns DisplayObject

  • Initialize fog of war - resetting it when switching scenes or re-drawing the canvas

    Returns Promise<void>

  • Clear the fog and reinitialize properties (commit and save in non reset mode)

    Returns Promise<void>

  • Once a new Fog of War location is explored, composite the explored container with the current staging sprite. Once the number of refresh is > to the commit threshold, save the fog texture to the database.

    Returns void

  • Load existing fog of war data from local storage and populate the initial exploration sprite

    Returns Promise<any>

  • Dispatch a request to reset the fog of war exploration status for all users within this Scene. Once the server has deleted existing FogExploration documents, the _onReset handler will re-draw the canvas.

    Returns Promise<void>

  • Request a fog of war save operation. Note: if a save operation is pending, we're waiting for its conclusion.

    Returns Promise<any>

  • Internal

    If fog of war data is reset from the server, deactivate the current fog and initialize the exploration.

    Returns Promise<any>

  • Protected

    Extract fog data as a base64 string

    Returns Promise<string>

  • Protected

    Prepare the data that will be used to update the FogExploration document.

    Parameters

    • base64Image: string

      The extracted base64 image data

    Returns FogExplorationData

    Exploration data to update

  • Load existing fog of war data from local storage and populate the initial exploration sprite

    Returns Promise<any>

  • Request a fog of war save operation. Note: if a save operation is pending, we're waiting for its conclusion.

    Returns Promise<void>

  • Update the fog exploration document with provided data.

    Parameters

    • updateData: object

    Returns Promise<void>

  • Deactivate fog of war. Clear all shared containers by unlinking them from their parent. Destroy all stored textures and graphics.

    Returns void

  • If fog of war data is reset from the server, deactivate the current fog and initialize the exploration.

    Returns Promise<any>