提交 c8cf005b 编写于 作者: N Nicolò Carpignoli 提交者: GitHub

Merge pull request #614 from jeromeetienne/ios13

fix ios13 permissions
# 2.0.2
- Fixed motion and orientation sensors permission for iOS 13+ devices
# 2.0.1 # 2.0.1
- Fixed location-based files build - Fixed location-based files build
......
...@@ -123,7 +123,7 @@ You can also use GeoAR.js **without** the script, adding `gps-entity-place` enti ...@@ -123,7 +123,7 @@ You can also use GeoAR.js **without** the script, adding `gps-entity-place` enti
<!doctype HTML> <!doctype HTML>
<html> <html>
<script src="https://aframe.io/releases/0.9.2/aframe.min.js"></script> <script src="https://aframe.io/releases/0.9.2/aframe.min.js"></script>
<script src="https://raw.githack.com/jeromeetienne/AR.js/2.0.1/aframe/build/aframe-ar.js"></script> <script src="https://raw.githack.com/jeromeetienne/AR.js/2.0.2/aframe/build/aframe-ar.js"></script>
<body style='margin : 0px; overflow: hidden;'> <body style='margin : 0px; overflow: hidden;'>
<a-scene embedded arjs> <a-scene embedded arjs>
<a-marker preset="hiro"> <a-marker preset="hiro">
......
...@@ -5308,7 +5308,7 @@ Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype ); ...@@ -5308,7 +5308,7 @@ Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype );
// ARjs.Context.baseURL = '../' // ARjs.Context.baseURL = '../'
// default to github page // default to github page
ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/' ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/'
ARjs.Context.REVISION = '2.0.1'; ARjs.Context.REVISION = '2.0.2';
/** /**
* Create a default camera for this trackingBackend * Create a default camera for this trackingBackend
...@@ -8747,14 +8747,28 @@ AFRAME.registerComponent('gps-camera', { ...@@ -8747,14 +8747,28 @@ AFRAME.registerComponent('gps-camera', {
var eventName = this._getDeviceOrientationEventName(); var eventName = this._getDeviceOrientationEventName();
this._onDeviceOrientation = this._onDeviceOrientation.bind(this); this._onDeviceOrientation = this._onDeviceOrientation.bind(this);
// From iOS 12.2 Safari has Motion & Orientation turned off by default. // if Safari
// This may change from iOS 13.*
if (!!navigator.userAgent.match(/Version\/[\d.]+.*Safari/)) { if (!!navigator.userAgent.match(/Version\/[\d.]+.*Safari/)) {
var timeout = setTimeout(function() { alert('Please enable device orientation in Settings > Safari > Motion & Orientation Access.')}, 750); // iOS 13+
window.addEventListener(eventName, function() { if (typeof DeviceOrientationEvent.requestPermission === 'function') {
var handler = function() {
console.log('Requesting device orientation permissions...')
DeviceOrientationEvent.requestPermission();
document.removeEventListener('touchend', handler);
};
document.addEventListener('touchend', function() { handler() }, false);
alert('Please tap the screen to active geolocation.');
} else {
var timeout = setTimeout(function () {
alert('Please enable device orientation in Settings > Safari > Motion & Orientation Access.')
}, 750);
window.addEventListener(eventName, function () {
clearTimeout(timeout); clearTimeout(timeout);
}); });
} }
}
window.addEventListener(eventName, this._onDeviceOrientation, false); window.addEventListener(eventName, this._onDeviceOrientation, false);
此差异已折叠。
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<meta http-equiv='X-UA-Compatible' content='IE=edge'> <meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>GeoAR.js demo</title> <title>GeoAR.js demo</title>
<script src='https://aframe.io/releases/0.9.2/aframe.min.js'></script> <script src='https://aframe.io/releases/0.9.2/aframe.min.js'></script>
<script src='https://raw.githack.com/jeromeetienne/AR.js/master/aframe/build/aframe-ar.min.js'></script> <script src='../../build/aframe-ar.js'></script>
<script> <script>
THREEx.ArToolkitContext.baseURL = 'https://raw.githack.com/jeromeetienne/ar.js/master/three.js/' THREEx.ArToolkitContext.baseURL = 'https://raw.githack.com/jeromeetienne/ar.js/master/three.js/'
</script> </script>
......
...@@ -24,7 +24,7 @@ function loadPlaceFromAPIs(position) { ...@@ -24,7 +24,7 @@ function loadPlaceFromAPIs(position) {
const params = { const params = {
radius: 300, // search places not farther than this value (in meters) radius: 300, // search places not farther than this value (in meters)
clientId: 'HZIJGI4COHQ4AI45QXKCDFJWFJ1SFHYDFCCWKPIJDWHLVQVZ', clientId: 'HZIJGI4COHQ4AI45QXKCDFJWFJ1SFHYDFCCWKPIJDWHLVQVZ',
clientSecret: '', clientSecret: '2VBFT2H3OWI03RY5TDIMANCX4ATUTRYSXWZJHUVYGRWEZQ24',
version: '20300101', // foursquare versioning, required but unuseful for this demo version: '20300101', // foursquare versioning, required but unuseful for this demo
}; };
......
...@@ -31,14 +31,28 @@ AFRAME.registerComponent('gps-camera', { ...@@ -31,14 +31,28 @@ AFRAME.registerComponent('gps-camera', {
var eventName = this._getDeviceOrientationEventName(); var eventName = this._getDeviceOrientationEventName();
this._onDeviceOrientation = this._onDeviceOrientation.bind(this); this._onDeviceOrientation = this._onDeviceOrientation.bind(this);
// From iOS 12.2 Safari has Motion & Orientation turned off by default. // if Safari
// This may change from iOS 13.*
if (!!navigator.userAgent.match(/Version\/[\d.]+.*Safari/)) { if (!!navigator.userAgent.match(/Version\/[\d.]+.*Safari/)) {
var timeout = setTimeout(function() { alert('Please enable device orientation in Settings > Safari > Motion & Orientation Access.')}, 750); // iOS 13+
window.addEventListener(eventName, function() { if (typeof DeviceOrientationEvent.requestPermission === 'function') {
var handler = function() {
console.log('Requesting device orientation permissions...')
DeviceOrientationEvent.requestPermission();
document.removeEventListener('touchend', handler);
};
document.addEventListener('touchend', function() { handler() }, false);
alert('After camera permission prompt, please tap the screen to active geolocation.');
} else {
var timeout = setTimeout(function () {
alert('Please enable device orientation in Settings > Safari > Motion & Orientation Access.')
}, 750);
window.addEventListener(eventName, function () {
clearTimeout(timeout); clearTimeout(timeout);
}); });
} }
}
window.addEventListener(eventName, this._onDeviceOrientation, false); window.addEventListener(eventName, this._onDeviceOrientation, false);
......
{ {
"name": "ar.js", "name": "ar.js",
"version": "2.0.1", "version": "2.0.2",
"description": "Efficient Augmented Reality for the Web", "description": "Efficient Augmented Reality for the Web",
"main": "", "main": "",
"scripts": { "scripts": {
......
...@@ -76,7 +76,7 @@ Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype ); ...@@ -76,7 +76,7 @@ Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype );
// ARjs.Context.baseURL = '../' // ARjs.Context.baseURL = '../'
// default to github page // default to github page
ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/' ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/'
ARjs.Context.REVISION = '2.0.1'; ARjs.Context.REVISION = '2.0.2';
/** /**
* Create a default camera for this trackingBackend * Create a default camera for this trackingBackend
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册