fluttercandies / flutter_tilt

👀 Easily apply tilt parallax hover effects for Flutter, which supports tilt, light, shadow effects, and gyroscope sensors | 为 Flutter 轻松创建倾斜视差悬停效果,支持倾斜、光照、阴影效果和陀螺仪传感器
https://pub.dev/packages/flutter_tilt
MIT License
145 stars 6 forks source link

Tilt & Hold Position? Or Tilt to Pan? #2

Open jtkeyva opened 1 year ago

jtkeyva commented 1 year ago

Hi, wondering if it's possible that when you tilt and keep it tilted that the position stays until you tilt it back to origin? This could be fun to be able to peek behind things or pan around a widget.

It has been implemented on the Motion Package https://github.com/mrcendre/motion/issues/8

AmosHuKe commented 1 year ago

Hi~ @jtkeyva You can try changing the enableSensorRevert and enableRevert of TiltConfig. It's like this:

Tilt(
  tiltConfig: const TiltConfig(
    enableRevert: false,
    enableSensorRevert: false,
  ),
),
jtkeyva commented 1 year ago

@AmosHuKe thanks, it works pretty good!

i did some experimenting and some tests and found that if i move it around enough it "tricks" it and doesn't recalibrate to it's origin.

i set my phone at an angle on the desk propped up on my laptop and started the app. i picked up my phone to look at it and set it back down where it was and it remembered the origin pretty good.

but if i move the phone around a bit, it loses track of the the origin.

is there any way to have high precision using this? i suppose it would be kinda like AR but with no lidar. So i could have widgets off screen and then pan over to see them. is that doable?

Also, what about spinning the phone around from portrait to landscape and retaining the orientation of the content? so essentially you could spin your phone and just reveal more parts of the content.

thank you, this is cool :)

AmosHuKe commented 1 year ago

@jtkeyva, Thanks for your use and suggestions!

Just released version 2.0.3 Fixed the device landscape mode not matching the sensor orientation.

I don't have a particularly good idea for positioning like AR at the moment, but I will continue to evaluate and test this effect.

jtkeyva commented 1 year ago

@AmosHuKe great to hear!

This package somehow seems to use AR without actually using AR as far as I can tell. I poked around and it seems like it uses the compass and sensors only?

https://pub.dev/packages/ar_location_view

Maybe you can get some ideas/inspiration from it :)

I look forward to your thoughts

jtkeyva commented 1 year ago

Cool it works well when I use it like:

void main() { runApp(MyApp()); SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]); }

It still doesn't perfectly remember the origin position when disabling revert. Not sure if that's possible? Maybe you can have an option to "set origin"? That way you can always return to the true position when it was set?