API Docs for: 1.0.1

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 String

    JSON url

  • opts Object

    Initial properties

Item Index

Properties

Methods

create

() Scene

Instantiates the scene.

Returns:

Scene:

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 Function

    Should be called when the resource is ready. The parameter is the loaded data.

  • onError Function

    Should be called when an error occurs

  • onProgress Function

    Should 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:

  • (*) Object

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