ConfigHandler

ConfigHandler

Base class for resource handlers, used to load all types of resources into the engine.
All the resource types in the bundle (noted by their extension) need to have a registered config
handler.
To handle a new type of component, create a class that inherits from this class, and override {update}.
In your class, call @_register('yourResourceExtension') to _register
the handler with the loader.

Constructor

new ConfigHandler(world, getConfig, updateObject, loadObject)

Parameters:
Name Type Description
world World

The sumerian world

getConfig function

The config loader function. See DynamicLoader#_loadRef.

updateObject function

The handler function. See DynamicLoader#_updateObject.

loadObject function

The object loader function. See DynamicLoader#_loadObject.

Methods

(static) _registerClass(type, klass)

Register a handler for a component type. Called in the class body of subclasses.

Parameters:
Name Type Description
type string
klass Class

the class to register for this component type

(static) getHandler(type) → {Class}

Get a handler class for the specified type of resource. The resource can be e.g. 'texture', 'mesh', etc.

Parameters:
Name Type Description
type string

update(ref, config, options) → {Promise}

Update engine object based on the config. Should be overridden in subclasses.
This method is called by #{DynamicLoader} to load new resources into the engine.

Parameters:
Name Type Description
ref string

The ref of this config

config Object
options Object