add option to wait for animation to complete
This commit is contained in:
@@ -138,7 +138,7 @@ class FilamentViewer extends AbstractFilamentViewer {
|
|||||||
@override
|
@override
|
||||||
Future setFrameRate(int framerate) async {
|
Future setFrameRate(int framerate) async {
|
||||||
final interval = 1000.0 / framerate;
|
final interval = 1000.0 / framerate;
|
||||||
set_frame_interval_ffi(interval);
|
set_frame_interval_ffi(_viewer!, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -494,6 +494,17 @@ class FilamentViewer extends AbstractFilamentViewer {
|
|||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<double> getAnimationDurationByName(
|
||||||
|
FilamentEntity entity, String name) async {
|
||||||
|
var animations = await getAnimationNames(entity);
|
||||||
|
var index = animations.indexOf(name);
|
||||||
|
if (index == -1) {
|
||||||
|
throw Exception("Failed to find animation $name");
|
||||||
|
}
|
||||||
|
return getAnimationDuration(entity, index);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future setMorphAnimationData(
|
Future setMorphAnimationData(
|
||||||
FilamentEntity entity, MorphAnimationData animation,
|
FilamentEntity entity, MorphAnimationData animation,
|
||||||
@@ -523,7 +534,7 @@ class FilamentViewer extends AbstractFilamentViewer {
|
|||||||
|
|
||||||
if (intersection.isEmpty) {
|
if (intersection.isEmpty) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"No morph targets specified in animation are present on targeted mesh");
|
"No morph targets specified in animation are present on mesh $meshName. If you weren't intending to animate every mesh, specify [targetMeshNames] when invoking this method.\nAnimation morph targets: ${animation.morphTargets}\nMesh morph targets ${meshMorphTargets}");
|
||||||
}
|
}
|
||||||
|
|
||||||
var indices =
|
var indices =
|
||||||
@@ -675,13 +686,20 @@ class FilamentViewer extends AbstractFilamentViewer {
|
|||||||
{bool loop = false,
|
{bool loop = false,
|
||||||
bool reverse = false,
|
bool reverse = false,
|
||||||
bool replaceActive = true,
|
bool replaceActive = true,
|
||||||
double crossfade = 0.0}) async {
|
double crossfade = 0.0,
|
||||||
|
bool wait = false}) async {
|
||||||
var animations = await getAnimationNames(entity);
|
var animations = await getAnimationNames(entity);
|
||||||
await playAnimation(entity, animations.indexOf(name),
|
var index = animations.indexOf(name);
|
||||||
|
var duration = await getAnimationDuration(entity, index);
|
||||||
|
print("Duration for $name : $duration");
|
||||||
|
await playAnimation(entity, index,
|
||||||
loop: loop,
|
loop: loop,
|
||||||
reverse: reverse,
|
reverse: reverse,
|
||||||
replaceActive: replaceActive,
|
replaceActive: replaceActive,
|
||||||
crossfade: crossfade);
|
crossfade: crossfade);
|
||||||
|
if (wait) {
|
||||||
|
await Future.delayed(Duration(milliseconds: (duration * 1000).toInt()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
Reference in New Issue
Block a user