constructor(typeId: TypeId, assetId: AssetId, path: string)
View sourceStores the type ID, asset ID, and path supplied for a completed asset load.
Class
Event data for an asset load that completed successfully.
A AssetServer#load request produces this
event after the response has been imported and stored in its typed asset
pool. The event becomes readable when the typed
Events<AssetLoadSuccess> resource publishes its pending batch. Failed
loads publish AssetLoadFail instead.
The payload identifies the requested asset family, its reserved or reused
packed pool ID, and the complete path used for the load. It does not carry
the imported asset; consumers can use the event’s typeId and assetId to
locate that value in the matching typed Assets pool.
import { AssetLoadSuccess, Assets } from '@wimaengine/asset'
import { Events } from '@wimaengine/event'
import { typeid } from '@wimaengine/type'
class Texture {}
const assets = new Assets(Texture)
const assetId = assets.add(new Texture()).id()
const typeId = typeid(Texture)
const path = '/textures/player.bin'
const events = new Events()
// The success event is available after the asset has been imported.
events.write(new AssetLoadSuccess(typeId, assetId, path))
events.clear()
events.each(({ data }) => {
console.log(`Loaded ${data.path} as asset ${data.assetId}`)
})constructor(typeId: TypeId, assetId: AssetId, path: string)Stores the type ID, asset ID, and path supplied for a completed asset load.
Runtime type ID of the loaded asset’s constructor.
Reserved or reused packed ID of the loaded asset in its typed pool.
Complete path used by the load request.