pc.SceneRegistry
Summary
Methods
| add | Add a new item to the scene registry. |
| find | Find a Scene by name and return the pc.SceneRegistryItem. |
| findByUrl | Find a scene by the URL and return the pc.SceneRegistryItem. |
| list | Return the list of scene. |
| loadScene | Load the scene hierarchy and scene settings. |
| 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. |
Details
Constructor
SceneRegistry(app)
Container for storing the name and url for scene files.
Parameters
| app | pc.Application | The application. |
Methods
add(name, url)
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
booleanReturns true if the scene was successfully added to the registry, false otherwise.
find(name)
Find a Scene by name and return the pc.SceneRegistryItem.
Parameters
| name | string | The name of the scene. |
Returns
pc.SceneRegistryItemThe stored data about a scene.
findByUrl(url)
Find a scene by the URL and return the pc.SceneRegistryItem.
Parameters
| url | string | The URL to search by. |
Returns
pc.SceneRegistryItemThe stored data about a scene.
loadScene(url, callback)
Load the scene hierarchy and scene settings. This is an internal method used by the pc.Application.
Parameters
| url | string | The URL of the scene file. |
| callback | pc.callbacks.LoadScene | The function called after the settings are applied. Passed (err, scene) where err is null if no error occurred and scene is the pc.Scene. |
loadSceneHierarchy(url, callback)
Load a scene file, create and initialize the Entity hierarchy and add the hierarchy to the application root Entity.
var url = app.scenes.getSceneUrl("Scene Name");
app.scenes.loadSceneHierarchy(url, function (err, entity) {
if (!err) {
var e = app.root.find("My New Entity");
} else {
// error
}
});
Parameters
| url | string | The URL of the scene file. Usually this will be "scene_id.json". |
| callback | pc.callbacks.LoadHierarchy | The function to call after loading, passed (err, entity) where err is null if no errors occurred. |
loadSceneSettings(url, callback)
Load a scene file and apply the scene settings to the current scene.
var url = app.getSceneUrl("Scene Name");
app.loadSceneSettings(url, function (err) {
if (!err) {
// success
} else {
// error
}
});
Parameters
| url | string | The URL of the scene file. This can be looked up using app.getSceneUrl. |
| callback | pc.callbacks.LoadSettings | The function called after the settings are applied. Passed (err) where err is null if no error occurred. |