Options
All
  • Public
  • Public/Protected
  • All
Menu

A Tile is an implementation of PlaceableObject which represents a static piece of artwork or prop within the Scene. Tiles are drawn inside the TilesLayer container.

see

TileDocument

see

TilesLayer

Hierarchy

Index

Constructors

  • new Tile(document: any): Tile

Properties

frame: any

The Tile border frame

property

{PIXI.Graphics} border

property

{ResizeHandle} handle

texture: Texture

The primary tile image texture

tile: Sprite

The Tile image sprite

bg: any

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

occluded: boolean = false

A flag which tracks whether the overhead tile is currently in an occluded state

_prevOccludedState: boolean = false

A flag which tracks occluded state change for roof

playing: boolean = ...

A flag which tracks if the Tile is currently playing

debounceSetOcclusion: ((arg0: occluded, arg1: boolean) => void) = ...

Type declaration

    • (arg0: occluded, arg1: boolean): void
    • Debounce assignment of the Tile occluded state to avoid cases like animated token movement which can rapidly change Tile appearance. Uses a 100ms debounce threshold.

      Parameters

      • arg0: occluded
      • arg1: boolean

      Returns void

mesh: any
hitArea: any
visible: boolean
_dragHandle: boolean
_dragScaleX: number
_dragScaleY: number
scene: Scene

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

document: Document

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

vision: { fov: Circle; los: PointSourcePolygon }

Track the field of vision for the placeable object. This is necessary to determine whether a player has line-of-sight towards a placeable object or vice-versa

Type declaration

controlIcon: ControlIcon

A control icon for interacting with the object

mouseInteractionManager: MouseInteractionManager

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

cullable: boolean
_isHoverIn: boolean = false

Know if a placeable is in the hover-in state.

internal
zIndex: number
alpha: number
_dragPassthrough: boolean = false

Passthrough certain drag operations on locked objects.

_textureData: { minX: number; minY: number; maxX: number; maxY: number; pixels: Uint8Array; texture: RenderTexture }

Contains :

  • the bounds of the tile data
  • the cached mapping of non-transparent pixels (if roof)
  • the filtered render texture (if roof)

Type declaration

  • minX: number
  • minY: number
  • maxX: number
  • maxY: number
  • pixels: Uint8Array
  • texture: RenderTexture
_linkedSprites: Map<number, Sprite> = ...

A map of all linked sprite(s) to this tile

#unlinkedVideo: boolean = false

A flag to capture whether this Tile has an unlinked video texture

#controlled: boolean = false
#hover: boolean = false
embeddedName: string = "Tile"

Identify the official Document name for this PlaceableObject class

ROOF_TYPES: { OCCLUSION: number; BACKGROUND: number; ILLUMINATION: number; COLORATION: number } = ...

Roof types

Type declaration

  • OCCLUSION: number
  • BACKGROUND: number
  • ILLUMINATION: number
  • COLORATION: number

Accessors

  • get aspectRatio(): number
  • Get the native aspect ratio of the base texture for the Tile sprite

    Returns number

  • override

    Returns Rectangle

  • get sourceElement(): HTMLImageElement | HTMLVideoElement
  • The HTML source element for the primary Tile texture

    Returns HTMLImageElement | HTMLVideoElement

  • get isVideo(): boolean
  • Does this Tile depict an animated video texture?

    Returns boolean

  • get isRoof(): boolean
  • Is this tile a roof?

    Returns boolean

  • get volume(): number
  • The effective volume at which this Tile should be playing, including the global ambient volume modifier

    Returns number

  • get interactionState(): { NONE: number; HOVER: number; CLICKED: number; DRAG: number; DROP: number }
  • The mouse interaction state of this placeable.

    Returns { NONE: number; HOVER: number; CLICKED: number; DRAG: number; DROP: number }

    • NONE: number
    • HOVER: number
    • CLICKED: number
    • DRAG: number
    • DROP: number
  • get center(): Point
  • The central coordinate pair of the placeable object based on it's own width and height

    Returns Point

  • get id(): string
  • The id of the corresponding Document which this PlaceableObject represents.

    Returns string

  • get objectId(): string
  • A unique identifier which is used to uniquely identify elements on the canvas related to this object.

    Returns string

  • 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 isPreview(): boolean
  • Is this placeable object a temporary preview?

    Returns boolean

  • The field-of-vision polygon for the object, if it has been computed

    Returns Circle

  • Provide a reference to the CanvasLayer which contains this PlaceableObject.

    Returns PlaceablesLayer

  • The line-of-sight polygon for the object, if it has been computed

    Returns PointSourcePolygon

  • A Form Application which is used to configure the properties of this Placeable Object or the Document it represents.

    Returns FormApplication

  • get controlled(): boolean
  • An indicator for whether the object is currently controlled

    Returns boolean

  • get hover(): boolean
  • set hover(state: boolean): void
  • An indicator for whether the object is currently a hover target

    Returns boolean

  • An indicator for whether the object is currently a hover target

    Parameters

    • state: boolean

    Returns void

Methods

  • _draw(): Promise<void>
  • _destroy(options: any): void
  • The inner _destroy method which may optionally be defined by each PlaceableObject subclass.

    Parameters

    • options: any

    Returns void

  • _refresh(options: any): void
  • testOcclusion(token: Token, [options]?: { corners: boolean }): boolean
  • Test whether a specific Token occludes this overhead tile. Occlusion is tested against 9 points, the center, the four corners-, and the four cardinal directions

    Parameters

    • token: Token

      The Token to test

    • [options]: { corners: boolean } = {}

      Additional options that affect testing

      • corners: boolean

    Returns boolean

    Is the Token occluded by the Tile?

  • containsPixel(x: number, y: number, alphaThreshold?: number): boolean
  • Test whether the Tile pixel data contains a specific point in canvas space

    Parameters

    • x: number
    • y: number
    • alphaThreshold: number = 0.75

      Value from which the pixel is taken into account, in the range [0, 1].

    Returns boolean

  • getPixelAlpha(x: number, y: number): number
  • Get alpha value at specific canvas coordinate.

    Parameters

    • x: number
    • y: number

    Returns number

    The alpha value (-1 if outside of the bounds) or null if no mesh or texture is present.

  • activateListeners(): void
  • _canConfigure(user: any, event: any): boolean
  • Does the User have permission to configure the Placeable Object?

    Parameters

    • user: any

      The User performing the action.

    • event: any

      The event object.

    Returns boolean

    The returned status.

  • _onHoverOut(event: any): boolean
  • Actions that should be taken for this Placeable Object when a mouseout event occurs

    Parameters

    • event: any

      The triggering canvas interaction event

    Returns boolean

  • _onClickLeft(event: any): boolean
  • 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

  • _onClickLeft2(event: any): void
  • Callback actions which occur on a double left-click event to activate

    Parameters

    • event: any

      The triggering canvas interaction event

    Returns void

  • _onDragLeftStart(event: any): any
  • Callback actions which occur when a mouse-drag action is first begun.

    Parameters

    • event: any

      The triggering canvas interaction event

    Returns any

  • _onDragLeftMove(event: any): any
  • Callback actions which occur on a mouse-move operation.

    Parameters

    • event: any

      The triggering canvas interaction event

    Returns any

  • _onDragLeftDrop(event: any): any
  • Callback actions which occur on a mouse-move operation.

    Parameters

    • event: any

      The triggering canvas interaction event

    Returns any

  • _onDragStart(): void
  • 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

  • _onDragEnd(): void
  • 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

  • _onDragLeftCancel(event: any): any
  • Callback actions which occur on a mouse-move operation.

    Parameters

    • event: any

      The triggering mouse click event

    Returns any

  • can(user: User, action: string): boolean
  • Test whether a user can perform a certain interaction regarding a Placeable Object

    Parameters

    • user: User

      The User performing the action

    • action: string

      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

  • destroy(options: any): any
  • control(options?: { releaseOthers: boolean }): boolean
  • Assume control over a PlaceableObject, flagging it as controlled and enabling downstream behaviors

    Parameters

    • options: { releaseOthers: boolean } = {}

      Additional options which modify the control request

      • releaseOthers: boolean

        Release any other controlled objects first

    Returns boolean

    A flag denoting whether control was successful

  • release(options?: any): boolean
  • Release control over a PlaceableObject, removing it from the controlled set

    Parameters

    • options: any = {}

      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

  • _updateRotation(options?: { angle: number; delta: number; snap: number }): number
  • 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

      • angle: number
      • delta: number
      • snap: number

    Returns number

    The new rotation angle for the object

  • _getShiftedPosition(dx: number, dy: number): { x: number; y: number }
  • Obtain a shifted position for the Placeable Object

    Parameters

    • dx: number

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

    • dy: number

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

    Returns { x: number; y: number }

    The shifted target coordinates

    • x: number
    • y: number
  • _onHoverIn(event: InteractionEvent, options?: { hoverOutOthers: boolean }): boolean
  • Actions that should be taken for this Placeable Object when a mouseover event occurs

    see

    MouseInteractionManager#_handleMouseOver

    Parameters

    • event: InteractionEvent

      The triggering canvas interaction event

    • options: { hoverOutOthers: boolean } = {}

      Options which customize event handling

      • hoverOutOthers: boolean

    Returns boolean

  • _onClickRight(event: InteractionEvent): void
  • Callback actions which occur on a single right-click event to configure properties of the object

    see

    MouseInteractionManager#_handleClickRight

    Parameters

    • event: InteractionEvent

      The triggering canvas interaction event

    Returns void

  • _onClickRight2(event: InteractionEvent): void
  • Callback actions which occur on a double right-click event to configure properties of the object

    see

    MouseInteractionManager#_handleClickRight2

    Parameters

    • event: InteractionEvent

      The triggering canvas interaction event

    Returns void

  • _refreshHandle(b: Rectangle, [options]?: { scaleX: number; scaleY: number }): void
  • Refresh the display of the Tile resizing handle.

    Parameters

    • b: Rectangle

      The bounds.

    • [options]: { scaleX: number; scaleY: number } = {}
      • scaleX: number
      • scaleY: number

    Returns void

  • _onHandleHoverIn(event: InteractionEvent): void
  • Handle mouse-over event on a control handle

    Parameters

    • event: InteractionEvent

      The mouseover event

    Returns void

  • _onHandleHoverOut(event: InteractionEvent): void
  • Handle mouse-out event on a control handle

    Parameters

    • event: InteractionEvent

      The mouseout event

    Returns void

  • _onHandleMouseDown(event: InteractionEvent): void
  • When we start a drag event - create a preview copy of the Tile for re-positioning

    Parameters

    • event: InteractionEvent

      The mousedown event

    Returns void

  • _onHandleDragStart(event: InteractionEvent): void
  • Handle the beginning of a drag event on a resize handle

    Parameters

    • event: InteractionEvent

      The mousedown event

    Returns void

  • _onHandleDragMove(event: InteractionEvent): void
  • Handle mousemove while dragging a tile scale handler

    Parameters

    • event: InteractionEvent

      The mousemove event

    Returns void

  • _onHandleDragDrop(event: InteractionEvent): any
  • Handle mouseup after dragging a tile scale handler

    Parameters

    • event: InteractionEvent

      The mouseup event

    Returns any

  • _onHandleDragCancel(): void
  • Handle cancellation of a drag event for one of the resizing handles

    Returns void

  • _canHUD(user: User, event: any): boolean
  • Can the User access the HUD for this Placeable Object?

    Parameters

    • user: User

      The User performing the action.

    • event: any

      The event object.

    Returns boolean

    The returned status.

  • _canControl(user: User, event: any): boolean
  • Does the User have permission to control the Placeable Object?

    Parameters

    • user: User

      The User performing the action.

    • event: any

      The event object.

    Returns boolean

    The returned status.

  • _canView(user: User, event: any): boolean
  • Does the User have permission to view details of the Placeable Object?

    Parameters

    • user: User

      The User performing the action.

    • event: any

      The event object.

    Returns boolean

    The returned status.

  • _canCreate(user: User, event: any): boolean
  • Does the User have permission to create the underlying Document?

    Parameters

    • user: User

      The User performing the action.

    • event: any

      The event object.

    Returns boolean

    The returned status.

  • _canDrag(user: User, event: any): boolean
  • Does the User have permission to drag this Placeable Object?

    Parameters

    • user: User

      The User performing the action.

    • event: any

      The event object.

    Returns boolean

    The returned status.

  • _canHover(user: User, event: any): boolean
  • Does the User have permission to hover on this Placeable Object?

    Parameters

    • user: User

      The User performing the action.

    • event: any

      The event object.

    Returns boolean

    The returned status.

  • _canUpdate(user: User, event: any): boolean
  • Does the User have permission to update the underlying Document?

    Parameters

    • user: User

      The User performing the action.

    • event: any

      The event object.

    Returns boolean

    The returned status.

  • _canDelete(user: User, event: any): boolean
  • Does the User have permission to delete the underlying Document?

    Parameters

    • user: User

      The User performing the action.

    • event: any

      The event object.

    Returns boolean

    The returned status.

  • _onCreate(data: any, options: any, userId: string): void
  • Register pending canvas operations which should occur after a new PlaceableObject of this type is created

    Parameters

    • data: any
    • options: any
    • userId: string

    Returns void

  • _onDelete(options: any, userId: string): void
  • Define additional steps taken when an existing placeable object of this type is deleted

    Parameters

    • options: any
    • userId: string

    Returns void

  • _onControl(options: any): void
  • Additional events which trigger once control of the object is established

    Parameters

    • options: any

      Optional parameters which apply for specific implementations

    Returns void

  • _onRelease(options: any): void
  • Additional events which trigger once control of the object is released

    Parameters

    • options: any

      Options which modify the releasing workflow

    Returns void

  • _onLongPress(event: InteractionEvent, origin: Point): any
  • Callback action which occurs on a long press.

    see

    MouseInteractionManager#_handleLongPress

    Parameters

    • event: InteractionEvent

      The triggering canvas interaction event

    • origin: Point

      The local canvas coordinates of the mousepress.

    Returns any

  • #refreshOcclusion(): void
  • Refresh the appearance of the occlusion state for tiles which are affected by a Token beneath them.

    Returns void

  • Refresh the display of the Tile border

    Parameters

    Returns void

  • #getTextureCoordinate(testX: number, testY: number): any
  • Get tile alpha map texture coordinate with canvas coordinate

    Parameters

    • testX: number

      Canvas x coordinate.

    • testY: number

      Canvas y coordinate.

    Returns any

    The texture {x, y} coordinates, or null if not able to do the conversion.

  • #getPixelAlpha(x: number, y: number): number
  • Get alpha value at specific texture coordinate.

    Parameters

    • x: number
    • y: number

    Returns number

    The alpha value (or -1 if outside of the bounds).

  • _createTextureData(): { minX: number; minY: number; maxX: number; maxY: number; pixels: Uint8Array }
  • Process the tile texture : Use the texture to create a cached mapping of pixel alpha for this Tile with real base texture size. Cache the bounding box of non-transparent pixels for the un-rotated shape.

    Returns { minX: number; minY: number; maxX: number; maxY: number; pixels: Uint8Array }

    • minX: number
    • minY: number
    • maxX: number
    • maxY: number
    • pixels: Uint8Array
  • Compute the alpha-based bounding box for the tile, including an angle of rotation.

    Returns Rectangle

  • _refreshPerception(): void
  • Update wall states and refresh lighting and vision when a tile becomes a roof, or when an existing roof tile's state changes.

    Returns void

  • _getResizedDimensions(event: any, origin: any, destination: any): Rectangle
  • Get resized Tile dimensions

    Parameters

    • event: any
    • origin: any
    • destination: any

    Returns Rectangle

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

    Parameters

    • data: any

      Initial data with which to create the preview Tile

    Returns PlaceableObject