diff --git a/thermion_dart/lib/src/filament/src/asset.dart b/thermion_dart/lib/src/filament/src/asset.dart index 9cf8dbe7..9658caa1 100644 --- a/thermion_dart/lib/src/filament/src/asset.dart +++ b/thermion_dart/lib/src/filament/src/asset.dart @@ -45,7 +45,8 @@ abstract class ThermionAsset { /// /// /// - Future getMaterialInstanceAt({ThermionEntity? entity, int index = 0}); + Future getMaterialInstanceAt( + {ThermionEntity? entity, int index = 0}); /// /// @@ -64,9 +65,19 @@ abstract class ThermionAsset { Future removeStencilHighlight(); /// - /// Creates/returns a wireframe asset representing the bounding box for this asset. + /// The bounding box for this asset, as an actual renderable asset. + /// Null by default; call [createBoundingBoxAsset] first to create. /// - Future getBoundingBoxAsset(); + ThermionAsset? get boundingBoxAsset; + + /// + /// Creates the renderable bounding box for this asset. + /// This is safe to call multiple times; if [boundingBoxAsset] is non-null, + /// this will simply return the existing bounding box asset. + /// + /// You will still need to call [Scene.add] to add this to the scene. + /// + Future createBoundingBoxAsset(); /// /// diff --git a/thermion_dart/lib/src/viewer/src/ffi/src/background_image.dart b/thermion_dart/lib/src/viewer/src/ffi/src/background_image.dart index 0aca691a..ee48f7f7 100644 --- a/thermion_dart/lib/src/viewer/src/ffi/src/background_image.dart +++ b/thermion_dart/lib/src/viewer/src/ffi/src/background_image.dart @@ -343,8 +343,10 @@ class BackgroundImage extends ThermionAsset { throw UnimplementedError(); } + ThermionAsset? get boundingBoxAsset => throw UnimplementedError(); + @override - Future getBoundingBoxAsset() { + Future createBoundingBoxAsset() { // TODO: implement getBoundingBoxAsset throw UnimplementedError(); } diff --git a/thermion_dart/lib/src/viewer/src/ffi/src/ffi_asset.dart b/thermion_dart/lib/src/viewer/src/ffi/src/ffi_asset.dart index 54c00bf0..3cf886ad 100644 --- a/thermion_dart/lib/src/viewer/src/ffi/src/ffi_asset.dart +++ b/thermion_dart/lib/src/viewer/src/ffi/src/ffi_asset.dart @@ -246,7 +246,7 @@ class FFIAsset extends ThermionAsset { throw UnimplementedError(); } - FFIAsset? boundingBoxAsset; + ThermionAsset? boundingBoxAsset; Future getBoundingBox() async { final entities = []; @@ -272,8 +272,7 @@ class FFIAsset extends ThermionAsset { /// /// /// - @override - Future getBoundingBoxAsset() async { + Future createBoundingBoxAsset() async { if (boundingBoxAsset == null) { final boundingBox = await SceneAsset_getBoundingBox(asset); @@ -365,6 +364,10 @@ class FFIAsset extends ThermionAsset { return boundingBoxAsset!; } + /// + /// + /// + @override Future getMaterialInstanceAt( {ThermionEntity? entity, int index = 0}) async { entity ??= this.entity;