From 8da65e26a6fe16cd2e970479ec980ce3183094b5 Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Sun, 12 Mar 2023 14:02:18 +0800 Subject: [PATCH] double tap to rotate --- lib/filament_gesture_detector.dart | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/filament_gesture_detector.dart b/lib/filament_gesture_detector.dart index 6b94fd82..8d64eb04 100644 --- a/lib/filament_gesture_detector.dart +++ b/lib/filament_gesture_detector.dart @@ -34,6 +34,8 @@ class _FilamentGestureDetectorState extends State { GestureType.RotateCamera: Icons.rotate_90_degrees_ccw }; + bool _rotating = false; + // to avoid duplicating code for pan/rotate (panStart, panUpdate, panEnd, rotateStart, rotateUpdate etc) // we have only a single function for start/update/end. // when the gesture type is changed, these properties are updated to point to the correct function. @@ -91,6 +93,10 @@ class _FilamentGestureDetectorState extends State { // - outer is a GestureDetector only for pinch zoom // - inner is a Listener for all other gestures (including scroll zoom on desktop) child: GestureDetector( + onDoubleTap: () { + _rotating = !_rotating; + print("Set rotating to $_rotating"); + }, onScaleStart: !widget.enableControls ? null : (d) async { @@ -140,7 +146,7 @@ class _FilamentGestureDetectorState extends State { onPointerDown: !widget.enableControls ? null : (d) async { - if (d.buttons == kTertiaryButton) { + if (d.buttons == kTertiaryButton || _rotating) { await widget.controller.rotateStart( d.localPosition.dx, d.localPosition.dy); } else { @@ -151,7 +157,7 @@ class _FilamentGestureDetectorState extends State { onPointerMove: !widget.enableControls ? null : (d) async { - if (d.buttons == kTertiaryButton) { + if (d.buttons == kTertiaryButton || _rotating) { await widget.controller.rotateUpdate( d.localPosition.dx, d.localPosition.dy); } else { @@ -162,7 +168,7 @@ class _FilamentGestureDetectorState extends State { onPointerUp: !widget.enableControls ? null : (d) async { - if (d.buttons == kTertiaryButton) { + if (d.buttons == kTertiaryButton || _rotating) { await widget.controller.rotateEnd(); } else { await _functionEnd();