API Documentation

for 0.0.1
Show:

Loader Class

A loader class that manage the loading of datas from url. This is mainly used internally to manage the preLoad method in users script. Users should usually use this class methods to load datas and obtain the result encapsulated in a LoadRequest object.

Constructor

Loader

(
  • params
)

Parameters:

  • params Object

    Config parameters

    • onLoad Function
    • onError Function
    • onComplete Function

Example:

this.preLoad = function(loader){

  logoFile = loader.loadImage({url:"logo_mobilizing.png",
                               onStart: function(){console.log("Started loading of logo");},
                               onLoad: function(data){console.log("Hell Yeah! Got", data);}
                              });
}

this.setup = function(){

  console.log("logoFile", logoFile);
  //will print the LoadRequest object. Access the loaded data with logoFile.getValue()
}

Methods

consumeAll

()

Consume (executes) all the requests

doComplete

() private

Helper method to update the status and trigger the complete event

load

(
  • params
)
LoadRequest

Load a data from the URL given in parameters. ResponseType is the default one of an Ajax object, that is String.

Parameters:

  • params Object

    The parameters object

    • url String

      the URL to load data from

    • [onStart= null] Function optional

      A function to be called when the loading starts

    • [onLoad= null] Function optional

      A function to be called when the loading finishes

    • [onError= null] Function optional

      A function to be called when the loading fails

    • [responseType] String optional

      The type of the respons to return from the Ajax call

    • processData Function

      function definning what to do with the data coming from the promise

Returns:

LoadRequest:

the LoadRequest object is incomplete at call and will be filled by the inner promise manager, when fulfilled.

load

(
  • url
  • callback
  • [responseType]
  • [processData]
)
static

Loads data from a URL. This static method must be provided a callback method.

Parameters:

  • url String

    the URL to load data from

  • callback Function

    callback function that the user wants to call on load completion

    • result Mixed

      The load result if successful

    • error String

      The load error if unsuccessful

  • [responseType] String optional

    The type of the respons to return from the Ajax call

  • [processData] Function optional

    function definning what to do with the data coming from the promise

loadArrayBuffer

(
  • params
)
LoadRequest

Loads an ArrayBuffer from a URL.

Parameters:

  • params Object

    The parameters object

    • url String

      the URL to load data from

    • [onStart= null] Function optional

      A function to be called when the loading starts

    • [onLoad= null] Function optional

      A function to be called when the loading finishes

    • [onError= null] Function optional

      A function to be called when the loading fails

Returns:

LoadRequest:

a LoadRequest who's value is incomplete at first and will be filled once the Ajax request is fulfilled

loadArrayBuffer

(
  • url
  • callback
)
static

Loads an arraybuffer from a URL. This static method must be provided a callback method.

Parameters:

  • url String

    the URL to load data from

  • callback Function

    callback function that the user wants to call on load completion

    • result Mixed

      The load result if successful

    • error String

      The load error if unsuccessful

loadBlob

(
  • url
  • callback
)
static

Loads a blob from a URL. This static method must be provided a callback method.

Parameters:

  • url String

    the URL to load data from

  • callback Function

    callback function that the user wants to call on load completion

loadBlob

(
  • params
)
LoadRequest

Loads a blob from a URL.

Parameters:

  • params Object

    The parameters object

    • url String

      the URL to load data from

    • [onStart= null] Function optional

      A function to be called when the loading starts

    • [onLoad= null] Function optional

      A function to be called when the loading finishes

    • [onError= null] Function optional

      A function to be called when the loading fails

Returns:

LoadRequest:

a LoadRequest who's value is incomplete at first and will be filled once the Ajax request is fulfilled

loadImage

(
  • url
  • callback
)
static

Loads an image from a URL. This static method must be provided a callback method.

Parameters:

  • url String

    the URL to load data from

  • callback Function

    callback function that the user wants to call on load completion

    • result Mixed

      The load result if successful

    • error String

      The load error if unsuccessful

loadImage

(
  • params
)
LoadRequest

Load an image from the URL given in parameters. The Image Object is given as the returned LoadRequest's value.

Parameters:

  • params Object

    The parameters object

    • url String

      the URL to load data from

    • [onStart= null] Function optional

      A function to be called when the loading starts

    • [onLoad= null] Function optional

      A function to be called when the loading finishes

    • [onError= null] Function optional

      A function to be called when the loading fails

Returns:

LoadRequest:

a LoadRequest who's value is incomplete at first and will be filled once the Ajax request is fulfilled

loadJSON

(
  • url
  • callback
)
static

Loads a JavaScript object, parsed from a JSON string from a URL. This static method must be provided a callback method.

Parameters:

  • url String

    the URL to load data from

  • callback Function

    callback function that the user wants to call on load completion

    • result Mixed

      The load result if successful

    • error String

      The load error if unsuccessful

loadJSON

(
  • params
)
LoadRequest

Loads a JavaScript object, parsed from a JSON string from a URL.

Parameters:

  • params Object

    The parameters object

    • url String

      the URL to load data from

    • [onStart= null] Function optional

      A function to be called when the loading starts

    • [onLoad= null] Function optional

      A function to be called when the loading finishes

    • [onError= null] Function optional

      A function to be called when the loading fails

Returns:

LoadRequest:

a LoadRequest who's value is incomplete at first and will be filled once the Ajax request is fulfilled

loadOBJ

(
  • url
  • callback
)
static

Loads an obj model from a URL. This static method must be provided a callback method. Mtl files are not supported with this method. Form mtl support, use the loadOBJ (not static) method of Loader.

Parameters:

  • url String

    the URL to load data from

  • callback Function

    callback function that the user wants to call on load completion. It receives the Mesh resulting from the loading.

loadOBJ

(
  • params
)
LoadRequest

Loads an OBJ from a URL.

Parameters:

  • params Object

    The parameters object

    • url String

      the URL to load data from

    • [onStart= null] Function optional

      A function to be called when the loading starts

    • [onLoad= null] Function optional

      A function to be called when the loading finishes

    • [onError= null] Function optional

      A function to be called when the loading fails

Returns:

LoadRequest:

a LoadRequest who's value is incomplete at first and will be filled once the Ajax request is fulfilled

loadScript

(
  • url
  • callback
)
static

Loads a script from a URL. This static method must be provided a callback method.

Parameters:

  • url String

    the URL to load data from

  • callback Function

    callback function that the user wants to call on load completion

loadText

(
  • params
)
LoadRequest

Loads a text from a URL.

Parameters:

  • params Object

    The parameters object

    • url String

      the URL to load data from

    • [onStart= null] Function optional

      A function to be called when the loading starts

    • [onLoad= null] Function optional

      A function to be called when the loading finishes

    • [onError= null] Function optional

      A function to be called when the loading fails

Returns:

LoadRequest:

a LoadRequest who's value is incomplete at first and will be filled once the Ajax request is fulfilled

loadText

(
  • url
  • callback
)
static

Loads a text from a URL. This static method must be provided a callback method.

Parameters:

  • url String

    the URL to load data from

  • callback Function

    callback function that the user wants to call on load completion

    • result Mixed

      The load result if successful

    • error String

      The load error if unsuccessful

loadTexture

(
  • params
)
Texture

Load a texture, that is an image that is injected in a texture

Parameters:

  • params Object

Returns:

Texture:

the constructed texture

loadVideo

(
  • params
)
LoadRequest

Load a video from the URL given in parameters. The Video Object is given as the returned LoadRequest's value.

Parameters:

  • params Object

    The parameters object

    • url String

      the URL to load data from

    • [onStart= null] Function optional

      A function to be called when the loading starts

    • [onLoad= null] Function optional

      A function to be called when the loading finishes

    • [onError= null] Function optional

      A function to be called when the loading fails

Returns:

LoadRequest:

a LoadRequest who's value is incomplete at first and will be filled once the request is fulfilled