Skip to content

Commit

Permalink
swap control scheme entering / exiting VR
Browse files Browse the repository at this point in the history
this actually seems to work
  • Loading branch information
kfarr committed Oct 11, 2023
1 parent b4341f2 commit c994452
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,24 @@
<script src="./src/components/ocean-plane.js"></script>

<!-- vr teleport controls -->
<script src="https://cdn.jsdelivr.net/npm/aframe-blink-controls/dist/aframe-blink-controls.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/aframe-blink-controls.min.js"></script>

<script>
window.addEventListener("DOMContentLoaded", function() {
const sceneEl = document.querySelector("a-scene");
sceneEl.addEventListener("enter-vr", function() {
document.querySelector('#cameraRig').removeAttribute('look-controls')
document.querySelector('#cameraRig').removeAttribute('wasd-controls')
document.querySelector('#cameraRig').removeAttribute('cursor-teleport')
document.querySelector('#cameraRig').setAttribute('position', '0 0 0')
});
sceneEl.addEventListener("exit-vr", function() {
document.querySelector('#cameraRig').setAttribute('cursor-teleport', "cameraRig: #cameraRig; cameraHead: #camera;")
document.querySelector('#cameraRig').setAttribute('look-controls', "reverseMouseDrag: true;")
document.querySelector('#cameraRig').setAttribute('wasd-controls', "enabled: true")
});
})
</script>
<title>3DStreet</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="ui_assets/favicon.ico">
Expand Down

0 comments on commit c994452

Please sign in to comment.