feat: add getAncestor method
This commit is contained in:
@@ -1043,6 +1043,12 @@ external int get_parent(
|
||||
int child,
|
||||
);
|
||||
|
||||
@ffi.Native<EntityId Function(ffi.Pointer<ffi.Void>, EntityId)>()
|
||||
external int get_ancestor(
|
||||
ffi.Pointer<ffi.Void> sceneManager,
|
||||
int child,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<ffi.Void>, EntityId, EntityId, ffi.Bool)>()
|
||||
external void set_parent(
|
||||
|
||||
@@ -773,9 +773,14 @@ abstract class ThermionViewer {
|
||||
PrimitiveType primitiveType = PrimitiveType.TRIANGLES});
|
||||
|
||||
///
|
||||
/// Gets the parent transform of [child].
|
||||
/// Gets the parent entity of [entity]. Returns null if the entity has no parent.
|
||||
///
|
||||
Future<ThermionEntity?> getParent(ThermionEntity child);
|
||||
Future<ThermionEntity?> getParent(ThermionEntity entity);
|
||||
|
||||
///
|
||||
/// Gets the ancestor (ultimate parent) entity of [entity]. Returns null if the entity has no parent.
|
||||
///
|
||||
Future<ThermionEntity?> getAncestor(ThermionEntity entity);
|
||||
|
||||
///
|
||||
/// Sets the parent transform of [child] to [parent].
|
||||
|
||||
@@ -1805,6 +1805,21 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
return parent;
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
@override
|
||||
Future<ThermionEntity?> getAncestor(ThermionEntity child) async {
|
||||
if (_sceneManager == null) {
|
||||
throw Exception("Asset manager must be non-null");
|
||||
}
|
||||
var parent = get_ancestor(_sceneManager!, child);
|
||||
if (parent == _FILAMENT_ASSET_ERROR) {
|
||||
return null;
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user