Foundry Virtual Tabletop - API Documentation - Version 14
    Preparing search index...

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

    Hierarchy (View Summary)

    Index

    Properties

    _updated: boolean = false

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

    exploration: documents.FogExploration | null = null

    The FogExploration document which applies to this canvas view

    emittedEvents: readonly ["explored"] = ...

    Accessors

    • get fogExploration(): boolean

      Does the currently viewed Scene support fog of war exploration?

      Returns boolean

    • get sharedExploration(): boolean

      Does the currently viewed Scene is in shared fog exploration?

      Returns boolean

    • get sprite(): SpriteMesh

      The exploration SpriteMesh which holds the fog exploration texture.

      Returns SpriteMesh

    • get tokenVision(): boolean

      Does the currently viewed Scene support Token field of vision?

      Returns boolean

    Methods

    • Internal

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

      Parameters

      • Optionaltex: Texture<Resource> | RenderTexture

        Optional exploration texture.

      Returns SpriteMesh

    • Internal

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

      Returns Promise<void>

    • Add a new event listener for a certain type of event.

      Parameters

      • type: string

        The type of event being registered for

      • listener: EmittedEventListener

        The listener function called when the event occurs

      • Optionaloptions: { once?: boolean } = {}

        Options which configure the event listener

        • Optionalonce?: boolean

          Should the event only be responded to once and then removed

      Returns 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

    • Destroy this FogManager.

      Returns void

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

      Returns Promise<void>

    • Is this position explored?

      Parameters

      • position: Point

        The position to be tested

      Returns boolean

      Is this position explored?

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

      Parameters

      • Optionaloptions: { preserve?: boolean } = {}
        • Optionalpreserve?: boolean

          Preserve current fog until the new one is ready.

      Returns Promise<void | Texture<Resource>>

    • 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.

      Parameters

      • Optionaloptions: { share?: boolean } = {}
        • Optionalshare?: boolean

          Broadcast the fog to other clients for local unionization.

      Returns Promise<void>

    • Synchronize one user's version of the Fog of War for this scene to other users. Note: This API is experimental and may be removed in later versions without deprecation. It is intended for one-time corrections of users' fog explorations, and should not be used for real-time synchronization of fog exploration.

      Parameters

      • from: User

        The user whose Fog of War to use as the source of truth.

      • Optionalto: User[]

        A list of users that should have their Fog of War synced. If none are specified then all users will be synced.

      Returns Promise<void>

      A promise that resolves when synchronization has been completed.

    • 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

    • Protected

      Unionize exploration inputs for initial scene load. Override this method to change union rules or to return additional exploration data (ex: positions). This method must not perform any persistent DB operations.

      Parameters

      Returns Promise<{ texture: RenderTexture; updateData: object | null }>