Fix cube rotation in Device Orientation API demo#12
Open
Macil wants to merge 2 commits intoAurelioDeRosa:masterfrom
Open
Fix cube rotation in Device Orientation API demo#12Macil wants to merge 2 commits intoAurelioDeRosa:masterfrom
Macil wants to merge 2 commits intoAurelioDeRosa:masterfrom
Conversation
|
Please implement this. |
If you hold your phone flat and then lower a side, then the part of the cube near that lowered side should be revealed. The cube shouldn't spin wildly when you hold your screen vertical.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the Device Orientation API demo, the way the cube rotates as you rotate your device is very unintuitive, which might suggest to the user that the device orientation API or their phone's sensors aren't very accurate or have fundamental limitations. This PR fixes this issue, making the cube's rotation much more intuitive and better showing off the power of the device orientation API. It feels a lot cooler to use with this change.
This PR fixes these kinds of issues:
I applied the tips from https://dev.opera.com/articles/w3c-device-orientation-usage/ to correct the cube rotation. It does add a chunk of matrix math code to an otherwise simple demo page implementation, but I think it's really worth it.
Here's a link to the to improved demo so you can try it easily: https://macil.github.io/HTML5-API-demos/demos/device-orientation-api-demo.html. You can see major improvements if you test with a phone held with its screen held vertically, or if you hold the phone at an angle and then rotate the screen while keeping it within the same plane. In both cases, the old code causes the cube to spontaneously rotate faces out of view, while the new code keeps a consistent view of the cube as if it's staying still in space behind your screen.
This PR also has a separate commit to change the cube to be less transparent since I had a lot of trouble telling apart the front and back faces and seeing it as a cube.