Class
Importers
View sourceRegistry that selects Importer instances by asset type ID and exact
extension label.
Each importer is indexed under its Importer#asset constructor and
every exact label returned by Importer#getExtensions. Registering
another importer for the same type-and-extension pair warns and selects the
newer importer for later lookups by AssetServer.
Examples
import { Importer, Importers } from '@wimaengine/asset'
import { typeid } from '@wimaengine/type'
class Texture {}
class PngImporter extends Importer {
constructor() { super(Texture) }
getExtensions() { return ['png'] }
}
const registry = new Importers()
const importer = new PngImporter()
registry.add(importer)
registry.get(typeid(Texture), 'png') // importerConstructor
Methods
add<T>(importer: Importer<T>): void
View sourceRegisters an importer 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 importer the result of subsequent lookups.
get<T>(type: TypeId, extension: string): Importer<T>
View sourceReturns an importer selected by an exact asset type ID and extension label.
The extension must match a label supplied to Importers#add,
including its spelling and case. A leading dot is not removed and the
label is not otherwise normalized. Path-based lookups use
AssetServer#getImporter.
