erikwatson / snowfall.js

Stay cool ☃️
https://erikwatson.github.io/snowfall.js/
MIT License
4 stars 2 forks source link

Gravity should respect device orientation #31

Open erikwatson opened 1 year ago

erikwatson commented 1 year ago

We can track the users device orientation and use that information to set the gravity vector. This will make it so that the snow always falls towards Earth, no matter the rotation of the phone/tablet/whatever.

I think this sounds like a fun feature but it should be optional. Stick it behind a setting like { trackDeviceOrientation: false } or something.

erikwatson commented 1 month ago

This now gets set in the gravity config setting:

snowfall.start({ gravity: { respectOrientation: true } })
erikwatson commented 1 month ago

Reopening this, it isn't as simple as it looked. It seemed to work okay in the simulator, but on a real device it's obviously buggy.

The 3 angles you get out of the device orientation events are not directly usable for our needs. This will require some on-device testing to make sure it's working properly.