constructor()
View sourceAssociates this importer with the Image asset constructor.
Class
ExtendsImporter
Converts browser image responses into Image assets.
RenderCorePlugin registers this importer for Image. It reports the exact
png and jpeg extension labels, so API users can load those image paths
through AssetServer.
import { AssetServer } from '@wimaengine/asset'
import { Image, ImageAssets } from '@wimaengine/render-core'
// RenderCorePlugin and AssetServerPlugin are registered and started.
const server = world.getResource(AssetServer)
const handle = server.load(Image, '/textures/player.png')
// The request is queued; `image` is available after loading completes.
const image = world.getResource(ImageAssets).get(handle)
// `image` is undefined until the load has completed.getExtensions(): string[]Lists the path extensions handled by this importer.
AssetServer indexes each returned label with the importer’s
asset constructor. Labels must omit the leading dot and match the
extension extracted from a load path exactly, including case. Return one
label for each supported response format.
The base implementation always throws an Error because it does not know
which formats the concrete importer supports. The empty array below is
only an unreachable fallback after that error.
deserialize(response: Response, _typeRegistry: TypeRegistry): Promise<Image>Converts a fetched response into the typed asset value.
Override this method to read the response body, parse its contents, and
resolve a T. Use the TypeRegistry argument when the format
stores reflected or nested values; a self-contained response can ignore
it. A concrete importer should resolve an asset value that can be stored
for the requested asset.
The base implementation always rejects with an Error because it has no
response format to parse. The undefined return below is only an
unreachable fallback after that error.