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

    A Token is an implementation of PlaceableObject which represents an foundry.documents.Actor within a viewed Scene on the game canvas.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Accessors

    Methods

    _applyRenderFlags _canConfigure _canControl _canDrag _canHover _canHUD _canView _clear _configureFilterEffect _createSharedFogVisionSource _destroy _draw _finalizeDragLeft _getConfigMovementPosition _getDragOrigin _getDragWaypointPosition _getHUDMovementPosition _getShiftedPosition _initializeDragLeft _onClickLeft _onClickLeft2 _onClickRight2 _onCreate _onDelete _onDragEnd _onDragLeftCancel _onDragLeftDrop _onDragLeftMove _onHoverIn _onHoverOut _onRelease _onUpdate _overlapsSelection _partialDraw _pasteObject _prepareDragLeftDropUpdates _propagateLeftClick _refreshState _refreshVisibility _removeAllFilterEffects _updateQuadtree _updateRotation _updateSpecialStatusFilterEffects _updateTarget activateListeners animate applyRenderFlags can checkCollision clone constrainMovementPath control createTerrainMovementPath destroy draw drawBars drawEffects findMovementPath getCenterPoint getDispositionColor getLightRadius getRingColors getRingEffects getShape getSnappedPosition initializeLightSource initializeSources initializeVisionSource measureMovementPath recalculatePlannedMovementPath refresh release rotate setTarget stopAnimation _addDragWaypoint _canCreate _canDelete _canDragLeftStart _canUpdate _canViewMode _changeDragElevation _createInteractionManager _drawBar _drawEffect _drawEffects _drawOverlay _drawTargetArrows _drawTargetPips _finalizeDragRight _getAnimationData _getAnimationDuration _getAnimationMovementSpeed _getAnimationRotationSpeed _getAnimationTransition _getBorderColor _getDragConstrainOptions _getDragLeftDropUpdateOptions _getDragMeasureOptions _getDragMovementAction _getDragPathfindingOptions _getDragTerrainOptions _getHUDMovementAction _getKeyboardMovementAction _getLightSourceData _getMovementCostFunction _getTargetAlpha _getTextStyle _getTooltipText _getVisionBlindedStates _getVisionSourceData _initializeDragRight _initializeRuler _isFogExplorationSource _isLightSource _isVisionSource _modifyAnimationMovementSpeed _onAnimationUpdate _onApplyStatusEffect _onClickRight _onControl _onDragClickLeft _onDragClickLeft2 _onDragClickRight _onDragClickRight2 _onDragLeftStart _onDragMouseWheel _onDragRightCancel _onDragRightDrop _onDragRightMove _onDragRightStart _onDragStart _onLongPress _onUnclickLeft _onUnclickRight _prepareAnimation _propagateRightClick _refreshBorder _refreshEffects _refreshElevation _refreshMesh _refreshMeshSizeAndScale _refreshNameplate _refreshPosition _refreshRingVisuals _refreshRotation _refreshRuler _refreshShader _refreshShape _refreshSize _refreshTarget _refreshTooltip _refreshTurnMarker _removeDragWaypoint _renderDetectionFilter _requiresRotationAnimation _shouldPreventDragLeftDrop _triggerDragLeftCancel _triggerDragLeftDrop _updateDragDestination #onDragRightStart _configureAnimationMovementSpeed _getCopiedObjectsOrigin _getDropActorPosition _getShiftedPosition

    Constructors

    Properties

    _preventKeyboardMovement: boolean = false

    Prevent keyboard movement of this Token?

    _previewType:
        | "wheel"
        | "controls"
        | "dragging"
        | "creation"
        | "config"
        | "api"
        | null

    The preview type, if any.

    _visionSourceVersion: number = 0

    Vision version incremented each time vision (and light) are updated.

    bars: Container<DisplayObject>

    The attribute bars of this Token.

    border: Graphics

    A Graphics instance which renders the border frame for this Token inside the GridLayer.

    controlIcon: ControlIcon | null

    A control icon for interacting with the object

    detectionFilter: Filter | null = null

    Defines the filter to use for detection.

    detectionFilterMesh: Container<DisplayObject>

    Renders the mesh of with the detection filter.

    document: CanvasDocument

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

    effects: Container<DisplayObject>

    The effects icons of temporary ActiveEffects that are applied to the Actor of this Token.

    A reference to the LightSource object which defines this light source area of effect. This is undefined if the Token does not provide an active source of light.

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

    mouseInteractionManager: MouseInteractionManager | null

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

    nameplate: PreciseText

    The nameplate of this Token, which displays its name.

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

    ruler: BaseTokenRuler | null

    The ruler of this Token.

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

    shape: Rectangle | Polygon | Circle | Ellipse

    The shape of this token.

    targetArrows: Graphics

    The target arrows marker, which indicates that this Token is targeted by this User.

    targeted: Set<documents.User> = ...

    Track the set of User documents which are currently targeting this Token

    targetPips: Graphics

    The target pips marker, which indicates that this Token is targeted by other User(s).

    texture: Texture<Resource>

    The texture of this Token, which is used by its mesh.

    tooltip: PreciseText

    The tooltip text of this Token, which contains its elevation.

    turnMarker: TokenTurnMarker | null = null

    The Turn Marker of this Token. Only a subset of Token objects have a turn marker at any given time.

    A reference to the VisionSource object which defines this vision source area of effect. This is undefined if the Token does not provide an active source of vision.

    voidMesh: Container<DisplayObject>

    Renders the mesh of this Token with ERASE blending in the Token.

    _plannedMovement: { [userId: string]: TokenPlannedMovement } = {}

    The ruler data.

    embeddedName: string = "Token"

    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[] };
        redrawEffects: {};
        refresh: { alias: boolean; propagate: string[] };
        refreshBars: {};
        refreshBorder: {};
        refreshEffects: {};
        refreshElevation: { propagate: string[] };
        refreshMesh: { propagate: string[] };
        refreshNameplate: {};
        refreshPosition: {};
        refreshRingVisuals: {};
        refreshRotation: {};
        refreshRuler: {};
        refreshShader: {};
        refreshShape: { propagate: string[] };
        refreshSize: { propagate: string[] };
        refreshState: { propagate: string[] };
        refreshTarget: {};
        refreshTooltip: {};
        refreshTransform: { alias: boolean; propagate: string[] };
        refreshTurnMarker: {};
        refreshVisibility: {};
    } = ...

    Accessors

    • get _original(): PlaceableObject | undefined

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

      Returns PlaceableObject | undefined

    • get actor(): documents.Actor | null

      A convenient reference to the Actor object associated with the Token embedded document.

      Returns documents.Actor | null

    • get animationName(): string

      The general animation name used for this Token.

      Returns string

    • get bounds(): Rectangle

      Returns Rectangle

    • get brightRadius(): number

      Translate the token's bright light distance in units into a radius in pixels.

      Returns number

    • get center(): Point

      Returns Point

    • get combatant(): documents.Combatant | null

      Return a reference to a Combatant that represents this Token, if one is present in the current encounter.

      Returns documents.Combatant | null

    • get controlled(): boolean

      An indicator for whether the object is currently controlled

      Returns boolean

    • get dimRadius(): number

      Translate the token's dim light distance in units into a radius in pixels.

      Returns number

    • get emitsDarkness(): boolean

      Does this token actively emit darkness given its properties and the current darkness level of the Scene?

      Returns boolean

    • get emitsLight(): boolean

      Does this token actively emit light given its properties and the current darkness level of the Scene?

      Returns boolean

    • get externalRadius(): number

      The external radius of the token in pixels.

      Returns number

    • get h(): number

      Translate the token's grid height into a pixel height based on the canvas size

      Returns number

    • get hasActiveHUD(): boolean

      Is the HUD display active for this Placeable?

      Returns boolean

    • get hasDynamicRing(): boolean

      A convenience boolean to test whether the Token is using a dynamic ring.

      Returns boolean

    • get hasLimitedSourceAngle(): boolean

      Test whether the Token uses a limited angle of vision or light emission.

      Returns boolean

    • get hasPreview(): boolean

      Does there exist a temporary preview of this placeable object?

      Returns boolean

    • get hasSight(): boolean

      Test whether the Token has sight (or blindness) at any radius

      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 inCombat(): boolean

      An indicator for whether or not this token is currently involved in the active combat encounter.

      Returns boolean

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

      The mouse interaction state of this placeable.

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

    • get isDragged(): boolean

      Is this Token currently being dragged?

      Returns boolean

    • get isInteractable(): boolean

      Returns boolean

    • 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 isTargeted(): boolean

      An indicator for whether the Token is currently targeted by the active game User

      Returns boolean

    • get isVideo(): boolean

      Does this Tile depict an animated video texture?

      Returns boolean

    • get isVisible(): boolean

      Determine whether the Token is visible to the calling user's perspective. Hidden Tokens are only displayed to GM Users. Non-hidden Tokens are always visible if Token Vision is not required. Controlled tokens are always visible. All Tokens are visible to a GM user if no Token is controlled.

      Returns boolean

    • get layer(): PlaceablesLayer

      Provide a reference to the CanvasLayer which contains this PlaceableObject.

      Returns PlaceablesLayer

    • get lightPerceptionRange(): number

      The range of this token's light perception in pixels.

      Returns number

    • get movementAnimationName(): string

      The animation name used to animate this Token's movement.

      Returns string

    • get movementAnimationPromise(): Promise<void> | null

      The promise of the current movement animation chain of this Token or null if there isn't a movement animation in progress.

      Returns Promise<void> | null

    • get name(): string

      Convenience access to the token's nameplate string

      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 observer(): boolean

      A boolean flag for whether the current game User has observer permission for the Token

      Returns boolean

    • get optimalSightRange(): number

      Translate the token's maximum vision range that takes into account lights.

      Returns number

    • get previewType(): "dragging" | "controls|"

      The preview type, if any.

      Returns "dragging" | "controls|"

    • get radius(): number

      The maximum radius in pixels of the light field

      Returns number

    • get ring(): TokenRing | null

      A TokenRing instance which is used if this Token applies a dynamic ring. This property is null if the Token does not use a dynamic ring.

      Returns TokenRing | null

    • get sheet(): DocumentSheetV2

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

      Returns DocumentSheetV2

    • get showRuler(): boolean

      Should the ruler of this Token be visible?

      Returns boolean

    • get sightRange(): number

      Translate the token's vision range in units into a radius in pixels.

      Returns number

    • get sourceElement(): ImageSource | null

      The HTML source element for the primary Tile texture

      Returns ImageSource | null

    • get sourceId(): string

      Returns string

    • get w(): number

      Translate the token's grid width into a pixel width based on the canvas size

      Returns number

    • get implementation(): typeof PlaceableObject

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

      Returns typeof PlaceableObject

    Methods

    • Apply render flags before a render occurs.

      Parameters

      • flags: any

        The render flags which must be applied

      Returns void

    • Parameters

      • user: any
      • event: any

      Returns boolean | undefined

    • Parameters

      • user: any
      • event: any

      Returns boolean

    • Parameters

      • user: any
      • event: any

      Returns boolean | undefined

    • Internal

      Add/Modify a filter effect on this token.

      Parameters

      • statusId: string

        The status effect ID being applied, from CONFIG.specialStatusEffects

      • active: boolean

        Is the special status effect now active?

      Returns void

    • 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: any

      Returns Promise<void>

    • Finalize the left-drag operation.

      Parameters

      • event: any

        The triggering mouse click event

      Returns void

    • Internal

      Get the origin of the drag operation.

      Returns Point

    • Internal

      Obtain a shifted waypoint for the Token. The returned waypoint must move the Token to a snapped 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

      Returns Partial<TokenPosition>

      The shifted target waypoint (snapped if square/hexagonal grid)

    • Initialize the left-drag operation.

      Parameters

      • event: any

        The triggering canvas interaction event

      Returns void

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

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

      Parameters

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

      Returns void

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

      Parameters

      • options: any
      • userId: any

      Returns 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 | undefined

    • 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: any

        The triggering canvas or DOM interaction event

      • options: any

        Options which customize event handling

      Returns boolean | void

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

      Parameters

      • event: any

        The triggering canvas or DOM interaction event

      • options: any

        Options which customize event handling

      Returns void

    • Additional events which trigger once control of the object is released

      Parameters

      • options: any

        Options which modify the releasing workflow

      Returns void

    • 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

    • Parameters

      • offset: any
      • __namedParameters: { hidden?: boolean; snap?: boolean } = {}

      Returns { elevation: any; hidden: any; level: string | null; x: number; y: number }

    • Parameters

      • event: any

      Returns (
          | { _id: string }[]
          | {
              _result?: (string | object)[];
              _updateData?: Record<string, object>;
              action?: "update";
              animate?: boolean;
              animation?: {
                  duration?: number;
                  easing?: CanvasAnimationEasingFunction;
                  linkToMovement?: boolean;
                  movementSpeed?: number;
              };
              autoRotate?: boolean;
              broadcast?: boolean;
              constrainOptions?: Omit<
                  TokenConstrainMovementPathOptions,
                  "preview"
                  | "history"
                  | "measureOptions",
              >;
              diff?: boolean;
              documentName?: string;
              dryRun?: boolean;
              extractedImages?: Record<string, string>;
              measureOptions?: Omit<TokenMeasureMovementPathOptions, "preview">;
              method: string;
              modifiedTime?: number;
              movement: {};
              noHook?: boolean;
              pack?: string | null;
              pan?:
                  | boolean
                  | { duration?: number; force?: boolean; transitionType?: string };
              parent?: Document<object, DocumentConstructionContext> | null;
              parentUuid?: string | null;
              planned?: boolean;
              recursive?: boolean;
              render?: boolean;
              showRuler?: boolean;
              terrainOptions?: Omit<TokenCreateTerrainMovementPathOptions, "preview">;
          }
      )[]

      • { _id: string }[]
      • {
            _result?: (string | object)[];
            _updateData?: Record<string, object>;
            action?: "update";
            animate?: boolean;
            animation?: {
                duration?: number;
                easing?: CanvasAnimationEasingFunction;
                linkToMovement?: boolean;
                movementSpeed?: number;
            };
            autoRotate?: boolean;
            broadcast?: boolean;
            constrainOptions?: Omit<
                TokenConstrainMovementPathOptions,
                "preview"
                | "history"
                | "measureOptions",
            >;
            diff?: boolean;
            documentName?: string;
            dryRun?: boolean;
            extractedImages?: Record<string, string>;
            measureOptions?: Omit<TokenMeasureMovementPathOptions, "preview">;
            method: string;
            modifiedTime?: number;
            movement: {};
            noHook?: boolean;
            pack?: string | null;
            pan?:
                | boolean
                | { duration?: number; force?: boolean; transitionType?: string };
            parent?: Document<object, DocumentConstructionContext> | null;
            parentUuid?: string | null;
            planned?: boolean;
            recursive?: boolean;
            render?: boolean;
            showRuler?: boolean;
            terrainOptions?: Omit<TokenCreateTerrainMovementPathOptions, "preview">;
        }
        • Optional_result?: (string | object)[]

          Used internally by the server-side backend

        • Optional_updateData?: Record<string, object>

          Used internally by the server-side backend

        • Optionalaction?: "update"

          The action of this database operation

        • Optionalanimate?: boolean

          Animate movement. Default: true.

        • Optionalanimation?: {
              duration?: number;
              easing?: CanvasAnimationEasingFunction;
              linkToMovement?: boolean;
              movementSpeed?: number;
          }

          The animation options.

          • Optionalduration?: number

            The duration of the animation in milliseconds (nonnegative).

          • Optionaleasing?: CanvasAnimationEasingFunction

            The easing function of the animation of non-movement properties. Default: undefined (linear).

          • OptionallinkToMovement?: boolean

            Set the duration of non-movement properties to the animation.

          • OptionalmovementSpeed?: number

            The base movement speed in grid size per second (positive).

        • OptionalautoRotate?: boolean

          Automatically rotate the token in the direction of movement? Default: game.settings.get("core", "tokenAutoRotate") if method is "dragging" or "keyboard" otherwise false.

        • Optionalbroadcast?: boolean

          Whether the database operation is broadcast to other connected clients

        • OptionalconstrainOptions?: Omit<
              TokenConstrainMovementPathOptions,
              "preview"
              | "history"
              | "measureOptions",
          >

          The options to constrain movement.

        • Optionaldiff?: boolean

          Difference each update object against current Document data and only use differential data for the update operation

        • OptionaldocumentName?: string

          The Document name

        • OptionaldryRun?: boolean

          Is the operation a dry run? If so, an empty result array is returned before the Documents are updated.

        • OptionalextractedImages?: Record<string, string>

          Base64 images extracted during server-side processing

        • OptionalmeasureOptions?: Omit<TokenMeasureMovementPathOptions, "preview">

          The options to measure movement.

        • method: string
        • OptionalmodifiedTime?: number

          The timestamp when the operation was performed

        • movement: {}
        • OptionalnoHook?: boolean

          Block the dispatch of hooks related to this operation

        • Optionalpack?: string | null

          A compendium collection ID which contains the Documents

        • Optionalpan?: boolean | { duration?: number; force?: boolean; transitionType?: string }

          Pan the canvas (with transition animation) to the destination if the token is controlled? Default: true.

        • Optionalparent?: Document<object, DocumentConstructionContext> | null

          A parent Document within which Documents are embedded

        • OptionalparentUuid?: string | null

          A parent Document UUID provided when the parent instance is unavailable

        • Optionalplanned?: boolean

          Don't start the movement yet? Default: false.

        • Optionalrecursive?: boolean

          Merge objects recursively. If false, inner objects will be replaced explicitly. Use with caution!

        • Optionalrender?: boolean

          Re-render Applications whose display depends on the created Documents

        • OptionalshowRuler?: boolean

          Show the ruler during the movement animation of the token? Default: true if method is "dragging" otherwise false. duration of movement. Default: false.

        • OptionalterrainOptions?: Omit<TokenCreateTerrainMovementPathOptions, "preview">

          The terrain movement options.

    • Refresh the displayed state of the placeable. Used to update aspects of the placeable which change based on the user interaction state.

      Returns void

    • Internal

      Remove all filter effects on this placeable.

      Returns void

    • Parameters

      • __namedParameters: { delta?: number; snap?: number } = {}

      Returns number

    • Internal

      Update the filter effects depending on special status effects TODO: replace this method by something more convenient.

      Returns void

    • Internal

      Handle updating the targeting state of this Token for a particular User.

      Parameters

      • targeted: boolean

        Is the token now targeted?

      • user: documents.User

        The user whose targeting state has changed

      Returns void

    • Animate from the old to the new state of this Token.

      Parameters

      Returns Promise<void>

      A promise which resolves once the animation has finished or stopped

    • 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:
            | "view"
            | "create"
            | "update"
            | "delete"
            | "control"
            | "hover"
            | "drag"
            | "configure"
            | "HUD"

        The named action being attempted

      Returns boolean

      Does the User have rights to perform the action?

    • Check for collision when attempting a move to a new position.

      The result of this function must not be affected by the animation of this Token.

      Parameters

      • destination: Point | ElevatedPoint

        The central destination point of the attempted movement. The elevation defaults to the elevation of the origin.

      • Optionaloptions: {
            mode?: "any" | "closest" | "all";
            origin?: Point | ElevatedPoint;
            type?: PointSourcePolygonType;
        } = {}

        Additional options forwarded to PointSourcePolygon.testCollision

        • Optionalmode?: "any" | "closest" | "all"

          The collision mode to test: "any", "all", or "closest"

        • Optionalorigin?: Point | ElevatedPoint

          The origin to be used instead of the current origin. The elevation defaults to the current elevation.

        • Optionaltype?: PointSourcePolygonType

          The collision type

      Returns boolean | PolygonVertex | PolygonVertex[] | null

      The collision result depends on the mode of the test: * any: returns a boolean for whether any collision occurred * all: returns a sorted array of PolygonVertex instances * closest: returns a PolygonVertex instance or null

    • 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: {
            force?: boolean;
            isNew?: boolean;
            releaseOthers?: boolean;
            renderSidebar?: boolean;
        } = {}

        Additional options which modify the control request

        • Optionalforce?: boolean

          Control the object even if it is not interactable?

        • OptionalisNew?: boolean

          Was this object just created?

        • OptionalreleaseOthers?: boolean

          Release any other controlled objects first

        • OptionalrenderSidebar?: boolean

          Re-render the sidebar.

      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

    • Refresh the display of Token attribute bars, rendering its latest resource data. If the bar attribute is valid (has a value and max), draw the bar. Otherwise hide it.

      Returns void

    • Draw the effect icons for ActiveEffect documents which apply to the Token's Actor.

      Returns Promise<PlaceableObject>

    • Find a movement path through the waypoints. The path may not necessarily be one with the least cost. The path returned may be partial, i.e. it doesn't go through all waypoints, but must always start with the first waypoints unless the waypoints are empty, in which case an empty path is returned.

      The result of this function must not be affected by the animation of this Token.

      Parameters

      Returns TokenFindMovementPathJob

      The job of the movement pathfinder

    • Get the center point of the Token.

      Parameters

      • Optionalposition: Point

        The position in pixels

      Returns Point

      The center point

    • Get the Color used to represent the disposition of this Token.

      Returns number

    • A generic transformation to turn a certain number of grid units into a radius in canvas pixels. This function adds additional padding to the light radius equal to the external radius of the token. This causes light to be measured from the outer token edge, rather than from the center-point.

      Parameters

      • units: number

        The radius in grid units

      Returns number

      The radius in pixels

    • Override ring colors for this particular Token instance.

      Returns {}

    • Get the shape of this Token.

      Returns Rectangle | Polygon | Circle | Ellipse

    • Update an emitted light source associated with this Token.

      Parameters

      • Optionaloptions: { deleted?: boolean } = {}
        • Optionaldeleted?: boolean

          Indicate that this light source has been deleted.

      Returns void

    • Update the light and vision source objects associated with this Token.

      Parameters

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

        Options which configure how perception sources are updated

        • Optionaldeleted?: boolean

          Indicate that this light and vision source has been deleted

      Returns void

    • Update the VisionSource instance associated with this Token.

      Parameters

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

        Options which affect how the vision source is updated

        • Optionaldeleted?: boolean

          Indicate that this vision source has been deleted.

      Returns void

    • Recalculate the planned movement path of this Token for the current User.

      Returns void

    • 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: { renderSidebar?: boolean } = {}

        Options which modify the releasing workflow

        • OptionalrenderSidebar?: boolean

          Re-render the sidebar.

      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

    • Set this Token as an active target for the current game User.

      Parameters

      • targeted: boolean = true

        Is the Token now targeted?

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

        Additional option which modify how targets are acquired

        • OptionalreleaseOthers?: boolean

          Release other active targets?

      Returns void

    • Terminate the animations of this particular Token, if exists.

      Parameters

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

        Additional options.

        • Optionalreset?: boolean

          Reset the TokenDocument?

      Returns void

    • Protected

      Add ruler waypoints and update ruler paths.

      Parameters

      • point: Point

        The (unsnapped) center point of the waypoint

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

        Additional options

        • Optionalsnap?: boolean

          Snap the added waypoint?

      Returns void

    • 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

      Change the elevation of the dragged Tokens.

      Parameters

      • delta: number

        The number vertical steps

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

        Additional options

        • Optionalprecise?: boolean

          Round elevations to multiples of the grid distance divided by CONFIG.Canvas.elevationSnappingPrecision? If false, rounds to multiples of the grid distance.

      Returns void

    • Protected

      Draw a single resource bar, given provided data

      Parameters

      • index: number

        The Bar index

      • bar: Graphics

        The Bar container

      • data: object

        Resource data for this bar

      Returns void

    • Protected

      Draw a status effect icon

      Parameters

      • src: string
      • tint: ColorSource | null

      Returns Promise<Sprite | undefined>

    • Protected

      Draw the effect icons for ActiveEffect documents which apply to the Token's Actor. Called by Token#drawEffects.

      Returns Promise<void>

    • Protected

      Draw the overlay effect icon

      Parameters

      • src: string
      • tint: number | null

      Returns Promise<Sprite>

    • Protected

      Draw the targeting arrows around this token.

      Parameters

      • Optionalreticule: ReticuleOptions = {}

        Additional parameters to configure how the targeting reticule is drawn.

      Returns void

    • Protected

      Draw the targeting pips around this token.

      Returns void

    • Protected

      Finalize the right-drag operation.

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The triggering mouse click event

      Returns void

    • Protected

      Get the base movement speed for the animation in grid size per second. The default implementation returns CONFIG.Token.movement.defaultSpeed.

      Parameters

      Returns number

      The base movement speed in grid size per second

    • Protected

      Get the rotation speed for the animation in 60 degrees per second. Returns the movement speed by default.

      Parameters

      Returns number

      The rotation speed in 60 degrees per second

    • Protected

      Get the hex color that should be used to render the Token border

      Returns number

      The hex color used to depict the border color

    • Protected

      Get the constrain options used during the drag operation.

      Returns Omit<
          TokenConstrainMovementPathOptions,
          "preview"
          | "history"
          | "measureOptions",
      >

      The constrain options

    • Protected

      Get the movement action for the waypoints placed during a drag operation.

      Returns string

      The movement action

    • Protected

      Get the movement action in CONFIG.Token.movement.actions to be used for keyboard movement. The default implementation returns this.document.movementAction.

      Returns string

    • Protected

      Create the movement cost function for this Token. In square and hexagonal grids it calculates the cost for single grid space move between two grid space offsets. For tokens that occupy more than one grid space the cost of movement is calculated as the median of all individual grid space moves unless the cost of any of these is infinite, in which case total cost is always infinite. In gridless grids the from and to parameters of the cost function are top-left offsets. If the movement cost function is undefined, the cost equals the distance moved.

      Parameters

      Returns void | TokenMovementCostFunction

    • Protected

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

      Returns number

    • Protected

      Get the text style that should be used for this Token's tooltip.

      Returns TextStyle

    • Protected

      Return the text which should be displayed in a token's tooltip field

      Returns string

    • Protected

      Returns a record of blinding state.

      Returns Record<string, boolean>

    • Protected

      Initialize the right-drag operation.

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The triggering canvas interaction event

      Returns void

    • Protected

      Create the BaseTokenRuler instance for this Token, if any. This function is called when the Token is drawn for the first time.

      Returns BaseTokenRuler | null

    • Protected

      Test whether this Token should contribute to shared Fog of War exploration.

      Returns boolean

    • Protected

      Does this Token actively emit light given its properties and the current darkness level of the Scene?

      Returns boolean

    • Protected

      Test whether this Token is a viable vision source for the current User.

      Returns boolean

    • Protected

      Modify the base movement speed of the animation. Divides by the terrain difficulty, if present, by default.

      Parameters

      • speed: number

        The base movement speed in grid size per second

      • options: TokenAnimationOptions

        The options that configure the animation behavior

      Returns number

      The modified movement speed in grid size per second

    • Protected

      Handle changes to Token behavior when a significant status effect is applied

      Parameters

      • statusId: string

        The status effect ID being applied, from CONFIG.specialStatusEffects

      • active: boolean

        Is the special status effect now active?

      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

      Additional events that trigger once control of the object is established

      Parameters

      • options: {
            pan?: boolean | { duration?: number; transitionType?: string };
            releaseOthers?: boolean;
        } = {}

        Optional parameters which apply for specific implementations

        • Optionalpan?: boolean | { duration?: number; transitionType?: string }

          Pan to the controlled Token

        • OptionalreleaseOthers?: boolean

          Release control of all other Tokens

      Returns void

    • Protected

      Called by foundry.canvas.layers.TokenLayer#_onClickLeft while this Token is in a drag workflow.

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The pointerdown event

      Returns void

    • Protected

      Called by foundry.canvas.layers.TokenLayer#_onClickLeft2 while this Token is in a drag workflow.

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The pointerdown event

      Returns void

    • Protected

      Called by foundry.canvas.layers.TokenLayer#_onClickRight while this Token is in a drag workflow.

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The pointerdown event

      Returns void

    • Protected

      Called by foundry.canvas.layers.TokenLayer#_onClickRight2 while this Token is in a drag workflow.

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The pointerdown event

      Returns void

    • Protected

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

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The triggering canvas interaction event

      Returns boolean | void

      If false, the start if prevented

    • Protected

      Change the elevation of Token during dragging.

      Parameters

      • event: WheelEvent

        The mousewheel 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 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

      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

      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

      Should the placeable propagate right click downstream?

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

      Returns boolean

    • Protected

      Refresh the border.

      Returns void

    • Protected

      Refresh the display of status effects, adjusting their position for the token width and height.

      Returns void

    • Protected

      Refresh the elevation

      Returns void

    • Protected

      Refresh the token mesh.

      Returns void

    • Protected

      Resize mesh and handle scale adjustment.

      Returns void

    • Protected

      Refresh the text content, position, and visibility of the Token nameplate.

      Returns void

    • Protected

      Refresh the position.

      Returns void

    • Protected

      Refresh the token ring visuals if necessary.

      Returns void

    • Protected

      Refresh the rotation.

      Returns void

    • Protected

      Refresh the display of the ruler.

      Returns void

    • Protected

      Refresh the token mesh shader.

      Returns void

    • Protected

      Refresh the shape.

      Returns void

    • Protected

      Refresh the size.

      Returns void

    • Protected

      Refresh the target indicators for the Token. Draw both target arrows for the primary User and indicator pips for other Users targeting the same Token.

      Returns void

    • Protected

      Refresh the tooltip.

      Returns void

    • Protected

      Refresh presentation of the Token's combat turn marker, if any.

      Returns void

    • Protected

      Remove last ruler waypoints and update ruler paths.

      Returns void

    • Protected

      Render the bound mesh detection filter. Note: this method does not verify that the detection filter exists.

      Parameters

      • renderer: Renderer

      Returns void

    • Protected

      Does this Token require rotation changes to be animated? If false is returned, the rotation speed is set to infinity.

      Returns boolean

    • Protected

      Prevent the drop event? Called by Token#_onDragLeftDrop.

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The pointerup event

      Returns boolean

    • Protected

      Cancel the drag workflow. This cancellation cannot be prevented by Token#_onDragLeftCancel.

      Returns void

    • Protected

      Update the destinations of the drag previews and rulers

      Parameters

      • point: Point

        The (unsnapped) center point of the waypoint

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

        Additional options

        • Optionalsnap?: boolean

          Snap the destination?

      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