add async gltf resource loading
This commit is contained in:
@@ -787,9 +787,16 @@ class FFIFilamentApp extends FilamentApp<Pointer> {
|
||||
cb));
|
||||
}
|
||||
if (loadResourcesAsync) {
|
||||
// GltfResourceLoader_asyncBeginLoad(gltfResourceLoader)
|
||||
throw UnimplementedError(
|
||||
"TODO"); // need to use a NativeFinalizer to ensure the pointer is still valid until resource loader has finished
|
||||
if(!GltfResourceLoader_asyncBeginLoad(gltfResourceLoader, filamentAsset)) {
|
||||
throw Exception("Failed to begin async loading");
|
||||
}
|
||||
GltfResourceLoader_asyncUpdateLoad(gltfResourceLoader);
|
||||
|
||||
var progress = GltfResourceLoader_asyncGetLoadProgress(gltfResourceLoader);
|
||||
while(progress < 1.0) {
|
||||
GltfResourceLoader_asyncUpdateLoad(gltfResourceLoader);
|
||||
progress = GltfResourceLoader_asyncGetLoadProgress(gltfResourceLoader);
|
||||
}
|
||||
} else {
|
||||
final result = await withBoolCallback((cb) =>
|
||||
GltfResourceLoader_loadResourcesRenderThread(
|
||||
|
||||
@@ -2847,13 +2847,25 @@ external void GltfResourceLoader_destroy(
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TGltfResourceLoader>,
|
||||
ffi.Bool Function(ffi.Pointer<TGltfResourceLoader>,
|
||||
ffi.Pointer<TFilamentAsset>)>(isLeaf: true)
|
||||
external void GltfResourceLoader_asyncBeginLoad(
|
||||
external bool GltfResourceLoader_asyncBeginLoad(
|
||||
ffi.Pointer<TGltfResourceLoader> tGltfResourceLoader,
|
||||
ffi.Pointer<TFilamentAsset> tFilamentAsset,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TGltfResourceLoader>)>(isLeaf: true)
|
||||
external void GltfResourceLoader_asyncUpdateLoad(
|
||||
ffi.Pointer<TGltfResourceLoader> tGltfResourceLoader
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Double Function(ffi.Pointer<TGltfResourceLoader>)>(isLeaf: true)
|
||||
external double GltfResourceLoader_asyncGetLoadProgress(
|
||||
ffi.Pointer<TGltfResourceLoader> tGltfResourceLoader
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TGltfResourceLoader>, ffi.Pointer<ffi.Char>,
|
||||
ffi.Pointer<ffi.Uint8>, ffi.Size)>(isLeaf: true)
|
||||
|
||||
Reference in New Issue
Block a user