-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
224 lines (224 loc) · 9.18 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
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
<!DOCTYPE html>
<html>
<head>
<title>Chem AR Interactive</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
<script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,700,1,0" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono">
<style>
html{
font-family: 'Roboto Mono', sans-serif;
}
.infopanel {
position:fixed;
top: 0;
left: 0;
padding: 20px;
width: calc(100% - 40px);
height: calc(100% - 40px);
background-color: #FB8500;
color: white;
}
.cont{
width: 100%;
height: 100%;
max-width: 600px;
margin-left: auto;
margin-right: auto;
}
p {
font-size: 20px;
margin-top: 20px;
margin-bottom: 10px;
}
h2{
margin-top: 10px;
margin-bottom: 10px;
}
h1{
margin-bottom: 5px;
}
.actionbutton {
display: block;
position: fixed;
bottom: 20px;
font-family: 'Roboto Mono', sans-serif;
width: calc(100% - 40px);
padding: 10px;
background-color: #023047;
color: white;
height: 50px;
max-width: 600px;
outline: none;
border: none;
left: 50%;
transform: translateX(-50%);
font-size: 30px;
line-height: 30px;
border-radius: 25px;
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}
#panel1{
display: block;
}
#panel2{
display: none;
}
#panel3{
display: none;
}
ul {
margin-top: 15px;
}
li{
margin-left: 7.5px;
font-size: 20px;
}
.examplecont {
width: calc(100vw - 60px);
height: 170px;
border-radius: 20px;
margin-left: auto;
padding: 10px;
max-width: 600px;
margin-right: auto;
background-color: black;
color: white;
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}
.maincont {
width: calc(100vw - 40px);
min-height: 170px;
border-radius: 20px;
padding: 15px;
left: 50%;
max-width: 600px;
position: fixed;
bottom: 30px;
z-index: 10;
display: none;
transform: translateX(-50%);
background-color: black;
color: white;
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}
.backbutton{
position: relative;
width: 50px;
height: 50px;
border-radius: 50px;
background-color: #FFB703;
color: white;
font-size: 48px;
display: inline-block;
text-align: center;
line-height: 50px;
border: none;
outline: none;
z-index: 11;
}
.forwardbutton{
position: relative;
width: 50px;
height: 50px;
border-radius: 50px;
background-color: #FFB703;
color: white;
font-size: 48px;
display: inline-block;
text-align: center;
line-height: 50px;
float: right;
z-index: 11;
border: none;
outline: none;
}
.material-symbols-outlined{
font-size: 40px;
margin-top:5px;
margin: 0px;
margin-top: 5px;
padding: 0px;
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body style="margin : 0px; overflow: hidden;">
<div class="infopanel" id="panel1">
<div class="cont">
<h1>Molecular Geometry Interactive</h1>
<p>See how different molecular geometries look like in real life using WebAR.</p>
<p>Click on the button below to start the AR session.</p>
<button class="actionbutton" onclick="onboard()">CONTINUE</button>
</div>
</div>
<div class="infopanel" id="panel2">
<div class="cont">
<h1>Getting Started</h1>
<p>Here are some tips:</p>
<ul>
<li>Make sure you have a <a href="https://stemkoski.github.io/AR-Examples/markers/hiro.png">Hiro Marker</a> nearby, either printed out or on another device</li>
<li>Keep the Hiro marker in frame</li>
<li>Be in a place with good lighting</li>
<li>Be mindful of your surroundings</li>
</ul>
<button class="actionbutton" onclick="onboard1()">START AR</button>
</div>
</div>
<div class="maincont">
<h2 style="marign-bottom: 0px; font-size: 25px;" id="geoname">Geometry Name</h2>
<p style="marign-top: -40px; font-size: 20px; margin-bottom: 20px;" id="anglename">Angle(s)</p>
<button class="backbutton" onclick="back()" id="backbut"><span class="material-symbols-outlined">arrow_back</span></button>
<button class="forwardbutton" onclick="forward()" id="forbut"><span class="material-symbols-outlined">arrow_forward</span></button>
</div>
<a-scene id="panel3" embedded arjs='sourceType: webcam; sourceWidth:1280; sourceHeight:960; displayWidth: 1280; displayHeight: 960;' renderer="logarithmicDepthBuffer: true; colorManagement: true;" vr-mode-ui="enabled: false" gltf-model="dracoDecoderPath: https://www.gstatic.com/draco/v1/decoders/">
<a-marker>
<a-entity id="model" gltf-model="" scale="0.1 0.1 0.1" position='0 0.5 0'></a-entity>
</a-marker>
<a-entity camera></a-entity>
</a-scene>
<script>
const molegeo = ["Linear (1 Electron Group)", "Trigonal Planar", "Bent (3 Electrons Groups)", "Tetrahedral", "Trigonal Pyramid", "Bent (4 Electrons Groups)", "Trigonal Bipyramidal", "Seesaw", "T-Structure", "Linear (5 Electron Groups)", "Octahedral", "Square Pyramidal", "Square Planar"];
const angle = ["180°", "120°", "<120°", "109.5°", "107°", "104.5°", "90°, 120°", "<90°, <120°", "<90°", "180°", "90°", "90°, <90°", "90°"];
const models = ["linear.glb", "trigonalplanar.glb", "bent3.glb", "tetrahedral.glb", "trigonalpyramid.glb", "bent4.glb", "trigonalbipyramidal.glb", "seesaw.glb", "tstructure.glb", "linear5.glb", "octahedral.glb", "squarepyramidal.glb", "squareplanar.glb"];
var currentindex = 0;
function onboard(){
document.getElementById("panel1").style.display = "none";
document.getElementById("panel2").style.display = "block";
}
function onboard1(){
document.getElementById("panel2").style.display = "none";
document.getElementById("panel3").style.display = "block";
document.getElementsByClassName("maincont")[0].style.display = "block";
}
function render(index){
document.getElementById("model").setAttribute("gltf-model", "https://cdn.jsdelivr.net/gh/Piflyer/cdn@main/chemmodels/" + models[index]);
document.getElementById("geoname").innerHTML = molegeo[index];
document.getElementById("anglename").innerHTML = angle[index];
}
function forward(){
if(currentindex == molegeo.length - 1){
currentindex = 0;
}
else{
currentindex++;
}
render(currentindex);
}
function back(){
if(currentindex == 0){
currentindex = molegeo.length - 1;
}
else{
currentindex--;
}
render(currentindex);
}
render(currentindex);
</script>
</body>
</html>