The Scene Entity

There are several important API layers which are useful when working with Scenes. Each Scene is an instance of the Scene() class which subclasses the base Entity().

The Scenes() collection contains all of the Scene instances which are defined by the World, the collection of these scenes is available as game.scenes.

When modifying the scene configuration, the data is rendered and edited using the SceneSheet() class which can be extended or overridden by systems or modules. To override the default implementation, a module should define the Config.Scene.sheetClass global configuration value.

Additionally, each scene has rich notes associated with it which are customizable using the SceneNotes() class. Similarly, this class can be overridden or extended by modules by altering the Config.Scene.notesClass global configuration.


The Scene Class

class foundry.Scene(args)

The Scene entity

foundry.Scene.Entity.create(data, options)

Create a new entity using provided input data The data for entity creation is typically provided from the server through the ‘create<Entity>’ socket Alternatively, the creation event may originate locally and the new entity can be pushed back to the server

Arguments:
  • data (Object) – The data with which to create the entity
  • options (Object) – Additional options which customize the creation workflow
  • options.temporary (Boolean) – Create a temporary entity which is not saved to the world database. Default is false.
  • options.displaySheet (Boolean) – Show the configuration sheet for the created entity once it is created. Default is true.
Returns:

Promise – A Promise which resolves to contain the created Entity

foundry.Scene.Entity.update(data, options)

Update the current entity using new data This new data is typically provided from the server through the ‘update<Entity>’ socket Alternatively, the update may originate locally, in which case it can be pushed back to the server

Arguments:
  • data (Object) – The data with which to update the entity
  • options (Object) – Additional options which customize the update workflow
  • options.diff (Boolean) – Diff the provided data against existing entity data, only submitting the difference to the server. Default is true.
Returns:

Promise – A Promise which resolves to the updated Entity

foundry.Scene.Entity.delete(options)

Delete the entity, removing it from its collection and deleting its data record

Arguments:
  • options (Object) – Additional options which customize the deletion workflow
Returns:

Promise – A Promise which resolves to the ID of the deleted Entity once handled by the server

foundry.Scene._notes

type: SceneNotes

A reference to the active Scene Notes instance for this Scene

foundry.Scene._onDelete(args)

Additional updating steps for the Scene entity the entity is deleted

foundry.Scene._view

type: Boolean

Track whether the scene is the active view

foundry.Scene._viewPosition

type: Object

Track the viewed position of each scene (while in memory only, not persisted) When switching back to a previously viewed scene, we can automatically pan to the previous position. Object with keys: x, y, scale

foundry.Scene.activate()

Set this scene as currently active

Returns:Promise – A Promise which resolves to the current scene once it has been successfully activated
foundry.Scene.notes

A singleton instance of the SheetNotes class

foundry.Scene.update(data, options)

Extend the default Entity update method to add additional functionality for handling Scene thumbnails

Arguments:
  • data (Object) – The data with which to update the entity
  • options (Object) – Additional options which customize the update workflow
Returns:

Promise – A Promise which resolves to the updated Entity

foundry.Scene.view()

Set this scene as the current view


The Scenes Collection

class Scenes()

The collection of Scene entities

Scenes.Collection.insert(entity)

Add a new Entity to the Collection, asserting that they are of the correct type

Arguments:
  • entity (Entity) – The entity instance to add to the collection
Scenes.Collection.remove(id)

Remove an Entity from the Collection by its ID.

Arguments:
  • id (String) – The entity ID which should be removed
Scenes.Collection.get(id)

Get an element from the collection by ID

Arguments:
  • id (String) – The entity ID to retrieve from the collection
Returns:

Entity – The retrieved Entity, if the ID was found, otherwise null;

Scenes.Collection.index(id)

Retrieve the index of an entity within the collection by its ID

Arguments:
  • id (String) – The entity ID to retrieve from the collection
Returns:

Number – The index of the Entity within the collection, if found, otherwise -1;

Scenes.Collection.render(args)

Re-render any currently visible applications associated with this Collection

Scenes.object

Elements of the Scenes collection are instances of the Scene class


Scene Configuration Sheet

class SceneSheet()

A Scene configuration sheet

SceneSheet.getData()

Default data preparation logic for the entity sheet

SceneSheet.id

Give each Scene Configuration sheet a unique css ID based on their entity ID


Scene Notes

class SceneNotes()

Long-form Scene notes

SceneNotes.id

Give each Scene Configuration sheet a unique css ID based on their entity ID

SceneNotes.title

Put the Scene name in the window title