Table Of Contents

Previous topic

21.39. The RequestHandler Object

Next topic

21.41. The AssetCache Object

This Page

21.40. The ResourceLoader Object

Provides loading and resolving of JSON files with external references. Upon completion of the resolution of all references the loader calls a specified callback passing it the resolved data.

Required scripts

The ResourceLoader object requires:

/*{{ javascript("jslib/resourceloader.js") }}*/
/*{{ javascript("jslib/vmath.js") }}*/

21.40.1. Constructor

21.40.1.1. create

Summary

Syntax

var resourceLoader = ResourceLoader.create();

21.40.2. Method

21.40.2.1. load

Summary

Requests loading and resolving of a set of JSON data from the specified assetPath. Upon completion the onload callback supplied in the loadParams will be executed.

Syntax

var loadParams = {
        append : true,
        nodesNamePrefix : "level1",
        shapesNamePrefix : "level1",
        requestHandler : requestHandler,
        onload : levelLoadedFn
    };

resourceLoader.load(assetPath, loadParams);
assetPath
An object which has already been loaded via asynchronous requests.
append
Option to specify whether the scene data is appended to the existing loaded resources or if the resources already loaded should cleared first.
nodesNamePrefix
Prefix to be added to all node names in the data to be loaded.
shapesNamePrefix
Prefix to be added to all geometry shape names in the data to be loaded.
requestHandler
A RequestHandler object.
onload
Callback to be executed when all the loading and resolving has finished.

21.40.2.2. resolve

Summary

Requests loading of animation data from an asset with a given path. Any animations stored in the animations property of the asset loaded will be stored in the animation manager by their dictionary name. The assets will be loaded asynchronously and may not be immediately available via the get method.

Syntax

var params = {
        data : jsonData,
        append : true,
        nodesNamePrefix : "level1",
        shapesNamePrefix : "level1",
        requestHandler : requestHandler,
        onload : levelLoadedFn
    };

resourceLoader.resolve(params);
append
Option to specify whether the scene data is appended to the existing loaded resources or if the resources already loaded should cleared first.
data
The scene data read from a JSON file, which contains references to be resolved.
nodesNamePrefix
Prefix to be added to all node names in the data to be loaded.
shapesNamePrefix
Prefix to be added to all geometry shape names in the data to be loaded.
requestHandler
A RequestHandler object.
onload
Callback to be executed when all the loading and resolving has finished.

21.40.2.3. clear

Summary

Clears the contents of the resource loader allowing a new set of resources to be loaded.

Syntax

resourceLoader.clear();

21.40.3. Properties

21.40.3.1. version

Summary

The version number of the ResourceLoader implementation.

Syntax

var versionNumber = resourceLoader.version;