A Region is an implementation of PlaceableObject which represents a Region document within a viewed Scene on the game canvas.

See

-

Hierarchy (view full)

Properties

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

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.

#highlight: RegionMesh

The highlight of this Region.

#border: Graphics

The border of this Region.

#original: PlaceableObject

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

#lastQuadtreeBounds: Rectangle

The bounds that the placeable was added to the quadtree with.

#drawing: Promise<PlaceableObject> = ...

An internal reference to a Promise in-progress to draw the Placeable Object.

#drawn: boolean = false

Has this Placeable Object been drawn and is there no drawing in progress?

embeddedName: string = "Region"

Identify the official Document name for this PlaceableObject class

RENDER_FLAGS: {
    redraw: {
        propagate: string[];
    };
    refresh: {
        propagate: string[];
        alias: boolean;
    };
    refreshState: {};
    refreshBorder: {};
} = ...

Type declaration

  • redraw: {
        propagate: string[];
    }
    • propagate: string[]
  • refresh: {
        propagate: string[];
        alias: boolean;
    }
    • propagate: string[]
    • alias: boolean
  • refreshState: {}
    • refreshBorder: {}
      #SHARED_POINT: Point = ...

      A temporary point used by this class.

      Accessors

      • get shapes(): readonly RegionShape[]
      • The shapes of this Region in draw order.

        Returns readonly RegionShape[]

      • get bottom(): number
      • The bottom elevation of this Region.

        Returns number

      • get top(): number
      • The top elevation of this Region.

        Returns number

      • get polygons(): readonly Polygon[]
      • The polygons of this Region.

        Returns readonly Polygon[]

      • get polygonTree(): RegionPolygonTree
      • The polygon tree of this Region.

        Returns RegionPolygonTree

      • get clipperPaths(): readonly (readonly IntPoint[])[]
      • The Clipper paths of this Region.

        Returns readonly (readonly IntPoint[])[]

      • get triangulation(): Readonly<{
            vertices: Float32Array;
            indices: Uint16Array | Uint32Array;
        }>
      • The triangulation of this Region.

        Returns Readonly<{
            vertices: Float32Array;
            indices: Uint16Array | Uint32Array;
        }>

      • get geometry(): RegionGeometry
      • The geometry of this Region.

        Returns RegionGeometry

      • get bounds(): any
      • Returns any

      • get center(): any
      • Returns any

      • get isVisible(): boolean
      • Is this Region currently visible on the Canvas?

        Returns boolean

      • get _original(): PlaceableObject
      • The object that this object is a preview of if this object is a preview.

        Returns PlaceableObject

      • get isOwner(): boolean
      • A convenient reference for whether the current User has full control over the document.

        Returns boolean

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

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

        • NONE: number
        • HOVER: number
        • CLICKED: number
        • GRABBED: number
        • DRAG: number
        • DROP: number
      • 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

      • get hasPreview(): boolean
      • Does there exist a temporary preview of this placeable object?

        Returns boolean

      • get layer(): PlaceablesLayer
      • Provide a reference to the CanvasLayer which contains this PlaceableObject.

        Returns PlaceablesLayer

      • get sheet(): FormApplication
      • 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
      • An indicator for whether the object is currently a hover target

        Returns boolean

      • get hasActiveHUD(): boolean
      • Is the HUD display active for this Placeable?

        Returns boolean

      Methods

      • Parameters

        • options: any

        Returns Promise<void>

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

        Parameters

        • options: any

          Optional parameters which apply for specific implementations

        Returns void

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

        Parameters

        • options: any

          Options which modify the releasing workflow

        Returns void

      • 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 interaction event

        • __namedParameters: {
              updateLegend: boolean;
          } = {}

          Options which customize event handling

          • updateLegend: boolean

        Returns void

        See

        MouseInteractionManager##handlePointerOver

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

        Parameters

        • event: any

          The triggering canvas interaction event

        • __namedParameters: {
              updateLegend: boolean;
          } = {}
          • updateLegend: boolean

        Returns void

        See

        MouseInteractionManager##handlePointerOut

      • Test whether the given point (at the given elevation) is inside this Region.

        Parameters

        • point: Point

          The point.

        • Optional elevation: number

          The elevation of the point.

        Returns boolean

        Is the point (at the given elevation) inside this Region?

      • Split the movement into its segments.

        Parameters

        • waypoints: RegionMovementWaypoint[]

          The waypoints of movement.

        • samples: Point[]

          The points relative to the waypoints that are tested. Whenever one of them is inside the region, the moved object is considered to be inside the region.

        • Optional options: {
              teleport: boolean;
          } = {}

          Additional options

          • teleport: boolean

            Is it teleportation?

        Returns RegionMovementSegment[]

        The movement split into its segments.

      • 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

      • Draw the placeable object into its parent container

        Parameters

        • Optional options: object = {}

          Options which may modify the draw and refresh workflow

        Returns Promise<PlaceableObject>

        The drawn object

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

        Parameters

        • Optional options: object = {}

          Options which may modify the refresh workflow

        Returns PlaceableObject

        The refreshed object

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

      • 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

      • 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

      • 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

          • angle: number

            An explicit angle, either this or delta must be provided

          • delta: number

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

          • snap: number

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

        Returns number

        The new rotation angle for the object

      • 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

        Returns Point

        The shifted target coordinates

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

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

        Parameters

        • event: FederatedEvent

          The triggering canvas interaction event

        Returns object[]

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

      • Protected

        Refresh the state of the Region.

        Returns void

      • Protected

        Refresh the border of the Region.

        Returns void

      • Protected

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

        Parameters

        • Optional options: object

          Options passed to the initial destroy call

        Returns void

      • Protected

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

        Returns number

      • 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

        Does the User have permission to configure the Placeable Object?

        Parameters

        • user: User

          The User performing the action.

        • event: object

          The event object.

        Returns boolean

        The returned status.

      • Protected

        Does the User have permission to control the Placeable Object?

        Parameters

        • user: User

          The User performing the action.

        • event: object

          The event object.

        Returns boolean

        The returned status.

      • Protected

        Does the User have permission to view details of the Placeable Object?

        Parameters

        • user: User

          The User performing the action.

        • event: object

          The event object.

        Returns boolean

        The returned status.

      • Protected

        Does the User have permission to create the underlying Document?

        Parameters

        • user: User

          The User performing the action.

        • event: object

          The event object.

        Returns boolean

        The returned status.

      • Protected

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

        Parameters

        • user: User

          The User performing the action.

        • event: object

          The event object.

        Returns boolean

        The returned status.

      • Protected

        Does the User have permission to hover on this Placeable Object?

        Parameters

        • user: User

          The User performing the action.

        • event: object

          The event object.

        Returns boolean

        The returned status.

      • Protected

        Does the User have permission to update the underlying Document?

        Parameters

        • user: User

          The User performing the action.

        • event: object

          The event object.

        Returns boolean

        The returned status.

      • Protected

        Does the User have permission to delete the underlying Document?

        Parameters

        • user: User

          The User performing the action.

        • event: object

          The event object.

        Returns boolean

        The returned status.

      • Protected

        Should the placeable propagate left click downstream?

        Parameters

        • event: FederatedEvent

        Returns boolean

      • Protected

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

        Parameters

        • event: FederatedEvent

          The triggering canvas interaction event

        Returns void

        See

        MouseInteractionManager##handleClickLeft

      • Protected

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

        Parameters

        • event: FederatedEvent

          The triggering canvas interaction event

        Returns void

      • Protected

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

        Parameters

        • event: FederatedEvent

          The triggering canvas interaction event

        Returns void

        See

        MouseInteractionManager##handleClickLeft2

      • Protected

        Should the placeable propagate right click downstream?

        Parameters

        • event: FederatedEvent

        Returns boolean

      • Protected

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

        Parameters

        • event: FederatedEvent

          The triggering canvas interaction event

        Returns void

        See

        MouseInteractionManager##handleClickRight

      • Protected

        Callback actions which occur on a single right-unclick event

        Parameters

        • event: FederatedEvent

          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

          The triggering canvas interaction event

        Returns void

        See

        MouseInteractionManager##handleClickRight2

      • Protected

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

        Parameters

        • event: FederatedEvent

          The triggering canvas interaction event

        Returns void

        See

        MouseInteractionManager##handleDragStart

      • 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

        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 mouse-move operation.

        Parameters

        • event: FederatedEvent

          The triggering canvas interaction event

        Returns void

        See

        MouseInteractionManager##handleDragMove

      • Protected

        Callback actions which occur on a mouse-move operation.

        Parameters

        • event: FederatedEvent

          The triggering canvas interaction event

        Returns boolean

        See

        MouseInteractionManager##handleDragDrop

      • Protected

        Callback actions which occur on a mouse-move operation.

        Parameters

        • event: FederatedEvent

          The triggering mouse click event

        Returns void

        See

        MouseInteractionManager##handleDragCancel

      • Protected

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

        Parameters

        • event: FederatedEvent

          The triggering mouse click event

        Returns any

        See

        MouseInteractionManager##handleDragStart

      • Protected

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

        Parameters

        • event: FederatedEvent

          The triggering canvas interaction event

        Returns any

        See

        MouseInteractionManager##handleDragMove

      • Protected

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

        Parameters

        • event: FederatedEvent

          The triggering canvas interaction event

        Returns Promise<any>

        See

        MouseInteractionManager##handleDragDrop

      • Protected

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

        Parameters

        • event: FederatedEvent

          The triggering mouse click event

        Returns any

        See

        MouseInteractionManager##handleDragCancel

      • Protected

        Callback action which occurs on a long press.

        Parameters

        • event: FederatedEvent

          The triggering canvas interaction event

        • origin: Point

          The local canvas coordinates of the mousepress.

        Returns any

        See

        MouseInteractionManager##handleLongPress

      • Initialize the Region.

        Returns void

      • Update the shapes of this region.

        Returns void

      • Create the Clipper polygon tree for this Region.

        Returns PolyTree

      • Build the Clipper batches.

        Returns {
            paths: IntPoint[][];
            fillType: PolyFillType;
            clipType: ClipType;
        }[]

      • Get the teleporation segment from the origin to the destination.

        Parameters

        • originX: number

          The x-coordinate of the origin.

        • originY: number

          The y-coordinate of the origin.

        • originElevation: number

          The elevation of the destination.

        • destinationX: number

          The x-coordinate of the destination.

        • destinationY: number

          The y-coordinate of the destination.

        • destinationElevation: number

          The elevation of the destination.

        • samples: Point[]

          The samples relative to the position.

        Returns void | RegionMovementSegment

        The teleportation segment, if any.

      • Test whether one of the samples relative to the given position is contained within this Region.

        Parameters

        • x: number

          The x-coordinate of the position.

        • y: number

          The y-coordinate of the position.

        • samples: Point[]

          The samples relative to the position.

        Returns boolean

        Is one of the samples contained within this Region?

      • Split the movement into its segments.

        Parameters

        • originX: number

          The x-coordinate of the origin.

        • originY: number

          The y-coordinate of the origin.

        • originElevation: number

          The elevation of the destination.

        • destinationX: number

          The x-coordinate of the destination.

        • destinationY: number

          The y-coordinate of the destination.

        • destinationElevation: number

          The elevation of the destination.

        • samples: Point[]

          The samples relative to the position.

        Returns {
            start: number;
            end: number;
        }[]

        The intervals where we have an intersection.

      • Test whether the movement could intersect this Region.

        Parameters

        • originX: number

          The x-coordinate of the origin.

        • originY: number

          The y-coordinate of the origin.

        • destinationX: number

          The x-coordinate of the destination.

        • destinationY: number

          The y-coordinate of the destination.

        • samples: Point[]

          The samples relative to the position.

        Returns boolean

        Could the movement intersect?

      • Compute the intervals of intersection of the movement.

        Parameters

        • originX: number

          The x-coordinate of the origin.

        • originY: number

          The y-coordinate of the origin.

        • destinationX: number

          The x-coordinate of the destination.

        • destinationY: number

          The y-coordinate of the destination.

        • samples: Point[]

          The samples relative to the position.

        Returns {
            start: number;
            end: number;
        }[]

        The intervals where we have an intersection.

      • Find the crossing (enter or exit) at the current position between the start and end position, if possible. The current position should be very close to crossing, otherwise we test a lot of pixels potentially. We use Bresenham's line algorithm to walk forward/backwards to find the crossing.

        Parameters

        • startX: number

          The start x-coordinate.

        • startY: number

          The start y-coordinate.

        • currentX: number

          The current x-coordinate.

        • currentY: number

          The current y-coordinate.

        • endX: number

          The end x-coordinate.

        • endY: number

          The end y-coordinate.

        • samples: boolean

          The samples.

        • enter: boolean

          Find enter? Otherwise find exit.

        Returns [from: {
            x: number;
            y: number;
            inside: boolean;
        }, to: {
            x: number;
            y: number;
            inside: boolean;
        }]

      • Perform database updates using the result of a drag-left-drop operation.

        Parameters

        • updates: object[]

          The database updates for documents in this collection

        Returns Promise<void>