gltf animation names are immutable, so cache these in a local copy in FFIAsset
This commit is contained in:
@@ -644,26 +644,30 @@ class FFIAsset extends ThermionAsset {
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String>? _gltfAnimationNames;
|
||||||
|
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@override
|
@override
|
||||||
Future<List<String>> getGltfAnimationNames() async {
|
Future<List<String>> getGltfAnimationNames() async {
|
||||||
var animationCount =
|
if (_gltfAnimationNames == null) {
|
||||||
AnimationManager_getGltfAnimationCount(animationManager, asset);
|
var animationCount =
|
||||||
if (animationCount == -1) {
|
AnimationManager_getGltfAnimationCount(animationManager, asset);
|
||||||
throw Exception("This is not a glTF asset");
|
if (animationCount == -1) {
|
||||||
|
throw Exception("This is not a glTF asset");
|
||||||
|
}
|
||||||
|
_gltfAnimationNames = [];
|
||||||
|
var outPtr = allocate<Char>(255);
|
||||||
|
for (int i = 0; i < animationCount; i++) {
|
||||||
|
AnimationManager_getGltfAnimationName(
|
||||||
|
animationManager, asset, outPtr, i);
|
||||||
|
_gltfAnimationNames!.add(outPtr.cast<Utf8>().toDartString());
|
||||||
|
}
|
||||||
|
free(outPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
var names = <String>[];
|
return _gltfAnimationNames!;
|
||||||
var outPtr = allocate<Char>(255);
|
|
||||||
for (int i = 0; i < animationCount; i++) {
|
|
||||||
AnimationManager_getGltfAnimationName(animationManager, asset, outPtr, i);
|
|
||||||
names.add(outPtr.cast<Utf8>().toDartString());
|
|
||||||
}
|
|
||||||
free(outPtr);
|
|
||||||
|
|
||||||
return names;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user