Skip to content

Make Three.js location-based examples available on iPhone #659

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

Merged
merged 2 commits into from
Mar 17, 2025

Conversation

ma2yama
Copy link
Contributor

@ma2yama ma2yama commented Mar 17, 2025

⚠️ All PRs have to be done versus 'dev' branch, so be aware of that, or we'll close your issue ⚠️

What kind of change does this PR introduce?

bugfix

Can it be referenced to an Issue? If so what is the issue # ?

No

How can we test it?

Using location-based examples on iPhone.

Summary

When using three.js/examples/location-based on my iPhone, I got the error "NotAllowedError: Requesting device orientation access requires a user gesture to prompt". So I decided to make the DeviceOrientationControls click the OK button before creating them.

Does this PR introduce a breaking change?

No

Please TEST your PR before proposing it. Specify here what device you have used for tests, version of OS and version of Browser

iPhone 14 Pro, mobile Safari, iOS 18.2

Other information

https://dev.to/li/how-to-requestpermission-for-devicemotion-and-deviceorientation-events-in-ios-13-46g2

@nickw1
Copy link
Collaborator

nickw1 commented Mar 17, 2025

Hi @ma2yama, many thanks. Let me test it (on an Android device) and confirm it still works as expected.
I'm not familiar with the iOS permissions API but it looks like it detects if the user interacts with the device (e.g. clicking a button) and if so, the permission is granted? (It confused me initally that you do not explicitly request permission when the button on your dialog is clicked).

@nickw1
Copy link
Collaborator

nickw1 commented Mar 17, 2025

Hi @ma2yama, I've tested the example and it all works fine on Android still. Will merge.
Many thanks for your contribution!

@nickw1 nickw1 merged commit dd5ce23 into AR-js-org:dev Mar 17, 2025
1 check passed
@kalwalt kalwalt added bug Something isn't working enhancement New feature or request location based iOS all about iOS devices labels Mar 18, 2025
@kalwalt
Copy link
Member

kalwalt commented Mar 18, 2025

Thank you @ma2yama @nickw1 for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request iOS all about iOS devices location based
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants