API Reference

Class List

pc.AssetReference

var reference = new pc.AssetReference('textureAsset', this, this.app.assets, {
    load: this.onTextureAssetLoad,
    add: this.onTextureAssetAdd,
    remove: this.onTextureAssetRemove
}, this);
reference.id = this.textureAsset.id;

Summary

Properties

idGet or set the asset id which this references.
urlGet or set the asset url which this references.

Details

Constructor

AssetReference(propertyName, parent, registry, callbacks, [scope])

An object that manages the case where an object holds a reference to an asset and needs to be notified when changes occur in the asset. e.g. notifications include load, add and remove events.

var reference = new pc.AssetReference('textureAsset', this, this.app.assets, {
    load: this.onTextureAssetLoad,
    add: this.onTextureAssetAdd,
    remove: this.onTextureAssetRemove
}, this);
reference.id = this.textureAsset.id;

Parameters

propertyNameStringThe name of the property that the asset is stored under, passed into callbacks to enable updating.
parentpc.Asset, ObjectThe parent object that contains the asset reference, passed into callbacks to enable updating. Currently an asset, but could be component or other.
registrypc.AssetRegistryThe asset registry that stores all assets.
callbacksObjectA set of functions called when the asset state changes: load, add, remove.
callbacks.loadObjectThe function called when the asset loads load(propertyName, parent, asset).
callbacks.addObjectThe function called when the asset is added to the registry add(propertyName, parent, asset).
callbacks.removeObjectThe function called when the asset is remove from the registry remove(propertyName, parent, asset).
scopeObjectThe scope to call the callbacks in

Properties

Numberid

Get or set the asset id which this references. One of either id or url must be set to initialize an asset reference.

Stringurl

Get or set the asset url which this references. One of either id or url must be called to initialize an asset reference.