A PlaceablesLayer designed for rendering the visual Scene for a specific vertical cross-section.

Hierarchy (View Summary)

Properties

_configPreview: null | Container<DisplayObject> = null

Preview container for config previews

clipboard: { cut: boolean; objects: PlaceableObject[] } = ...

Keep track of objects copied with CTRL+C/X which can be pasted later.

eventMode: string = "passive"
highlightObjects: boolean = false

Track whether "highlight all objects" is currently active

history: CanvasHistoryEvent[] = []

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

interactiveChildren: boolean = false

Whether this event target has any children that need UI events. This can be used optimize event propagation.

objects: null | Container<DisplayObject> = null

Placeable Layer Objects

options: { name: string } = ...

Options for this layer instance.

preview: null | Container<DisplayObject> = null

Preview Object Placement

quadtree: null | Quadtree = ...

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

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

Creation states affected to placeables during their construction.

documentName: string = "Tile"

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.

Accessors

  • get active(): boolean

    Is this layer currently active

    Returns boolean

  • 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 documentCollection(): null | DocumentCollection

    Obtain a reference to the Collection of embedded Document instances within the currently viewed Scene

    Returns null | DocumentCollection

  • get hasPreview(): boolean

    To know wheter this layer has a preview object or not.

    Returns boolean

  • 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 hover(): null | PlaceableObject

    Track the PlaceableObject on this layer which is currently hovered upon.

    Returns null | PlaceableObject

  • get hud(): TileHUD

    If objects on this PlaceablesLayer have a HUD UI, provide a reference to its instance

    Returns TileHUD

  • 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

    canvas.lighting.name -> "LightingLayer"
    
  • get placeables(): PlaceableObject[]

    A convenience method for accessing the placeable object instances contained in this layer

    Returns PlaceableObject[]

  • get instance(): CanvasLayer

    Return a reference to the active instance of this canvas layer

    Returns CanvasLayer

  • get layerOptions(): object

    Configuration options for the PlaceablesLayer.

    Returns object

  • get placeableClass(): typeof PlaceableObject

    Obtain a reference to the PlaceableObject class definition which represents the Document type in this layer.

    Returns typeof PlaceableObject

Methods

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

    • Optionaloptions: { left?: number; renderSheet?: boolean; top?: number } = {}

      Options which configure preview creation

      • Optionalleft?: number

        The offset-left position where the sheet should be rendered

      • OptionalrenderSheet?: boolean

        Render the preview object config sheet?

      • Optionaltop?: number

        The offset-top position where the sheet should be rendered

    Returns PlaceableObject

    The created preview object

  • Parameters

    • options: any

    Returns Promise<void>

  • Internal

    An internal helper method to identify the array of PlaceableObjects which can be copied/cut.

    Parameters

    • options: { cut: boolean }

      Additional options

      • cut: boolean

        Cut instead of copy?

    Returns PlaceableObject[]

    An array of objects which can be copied/cut

  • Prepare the data object when a new Tile is dropped onto the canvas

    Parameters

    • event: DragEvent

      The concluding drag event

    • data: object

      The extracted Tile data

    Returns object

    The prepared data to create

  • Internal

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

    Parameters

    • ids: undefined | 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

    If any explicitly requested ID is not valid

  • 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

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

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

    Parameters

    • Optionaloptions: { tool?: string } = {}

      Options which configure layer activation

      • Optionaltool?: string

        A specific tool in the control palette to set as active

    Returns InteractionLayer

    The layer instance, now activated

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

    Returns void

  • 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

  • Copy (or cut) currently controlled PlaceableObjects, ready to paste back into the Scene later.

    Parameters

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

      Additional options

      • Optionalcut?: boolean

        Cut instead of copy?

    Returns readonly PlaceableObject[]

    The Array of copied PlaceableObject instances

  • 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

  • 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

    • Optionaloptions: object = {}

      Options which configure how the layer is drawn

    Returns Promise<CanvasLayer>

  • 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

  • Get the maximum sort value of all placeables.

    Returns number

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

  • Snaps the given point to grid. The layer defines the snapping behavior.

    Parameters

    • point: any

      The point that is to be snapped

    Returns any

    The snapped point

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

    Returns number

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

    Parameters

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

      Options which configure how multiple objects are moved

      • Optionaldx?: 0 | 1 | -1

        Horizontal movement direction

      • Optionaldy?: 0 | 1 | -1

        Vertical movement direction

      • Optionaldz?: 0 | 1 | -1

        Movement direction along the z-axis (elevation)

      • Optionalids?: string[]

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

      • OptionalincludeLocked?: boolean

        Move objects whose documents are locked?

      • Optionalrotate?: boolean

        Rotate the placeable to direction instead of moving

    Returns Promise<PlaceableObject[]>

    An array of objects which were moved during the operation

    An error if an explicitly provided id is not valid

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

    Parameters

    • position: Point

      The destination position for the copied data.

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

      Options which modify the paste operation

      • Optionalhidden?: boolean

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

      • Optionalsnap?: boolean

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

    Returns Promise<Document[]>

    An Array of created Document instances

  • Release all controlled PlaceableObject instance from this layer.

    Parameters

    • options: object = {}

      Options passed to the release method of each object

    Returns number

    The number of PlaceableObject instances which were released

  • 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;
          ids?: any[];
          includeLocked?: boolean;
          snap?: number;
      } = {}

      Options which configure how multiple objects are rotated

      • Optionalangle?: number

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

      • Optionaldelta?: number

        An incremental angle of rotation (in degrees)

      • Optionalids?: any[]

        An Array of object IDs to target for rotation

      • OptionalincludeLocked?: boolean

        Rotate objects whose documents are locked?

      • Optionalsnap?: number

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

    Returns Promise<PlaceableObject[]>

    An array of objects which were rotated

    An error if an explicitly provided id is not valid

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

    Parameters

    • Optionaloptions: {
          controlOptions?: object;
          height?: number;
          releaseOptions?: object;
          width?: number;
          x?: number;
          y?: number;
      } = {}
      • OptionalcontrolOptions?: object

        Optional arguments provided to any called control() method.

      • Optionalheight?: number

        The height of the selection rectangle.

      • OptionalreleaseOptions?: object

        Optional arguments provided to any called release() method.

      • Optionalwidth?: number

        The width of the selection rectangle.

      • Optionalx?: number

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

      • Optionaly?: number

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

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

      Additional options to configure selection behaviour.

      • OptionalreleaseOthers?: boolean

        Whether to release other selected objects.

    Returns boolean

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

  • Assign a set of render flags to all placeables in this layer.

    Parameters

    • flags: Record<string, boolean>

      The flags to set

    Returns void

  • Record a new CRUD event in the history log so that it can be undone later. The base implemenation calls PlaceablesLayer#_storeHistory without passing the given options. Subclasses may override this function and can call PlaceablesLayer#_storeHistory themselves to pass options as needed.

    Parameters

    • type: "update" | "delete" | "create"

      The event type

    • data: object[]

      The create/update/delete data

    • Optionaloptions: object

      The create/update/delete options

    Returns void

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

    Parameters

    • Optionaloptions: object = {}

      Options which configure how the layer is deconstructed

    Returns Promise<CanvasLayer>

  • 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

  • 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: null | Function = null

      A function which tests whether to target each object

    • Optionaloptions: object = {}

      Additional options passed to Document.update

    Returns Promise<Document[]>

    An array of updated data once the operation is complete

  • Protected

    Get the world-transformed drop position.

    Parameters

    • event: DragEvent
    • Optionaloptions: { center?: boolean } = {}
      • Optionalcenter?: 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<UIEvent | PixiTouch>

      The PIXI InteractionEvent which wraps a PointerEvent

    Returns void

  • Protected

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

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The PIXI InteractionEvent which wraps a PointerEvent

    Returns void

  • Protected

    Handle a Cycle View keypress while this layer is active.

    Parameters

    • event: KeyboardEvent

      The cycle-view key press event

    Returns boolean

    Was the event handled?

  • Protected

    Undo creation with deletion workflow

    Parameters

    • event: Event

    Returns Promise<Document[]>

    An array of documents which were modified by the undo operation

  • Protected

    Undo deletion with creation workflow.

    Parameters

    • event: Event

    Returns Promise<Document[]>

    An array of documents which were modified by the undo operation

  • Protected

    Undo updates with update workflow.

    Parameters

    • event: Event

    Returns Promise<Document[]>

    An array of documents which were modified by the undo operation

  • Protected

    Record a new CRUD event in the history log so that it can be undone later. Updates without changes are filtered out unless the diff option is set to false. This function may not be overridden.

    Parameters

    • type: "update" | "delete" | "create"

      The event type

    • data: object[]

      The create/update/delete data

    • Optionaloptions: object = {}

      The options of the undo operation

    Returns void

  • Returns {
        activeTool: string;
        icon: string;
        layer: string;
        name: string;
        onChange: (event: any, active: any) => void;
        onToolChange: () => any;
        order: number;
        title: string;
        tools: {
            browse: {
                button: boolean;
                icon: string;
                name: string;
                onChange: () => Promise<FilePicker>;
                order: number;
                title: string;
                toolclip: {
                    heading: string;
                    items: ToolclipConfigurationItem[];
                    src: string;
                };
            };
            foreground: {
                active: boolean;
                icon: string;
                name: string;
                onChange: (event: any, active: any) => void;
                order: number;
                title: string;
                toggle: boolean;
            };
            select: {
                icon: string;
                name: string;
                order: number;
                title: string;
                toolclip: {
                    heading: string;
                    items: ToolclipConfigurationItem[];
                    src: string;
                };
            };
            snap: {
                active: boolean;
                icon: string;
                name: string;
                onChange: (event: any, toggled: any) => any;
                order: number;
                title: string;
                toggle: boolean;
                visible: boolean;
            };
            tile: {
                icon: string;
                name: string;
                order: number;
                title: string;
                toolclip: {
                    heading: string;
                    items: ToolclipConfigurationItem[];
                    src: string;
                };
            };
        };
        visible: boolean;
    }