A Tile is an implementation of PlaceableObject which represents a static piece of artwork or prop within the Scene.

Hierarchy (View Summary)

Constructors

Properties

Accessors

Methods

Constructors

Properties

bg: null | Graphics = null

A Tile background which is displayed if no valid image texture is present

controlIcon: null | ControlIcon

A control icon for interacting with the object

document: CanvasDocument

A reference to the Scene embedded Document instance which this object represents

frame: Container<DisplayObject>

The Tile border frame

mesh: any = null

A reference to the SpriteMesh which displays this Tile in the PrimaryCanvasGroup.

mouseInteractionManager: MouseInteractionManager

A mouse interaction manager instance which handles mouse workflows related to this object.

renderFlags: RenderFlags

Status flags which are applied at render-time to update the PlaceableObject. If an object defines RenderFlags, it should at least include flags for "redraw" and "refresh".

Retain a reference to the Scene within which this Placeable Object resides

texture: null | Texture<Resource> | Spritesheet<ISpritesheetData> = null

The primary tile image texture

embeddedName: string = "Tile"

Identify the official Document name for this PlaceableObject class

RENDER_FLAG_PRIORITY: string = "OBJECTS"

The ticker priority when RenderFlags of this class are handled. Valid values are OBJECTS or PERCEPTION.

RENDER_FLAGS: {
    redraw: { propagate: string[] };
    refresh: { alias: boolean; propagate: string[] };
    refreshElevation: { propagate: string[] };
    refreshFrame: {};
    refreshMesh: {};
    refreshPerception: {};
    refreshPosition: { propagate: string[] };
    refreshRotation: { propagate: string[] };
    refreshShape: {
        deprecated: { alias: boolean; since: number; until: number };
        propagate: string[];
    };
    refreshSize: { propagate: string[] };
    refreshState: { propagate: string[] };
    refreshTransform: { alias: boolean; propagate: string[] };
    refreshVideo: {};
} = ...

Type declaration

  • redraw: { propagate: string[] }
  • refresh: { alias: boolean; propagate: string[] }
  • refreshElevation: { propagate: string[] }
  • refreshFrame: {}
  • refreshMesh: {}
  • refreshPerception: {}
  • refreshPosition: { propagate: string[] }
  • refreshRotation: { propagate: string[] }
  • refreshShape: {
        deprecated: { alias: boolean; since: number; until: number };
        propagate: string[];
    }

    since v12

  • refreshSize: { propagate: string[] }
  • refreshState: { propagate: string[] }
  • refreshTransform: { alias: boolean; propagate: string[] }
  • refreshVideo: {}

Accessors

  • get _original(): undefined | PlaceableObject

    The object that this object is a preview of if this object is a preview.

    Returns undefined | PlaceableObject

  • get aspectRatio(): number

    Get the native aspect ratio of the base texture for the Tile sprite

    Returns number

  • get bounds(): any

    Returns any

  • get center(): Point

    The central coordinate pair of the placeable object based on it's own width and height

    Returns Point

  • get controlled(): boolean

    An indicator for whether the object is currently controlled

    Returns boolean

  • get hasActiveHUD(): boolean

    Is the HUD display active for this Placeable?

    Returns boolean

  • get hasPreview(): boolean

    Does there exist a temporary preview of this placeable object?

    Returns boolean

  • get hover(): boolean

    An indicator for whether the object is currently a hover target

    Returns boolean

  • get id(): string

    The id of the corresponding Document which this PlaceableObject represents.

    Returns string

  • get interactionState(): | undefined
    | {
        CLICKED: number;
        DRAG: number;
        DROP: number;
        GRABBED: number;
        HOVER: number;
        NONE: number;
    }

    The mouse interaction state of this placeable.

    Returns
        | undefined
        | {
            CLICKED: number;
            DRAG: number;
            DROP: number;
            GRABBED: number;
            HOVER: number;
            NONE: number;
        }

  • get isOwner(): boolean

    A convenient reference for whether the current User has full control over the document.

    Returns boolean

  • get isPreview(): boolean

    Is this placeable object a temporary preview?

    Returns boolean

  • get isVideo(): boolean

    Does this Tile depict an animated video texture?

    Returns boolean

  • get isVisible(): boolean

    Is this Tile currently visible on the Canvas?

    Returns boolean

  • get layer(): PlaceablesLayer

    Provide a reference to the CanvasLayer which contains this PlaceableObject.

    Returns PlaceablesLayer

  • get objectId(): string

    A unique identifier which is used to uniquely identify elements on the canvas related to this object.

    Returns string

  • get occluded(): boolean

    Is this tile occluded?

    Returns boolean

  • get playing(): boolean

    Is the tile video playing?

    Returns boolean

  • get sheet(): DocumentSheetV2

    A document sheet used to configure the properties of this Placeable Object or the Document it represents.

    Returns DocumentSheetV2

  • get sourceElement(): null | ImageSource

    The HTML source element for the primary Tile texture

    Returns null | ImageSource

  • get sourceId(): string

    The named identified for the source object associated with this PlaceableObject. This differs from the objectId because the sourceId is the same for preview objects as for the original.

    Returns string

  • get volume(): number

    The effective volume at which this Tile should be playing, including the global ambient volume modifier

    Returns number

  • get implementation(): typeof PlaceableObject

    Return a reference to the configured subclass of this base PlaceableObject type.

    Returns typeof PlaceableObject

Methods

  • The inner _destroy method which may optionally be defined by each PlaceableObject subclass.

    Parameters

    • options: any

      Options passed to the initial destroy call

    Returns void

  • Parameters

    • options: {} = {}

    Returns Promise<void>

  • Internal

    Obtain a shifted position for the Placeable Object.

    Parameters

    • dx: -1 | 0 | 1

      The number of grid units to shift along the X-axis

    • dy: -1 | 0 | 1

      The number of grid units to shift along the Y-axis

    • dz: -1 | 0 | 1

      The number of grid units to shift along the Z-axis

    Returns object

    The shifted target coordinates

  • Callback actions which occur on a single left-click event to assume control of the object

    Parameters

    • event: any

      The triggering canvas interaction event

    Returns boolean | void

  • Callback actions which occur on a mouse-move operation.

    Parameters

    • event: any

      The triggering mouse click event

    Returns boolean | void

    If false, the cancellation is prevented

  • Callback actions which occur on a mouse-move operation.

    Parameters

    • event: any

      The triggering canvas interaction event

    Returns false | void

  • Callback actions which occur on a mouse-move operation.

    Parameters

    • event: any

      The triggering canvas interaction event

    Returns void

  • Callback actions which occur when a mouse-drag action is first begun.

    Parameters

    • event: any

      The triggering canvas interaction event

    Returns boolean | void

    If false, the start if prevented

  • Define additional steps taken when an existing placeable object of this type is updated with new data

    Parameters

    • changed: any
    • options: any
    • userId: any

    Returns void

  • Internal

    Get the data of the copied object pasted at the position given by the offset. Called by foundry.canvas.layers.PlaceablesLayer#pasteObjects for each copied object.

    Parameters

    • offset: Point

      The offset relative from the current position to the destination

    • Optionaloptions: { hidden?: boolean; snap?: boolean } = {}
      • Optionalhidden?: boolean

        Paste in a hidden state, if applicable. Default is false.

      • Optionalsnap?: boolean

        Snap to the grid. Default is true.

    Returns object

    The update data

  • Internal

    Determine a new angle of rotation for a PlaceableObject either from an explicit angle or from a delta offset.

    Parameters

    • options: { angle?: number; delta?: number; snap?: number } = {}

      An object which defines the rotation update parameters

      • Optionalangle?: number

        An explicit angle, either this or delta must be provided

      • Optionaldelta?: number

        A relative angle delta, either this or the angle must be provided

      • Optionalsnap?: number

        A precision (in degrees) to which the resulting angle should snap. Default is 0.

    Returns number

    The new rotation angle for the object

  • Test whether a user can perform a certain interaction regarding a Placeable Object

    Parameters

    • user: documents.User

      The User performing the action. Must be equal to game.user.

    • action:
          | "update"
          | "delete"
          | "view"
          | "create"
          | "control"
          | "configure"
          | "hover"
          | "drag"
          | "HUD"

      The named action being attempted

    Returns boolean

    Does the User have rights to perform the action?

  • Clone the placeable object, returning a new object with identical attributes. The returned object is non-interactive, and has no assigned ID. If you plan to use it permanently you should call the create method.

    Returns PlaceableObject

    A new object with identical data

  • Assume control over a PlaceableObject, flagging it as controlled and enabling downstream behaviors

    Parameters

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

      Additional options which modify the control request

      • OptionalreleaseOthers?: boolean

        Release any other controlled objects first

    Returns boolean

    A flag denoting whether control was successful

  • Draw the placeable object into its parent container

    Parameters

    • Optionaloptions: object = {}

      Options which may modify the draw and refresh workflow

    Returns Promise<PlaceableObject>

    The drawn object

  • Get the snapped position for a given position or the current position.

    Parameters

    • Optionalposition: any

      The position to be used instead of the current position

    Returns Point

    The snapped position

  • Refresh all incremental render flags for the PlaceableObject. This method is no longer used by the core software but provided for backwards compatibility.

    Parameters

    • Optionaloptions: object = {}

      Options which may modify the refresh workflow

    Returns PlaceableObject

    The refreshed object

  • Release control over a PlaceableObject, removing it from the controlled set

    Parameters

    • options: object = {}

      Options which modify the releasing workflow

    Returns boolean

    A Boolean flag confirming the object was released.

  • Rotate the PlaceableObject to a certain angle of facing

    Parameters

    • angle: number

      The desired angle of rotation

    • snap: number

      Snap the angle of rotation to a certain target degree increment

    Returns Promise<PlaceableObject>

    The rotated object

  • Protected

    Does the User have permission to left-click drag this Placeable Object?

    Parameters

    • user: documents.User

      The User performing the action. Always equal to game.user.

    • event: FederatedEvent<UIEvent | PixiTouch>

      The pointer event

    • Optionaloptions: { notify: boolean } = {}

      Options, used internally

    Returns boolean

  • Protected

    Finalize the left-drag operation.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering mouse click event

    Returns void

  • Protected

    Finalize the right-drag operation.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering mouse click event

    Returns void

  • Protected

    Get the target opacity that should be used for a Placeable Object depending on its preview state.

    Returns number

  • Protected

    Initialize the left-drag operation.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering canvas interaction event

    Returns void

  • Protected

    Initialize the right-drag operation.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering canvas interaction event

    Returns void

  • Protected

    Callback actions which occur on a double left-click event to activate

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering canvas interaction event

    Returns void

  • Protected

    Callback actions which occur on a single right-click event to configure properties of the object

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering canvas interaction event

    Returns void

  • Protected

    Callback actions which occur on a double right-click event to configure properties of the object

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering canvas interaction event

    Returns void

  • Protected

    Additional events that trigger once control of the object is established

    Parameters

    • options: object

      Optional parameters which apply for specific implementations

    Returns void

  • Protected

    Register pending canvas operations which should occur after a new PlaceableObject of this type is created

    Parameters

    • data: object
    • options: object
    • userId: string

    Returns void

  • Protected

    Define additional steps taken when an existing placeable object of this type is deleted

    Parameters

    • options: object
    • userId: string

    Returns void

  • Protected

    Conclude a drag operation from the perspective of the preview clone. Modify the appearance of both the clone (this) and the original (_original) object.

    Returns void

  • Protected

    Callback actions which occur on a right mouse-drag operation.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering mouse click event

    Returns boolean | void

    If false, the cancellation is prevented

  • Protected

    Callback actions which occur on a right mouse-drag operation.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering canvas interaction event

    Returns void

  • Protected

    Callback actions which occur on a right mouse-drag operation.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering canvas interaction event

    Returns void

  • Protected

    Callback actions which occur on a right mouse-drag operation.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering mouse click event

    Returns false | void

    If false, the start if prevented

  • Protected

    Begin a drag operation from the perspective of the preview clone. Modify the appearance of both the clone (this) and the original (_original) object.

    Returns void

  • Protected

    Handle cancellation of a drag event for one of the resizing handles

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The mouseup event

    Returns void

  • Protected

    Handle mouseup after dragging a tile scale handler

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The mouseup event

    Returns void

  • Protected

    Handle mousemove while dragging a tile scale handler

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The mousemove event

    Returns void

  • Protected

    Handle the beginning of a drag event on a resize handle.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The mousedown event

    Returns void

  • Protected

    Handle mouse-over event on a control handle

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The mouseover event

    Returns void

  • Protected

    Handle mouse-out event on a control handle

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The mouseout event

    Returns void

  • Protected

    Actions that should be taken for this Placeable Object when a mouseover event occurs. Hover events on PlaceableObject instances allow event propagation by default.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering canvas interaction event

    • options: { hoverOutOthers?: boolean } = {}

      Options which customize event handling

      • OptionalhoverOutOthers?: boolean

        Trigger hover-out behavior on sibling objects

    Returns boolean | void

  • Protected

    Actions that should be taken for this Placeable Object when a mouseout event occurs

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering canvas interaction event

    Returns void

  • Protected

    Callback action which occurs on a long press.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering canvas interaction event

    • origin: Point

      The local canvas coordinates of the mousepress.

    Returns any

  • Protected

    Additional events which trigger once control of the object is released

    Parameters

    • options: object

      Options which modify the releasing workflow

    Returns void

  • Protected

    Callback actions which occur on a single left-unclick event to assume control of the object

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering canvas interaction event

    Returns void

  • Protected

    Callback actions which occur on a single right-unclick event

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering canvas interaction event

    Returns void

  • Protected

    Perform the database updates that should occur as the result of a drag-left-drop operation.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering canvas interaction event

    Returns null | object[] | [updates: object[], options?: object]

    An array of database updates to perform for documents in this collection

  • Protected

    Should the placeable propagate left click downstream?

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

    Returns boolean

  • Protected

    Should the placeable propagate right click downstream?

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

    Returns boolean

  • Protected

    Refresh the elevation.

    Returns void

  • Protected

    Refresh the border frame that encloses the Tile.

    Returns void

  • Protected

    Refresh the appearance of the tile.

    Returns void

  • Protected

    Refresh the position.

    Returns void

  • Protected

    Refresh the rotation.

    Returns any

  • Protected

    Refresh the size.

    Returns undefined | Graphics

  • Protected

    Refresh the displayed state of the Tile. Updated when the tile interaction state changes, when it is hidden, or when its elevation changes.

    Returns void

  • Protected

    Refresh changes to the video playback state.

    Returns void

  • Protected

    Callback actions which occur on a right mouse-drag operation.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The triggering mouse click event

    Returns false | void

    If false, the start if prevented

  • Internal

    Obtain the shifted position.

    Parameters

    • dx: -1 | 0 | 1

      The number of grid units to shift along the X-axis

    • dy: -1 | 0 | 1

      The number of grid units to shift along the Y-axis

    • dz: -1 | 0 | 1

      The number of grid units to shift along the Z-axis

    • position: ElevatedPoint

      The unsnapped position

    • snapped: ElevatedPoint

      The snapped position

    • grid: BaseGrid<GridCoordinates2D, GridCoordinates3D>

      The grid

    Returns ElevatedPoint

    The shifted target coordinates

  • Create a preview tile with a background texture instead of an image

    Parameters

    • data: object

      Initial data with which to create the preview Tile

    Returns PlaceableObject