Skip to content

Commit

Permalink
Add device orientation test
Browse files Browse the repository at this point in the history
  • Loading branch information
nickw1 committed Dec 23, 2024
1 parent 6195658 commit 1c8323f
Show file tree
Hide file tree
Showing 20 changed files with 3,891 additions and 3,851 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Some of these issues, such as incorrect North on some devices, may well be to do

For this reason, the focus at present will be on developing a **pure three.js version only**. When we believe that the key bugs and issues have been resolved, the plan is to then provide an A-Frame wrapper.

## Cross-platform Compatibility

Chrome on Android is recommended. It may also work on Chrome in iOS; please file an issue if not. It will not work on Safari on iOS, due to permissions issues - **though pull requests are welcome to fix this**. Firefox unfortunately does not appear to fully implement the Device Orientation API so is unlikely to work

## Using the library

The library has been published to `npm` so you can install with:
Expand Down
5 changes: 3 additions & 2 deletions docs/01-helloworld/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
<html>
<head>
<title>three.js</title>
<script type="module" crossorigin src="/locar.js/assets/01-helloworld-C3Ps4H1F.js"></script>
<link rel="modulepreload" crossorigin href="/locar.js/assets/locar.es-CkPE0o6E.js">
<script type="module" crossorigin src="/locar.js/assets/01-helloworld-BlqDPYE-.js"></script>
<link rel="modulepreload" crossorigin href="/locar.js/assets/modulepreload-polyfill-B5Qt9EMX.js">
<link rel="modulepreload" crossorigin href="/locar.js/assets/locar.es-B7Q9QSyi.js">
</head>
<body>
</body>
Expand Down
5 changes: 3 additions & 2 deletions docs/02-gps-and-sensors/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
<html>
<head>
<title>three.js</title>
<script type="module" crossorigin src="/locar.js/assets/02-gps-and-sensors-W9Vrp_cg.js"></script>
<link rel="modulepreload" crossorigin href="/locar.js/assets/locar.es-CkPE0o6E.js">
<script type="module" crossorigin src="/locar.js/assets/02-gps-and-sensors-B6zTVYc_.js"></script>
<link rel="modulepreload" crossorigin href="/locar.js/assets/modulepreload-polyfill-B5Qt9EMX.js">
<link rel="modulepreload" crossorigin href="/locar.js/assets/locar.es-B7Q9QSyi.js">
</head>
<body>
</body>
Expand Down
5 changes: 3 additions & 2 deletions docs/03-api-communication/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
<html>
<head>
<title>three.js</title>
<script type="module" crossorigin src="/locar.js/assets/03-api-communication-DGcf2jls.js"></script>
<link rel="modulepreload" crossorigin href="/locar.js/assets/locar.es-CkPE0o6E.js">
<script type="module" crossorigin src="/locar.js/assets/03-api-communication-NDo1RJk2.js"></script>
<link rel="modulepreload" crossorigin href="/locar.js/assets/modulepreload-polyfill-B5Qt9EMX.js">
<link rel="modulepreload" crossorigin href="/locar.js/assets/locar.es-B7Q9QSyi.js">
</head>
<body>
</body>
Expand Down
1 change: 1 addition & 0 deletions docs/assets/01-helloworld-BlqDPYE-.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion docs/assets/01-helloworld-C3Ps4H1F.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/assets/02-gps-and-sensors-B6zTVYc_.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion docs/assets/02-gps-and-sensors-W9Vrp_cg.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/assets/03-api-communication-DGcf2jls.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/assets/03-api-communication-NDo1RJk2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/assets/devorient-CH4DwcZB.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import"./modulepreload-polyfill-B5Qt9EMX.js";window.addEventListener("deviceorientationabsolute",e=>{document.getElementById("devorient").innerHTML=`Alpha: ${e.alpha}<br />Beta: ${e.beta}<br />Gamma: ${e.gamma}`});
3,841 changes: 3,841 additions & 0 deletions docs/assets/locar.es-B7Q9QSyi.js

Large diffs are not rendered by default.

3,841 changes: 0 additions & 3,841 deletions docs/assets/locar.es-CkPE0o6E.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/assets/modulepreload-polyfill-B5Qt9EMX.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions docs/devorient/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Device Orientation Test</title>
<script type="module" crossorigin src="/locar.js/assets/devorient-CH4DwcZB.js"></script>
<link rel="modulepreload" crossorigin href="/locar.js/assets/modulepreload-polyfill-B5Qt9EMX.js">
</head>
<body>
<h1>Device Orientation Test</h1>
<div id='devorient'></div>
</body>
</html>
2 changes: 2 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ <h2>Examples</h2>
</ol>
<h2>API documentation</h2>
<p>Please see <a href='/locar.js/api'>here</a>.</p>
<h2>Device Orientation Test</h2>
<p>You can use <a href='/locar.js/devorient/index.html'>this test page</a> to test your device orientation. The "alpha" value should match the bearing the device is facing, in degrees.</p>
</body>
</html>
11 changes: 11 additions & 0 deletions examples/devorient/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Device Orientation Test</title>
<script type='module' src='src/main.js'></script>
</head>
<body>
<h1>Device Orientation Test</h1>
<div id='devorient'></div>
</body>
</html>
4 changes: 4 additions & 0 deletions examples/devorient/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
window.addEventListener("deviceorientationabsolute", e => {
document.getElementById("devorient").innerHTML =
`Alpha: ${e.alpha}<br />Beta: ${e.beta}<br />Gamma: ${e.gamma}`;
});
2 changes: 2 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ <h2>Examples</h2>
</ol>
<h2>API documentation</h2>
<p>Please see <a href='/locar.js/api'>here</a>.</p>
<h2>Device Orientation Test</h2>
<p>You can use <a href='/locar.js/devorient/index.html'>this test page</a> to test your device orientation. The "alpha" value should match the bearing the device is facing, in degrees.</p>
</body>
</html>
2 changes: 1 addition & 1 deletion examples/vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig } from 'vite';
import { resolve } from 'path';

const entries = { main: 'index.html' };
['01-helloworld', '02-gps-and-sensors', '03-api-communication'].forEach ( example => {
['01-helloworld', '02-gps-and-sensors', '03-api-communication', 'devorient'].forEach ( example => {
entries[example] = resolve(__dirname, `${example}/index.html`);
});

Expand Down

0 comments on commit 1c8323f

Please sign in to comment.