AssetServerPlugin

View source

ExtendsPlugin

Installs app-wide asset loading and saving support.

This plugin has no options. It adds an AssetServer resource to the app’s default world and makes typed result events available for AssetLoadSuccess, AssetSaveSuccess, and AssetLoadFail. Use AssetPlugin, AssetImporterPlugin, and AssetExporterPlugin to provide the asset types and handlers that the server uses for loading and saving.

Register CorePlugin and ReflectPlugin before this plugin. Registering AssetServerPlugin does not add either dependency.

Examples

import { App } from '@wimaengine/app'
import { AssetServerPlugin } from '@wimaengine/asset'
import { CorePlugin } from '@wimaengine/core'
import { ReflectPlugin } from '@wimaengine/reflect'

new App()
  .registerPlugin(new ReflectPlugin())
  .registerPlugin(new CorePlugin())
  .registerPlugin(new AssetServerPlugin())
  .setRunner(() => {})
  .run()

Constructor


constructor()

Methods


register(app: App): void

View source

Adds the asset server and its typed result events to the app.

The app receives an AssetServer resource in its default world and typed event resources through EventPlugin for AssetLoadSuccess, AssetSaveSuccess, and AssetLoadFail.

Requests made through AssetServer are queued and processed in order. A load fetches and imports asset data, while a save exports asset data and sends it to its destination. Successful operations publish their matching result event, and failed loads or saves publish AssetLoadFail.

Parameters

NameDescriptionDefault
app

App receiving the asset runtime configuration.

—

requires(): TypeId[]

View source

Declares the plugins required by the asset server.

The asset server depends on CorePlugin and ReflectPlugin. Register both plugins before using the asset server; this plugin does not install them automatically.

Returns

Required plugin type IDs.