Extends
Members
(static) layerOptions
_active :boolean
- Overrides:
Track whether the canvas layer is currently active for interaction
Type:
- boolean
_chain :boolean
Track whether we are currently within a chained placement workflow
Type:
- boolean
_controlled :Object
- Overrides:
Track the set of PlaceableObjects on this layer which are currently controlled by their id
Type:
- Object
_copy :Array.<PlaceableObject>
- Overrides:
Keep track of an object copied with CTRL+C which can be pasted later
Type:
_forceSnap :boolean
Track whether the layer is currently toggled to snap at exact grid precision
Type:
- boolean
_hover :PlaceableObject
- Overrides:
Track the PlaceableObject on this layer which is currently being hovered upon
Type:
chain :PIXI.Graphics
A graphics layer used to display chained Wall selection
Type:
- PIXI.Graphics
controlled
- Overrides:
An Array of placeable objects in this layer which have the _controlled attribute
documentCollection :Collection|null
- Overrides:
Obtain a reference to the Collection of embedded Document instances within the currently viewed Scene
Type:
- Collection | null
documentName :string
- Overrides:
A reference to the named Document type which is contained within this Canvas Layer.
Type:
- string
doors :Array.<Wall>
An Array of Wall instances in the current Scene which act as Doors.
Type:
endpoints :Array.<PointArray>
An array of all the unique perception-blocking endpoints which are present in the layer We keep this array cached for faster sight polygon computations
Type:
gridPrecision :number
- Overrides:
Gate the precision of wall snapping to become less precise for small scale maps.
Type:
- number
history :Array.<CanvasHistory>
- Overrides:
Keep track of history so that CTRL+Z can undo changes
Type:
hud :BasePlaceableHUD|null
- Overrides:
If objects on this PlaceableLayer have a HUD UI, provide a reference to its instance
Type:
- BasePlaceableHUD | null
name :string
- Overrides:
The canonical name of the CanvasLayer
Type:
- string
objects :PIXI.Container
- Overrides:
Placeable Layer Objects
Type:
- PIXI.Container
options :CanvasLayerOptions
- Overrides:
Options for this layer instance.
Type:
placeables :Array.<PlaceableObject>
- Overrides:
A convenience method for accessing the placeable object instances contained in this layer
Type:
preview
- Overrides:
Preview Object Placement
quadtree :Quadtree|null
- Overrides:
A Quadtree which partitions and organizes Walls into quadrants for efficient target identification.
Type:
- Quadtree | null
Methods
(static) castRays(x, y, distance, density, endpoints, limitAngle, aMin, aMax) → {Array.<Ray>}
A helper method responsible for casting rays at wall endpoints. Rays are restricted by limiting angles.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The origin x-coordinate |
y |
number | The origin y-coordinate |
distance |
number | The ray distance |
density |
number | The desired radial density |
endpoints |
Array.<PointArray> | An array of endpoints to target |
limitAngle |
boolean | Whether the rays should be cast subject to a limited angle of emission |
aMin |
number | The minimum bounding angle |
aMax |
number | The maximum bounding angle |
Returns:
An array of Ray objects
(static) getClosestCollision(collisions) → {RayIntersection|null}
Identify the closest collision point from an array of collisions
Parameters:
Name | Type | Description |
---|---|---|
collisions |
Array.<RayIntersection> | An array of intersection points |
Returns:
The closest blocking intersection or null if no collision occurred
- Type
- RayIntersection | null
(static) getClosestEndpoint(point, wall) → {PointArray}
Given a point and the coordinates of a wall, determine which endpoint is closer to the point
Parameters:
Name | Type | Description |
---|---|---|
point |
Point | The origin point of the new Wall placement |
wall |
Wall | The existing Wall object being chained to |
Returns:
The [x,y] coordinates of the starting endpoint
- Type
- PointArray
(static) getUniqueEndpoints(walls, optionsopt) → {Array.<PointArray>}
Given an array of Wall instances, identify the unique endpoints across all walls.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
walls |
Array.<Wall> | Set.<Wall> | An collection of Wall objects |
|||||||||||||||||
options |
object |
<optional> |
{}
|
Additional options which modify the set of endpoints identified Properties
|
Returns:
An array of endpoints
- Type
- Array.<PointArray>
(static) testWall(ray, wall) → {RayIntersection|null}
Test a single Ray against a single Wall
Parameters:
Name | Type | Description |
---|---|---|
ray |
Ray | The Ray being tested |
wall |
Wall | The Wall against which to test |
Returns:
A RayIntersection if a collision occurred, or null
- Type
- RayIntersection | null
_onClickLeft()
- Overrides:
- See:
-
- {Canvas#_onClickLeft}
Handle left mouse-click events which originate from the Canvas stage and are dispatched to this Layer.
_onClickLeft2()
- Overrides:
- See:
Handle double left-click events which originate from the Canvas stage and are dispatched to this Layer.
_onClickRight()
- Overrides:
- See:
-
- {Canvas#_onClickRight}
Handle right mouse-click events which originate from the Canvas stage and are dispatched to this Layer.
_onDragLeftCancel()
- Overrides:
- See:
-
- {Canvas#_onDragLeftDrop}
Cancel a left-click drag workflow originating from the Canvas stage.
(async) _onDragLeftDrop() → {Promise}
- Overrides:
- See:
-
- {Canvas#_onDragLeftDrop}
Conclude a left-click drag workflow originating from the Canvas stage.
Returns:
- Type
- Promise
_onDragLeftMove()
- Overrides:
- See:
-
- {Canvas#_onDragLeftMove}
Continue a left-click drag workflow originating from the Canvas stage.
(async) _onDragLeftStart() → {Promise.<void>}
- Overrides:
- See:
-
- {Canvas#_onDragLeftStart}
Start a left-click drag workflow originating from the Canvas stage.
Returns:
- Type
- Promise.<void>
_onMouseWheel(event)
- Overrides:
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 |
checkCollision(ray, optionsopt) → {boolean}
Test whether movement along a given Ray collides with a Wall.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ray |
Ray | The attempted movement |
|||||||||||||||||
options |
object |
<optional> |
{}
|
Options which customize how collision is tested Properties
|
Returns:
Does a collision occur along the tested Ray?
- Type
- boolean
computePolygon(origin, radius, optionsopt) → {Object}
Compute source polygons of a requested type for a given origin position and maximum radius. This method returns two polygons, one which is unrestricted by the provided radius, and one that is constrained by the maximum radius.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
origin |
Point | An point with coordinates x and y representing the origin of the test |
||||||||||||||||||||||||||||||||
radius |
number | A distance in canvas pixels which reflects the visible range |
||||||||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Additional options which modify the sight computation Properties
|
Returns:
The computed rays and polygons
- Type
- Object
controlAll(options) → {Array.<PlaceableObject>}
- Overrides:
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>}
- Overrides:
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}
- Overrides:
Draw a single placeable object
Returns:
- Type
- PlaceableObject
(async) deleteAll() → {Promise.<Array.<Document>>}
- Overrides:
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}
- Overrides:
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>
getRayCollisions(ray, optionsopt) → {Array.<object>|object|boolean}
Get the set of wall collisions for a given Ray
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ray |
Ray | The Ray being tested |
||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Options which customize how collision is tested Properties
|
Returns:
An array of collisions, if mode is "all" The closest collision, if mode is "closest" Whether any collision occurred if mode is "any"
- Type
- Array.<object> | object | boolean
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
highlightControlledSegments()
Highlight the endpoints of Wall segments which are currently group-controlled on the Walls layer
identifyInteriorWalls()
Identify walls which are treated as "interior" because they are contained fully within a roof tile.
initialize()
Perform initialization steps for the WallsLayer whenever the composition of walls in the Scene is changed. Cache unique wall endpoints and identify interior walls using overhead roof tiles.
(async) moveMany(options) → {Promise.<Array.<PlaceableObject>>}
- Overrides:
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
|
Returns:
An array of objects which were moved during the operation
- Type
- Promise.<Array.<PlaceableObject>>
(async) pasteObjects(position, hiddenopt, snapopt) → {Promise.<Array.<Document>>}
- Overrides:
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>>
releaseAll(options) → {number}
- Overrides:
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>>}
- Overrides:
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
|
Returns:
An array of objects which were rotated
- Type
- Promise.<Array.<PlaceableObject>>
selectObjects(x, y, width, height, releaseOptions, controlOptions) → {boolean}
- Overrides:
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)
- Overrides:
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>>}
- Overrides:
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>>}
- Overrides:
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>>