-
Notifications
You must be signed in to change notification settings - Fork 924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimplementation of device orientation code - iOS/Safari user participation needed! #302
Comments
Just to add to this, there are three functions in
They seem to be doing some kind of update of the yaw dependent on the rotation:
but given that the three.js @nicolocarpignoli any idea on this? |
Another update: I tried removing the three methods in the last post; they are necessary as the augmented content is completely out of sync with the real world if they are removed. Also, and importantly, I have found that the basic A-Frame example on the first post in fact does not work consistently on my devices, either under Chrome or Firefox. Sometimes it's 180 degrees rotated so that the 'north' sphere appears to the south. Refreshing the page sometimes fixes it. In conclusion, as the basic A-Frame example does not reliably work, I'm wondering whether there is a bug in the version of |
Starting to get to the bottom of this I think. The problem is that we cannot rely on the In tests, I am finding that However, This (admittedly not up-to-date) article on W3C suggests that Try out an alpha/beta/gamma demo on your device here if you're interested. |
The fun continues... Looks like we can solve this reliably on Chrome, and also possibly Safari, using the Can't find a solution for Firefox to be honest. Guessing we might have to take the raw accelerometer and magnetic field values, and calculate an orientation matrix from them, as has been done in the Android API. Maybe someone has developed a library for that already - need to investigate. Or - less good - calculate the heading from successive GPS lat/lon readings from the Geolocation API, obviously this is no good if you're standing still though. If anyone has any thoughts on this, do please post them here. Stack Overflow discussion here |
I'm wondering whether, sadly, it is currently impossible to do this on Firefox. It seems that the https://developer.mozilla.org/en-US/docs/Web/API/Magnetometer What seems a little inexplicable is that apparently this used to be possible as the If anyone can suggest a way of getting this working on Firefox in the meantime, that would be great - otherwise for now, I think we're stuck with limiting support to Chrome and Safari. |
OK I have found some time to start investigating this and to replace the current device orientation code with a new implementation which takes into account changes in the device orientation API. I have a small demo at https://hikar.org/orient2/ which shows the current azimuth (compass bearing), pitch and roll of the device. This gives the expected values on Chrome, in portrait (EDIT landscape is more complex - this is a todo) It will not work on Firefox; as said above, sadly there appears to be no way to currently obtain absolute orientation on Firefox. It should in theory work on Safari but I have no way of testing this. Therefore, if anyone with an iOS device is able to test out the demo on Safari and report how:
... that would be great. Thanks, |
@nickw1 At the moment, on Safari/iOS 14, I get an alert "aaa", and after that a page with no orientation data. |
Hey, this discussion seems relevant to my problem can someone help? |
@cameronValtech ok thanks. This is proving to be a difficult one. Are you able to run it with the developer tools for Safari? Would be good to see if there is a specific error. No worries if not! The 'aaa' is just a debug thing btw... |
@nickw1 , this is the error message on iOS 15:
You would need to add a button which actually requests access to the API |
@ThorstenBux ok thanks. |
I was able to use the demo on iOS 15.1 and it seemed to be working correctly. Azimuth seemed to correspond to the compass heading (when the device laying flat on a table or held upright), pitch to corresponded to the device's orientation laying flat or standing upright, and roll to the side to side rotation that would shift between portrait and landscape. I couldn't figure out what heading corresponded to though. |
@drewish many thanks. Did azimuth correspond to the compass heading when the device was NOT lying flat?
|
Heading seemed to have no relation to the compass. It would also jitter erratically by a 2 or 3 when the phone was laying stationary on the table |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Rotation of AR view is often 90 degrees out on Firefox (but not consistently).
If the current behavior is a bug, please provide the steps to reproduce.
Try a location-based example, such as https://hikar.org/webapp/ (in Europe and Turkey), on Firefox, you will find that the augmented content might be 90 degrees out.
Investigating this issue
I'd like to investigate this issue a bit further, to find out whether it is within AR.js or whether it is in the THREE.js DeviceOrientationControls used by A-Frame to perform automatic rotation based on the compass and accelerometer sensors.
To do this I have created a very simple pure A-Frame (no ar.js) example here:
https://hikar.org/aframe/
Please try this on your own device, in a location where you will not get magnetic interference, and see if you get the expected behaviour, which is:
Please report the behaviour on your device, stating device, operating system and critically, browser and version. Note on Firefox you have to tap the screen to start the auto-rotation.
If this works for most devices, we know the problem is in AR.js. If it frequently fails on Firefox, we know the problem may well be with DeviceOrientationControls.
I will start by reporting
expected behaviourunexpected behaviour: sometimes the spheres are 180 degrees out onThanks. The more reports we get, the more we can be sure whether the issue is likely to be within AR.js or not.
The text was updated successfully, but these errors were encountered: