-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
31 lines (25 loc) · 1.01 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id='accel'>Static stuff</div>
<div id="magneto">Static stuff</div>
<script>window.addEventListener('deviceorientation', function(event) {
document.getElementById("accel").innerText = event.alpha + ' : ' + event.beta + ' : ' + event.gamma
});
let sensor = new Accelerometer();
sensor.start();
sensor.onreading = () => {
document.getElementById("magneto").innerText = "x: " + sensor.x + " y: " + sensor.y + " z: " + sensor.z
}
sensor.onerror = event => console.log(event.error.name, event.error.message);
</script>
<video autoplay></video>
<script> const constraints = { video: true }; const video = document.querySelector('video'); navigator.mediaDevices.getUserMedia(constraints). then((stream) => {video.srcObject = stream}); </script>
</body>
</html>