-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathhelpers.js
More file actions
49 lines (41 loc) · 1.61 KB
/
Copy pathhelpers.js
File metadata and controls
49 lines (41 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//==========================================================================================
function findByAddress(obj, address) {
if (obj.address === address) return obj;
if (Array.isArray(obj)) {
for (const el of obj) {
const found = findByAddress(el, address);
if (found) return found;
}
} else if (obj && typeof obj === 'object') {
for (const key in obj) {
const found = findByAddress(obj[key], address);
if (found) return found;
}
}
return null;
}
//==========================================================================================
function getParamMinMax(param) {
const minValue = param?.min;
const maxValue = param?.max;
return [minValue, maxValue]
}
//==========================================================================================
function setMotionListeners() {
if (typeof DeviceMotionEvent.requestPermission === 'function') {
// alert('Motion sensors permission denied. Please enable in Settings > Safari > Motion & Orientation Access');
// iOS 13+ requires permission request from user gesture
DeviceMotionEvent.requestPermission()
.then(permissionState => {
if (permissionState === 'granted') {
console.log("Permission granted to sensors");
}
})
.catch((error) => {
console.log("Error getting sensor permission: %O", error);
alert('Motion sensors permission denied.');
});
}
}
//==========================================================================================
const audioContext = new AudioContext();