add error check for failed to load

This commit is contained in:
Nick Fisher
2022-12-22 19:58:53 +08:00
parent 1d08b7ead0
commit 9ca3f3d2b4

View File

@@ -10,6 +10,7 @@ import 'package:flutter/services.dart';
// should make this consistent
typedef FilamentAsset = int;
typedef FilamentLight = int;
const FilamentAsset FILAMENT_ASSET_ERROR = 0;
abstract class FilamentController {
Size get size;
@@ -230,6 +231,9 @@ class PolyvoxFilamentController extends FilamentController {
Future<FilamentAsset> loadGlb(String path) async {
print("Loading GLB at $path ");
var asset = await _channel.invokeMethod("loadGlb", path);
if (asset == FILAMENT_ASSET_ERROR) {
throw Exception("An error occurred loading the asset at $path");
}
return asset as FilamentAsset;
}