This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
92 lines (82 loc) · 3.7 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<html>
<head>
<title>Magic Matta - Peeps on the Bus</title>
<script src="https://aframe.io/releases/0.9.2/aframe.min.js"></script>
<script src="build/build.js"></script>
<style>
.menu-overlay {
z-index: 99999;
position: fixed;
top: 20px;
right: 20px;
box-sizing: border-box;
padding: 1.5em;
width: 60px;
height: 60px;
padding-bottom: 0px;
background: rgba(0, 0, 0, 0.5) url(./assets/images/hamburger-white.png) center no-repeat;
background-size: 40px 40px;
font-family: Source Sans Pro, Helvetica Neue, Helvetica, Arial, sans-serif;
}
.menu-overlay:hover {
background: rgba(0, 0, 0, 0.2) url(./assets/images/hamburger-white.png) center no-repeat;
background-size: 40px 40px;
}
</style>
</head>
<body>
<div id="app"></div>
<a onclick="AFRAME.scenes[0].emit('resetGameState');"><div class="menu-overlay btn btn-outline-secondary"></div></a>
<script>
console.log("Run `makeWASD();` if you need to use a keyboard without a WebVR browser.");
AFRAME.registerComponent('make-server-if-vr', {
init: function () {
this.el.sceneEl.addEventListener('enter-vr', function () {
console.log("ENTERED VR");
makeServer();
});
}
});
function makeProjector() {
AFRAME.scenes[0].setAttribute("orbit-controls", "target: 0 0 0; initialPosition: 0 0.5 0;");
document.getElementsByClassName("a-enter-vr-button")[0].hidden = true;
AFRAME.scenes[0].camera.zoom = 2;
AFRAME.scenes[0].camera.updateProjectionMatrix();
// Disabled, not sure why this causes controllers to disappear :(
// AFRAME.scenes[0].emit('setClientMode');
}
function makeOrtho() {
var cameraEl = document.querySelector("[camera]");
cameraEl.setAttribute("ortho", "width: 2.61; height 1.65; near: -100; far: 100");
cameraEl.setAttribute("rotation", "-90 0 0");
}
function makeWASD() {
// find bus object - make it located reasonable location // detach tracker binding?
var controllerEl = document.querySelector("#bus1-controller");
controllerEl.removeAttribute("tracked-controls");
controllerEl.setAttribute("position", "0 0.1 0");
controllerEl.setAttribute("wasd-controls", "acceleration: 6");
var cameraEl = document.querySelectorAll("[camera]");
cameraEl[0].removeAttribute("wasd-controls");
AFRAME.scenes[0].setAttribute("orbit-controls", "target: 0 0 0; initialPosition: 0 0.5 0;");
AFRAME.scenes[0].emit('setClientMode');
}
function makeServer() {
// add tracked controller to above thing
// tracked-controls="idPrefix: OpenVR; controller: 2; orientationOffset:-90 180 0"
var controllerEl = document.querySelector("#bus1-controller");
controllerEl.setAttribute("tracked-controls", "idPrefix: OpenVR; orientationOffset:-90 0 0");
controllerEl.setAttribute("bind__tracked-controls", "controller: controls.bus1ControllerId");
document.querySelector("#tracker-model").setAttribute("visible", "true");
controllerEl.setAttribute("broadcast", "send: position, rotation");
document.getElementById("leftHand").setAttribute("broadcast", "send: position, rotation");
document.getElementById("rightHand").setAttribute("broadcast", "send: position, rotation");
AFRAME.scenes[0].emit('setServerMode');
}
// document.querySelector('a-scene').addEventListener('enter-vr', function () {
// console.log("ENTERED VR");
// makeServer();
// });
</script>
</body>
</html>