Adds the configured typed asset pool and optional lifecycle event resources
to an app.
The plugin creates an Assets pool for the configured asset
constructor and makes it available through the app’s typed resource store.
The pool connects to the app’s AssetServer so server-managed
assets can use the typed pool.
If events is configured, the plugin creates typed Events
resources for added, modified, and dropped values. Lifecycle events from
the pool are exposed through those resources, and dropped asset metadata is
removed from the server.
An AssetServer resource must be available to the app. Register
AssetServerPlugin, or provide that resource yourself, in addition
to this plugin. This plugin does not install an asset importer or exporter.
Examples
import { App } from '@wimaengine/app'
import { AssetAdded, AssetDropped, AssetModified, AssetPlugin, AssetServerPlugin } from '@wimaengine/asset'
import { CorePlugin } from '@wimaengine/core'
import { ReflectPlugin } from '@wimaengine/reflect'
class Texture {}
new App()
.registerPlugin(new ReflectPlugin())
.registerPlugin(new CorePlugin())
.registerPlugin(new AssetServerPlugin())
.registerPlugin(new AssetPlugin({
asset: Texture,
events: { added: AssetAdded, modified: AssetModified, dropped: AssetDropped }
}))
.setRunner(() => {})
.run()
// The plugin stages Assets<Texture> and the three typed event resources.