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.loadImage(path)

Loads an image from an item by its relative path

Parameters:

path (str) – relative path to the image file inside the project i.e. (“/resources/textures/tex1”)

Returns:

returns a promise that will deliver a Texture object

Return type:

Promise

loader.loadMaterial(path)

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

Parameters:

path (str) – relative path to the material item inside the project i.e. (“/resources/materials/mat1”)

Returns:

returns a promise that will deliver a Material object

Return type:

Promise

loader.loadMesh(path)

Loads a mesh from an item by its relative path.

Parameters:

path (str) – relative path to the mesh item inside the project i.e. (“/resources/meshes/mesh1”)

Returns:

returns a promise that will deliver a Mesh object

Return type:

Promise

loader.loadPrefab(path)

Loads a prefab from an item by its relative path.

Parameters:

path (str) – relative path to the prefab item inside the project i.e. (“/resources/meshes/prefab1”)

Returns:

returns a promise that will deliver a Prefab object

Return type:

Promise

Examples

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

function init()
    Loader.loadImage("/resources/textures/mytexture"):next(function(texture)
        print("Loaded the texture: ", texture:getName())
    end)
end