AssetManager

Manages the loading and caching of Assets. This is a singleton class accessed via L3D.Loki.assetManager.

Constructor

new L3D.AssetManager()

The AssetManager is constructed by the Loki initialization process.

Properties

path String

The path where assets are found. This may be the path to the server's asset manager.

scripts Set

The set of scripts currently loaded by the asset manager.

Methods

add(url, asset)Asset

Register an asset with the asset manager so it's cached for the next time it's requested with load or get.

Parameters
url String
asset Asset
Returns
Asset

deleteAsset(url)

Remove an asset from the cache.

Parameters
url String

get(url) → nullable Asset

Returns the asset cached with the given path, undefined if it hasn't been cached yet.

Parameters
url String
Returns
Asset

getAssetPath(url) → String

Get the full path to an asset.

Parameters
url String
Returns
String

getLoaderForExtension(ext) → nullable AssetLoader

Find a AssetLoader that's associated with the given file extension.

Parameters
ext String
Returns
AssetLoader

getLoaderForFilename(filename) → nullable AssetLoader

Find an AssetLoader that's associated with the given file name.

Parameters
filename String
Returns
AssetLoader

has(url) → bool

Does the asset manager have an asset cached with the given path?

Parameters
url String
Returns
bool

initialize(assetPath)

Registers all of the system assets

Parameters
assetPath String

isAssetInvalid(url) → bool

Invalid assets are assets that have been requested but couldn't be loaded, likely because the path is invalid, or there is no asset with that path.

Parameters
url String
Returns
bool

true if the asset is invalid

load(url, onLoad, noCache) → nullable Asset

Load an asset from the given URL. The AssetLoader of the asset is determined by the file extension of the URL. URLs that begin with ":" are internal built-in assets.

Parameters
url String
onLoad function
noCache bool
Returns
Asset

registerLoader(loaderClass)

Register an AssetLoader class with the asset manager.

Parameters
loaderClass Class

updateAsset(id, properties)

Update the properties of the asset on the server.

Parameters
id String
properties Object