demo
This commit is contained in:
parent
8c51ca5ede
commit
feaa6023b9
|
|
@ -66,15 +66,16 @@ rotation: from.x"
|
||||||
|
|
||||||
function onDeviceOrientation(e) {
|
function onDeviceOrientation(e) {
|
||||||
console.log(event);
|
console.log(event);
|
||||||
// ropes.forEach(rope => { rope.gravity = { x: 0, y: 0} })
|
// ropes.forEach(rope => { rope.gravity = { x: 0, y: 0} })
|
||||||
}
|
}
|
||||||
|
|
||||||
window.enableGravity = async function enableGravity() {
|
window.enableGravity = async function enableGravity() {
|
||||||
if (DeviceOrientationEvent.requestPermission) {
|
if (DeviceOrientationEvent.requestPermission) {
|
||||||
const permission = await DeviceOrientationEvent.requestPermission();
|
const permission = await DeviceOrientationEvent.requestPermission();
|
||||||
|
console.log(permission)
|
||||||
if (permission === "granted") {
|
if (permission === "granted") {
|
||||||
window.addEventListener("deviceorientation", onDeviceOrientation);
|
window.addEventListener("deviceorientation", onDeviceOrientation);
|
||||||
|
console.log('registered')
|
||||||
} else {
|
} else {
|
||||||
console.warn('Permission for device orientation rejected', permission)
|
console.warn('Permission for device orientation rejected', permission)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue