/** * 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. * * @category Asset */ export class AssetReference { /** * Create a new AssetReference instance. * * @param {string} propertyName - The name of the property that the asset is stored under, * passed into callbacks to enable updating. * @param {import('./asset.js').Asset|object} parent - The parent object that contains the * asset reference, passed into callbacks to enable updating. Currently an asset, but could be * component or other. * @param {import('./asset-registry.js').AssetRegistry} registry - The asset registry that * stores all assets. * @param {object} callbacks - A set of functions called when the asset state changes: load, * add, remove. * @param {object} [callbacks.load] - The function called when the asset loads * load(propertyName, parent, asset). * @param {object} [callbacks.add] - The function called when the asset is added to the * registry add(propertyName, parent, asset). * @param {object} [callbacks.remove] - The function called when the asset is remove from the * registry remove(propertyName, parent, asset). * @param {object} [callbacks.unload] - The function called when the asset is unloaded * unload(propertyName, parent, asset). * @param {object} [scope] - The scope to call the callbacks in. * @example * const reference = new pc.AssetReference('textureAsset', this, this.app.assets, { * load: this.onTextureAssetLoad, * add: this.onTextureAssetAdd, * remove: this.onTextureAssetRemove * }, this); * reference.id = this.textureAsset.id; */ constructor(propertyName: string, parent: import("./asset.js").Asset | object, registry: import("./asset-registry.js").AssetRegistry, callbacks: { load?: object; add?: object; remove?: object; unload?: object; }, scope?: object); /** * @type {import('../../core/event-handle.js').EventHandle|null} * @private */ private _evtLoadById; /** * @type {import('../../core/event-handle.js').EventHandle|null} * @private */ private _evtUnloadById; /** * @type {import('../../core/event-handle.js').EventHandle|null} * @private */ private _evtAddById; /** * @type {import('../../core/event-handle.js').EventHandle|null} * @private */ private _evtRemoveById; /** * @type {import('../../core/event-handle.js').EventHandle|null} * @private */ private _evtLoadByUrl; /** * @type {import('../../core/event-handle.js').EventHandle|null} * @private */ private _evtAddByUrl; /** * @type {import('../../core/event-handle.js').EventHandle|null} * @private */ private _evtRemoveByUrl; propertyName: string; parent: any; _scope: any; _registry: import("./asset-registry.js").AssetRegistry; /** * Sets the asset id which this references. One of either id or url must be set to * initialize an asset reference. * * @type {number} */ set id(value: number); /** * Gets the asset id which this references. * * @type {number} */ get id(): number; /** * Sets the asset url which this references. One of either id or url must be called to * initialize an asset reference. * * @type {string|null} */ set url(value: string | null); /** * Gets the asset url which this references. * * @type {string|null} */ get url(): string | null; asset: any; _onAssetLoad: any; _onAssetAdd: any; _onAssetRemove: any; _onAssetUnload: any; _id: number; _url: string; _bind(): void; _unbind(): void; _onLoad(asset: any): void; _onAdd(asset: any): void; _onRemove(asset: any): void; _onUnload(asset: any): void; }