diff --git a/example/lib/main.dart b/example/lib/main.dart index 4b13fec2..40fa2cde 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -231,16 +231,20 @@ class _ExampleWidgetState extends State { }, "animate cube morph weights #1 and #2"), _item(() { _filamentController.setMaterialColor(_cube!, "Cone", 0, Colors.purple); - }, "set cone material color to purple") + }, "set cone material color to purple"), + _item(() { + _loop = !_loop; + setState(() {}); + }, "toggle animation looping ${_loop ? "OFF" : "ON"}") ]; if (_animations != null) { children.addAll(_animations!.map((a) => _item(() { _filamentController.playAnimation(_cube!, _animations!.indexOf(a), - replaceActive: true, crossfade: 0.5); + replaceActive: true, crossfade: 0.5, loop: _loop); }, "play animation ${_animations!.indexOf(a)} (replace/fade)"))); children.addAll(_animations!.map((a) => _item(() { _filamentController.playAnimation(_cube!, _animations!.indexOf(a), - replaceActive: false); + replaceActive: false, loop: _loop); }, "play animation ${_animations!.indexOf(a)} (noreplace)"))); } @@ -268,9 +272,7 @@ class _ExampleWidgetState extends State { // _item(36 () async { 'play animation 3'), // _item(34 () async { 'play animation 3 (noreplace)'), // _item(37 () async { 'stop animation 0'), - // _item(11 () async { - // Text( - // _loop ? "don't loop animation" : "loop animation")), + // _item(14 () async { 'set camera'), // _item(15 () async { 'animate weights'), // _item(16 () async { 'get target names'), diff --git a/ios/src/AssetManager.cpp b/ios/src/AssetManager.cpp index 1ecbe6b1..9ce75cb4 100644 --- a/ios/src/AssetManager.cpp +++ b/ios/src/AssetManager.cpp @@ -303,6 +303,9 @@ void AssetManager::updateAnimations() { break; } } + if(anim.mLoop && elapsed >= anim.mDuration) { + anim.mStart = now; + } // animation has completed } else { completed.push_back(anim); diff --git a/lib/filament_controller.dart b/lib/filament_controller.dart index 51a84fd2..f5eac296 100644 --- a/lib/filament_controller.dart +++ b/lib/filament_controller.dart @@ -337,15 +337,8 @@ class FilamentController { bool reverse = false, bool replaceActive = true, double crossfade = 0.0}) async { - await _channel.invokeMethod("playAnimation", [ - _assetManager, - asset, - index, - loop ? 1 : 0, - reverse ? 1 : 0, - replaceActive, - crossfade - ]); + await _channel.invokeMethod("playAnimation", + [_assetManager, asset, index, loop, reverse, replaceActive, crossfade]); } void setAnimationFrame(