Skip to content

Commit 0763d1b

Browse files
yaustarsteveny-sc
andauthored
Update scene registry JSDocs with example loadSceneData (playcanvas#3173)
Co-authored-by: Steven Yau <syau@snapchat.com>
1 parent b02f552 commit 0763d1b

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/framework/scene-registry.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { SceneRegistryItem } from './scene-registry-item.js';
99
/**
1010
* @class
1111
* @name SceneRegistry
12-
* @description Container for storing the name and url for scene files.
12+
* @classdesc Container for storing and loading of scenes. An instance of the registry is created on the {@link Application} object as {@link Application#scenes}.
1313
* @param {Application} app - The application.
1414
*/
1515
class SceneRegistry {
@@ -185,11 +185,19 @@ class SceneRegistry {
185185
* @name SceneRegistry#loadSceneData
186186
* @description Loads and stores the scene data to reduce the number of the network
187187
* requests when the same scenes are loaded multiple times. Can also be used to load data before calling
188-
* {@link SceneRegistry.loadSceneHierarchy} and {@link SceneRegistry#loadSceneSettings} to make
188+
* {@link SceneRegistry#loadSceneHierarchy} and {@link SceneRegistry#loadSceneSettings} to make
189189
* scene loading quicker for the user.
190-
* @param {SceneRegistryItem | string} sceneItem - The scene item or URL of the scene file. Usually this will be "scene_id.json".
190+
* @param {SceneRegistryItem | string} sceneItem - The scene item (which can be found with {@link SceneRegistry#find} or URL of the scene file. Usually this will be "scene_id.json".
191191
* @param {callbacks.LoadSceneData} callback - The function to call after loading,
192192
* passed (err, sceneItem) where err is null if no errors occurred.
193+
* @example
194+
*
195+
* var sceneItem = app.scenes.find("Scene Name");
196+
* app.scenes.loadSceneData(sceneItem, function (err, sceneItem) {
197+
* if (err) {
198+
* // error
199+
* }
200+
* });
193201
*/
194202
loadSceneData(sceneItem, callback) {
195203
this._loadSceneData(sceneItem, true, callback);
@@ -199,7 +207,11 @@ class SceneRegistry {
199207
* @function
200208
* @name SceneRegistry#unloadSceneData
201209
* @description Unloads scene data that has been loaded previously using {@link SceneRegistry#loadSceneData}.
202-
* @param {SceneRegistryItem | string} sceneItem - The scene item or URL of the scene file. Usually this will be "scene_id.json".
210+
* @param {SceneRegistryItem | string} sceneItem - The scene item (which can be found with {@link SceneRegistry#find} or URL of the scene file. Usually this will be "scene_id.json".
211+
* @example
212+
*
213+
* var sceneItem = app.scenes.find("Scene Name");
214+
* app.scenes.unloadSceneData(sceneItem);
203215
*/
204216
unloadSceneData(sceneItem) {
205217
if (typeof sceneItem === 'string') {
@@ -216,7 +228,7 @@ class SceneRegistry {
216228
* @name SceneRegistry#loadSceneHierarchy
217229
* @description Load a scene file, create and initialize the Entity hierarchy
218230
* and add the hierarchy to the application root Entity.
219-
* @param {SceneRegistryItem | string} sceneItem - The scene item or URL of the scene file. Usually this will be "scene_id.json".
231+
* @param {SceneRegistryItem | string} sceneItem - The scene item (which can be found with {@link SceneRegistry#find} or URL of the scene file. Usually this will be "scene_id.json".
220232
* @param {callbacks.LoadHierarchy} callback - The function to call after loading,
221233
* passed (err, entity) where err is null if no errors occurred.
222234
* @example
@@ -275,7 +287,7 @@ class SceneRegistry {
275287
* @function
276288
* @name SceneRegistry#loadSceneSettings
277289
* @description Load a scene file and apply the scene settings to the current scene.
278-
* @param {SceneRegistryItem | string} sceneItem - The scene item or URL of the scene file. Usually this will be "scene_id.json".
290+
* @param {SceneRegistryItem | string} sceneItem - The scene item (which can be found with {@link SceneRegistry#find} or URL of the scene file. Usually this will be "scene_id.json".
279291
* @param {callbacks.LoadSettings} callback - The function called after the settings
280292
* are applied. Passed (err) where err is null if no error occurred.
281293
* @example

0 commit comments

Comments
 (0)