-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
232 lines (203 loc) · 9.04 KB
/
index.html
File metadata and controls
232 lines (203 loc) · 9.04 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<html>
<head>
<title>Membuat Parsing data Dari Firebase</title>
<script src="bootstrap4/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="bootstrap4/css/bootstrap.min.css"></link>
<style>
html {
min-height: 100%;
overflow-y: hidden;
overflow-x: hidden;
}
body{
background-image: url("img/body1.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
line-height: 60px;
background-color:white;
color: black;
padding-top: 15px;
opacity: 0.8;
}
.fontfotter{
margin-left: 15px;
}
</style>
</head>
<body>
<div class="row">
<div class="col-12">
<nav class="navbar navbar-expand-sm" style="background-color: white; font-style: italic; opacity: 0.8;" >
<h2>APTRG GUI</h2>
</nav>
<br>
<div class="row">
<div class="col-sm-3" style="color:lightgreen;"><h3>  Accelero X</h3></div>
<div class="col-sm-3" style="color:lightgreen;"><h3>  Accelero Y</h3></div>
<div class="col-sm-3" style="color:lightgreen;"><h3>  Accelero Z</h3></div>
<div class="col-sm-3" style="color:lightgreen;"><h3>  Humidity</h3></div>
</div>
<div class="row">
<div class="col-sm-3" style="color:white; height: 50px;"><h4 id="accx" style=" margin-left: 10px;"> Sensor 1</h4></div>
<div class="col-sm-3" style="color:white; height: 50px;"><h4 id="accy" style=" margin-left: 10px;"> Sensor 2</h4></div>
<div class="col-sm-3" style="color:white; height: 50px;"><h4 id="accz" style=" margin-left: 10px;"> Sensor 3</h4></div>
<div class="col-sm-3" style="color:white; height: 50px;"><h4 id="humidity" style=" margin-left: 10px;"> Sensor 7</h4></div>
</div>
<div class="row">
<div class="col-sm-3" style="color:lightgreen;"><h3>  Gyro X</h3></div>
<div class="col-sm-3" style="color:lightgreen;"><h3>  Gyro Y</h3></div>
<div class="col-sm-3" style="color:lightgreen;"><h3>  Gyro z</h3></div>
<div class="col-sm-3" style="color:lightgreen;"><h3>  Temperature</h3></div>
</div>
<div class="row">
<div class="col-sm-3" style="color:white; height: 50px;"><h4 id="gyrox" style=" margin-left: 10px;"> Sensor 4</h4></div>
<div class="col-sm-3" style="color:white; height: 50px;"><h4 id="gyroy" style=" margin-left: 10px;"> Sensor 5</h4></div>
<div class="col-sm-3" style="color:white; height: 50px;"><h4 id="gyroz" style=" margin-left: 10px;"> Sensor 6</h4></div>
<div class="col-sm-3" style="color:white; height: 50px;"><h4 id="temperatur" style=" margin-left: 10px;"> Sensor 8</h4></div>
</div>
<div class="row">
<div class="col-sm-3" style="color:lightgreen;"><h3>  3D Model</h3></div>
</div>
<div class="row">
<div class="col-sm-3">
<canvas id="c" style="width:500; height:300;"></canvas>
</div>
</div>
</div>
</div>
<footer class="footer">
<h5 class="fontfotter">© 2021 Copyright <a href="https://www.instagram.com/aptrg"><font color="green">APTRG</font></a></h5>
</footer>
</body>
</html>
<!-- Insert these scripts at the bottom of the HTML, but before you use any Firebase services -->
<!-- Firebase App (the core Firebase SDK) is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-database.js"></script>
<!-- If you enabled Analytics in your project, add the Firebase SDK for Analytics -->
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-analytics.js"></script>
<!-- Add Firebase products that you want to use -->
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-firestore.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyBmBC5EwOP4WNUvXMv2N_B8nVSsTgxsAX0",
authDomain: "parsing-iot.firebaseapp.com",
databaseURL: "https://parsing-iot-default-rtdb.firebaseio.com",
projectId: "parsing-iot",
storageBucket: "parsing-iot.appspot.com",
messagingSenderId: "209756588039",
appId: "1:209756588039:web:9f50ab3324a4feb57f42a2"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
var accx = document.getElementById("accx");
var accy = document.getElementById("accy");
var accz = document.getElementById("accz");
var humidity = document.getElementById("humidity");
var gyrox = document.getElementById("gyrox");
var gyroy = document.getElementById("gyroy");
var gyroz = document.getElementById("gyroz");
var temperatur = document.getElementById("temperatur");
var accxref = firebase.database().ref().child("Accelero X/Value");
var accyref = firebase.database().ref().child("Accelero Y/Value");
var acczref = firebase.database().ref().child("Accelero Z/Value");
var humidityref = firebase.database().ref().child("Humidity/Value");
var gyroxref = firebase.database().ref().child("Gyro X/Value");
var gyroyref = firebase.database().ref().child("Gyro Y/Value");
var gyrozref = firebase.database().ref().child("Gyro Z/Value");
var temperaturref = firebase.database().ref().child("Temperatur/Value");
accxref.on('value', function(datasnapshot){
accx.innerText = datasnapshot.val();
});
accyref.on('value', function(datasnapshot){
accy.innerText = datasnapshot.val();
});
acczref.on('value', function(datasnapshot){
accz.innerText = datasnapshot.val();
});
humidityref.on('value', function(datasnapshot){
humidity.innerText = datasnapshot.val();
});
gyroxref.on('value', function(datasnapshot){
gyrox.innerText = datasnapshot.val();
});
gyroyref.on('value', function(datasnapshot){
gyroy.innerText = datasnapshot.val();
});
gyrozref.on('value', function(datasnapshot){
gyroz.innerText = datasnapshot.val();
});
temperaturref.on('value', function(datasnapshot){
temperatur.innerText = datasnapshot.val();
});
</script>
<script src="./threejs/build/three.js"></script>
<script src="./threejs/build/OrbitControls.js"></script>
<script src="./threejs/build/stats.js"></script>
<script>
function main() {
const canvas = document.querySelector('#c');
const renderer = new THREE.WebGLRenderer({canvas, alpha: true});
const fov = 7;
const aspect = 2; // the canvas default
const near = 0.1;
const far = 1000;
const camera = new THREE.PerspectiveCamera(75, aspect, near, far);
camera.position.z = 4;
//create the shape
const scene = new THREE.Scene();
renderer.setClearColor( 0x000000, 0.7 ); // the default
var geometry = new THREE.CylinderGeometry( 1, 1, 3, 32 );
//create a material color or image
var material = new THREE.MeshBasicMaterial( {color: 0x66ff99, wireframe: true} );
function makeInstance(geometry) {
cylinder = new THREE.Mesh( geometry, material );
scene.add( cylinder );
return cylinder;
}
const cylinders = [
makeInstance(geometry),
];
function resizeRendererToDisplaySize(renderer) {
const canvas = renderer.domElement;
const width = canvas.clientWidth;
const height = canvas.clientHeight;
const needResize = canvas.width !== width || canvas.height !== height;
if (needResize) {
renderer.setSize(width, height, false);
}
return needResize;
}
/*var material = new THREE.MeshBasicMaterial( { color: 0xFFFFFF, wireframe: true } );
var cube = new THREE.Mesh( geometry, material );
scene.add( cube );
*/
//game logic
//draw scene
function render(){
if (resizeRendererToDisplaySize(renderer)) {
const canvas = renderer.domElement;
camera.aspect = canvas.clientWidth / canvas.clientHeight;
camera.updateProjectionMatrix();
}
cylinders.forEach((cylinder) => {
cylinder.rotation.x = document.getElementById("gyrox").innerHTML / Math.PI *0.05;
cylinder.rotation.y = document.getElementById("gyroy").innerHTML / Math.PI *0.005;
cylinder.rotation.z = document.getElementById("gyroz").innerHTML / Math.PI *0.05;
});
renderer.render( scene,camera );
requestAnimationFrame(render);
}
requestAnimationFrame(render);
}
main();
</script>