Container for storing and loading of scenes. An instance of the registry is created on the AppBase object as AppBase#scenes.

Constructors

Methods

  • Add a new item to the scene registry.

    Parameters

    • name: string

      The name of the scene.

    • url: string

      The url of the scene file.

    Returns boolean

    Returns true if the scene was successfully added to the registry, false otherwise.

  • Change to a new scene. Calling this function will load the scene data, delete all entities and graph nodes under app.root and load the scene settings and hierarchy.

    Parameters

    • sceneItem: string | SceneRegistryItem

      The scene item (which can be found with SceneRegistry#find, URL of the scene file (e.g."scene_id.json") or name of the scene.

    • Optionalcallback: ChangeSceneCallback

      The function to call after loading, passed (err, entity) where err is null if no errors occurred.

    Returns void

    app.scenes.changeScene("Scene Name", function (err, entity) {
    if (!err) {
    // success
    } else {
    // error
    }
    });
  • Load a scene file, create and initialize the Entity hierarchy and add the hierarchy to the application root Entity.

    Parameters

    • sceneItem: string | SceneRegistryItem

      The scene item (which can be found with SceneRegistry#find, URL of the scene file (e.g."scene_id.json") or name of the scene.

    • callback: LoadHierarchyCallback

      The function to call after loading, passed (err, entity) where err is null if no errors occurred.

    Returns void

    const sceneItem = app.scenes.find("Scene Name");
    app.scenes.loadSceneHierarchy(sceneItem, function (err, entity) {
    if (!err) {
    const e = app.root.find("My New Entity");
    } else {
    // error
    }
    });
  • Load a scene file and apply the scene settings to the current scene.

    Parameters

    • sceneItem: string | SceneRegistryItem

      The scene item (which can be found with SceneRegistry#find, URL of the scene file (e.g."scene_id.json") or name of the scene.

    • callback: LoadSettingsCallback

      The function called after the settings are applied. Passed (err) where err is null if no error occurred.

    Returns void

    const sceneItem = app.scenes.find("Scene Name");
    app.scenes.loadSceneSettings(sceneItem, function (err) {
    if (!err) {
    // success
    } else {
    // error
    }
    });