add option for async loading glTF resources

This commit is contained in:
Nick Fisher
2024-10-10 14:58:09 +08:00
parent 9deafc7371
commit 95a44936ac
9 changed files with 37 additions and 19 deletions

View File

@@ -257,7 +257,7 @@ namespace thermion
}
EntityId SceneManager::loadGlbFromBuffer(const uint8_t *data, size_t length, int numInstances, bool keepData, int priority, int layer)
EntityId SceneManager::loadGlbFromBuffer(const uint8_t *data, size_t length, int numInstances, bool keepData, int priority, int layer, bool loadResourcesAsync)
{
FilamentAsset *asset = nullptr;
@@ -304,10 +304,18 @@ namespace thermion
_gltfResourceLoader->asyncUpdateLoad();
}
#else
if (!_gltfResourceLoader->loadResources(asset))
{
Log("Unknown error loading glb asset");
return 0;
if(loadResourcesAsync) {
if (!_gltfResourceLoader->asyncBeginLoad(asset))
{
Log("Unknown error loading glb asset");
return 0;
}
} else {
if (!_gltfResourceLoader->loadResources(asset))
{
Log("Unknown error loading glb asset");
return 0;
}
}
#endif