ResourceLoader
ResourceLoader loads external resources referenced by glTF assets.
ResourceLoader handles:
Loading textures from URIs
Uploading vertex/index buffer data
Computing tangent quaternions (via Mikktspace when needed)
Async resource loading for progressive rendering
Typical usage:
val stb = createStbProvider(engine)
val resourceLoader = ResourceLoader(ResourceConfiguration(engine))
resourceLoader.addTextureProvider("image/png", stb)
resourceLoader.addTextureProvider("image/jpeg", stb)
resourceLoader.loadResources(asset) // Synchronously load all resources
resourceLoader.destroy()
stb.destroy()Async usage:
resourceLoader.asyncBeginLoad(asset)
while (resourceLoader.asyncGetLoadProgress() < 1.0f) {
resourceLoader.asyncUpdateLoad() // Load in chunks
}See also
Properties
Functions
Feeds the binary content of an external resource into the loader's URI cache.
Starts an asynchronous resource load (texture decoding may use worker threads). Requires periodic calls to asyncUpdateLoad until asyncGetLoadProgress reaches 1.0.
Cancels pending decoder jobs, frees all CPU-side texel data, and flushes the Engine. Only needed if asyncBeginLoad was used and cancellation is required before completion.
Gets the status of an asynchronous load as a percentage in [0, 1].
Performs any pending main-thread work of an asynchronous load. Call periodically until asyncGetLoadProgress returns 1.0; harmless after that.
Frees memory by evicting the URI cache populated via addResourceData. Call only after a model is fully loaded or loading has been cancelled.
Checks whether the given resource URI has already been added via addResourceData.
Synchronously loads resources for asset from the URI cache and finalizes the asset: transforms vertex data if necessary, decodes images, and supplies tangent data.
Replaces the configuration the loader was created with.