API Reference

Class List

SceneRegistry

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

Summary

Methods

add

Add a new item to the scene registry.

find

Find a Scene by name and return the SceneRegistryItem.

findByUrl

Find a scene by the URL and return the SceneRegistryItem.

list

Return the list of scene.

loadScene

Load the scene hierarchy and scene settings.

loadSceneData

Loads and stores the scene data to reduce the number of the network requests when the same scenes are loaded multiple times.

loadSceneHierarchy

Load a scene file, create and initialize the Entity hierarchy and add the hierarchy to the application root Entity.

loadSceneSettings

Load a scene file and apply the scene settings to the current scene.

remove

Remove an item from the scene registry.

unloadSceneData

Unloads scene data that has been loaded previously using SceneRegistry#loadSceneData.

Details

Constructor

SceneRegistry(app)

Parameters

appApplication

The application.

Methods

add(name, url)

Add a new item to the scene registry.

Parameters

namestring

The name of the scene.

urlstring

The url of the scene file.

Returns

boolean

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

find(name)

Find a Scene by name and return the SceneRegistryItem.

Parameters

namestring

The name of the scene.

Returns

SceneRegistryItem

The stored data about a scene.

findByUrl(url)

Find a scene by the URL and return the SceneRegistryItem.

Parameters

urlstring

The URL to search by.

Returns

SceneRegistryItem

The stored data about a scene.

list()

Return the list of scene.

Returns

SceneRegistryItem[]

All items in the registry.

loadScene(url, callback)

Load the scene hierarchy and scene settings. This is an internal method used by the Application.

Parameters

urlstring

The URL of the scene file.

callbackcallbacks.LoadScene

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

loadSceneData(sceneItem, callback)

Loads and stores the scene data to reduce the number of the network requests when the same scenes are loaded multiple times. Can also be used to load data before calling SceneRegistry#loadSceneHierarchy and SceneRegistry#loadSceneSettings to make scene loading quicker for the user.

var sceneItem = app.scenes.find("Scene Name");
app.scenes.loadSceneData(sceneItem, function (err, sceneItem) {
    if (err) {
        // error
    }
});

Parameters

sceneItemSceneRegistryItem, string

The scene item (which can be found with SceneRegistry#find or URL of the scene file. Usually this will be "scene_id.json".

callbackcallbacks.LoadSceneData

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

loadSceneHierarchy(sceneItem, callback)

Load a scene file, create and initialize the Entity hierarchy and add the hierarchy to the application root Entity.

var sceneItem = app.scenes.find("Scene Name");
app.scenes.loadSceneHierarchy(sceneItem, function (err, entity) {
    if (!err) {
        var e = app.root.find("My New Entity");
    } else {
        // error
    }
});

Parameters

sceneItemSceneRegistryItem, string

The scene item (which can be found with SceneRegistry#find or URL of the scene file. Usually this will be "scene_id.json".

callbackcallbacks.LoadHierarchy

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

loadSceneSettings(sceneItem, callback)

Load a scene file and apply the scene settings to the current scene.

var sceneItem = app.scenes.find("Scene Name");
app.scenes.loadSceneHierarchy(sceneItem, function (err, entity) {
    if (!err) {
        var e = app.root.find("My New Entity");
    } else {
        // error
    }
});

Parameters

sceneItemSceneRegistryItem, string

The scene item (which can be found with SceneRegistry#find or URL of the scene file. Usually this will be "scene_id.json".

callbackcallbacks.LoadSettings

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

remove(name)

Remove an item from the scene registry.

Parameters

namestring

The name of the scene.

unloadSceneData(sceneItem)

Unloads scene data that has been loaded previously using SceneRegistry#loadSceneData.

var sceneItem = app.scenes.find("Scene Name");
app.scenes.unloadSceneData(sceneItem);

Parameters

sceneItemSceneRegistryItem, string

The scene item (which can be found with SceneRegistry#find or URL of the scene file. Usually this will be "scene_id.json".