when destroying an asset, remove/destroy instances before destroying the parent asset
This commit is contained in:
@@ -263,6 +263,15 @@ class FFIFilamentApp extends FilamentApp<Pointer> {
|
||||
///
|
||||
Future destroyAsset(covariant FFIAsset asset) async {
|
||||
await asset.removeAnimationComponent();
|
||||
if (!asset.isInstance) {
|
||||
for (final instance in (await asset.getInstances()).cast<FFIAsset>()) {
|
||||
await instance.removeAnimationComponent();
|
||||
await withVoidCallback((requestId, cb) =>
|
||||
SceneAsset_destroyRenderThread(instance.asset, requestId, cb));
|
||||
await instance.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
await withVoidCallback((requestId, cb) =>
|
||||
SceneAsset_destroyRenderThread(asset.asset, requestId, cb));
|
||||
await asset.dispose();
|
||||
|
||||
@@ -480,7 +480,11 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
await scene.remove(asset.boundingBoxAsset! as FFIAsset);
|
||||
await FilamentApp.instance!.destroyAsset(asset.boundingBoxAsset!);
|
||||
}
|
||||
for (final instance in (await asset.getInstances()).cast<FFIAsset>()) {
|
||||
await scene.remove(instance);
|
||||
}
|
||||
await FilamentApp.instance!.destroyAsset(asset);
|
||||
_logger.info("Destroyed asset");
|
||||
}
|
||||
_assets.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user