Skip to content

Commit

Permalink
Update main.js
Browse files Browse the repository at this point in the history
updated sceenstatus() gyropermission()
added isIOS() function
  • Loading branch information
Arcriet0727 authored Jul 31, 2024
1 parent 72bb476 commit 92f657c
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -837,9 +837,19 @@ function screenstatus() {
if (orientation.type.startsWith('portrait')) {
screenOrientationStatus = 'portrait';
} else if (orientation.type === 'landscape-primary') {
screenOrientationStatus = 'rightlandscape';
if (isIOS()) {
screenOrientationStatus = 'rightlandscape';
}
else {
screenOrientationStatus = 'leftlandscape';
}
} else if (orientation.type === 'landscape-secondary') {
screenOrientationStatus = 'leftlandscape';
if (isIOS()) {
screenOrientationStatus = 'leftlandscape';
}
else {
screenOrientationStatus = 'righttlandscape';
}
} else {
screenOrientationStatus = 'unknown';
}
Expand Down Expand Up @@ -1015,10 +1025,14 @@ function checkgyromode() {
}
}

function isIOS() {
return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
}

function gyropermission() {

if (isIOS()) {
if (typeof DeviceOrientationEvent.requestPermission === 'function') {
// document.body.addEventListener('click', function() {
//document.body.addEventListener('click', function() {
DeviceOrientationEvent.requestPermission()
.then(function() {
//console.log('DeviceOrientationEvent enabled');
Expand Down Expand Up @@ -1058,7 +1072,23 @@ function gyropermission() {
initialGamma=undefined;
setInfo('Gyroscope mode started');
}
//window.addEventListener("deviceorientation", handleOrientation, true);
} else {
window.addEventListener("deviceorientation", handleOrientation, true);
permission = true;
isGyroActive=!isGyroActive;
startToggle.name('Stop gyroscope mode');
gyroSpeedy.show();
controlspheretoggle.show();
ControlSphere.visible= true;
rearControlSphere.visible= true;
dragControls.enabled= true;
reardragControls.enabled= true;
initialAlpha=undefined;
initialBeta=undefined;
initialGamma=undefined;
setInfo('Gyroscope mode started');
}

}

function stopGyro() {
Expand Down

0 comments on commit 92f657c

Please sign in to comment.