API Reference

Class List

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

apppc.Application

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 pc.SceneRegistryItem.

Parameters

namestring

The name of the scene.

Returns

pc.SceneRegistryItem

The stored data about a scene.

findByUrl(url)

Find a scene by the URL and return the pc.SceneRegistryItem.

Parameters

urlstring

The URL to search by.

Returns

pc.SceneRegistryItem

The stored data about a scene.

list()

Return the list of scene.

Returns

pc.SceneRegistryItem[]

All items in the registry.

loadScene(url, callback)

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

Parameters

urlstring

The URL of the scene file.

callbackpc.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

urlstring

The URL of the scene file. Usually this will be "scene_id.json".

callbackpc.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

urlstring

The URL of the scene file. This can be looked up using app.getSceneUrl.

callbackpc.callbacks.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.