Class
Exporters
View sourceRegistry that selects Exporter instances by asset type ID and exact
extension label.
Each exporter is indexed under its Exporter#asset constructor and
every exact label returned by Exporter#getExtensions. Registering
another exporter for the same type-and-extension pair warns and selects the
newer exporter for later lookups by AssetServer.
Examples
import { Exporter, Exporters } from '@wimaengine/asset'
import { typeid } from '@wimaengine/type'
class Texture {}
class PngExporter extends Exporter {
constructor() { super(Texture) }
getExtensions() { return ['png'] }
}
const registry = new Exporters()
const exporter = new PngExporter()
registry.add(exporter)
registry.get(typeid(Texture), 'png') // exporterConstructor
Methods
add<T>(exporter: Exporter<T>): void
View sourceRegisters an exporter for its asset type and each extension label it declares.
If the same type-and-extension pair is already registered, this warns and makes the new exporter the result of subsequent lookups.
get<T>(type: TypeId, extension: string): Exporter<T>
View sourceReturns an exporter selected by an exact asset type ID and extension label.
The extension must match a label supplied to Exporters#add,
including its spelling and case. A leading dot is not removed and the
label is not otherwise normalized. Path-based lookups use
AssetServer#getExporter.
