Constructor
new DynamicLoader(options)
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Methods
(static) _findRefsInConfig(config, onRef)
Traverses a json-like structure and calls a function for each ref
Parameters:
Name | Type | Description |
---|---|---|
config |
Object |
The configuration to search |
onRef |
function |
function called when a ref is found. |
(static) _getRefsFromConfig(config) → {Array}
Traverses a json-like structure and collects refs in an array
Parameters:
Name | Type | Description |
---|---|---|
config |
(static) getTypeForRef(ref) → {string}
Gets the type of a reference.
Parameters:
Name | Type | Description |
---|---|---|
ref |
string |
Reference. |
_setAssetDirectory(assetDirectory)
Called by SceneHandler. The data is used by _getConfigs.
Parameters:
Name | Type | Description |
---|---|---|
assetDirectory |
Object |
an object with the format:
|
clear() → {Promise}
Clears the cache of all the handlers. Also clears the engine.
listAssetPacks() → {Promise.<Array.<AssetPackInfo>>}
Get information about all the assets packs in the scene bundle.
listAssets() → {Promise.<Array.<AssetInfo>>}
Get information about all the assets in the scene bundle.
load(ref, options) → {Promise}
Load an object with the specified id into the engine. If an object is already
loaded, it will return that object without updating it.
The object can be of any type, what loading does is determined by the ref
type and the registered ConfigHandler.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ref |
string |
Id of object to load. |
||||||||||||||||||||
options |
Object |
Properties
|
loadInstance(ref, options) → {Promise}
Like DynamicLoader#load, but creates an unique instance of the
specified resource each time loadInstance is called. This function works on
any resource type, but is intended primarily for use with entities.
In general, loadInstance creates a "shallow" instance of the resource. That
means that resources referenced by the instanced resource are not themselves
instanced. For example, instances of a material resource will initially all
share the same shader and texture resources; but the instances are distinct
from each other and can be individually modified to reference other shaders
or textures. For comparision, if load was used instead of loadInstance, then
the same material object would be returned every time, so changing the
shader or texture it references would apply to every use of the material.
However, when an entity that has child entities is instanced, an instance of
each of those child entities is also created. Otherwise the instance and the
original would both behave as if they had exclusive control over all the
children.
A few other resource types are also always instanced in order to insure they
work correctly.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ref |
string |
Id of object to load. |
|||||||||||||||||||||||||
options |
Object |
Properties
|
preload(bundle, clearopt)
Load configs into the loader cache without loading anything into the engine.
Subsequent calls to load and update will draw configs from the prefilled cache.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
bundle |
Object |
Bundle object. Keys should be refs, and values are the config objects. If a config is null, |
||
clear |
boolean |
<optional> |
false |
If true, possible previous cache will be cleared. Otherwise the existing cache is extended. |
update(ref, configopt, options) → {Promise}
Update an object in the world with an updated config. The object can be of any
type, updating behavior is determined by the registered {ConfigHandler}.
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ref |
string |
Ref of object to update. |
|||||||||||
config |
Object |
<optional> |
New configuration (formatted according to data model). |
||||||||||
options |
Object |
Properties
|