Grape.JSONSceneSource Class
Represents a JSON scene source. After the scene source is loaded, you can instantiate the scene. The type of the instances have to be defined in a type mapping.
Constructor
Grape.JSONSceneSource
-
url
-
opts
Parameters:
-
url
StringJSON url
-
opts
ObjectInitial properties
Methods
create
()
Scene
Instantiates the scene.
Returns:
The new scene instance
getResourceKey
()
An abstract method which should return the same key when the resource is the same, it is used as cache key. A typical key is the url.
loadResource
-
onFinish
-
onError
-
onProgress
This method is called when we want to load the resource and it is not in the cache.
Parameters:
-
onFinish
FunctionShould be called when the resource is ready. The parameter is the loaded data.
-
onError
FunctionShould be called when an error occurs
-
onProgress
FunctionShould be called when the loading progress changes (0-100)
process
-
(*)
This method is called after load is called. If load is called multiple times, this method is not called more than once. It should initialize the resource with the loaded data.
Parameters:
-
(*)
Objectdata The loaded data (passed to the onFinish method in loadResource
Properties
type
Class
The type(class) of the scene to create.
Default: Grape.Scene
typeMapping
Object
The type mapping as key:class pairs.