-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsample1.html
134 lines (114 loc) · 4.97 KB
/
sample1.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello, WebVR! • A-Frame</title>
<meta name="description" content="Hello, WebVR! • A-Frame">
<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
</head>
<body>
<a-scene background="color: #FAFAFA">
<a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9" shadow></a-box>
<a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E" shadow></a-sphere>
<a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D" shadow></a-cylinder>
<a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4" shadow></a-plane>
<a-entity id="ctlL" oculus-touch-controls="hand: left"></a-entity>
<a-entity id="ctlR" oculus-touch-controls="hand: right"></a-entity>
<a-entity camera look-controls position="0 1.6 0">
<a-text id="txt" value="" position="0 0 -1" scale="0.4 0.4 0.4" align="center" color="#000000"></a-text>
<a-text id="txt2" value="" position="0 -0.15 -1" scale="0.4 0.4 0.4" align="center" color="#000000"></a-text>
</a-entity>
</a-scene>
<script>
const ctlL = document.getElementById("ctlL");
const ctlR = document.getElementById("ctlR");
const txt = document.getElementById("txt");
const txt2 = document.getElementById("txt2");
//Getting Position of Right Controller.
const timer = setInterval(() => {
var p=ctlR.object3D.position;
txt2.setAttribute("value","R-Position: "+ p.x.toFixed(2)+", "+p.y.toFixed(2)+", "+p.z.toFixed(2));
}, 100);
ctlL.addEventListener('thumbstickmoved',function(event){
txt.setAttribute("value", "L Stick x:"+event.detail.x.toFixed(2)+", y:"+event.detail.y.toFixed(2));
});
ctlR.addEventListener('thumbstickmoved',function(event){
txt.setAttribute("value", "R Stick x:"+event.detail.x.toFixed(2)+", y:"+event.detail.y.toFixed(2));
});
//Trigger Touch Started
ctlL.addEventListener('triggertouchstart', function (event) {
txt.setAttribute("value","Left touch started ");
});
ctlR.addEventListener('triggertouchstart', function (event) {
txt.setAttribute("value","Right touch started");
});
//Trigger Touch Ended
ctlL.addEventListener('triggertouchend', function (event) {
txt.setAttribute("value","Left touch ended ");
});
ctlR.addEventListener('triggertouchend', function (event) {
txt.setAttribute("value","Right touch ended");
});
//Trigger Pressed
ctlL.addEventListener('triggerdown', function (event) {
txt.setAttribute("value","Left trigger down");
});
ctlR.addEventListener('triggerdown', function (event) {
txt.setAttribute("value","Right trigger down");
});
//Trigger Released
ctlL.addEventListener('triggerup', function (event) {
txt.setAttribute("value","Left trigger up");
});
ctlR.addEventListener('triggerup', function (event) {
txt.setAttribute("value","Right trigger up");
});
//Grip Pressed
ctlL.addEventListener('gripdown', function (event) {
txt.setAttribute("value","Left gripdown down");
});
ctlR.addEventListener('gripdown', function (event) {
txt.setAttribute("value","Right gripdown down");
});
//Grip Released
ctlL.addEventListener('gripup', function (event) {
txt.setAttribute("value","Left gripdown up");
});
ctlR.addEventListener('gripup', function (event) {
txt.setAttribute("value","Right gripdown up");
});
//A-buttorn Pressed
ctlR.addEventListener('abuttondown', function (event) {
txt.setAttribute("value","Right A-button down");
});
//A-buttorn Released
ctlR.addEventListener('abuttonup', function (event) {
txt.setAttribute("value","Right A-button up");
});
//B-buttorn Pressed
ctlR.addEventListener('bbuttondown', function (event) {
txt.setAttribute("value","Right B-button down");
});
//B-buttorn Released
ctlR.addEventListener('bbuttonup', function (event) {
txt.setAttribute("value","Right B-button up");
});
//Y-buttorn Pressed
ctlL.addEventListener('ybuttondown', function (event) {
txt.setAttribute("value","Left Y-button down");
});
//Y-buttorn Released
ctlL.addEventListener('ybuttonup', function (event) {
txt.setAttribute("value","Left Y-button up");
});
//X-buttorn Pressed
ctlL.addEventListener('xbuttondown', function (event) {
txt.setAttribute("value","Left X-button down");
});
//X-buttorn Released
ctlL.addEventListener('xbuttonup', function (event) {
txt.setAttribute("value","Left X-button up");
});
</script>
</body>
</html>