ForegroundLayer

ForegroundLayer

An extension of the MapLayer that displays overhead in the foreground of the Scene.

Constructor

new ForegroundLayer()

Extends

Members

(static) layerOptions

_active :boolean

Inherited From:

Track whether the canvas layer is currently active for interaction

Type:
  • boolean

_controlled :Object

Inherited From:

Track the set of PlaceableObjects on this layer which are currently controlled by their id

Type:
  • Object

_copy :Array.<PlaceableObject>

Inherited From:

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

Type:

_hover :PlaceableObject

Inherited From:

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

Type:

bg :PIXI.Sprite

Inherited From:

The layer background image

Type:
  • PIXI.Sprite

bgPath :string

Inherited From:

The background source path

Type:
  • string

bgSource :HTMLImageElement|HTMLVideoElement

Inherited From:

Return the base HTML image or video element which is used to generate the background Sprite.

Type:
  • HTMLImageElement | HTMLVideoElement

controlled

Inherited From:

An Array of placeable objects in this layer which have the _controlled attribute

displayRoofs :boolean

Determine whether to display roofs

Type:
  • boolean

documentCollection :Collection|null

Inherited From:

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

Type:

gridPrecision

Inherited From:

Return the precision relative to the Scene grid with which Placeable objects should be snapped

history :Array.<CanvasHistory>

Inherited From:

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

Type:

isVideo :boolean

Inherited From:

Is the background texture used in this layer a video?

Type:
  • boolean

level :number

Inherited From:

The numeric Scene level to which this layer belongs

Type:
  • number

name :string

Inherited From:

The canonical name of the CanvasLayer

Type:
  • string

objects :PIXI.Container

Inherited From:

Placeable Layer Objects

Type:
  • PIXI.Container

options :Object

Inherited From:

PlaceableObject layer options

Type:
  • Object

placeables :Array.<PlaceableObject>

Inherited From:

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

Type:

preview

Inherited From:

Preview Object Placement

quadtree :Quadtree|null

Inherited From:

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

Type:

roofs

Get an array of overhead Tile objects which are roofs

tiles :Array.<Tile>

Inherited From:

An array of Tile objects which are rendered within the objects container

Type:

Methods

(async) _getDropData(event, data) → {object}

Overrides:

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

Parameters:
Name Type Description
event DragEvent

The concluding drag event

data object

The extracted Tile data

Returns:

The prepared data to create

Type
object

_onClickLeft()

Inherited From:
See:
  • {Canvas#_onClickLeft}

Handle left mouse-click events which originate from the Canvas stage and are dispatched to this Layer.

_onClickLeft2()

Inherited From:
See:

Handle double left-click events which originate from the Canvas stage and are dispatched to this Layer.

_onClickRight()

Inherited From:
See:
  • {Canvas#_onClickRight}

Handle right mouse-click events which originate from the Canvas stage and are dispatched to this Layer.

_onMouseWheel(event)

Inherited From:

Handle mouse-wheel events at the PlaceableObjects layer level to rotate multiple objects at once. This handler will rotate all controlled objects by some incremental angle.

Parameters:
Name Type Description
event MouseWheelEvent

The mousewheel event which originated the request

controlAll(options) → {Array.<PlaceableObject>}

Inherited From:

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

Parameters:
Name Type Description
options object

Options passed to the control method of each object

Returns:

An array of objects that were controlled

Type
Array.<PlaceableObject>

copyObjects() → {Array.<PlaceableObject>}

Inherited From:

Copy currently controlled PlaceableObjects to a temporary Array, ready to paste back into the scene later

Returns:

The Array of copied PlaceableObject instances

Type
Array.<PlaceableObject>

createObject() → {PlaceableObject}

Inherited From:

Draw a single placeable object

Returns:
Type
PlaceableObject

(async) deleteAll() → {Promise.<Array.<Document>>}

Inherited From:

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:

An array of Document objects which were deleted by the operation

Type
Promise.<Array.<Document>>

get(objectId) → {PlaceableObject}

Inherited From:

Get a PlaceableObject contained in this layer by it's ID

Parameters:
Name Type Description
objectId string

The ID of the contained object to retrieve

Returns:

The object instance, or undefined

Type
PlaceableObject

getDocuments() → {Array.<Document>}

Overrides:

Obtain an iterable of objects which should be added to this PlaceableLayer

Returns:
Type
Array.<Document>

getZIndex() → {number}

Overrides:

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

Returns:
Type
number

(async) moveMany(options) → {Promise.<Array.<PlaceableObject>>}

Inherited From:

Simultaneously move multiple PlaceableObjects via keyboard movement offsets. This executes a single database operation using Scene.update. If moving only a single object, this will delegate to PlaceableObject.update for performance reasons.

Parameters:
Name Type Description
options object

Options which configure how multiple objects are moved

Properties
Name Type Attributes Default Description
dx number <optional>
0

The number of incremental grid units in the horizontal direction

dy number <optional>
0

The number of incremental grid units in the vertical direction

rotate boolean <optional>
false

Rotate the token to the keyboard direction instead of moving

ids Array <optional>

An Array of object IDs to target for movement

Returns:

An array of objects which were moved during the operation

Type
Promise.<Array.<PlaceableObject>>

(async) pasteObjects(position, hiddenopt, snapopt) → {Promise.<Array.<Document>>}

Inherited From:

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

Parameters:
Name Type Attributes Description
position Point

The destination position for the copied data.

hidden boolean <optional>

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

snap boolean <optional>

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

Returns:

An Array of created Document instances

Type
Promise.<Array.<Document>>

refresh()

Refresh the display of tiles on the Foreground Layer depending on Token occlusion.

releaseAll(options) → {number}

Inherited From:

Release all controlled PlaceableObject instance from this layer.

Parameters:
Name Type Description
options object

Options passed to the release method of each object

Returns:

The number of PlaceableObject instances which were released

Type
number

(async) rotateMany(options) → {Promise.<Array.<PlaceableObject>>}

Inherited From:

Simultaneously rotate multiple PlaceableObjects using a provided angle or incremental. This executes a single database operation using Scene.update. If rotating only a single object, it is better to use the PlaceableObject.rotate instance method.

Parameters:
Name Type Description
options object

Options which configure how multiple objects are rotated

Properties
Name Type Attributes Description
angle number <optional>

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

delta number <optional>

An incremental angle of rotation (in degrees)

snap number <optional>

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

ids Array <optional>

An Array of object IDs to target for rotation

Returns:

An array of objects which were rotated

Type
Promise.<Array.<PlaceableObject>>

selectObjects(x, y, width, height, releaseOptions, controlOptions) → {boolean}

Inherited From:

Select all PlaceableObject instances which fall within a coordinate rectangle.

Parameters:
Name Type Description
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

Returns:

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

Type
boolean

storeHistory(type, data)

Inherited From:

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

Parameters:
Name Type Description
type string

The event type (create, update, delete)

data Array.<Object>

The object data

(async) undoHistory() → {Promise.<Array.<Document>>}

Inherited From:

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

Returns:

An array of documents which were modified by the undo operation

Type
Promise.<Array.<Document>>

(async) updateAll(transformation, condition, optionsopt) → {Promise.<Array.<Document>>}

Inherited From:

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

Parameters:
Name Type Attributes Default Description
transformation function | object

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

condition function | null null

A function which tests whether to target each object

options object <optional>

Additional options passed to Entity.update

Returns:

An array of updated data once the operation is complete

Type
Promise.<Array.<Document>>

updateOcclusion()

Update occlusion for all tiles on the foreground layer