Loader

The Loader module is responsible for loading additional resources into the engine.

Reference

loader.getItemCountToLoad()

Return how many items are currently beeing loaded

Returns:

item count

Return type:

number

loader.loadTexture(id, options)

Loads a texture by its item ID

Parameters:
  • id (str) – the ID of the texture to load

  • options (table) – options to use when loading the texture. Currently implemented options: lodMode

Returns:

returns a promise that will deliver a Texture object

Return type:

Promise

loader.loadMaterial(id)

Loads a material by ID and will emit an loadMaterialResult event when the material is ready or loadMaterialError event on error

Parameters:

id (str) – the ID of the material to load

Returns:

returns a promise that will deliver a Material object

Return type:

Promise

loader.loadMesh(id)

Loads a material by ID and will emit an loadMaterialResult event when the material is ready or loadMaterialError event on error

Parameters:

id (str) – the ID of the mesh to load

Returns:

returns a promise that will deliver a Mesh object

Return type:

Promise

Examples

Load a texture
local Loader = require 'engine/loader'

function init()
    Loader.loadTexture("<texture item id>"):next(function(texture)
        print("Loaded the texture: ", texture:getName())
    end)
end