add removeEntity method on Scene
This commit is contained in:
@@ -4,7 +4,6 @@ import 'package:thermion_dart/thermion_dart.dart';
|
|||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
|
|
||||||
class FFIScene extends Scene {
|
class FFIScene extends Scene {
|
||||||
|
|
||||||
late final _logger = Logger(this.runtimeType.toString());
|
late final _logger = Logger(this.runtimeType.toString());
|
||||||
|
|
||||||
final Pointer<TScene> scene;
|
final Pointer<TScene> scene;
|
||||||
@@ -32,6 +31,14 @@ class FFIScene extends Scene {
|
|||||||
SceneAsset_removeFromScene(asset.asset, scene);
|
SceneAsset_removeFromScene(asset.asset, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
///
|
||||||
|
///
|
||||||
|
@override
|
||||||
|
Future removeEntity(ThermionEntity entity) async {
|
||||||
|
Scene_removeEntity(scene, entity);
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@@ -42,16 +49,16 @@ class FFIScene extends Scene {
|
|||||||
.warning("No stencil highlight for asset (entity ${asset.entity})");
|
.warning("No stencil highlight for asset (entity ${asset.entity})");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.info(
|
_logger
|
||||||
"Removing stencil highlight for asset (entity ${asset.entity})");
|
.info("Removing stencil highlight for asset (entity ${asset.entity})");
|
||||||
_highlighted.remove(asset);
|
_highlighted.remove(asset);
|
||||||
final highlight = _highlightInstances[asset]!;
|
final highlight = _highlightInstances[asset]!;
|
||||||
|
|
||||||
await remove(highlight);
|
await remove(highlight);
|
||||||
await FilamentApp.instance!.destroyAsset(highlight);
|
await FilamentApp.instance!.destroyAsset(highlight);
|
||||||
|
|
||||||
_logger.info(
|
_logger
|
||||||
"Removed stencil highlight for asset (entity ${asset.entity})");
|
.info("Removed stencil highlight for asset (entity ${asset.entity})");
|
||||||
}
|
}
|
||||||
|
|
||||||
static MaterialInstance? _highlightMaterialInstance;
|
static MaterialInstance? _highlightMaterialInstance;
|
||||||
@@ -72,9 +79,8 @@ class FFIScene extends Scene {
|
|||||||
|
|
||||||
if (_highlighted.contains(asset)) {
|
if (_highlighted.contains(asset)) {
|
||||||
_logger
|
_logger
|
||||||
.info("Stencil highlight exists for asset (entity ${asset.entity})");
|
.info("Stencil highlight exists for asset (entity ${asset.entity})");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
_highlighted.add(asset);
|
_highlighted.add(asset);
|
||||||
_highlightMaterialInstance ??=
|
_highlightMaterialInstance ??=
|
||||||
await FilamentApp.instance!.createUnlitMaterialInstance();
|
await FilamentApp.instance!.createUnlitMaterialInstance();
|
||||||
@@ -102,7 +108,7 @@ class FFIScene extends Scene {
|
|||||||
await _highlightMaterialInstance!
|
await _highlightMaterialInstance!
|
||||||
.setParameterFloat4("baseColorFactor", r, g, b, 1.0);
|
.setParameterFloat4("baseColorFactor", r, g, b, 1.0);
|
||||||
|
|
||||||
await add(highlightInstance as FFIAsset);
|
await add(highlightInstance);
|
||||||
|
|
||||||
var transform = await FilamentApp.instance!
|
var transform = await FilamentApp.instance!
|
||||||
.getWorldTransform(highlightInstance.entity);
|
.getWorldTransform(highlightInstance.entity);
|
||||||
@@ -113,11 +119,9 @@ class FFIScene extends Scene {
|
|||||||
await FilamentApp.instance!.setPriority(highlightInstance.entity, 7);
|
await FilamentApp.instance!.setPriority(highlightInstance.entity, 7);
|
||||||
|
|
||||||
await FilamentApp.instance!.setParent(highlightInstance.entity, entity);
|
await FilamentApp.instance!.setParent(highlightInstance.entity, entity);
|
||||||
|
|
||||||
_logger
|
_logger
|
||||||
.info("Added stencil highlight for asset (entity ${asset.entity})");
|
.info("Added stencil highlight for asset (entity ${asset.entity})");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user