add animation ticker inside render loop
This commit is contained in:
@@ -20,7 +20,7 @@ abstract class FilamentController {
|
||||
Future playAnimation(int index);
|
||||
|
||||
// Weights is expected to be a contiguous sequence of floats of size W*F, where W is the number of weights and F is the number of frames
|
||||
void animate(List<double> weights, int numWeights, double frameRate);
|
||||
Future animate(List<double> weights, int numWeights, double frameRate);
|
||||
Future createMorpher(String meshName, List<int> primitives);
|
||||
Future zoom(double z);
|
||||
}
|
||||
@@ -102,8 +102,9 @@ class MimeticFilamentController extends FilamentController {
|
||||
return result;
|
||||
}
|
||||
|
||||
void animate(List<double> weights, int numWeights, double frameRate) async {
|
||||
_channel.invokeMethod("animateWeights", [weights, numWeights, frameRate]);
|
||||
Future animate(List<double> weights, int numWeights, double frameRate) async {
|
||||
await _channel
|
||||
.invokeMethod("animateWeights", [weights, numWeights, frameRate]);
|
||||
}
|
||||
|
||||
Future releaseSourceAssets() async {
|
||||
|
||||
@@ -4,8 +4,10 @@ import 'package:mimetic_filament/view/filament_widget.dart';
|
||||
|
||||
class GestureDetectingFilamentView extends StatefulWidget {
|
||||
final FilamentController controller;
|
||||
final bool rotate;
|
||||
|
||||
const GestureDetectingFilamentView({Key? key, required this.controller})
|
||||
const GestureDetectingFilamentView(
|
||||
{Key? key, required this.controller, this.rotate = false})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -14,7 +16,6 @@ class GestureDetectingFilamentView extends StatefulWidget {
|
||||
|
||||
class _GestureDetectingFilamentViewState
|
||||
extends State<GestureDetectingFilamentView> {
|
||||
bool _rotate = false;
|
||||
int _primitiveIndex = 0;
|
||||
double _weight = 0.0;
|
||||
|
||||
@@ -23,21 +24,23 @@ class _GestureDetectingFilamentViewState
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onPanDown: (details) {
|
||||
_rotate
|
||||
widget.rotate
|
||||
? widget.controller.rotateStart(
|
||||
details.localPosition.dx, details.localPosition.dy)
|
||||
: widget.controller
|
||||
.panStart(details.localPosition.dx, details.localPosition.dy);
|
||||
},
|
||||
onPanUpdate: (details) {
|
||||
_rotate
|
||||
widget.rotate
|
||||
? widget.controller.rotateUpdate(
|
||||
details.localPosition.dx, details.localPosition.dy)
|
||||
: widget.controller.panUpdate(
|
||||
details.localPosition.dx, details.localPosition.dy);
|
||||
},
|
||||
onPanEnd: (d) {
|
||||
_rotate ? widget.controller.rotateEnd() : widget.controller.panEnd();
|
||||
widget.rotate
|
||||
? widget.controller.rotateEnd()
|
||||
: widget.controller.panEnd();
|
||||
},
|
||||
child: FilamentWidget(controller: widget.controller));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user