@vaguevoid/fiasco / textureAssetManager / Texture
Type Alias: Texture
Texture =
PendingTexture
|LoadedTexture
|EngineTexture
|FailedTexture
Defined in: src/textureAssetManager.ts:70
Represents a discriminate union of all the possible Texture states.
Use the kind
field to narrow the type.
ts
import { GpuInterface, TextureRender, Query } from '@vaguevoid/fiasco'
function system(gpuInterface: GpuInterface, textureRenders: Query<[TextureRender]>) {
for (const [textureRender] of textureRenders) {
const texture = gpuInterface.textureAssetManager.getTextureById(textureRender.textureId)
if (!texture) { continue }
if (texture.kind === 'loaded') {
// ...
} else if (texture.kind === 'failed') {
// ...
} else if (texture.kind === 'pending') {
// ...
} else if (texture.kind === 'engine') {
// ...
}
}
}