The Walls canvas layer which provides a container for Wall objects within the rendered Scene.

Hierarchy (view full)

Properties

chain: Graphics = null

A graphics layer used to display chained Wall selection

_chain: boolean = false

Track whether we are currently within a chained placement workflow

objects: any = null

Placeable Layer Objects

preview: any = null

Preview Object Placement

history: CanvasHistory[] = []

Keep track of history so that CTRL+Z can undo changes

_copy: PlaceableObject[] = []

Keep track of an object copied with CTRL+C which can be pasted later

quadtree: Quadtree = ...

A Quadtree which partitions and organizes Walls into quadrants for efficient target identification.

highlightObjects: boolean = false

Track whether "highlight all objects" is currently active

eventMode: string = "passive"
options: {
    name: string;
} = ...

Options for this layer instance.

Type declaration

  • name: string
_cloneType: Object = null

Track the most recently created or updated wall data for use with the clone tool

last: {
    point: PointArray;
} = ...

Reference the last interacted wall endpoint for the purposes of chaining

Type declaration

  • point: PointArray
#grid: BaseGrid = canvas.grid

The grid used for snapping. It's the same as canvas.grid except in the gridless case where this is the square version of the gridless grid.

#drawing: Promise<CanvasLayer> = ...

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

#drawn: boolean = false

Is the layer drawn?

documentName: string = "Wall"

A reference to the named Document type which is contained within this Canvas Layer.

SORT_ORDER: number = 0

Sort order for placeables belonging to this layer.

CREATION_STATES: {
    NONE: number;
    POTENTIAL: number;
    CONFIRMED: number;
    COMPLETED: number;
} = ...

Creation states affected to placeables during their construction.

Type declaration

  • NONE: number
  • POTENTIAL: number
  • CONFIRMED: number
  • COMPLETED: number

Accessors

  • get hookName(): string
  • The name used by hooks to construct their hook string. Note: You should override this getter if hookName should not return the class constructor name.

    Returns string

  • get doors(): Wall[]
  • An Array of Wall instances in the current Scene which act as Doors.

    Returns Wall[]

  • get documentCollection(): any
  • Obtain a reference to the Collection of embedded Document instances within the currently viewed Scene

    Returns any

  • get hud(): BasePlaceableHUD<any, any, any>
  • If objects on this PlaceablesLayer have a HUD UI, provide a reference to its instance

    Returns BasePlaceableHUD<any, any, any>

  • get placeables(): PlaceableObject[]
  • A convenience method for accessing the placeable object instances contained in this layer

    Returns PlaceableObject[]

  • get controlled(): PlaceableObject[]
  • An Array of placeable objects in this layer which have the _controlled attribute

    Returns PlaceableObject[]

  • get controlledObjects(): Map<string, PlaceableObject>
  • Track the set of PlaceableObjects on this layer which are currently controlled.

    Returns Map<string, PlaceableObject>

  • get hover(): PlaceableObject
  • Track the PlaceableObject on this layer which is currently hovered upon.

    Returns PlaceableObject

  • get active(): boolean
  • Is this layer currently active

    Returns boolean

  • get name(): string
  • The canonical name of the CanvasLayer is the name of the constructor that is the immediate child of the defined baseClass for the layer type.

    Returns string

    Example

    canvas.lighting.name -> "LightingLayer"
    
  • get layerOptions(): object
  • Configuration options for the PlaceablesLayer.

    Returns object

  • get placeableClass(): Function
  • Obtain a reference to the PlaceableObject class definition which represents the Document type in this layer.

    Returns Function

  • get instance(): CanvasLayer
  • Return a reference to the active instance of this canvas layer

    Returns CanvasLayer

Methods

  • Parameters

    • options: any

    Returns Promise<void>

  • Release all controlled PlaceableObject instance from this layer.

    Parameters

    • options: any

      Options passed to the release method of each object

    Returns number

    The number of PlaceableObject instances which were released

  • Internal

    Get the wall endpoint coordinates for a given point.

    Parameters

    • point: Point

      The candidate wall endpoint.

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

        Snap to the grid?

    Returns [x: number, y: number]

    The wall endpoint coordinates.

  • Identify the interior enclosed by the given walls.

    Parameters

    • walls: Wall[]

      The walls that enclose the interior.

    Returns Polygon[]

    The polygons of the interior.

    License

    MIT

  • Get the maximum sort value of all placeables.

    Returns number

    The maximum sort value (-Infinity if there are no objects)

  • Internal

    Send the controlled objects of this layer to the back or bring them to the front.

    Parameters

    • front: boolean

      Bring to front instead of send to back?

    Returns boolean

    Returns true if the layer has sortable object, and false otherwise

  • Obtain an iterable of objects which should be added to this PlaceablesLayer

    Returns Document[]

  • The inner _tearDown method which may be customized by each CanvasLayer subclass.

    Parameters

    • options: any

      Options which configure how the layer is deconstructed

    Returns Promise<void>

  • Clear the contents of the preview container, restoring visibility of original (non-preview) objects.

    Returns void

  • Get a PlaceableObject contained in this layer by its ID. Returns undefined if the object doesn't exist or if the canvas is not rendering a Scene.

    Parameters

    • objectId: string

      The ID of the contained object to retrieve

    Returns PlaceableObject

    The object instance, or undefined

  • Acquire control over all PlaceableObject instances which are visible and controllable within the layer.

    Parameters

    • options: object = {}

      Options passed to the control method of each object

    Returns PlaceableObject[]

    An array of objects that were controlled

  • Simultaneously rotate multiple PlaceableObjects using a provided angle or incremental. This executes a single database operation using Scene#updateEmbeddedDocuments.

    Parameters

    • options: {
          angle: number;
          delta: number;
          snap: number;
          ids: any[];
          includeLocked: boolean;
      } = {}

      Options which configure how multiple objects are rotated

      • angle: number

        A target angle of rotation (in degrees) where zero faces "south"

      • delta: number

        An incremental angle of rotation (in degrees)

      • snap: number

        Snap the resulting angle to a multiple of some increment (in degrees)

      • ids: any[]

        An Array of object IDs to target for rotation

      • includeLocked: boolean

        Rotate objects whose documents are locked?

    Returns Promise<PlaceableObject[]>

    An array of objects which were rotated

    Throws

    An error if an explicitly provided id is not valid

  • Simultaneously move multiple PlaceableObjects via keyboard movement offsets. This executes a single database operation using Scene#updateEmbeddedDocuments.

    Parameters

    • options: {
          dx: -1 | 0 | 1;
          dy: -1 | 0 | 1;
          rotate: boolean;
          ids: string[];
          includeLocked: boolean;
      } = {}

      Options which configure how multiple objects are moved

      • dx: -1 | 0 | 1

        Horizontal movement direction

      • dy: -1 | 0 | 1

        Vertical movement direction

      • rotate: boolean

        Rotate the placeable to direction instead of moving

      • ids: string[]

        An Array of object IDs to target for movement. The default is the IDs of controlled objects.

      • includeLocked: boolean

        Move objects whose documents are locked?

    Returns Promise<PlaceableObject[]>

    An array of objects which were moved during the operation

    Throws

    An error if an explicitly provided id is not valid

  • Internal

    An internal helper method to identify the array of PlaceableObjects which can be moved or rotated.

    Parameters

    • ids: string[]

      An explicit array of IDs requested.

    • includeLocked: boolean

      Include locked objects which would otherwise be ignored?

    Returns PlaceableObject[]

    An array of objects which can be moved or rotated

    Throws

    An error if any explicitly requested ID is not valid

  • Undo a change to the objects in this layer This method is typically activated using CTRL+Z while the layer is active

    Returns Promise<Document[]>

    An array of documents which were modified by the undo operation

  • A helper method to prompt for deletion of all PlaceableObject instances within the Scene Renders a confirmation dialogue to confirm with the requester that all objects will be deleted

    Returns Promise<Document[]>

    An array of Document objects which were deleted by the operation

  • Record a new CRUD event in the history log so that it can be undone later

    Parameters

    • type: string

      The event type (create, update, delete)

    • data: Object[]

      The object data

    Returns void

  • Paste currently copied PlaceableObjects back to the layer by creating new copies

    Parameters

    • position: Point

      The destination position for the copied data.

    • Optional options: {
          hidden: boolean;
          snap: boolean;
      } = {}

      Options which modify the paste operation

      • hidden: boolean

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

      • snap: boolean

        Snap the resulting objects to the grid. Default is true.

    Returns Promise<Document[]>

    An Array of created Document instances

  • Select all PlaceableObject instances which fall within a coordinate rectangle.

    Parameters

    • Optional options: {
          x: number;
          y: number;
          width: number;
          height: number;
          releaseOptions: object;
          controlOptions: object;
      } = {}
      • x: number

        The top-left x-coordinate of the selection rectangle.

      • y: number

        The top-left y-coordinate of the selection rectangle.

      • width: number

        The width of the selection rectangle.

      • height: number

        The height of the selection rectangle.

      • releaseOptions: object

        Optional arguments provided to any called release() method.

      • controlOptions: object

        Optional arguments provided to any called control() method.

    • Optional aoptions: {
          releaseOthers: boolean;
      } = {}

      Additional options to configure selection behaviour.

      • releaseOthers: boolean

        Whether to release other selected objects.

    Returns boolean

    A boolean for whether the controlled set was changed in the operation.

  • Update all objects in this layer with a provided transformation. Conditionally filter to only apply to objects which match a certain condition.

    Parameters

    • transformation: object | Function

      An object of data or function to apply to all matched objects

    • condition: Function = null

      A function which tests whether to target each object

    • Optional options: object = {}

      Additional options passed to Document.update

    Returns Promise<Document[]>

    An array of updated data once the operation is complete

  • Internal

    Create a preview of this layer's object type from a world document and show its sheet to be finalized.

    Parameters

    • createData: object

      The data to create the object with.

    • Optional options: {
          renderSheet: boolean;
          top: number;
          left: number;
      } = {}

      Options which configure preview creation

      • renderSheet: boolean

        Render the preview object config sheet?

      • top: number

        The offset-top position where the sheet should be rendered

      • left: number

        The offset-left position where the sheet should be rendered

    Returns PlaceableObject

    The created preview object

  • Activate the InteractionLayer, deactivating other layers and marking this layer's children as interactive.

    Parameters

    • Optional options: {
          tool: string;
      } = {}

      Options which configure layer activation

      • tool: string

        A specific tool in the control palette to set as active

    Returns InteractionLayer

    The layer instance, now activated

  • Get the zIndex that should be used for ordering this layer vertically relative to others in the same Container.

    Returns number

  • Draw the canvas layer, rendering its internal components and returning a Promise. The Promise resolves to the drawn layer once its contents are successfully rendered.

    Parameters

    • Optional options: object = {}

      Options which configure how the layer is drawn

    Returns Promise<CanvasLayer>

  • Deconstruct data used in the current layer in preparation to re-draw the canvas

    Parameters

    • Optional options: object = {}

      Options which configure how the layer is deconstructed

    Returns Promise<CanvasLayer>

  • Protected

    Get the world-transformed drop position.

    Parameters

    • event: DragEvent
    • Optional options: {
          center: boolean;
      } = {}
      • center: boolean

        Return the coordinates of the center of the nearest grid element.

    Returns boolean | number[]

    Returns the transformed x, y coordinates, or false if the drag event was outside the canvas.

  • Protected

    Handle double left-click events which originate from the Canvas stage.

    Parameters

    • event: FederatedEvent

      The PIXI InteractionEvent which wraps a PointerEvent

    Returns void

    See

    Canvas.#onClickLeft2

  • Private

    Pan the canvas view when the cursor position gets close to the edge of the frame

    Parameters

    • event: MouseEvent

      The originating mouse movement event

    • x: number

      The x-coordinate

    • y: number

      The y-coordinate

    Returns any

  • Private

    The Scene Controls tools provide several different types of prototypical Walls to choose from This method helps to translate each tool into a default wall data configuration for that type

    Parameters

    • tool: string

      The active canvas tool

    Returns Object

  • Given a point and the coordinates of a wall, determine which endpoint is closer to the point

    Parameters

    • point: Point

      The origin point of the new Wall placement

    • wall: Wall

      The existing Wall object being chained to

    Returns PointArray

    The [x,y] coordinates of the starting endpoint