-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
341 lines (281 loc) · 13.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
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<!DOCTYPE html>
<html>
<head>
<title>html2three</title>
<!-- The main stylesheet is used to layout the page for non-VR users -->
<style>
.vrPanel {
margin: 1em auto;
}
/* Do not use "display: none", all objects must take up
space on the page for them to be clickable in VR */
.vrOnly{
visibility: hidden;
position: absolute;
top:0;
z-index: -1;
}
</style>
<style id="inVR">
.vrOnly{
position: static;
}
</style>
<!-- A separate stylesheet is used for objects that are
rendered in VR.
Troubleshooting texture generation:
- All tag names must be in lowercase
- #id selectors cannot be rendered in Firefox.
- Set "debugTextures" in DebugOverlay.js to debug
-->
<style id="vrStyles">
.vrPanel {
background: rgba(255,255,255,0.5);
padding: 1em;
border-radius: 1em;
font-size: 24pt;
}
.vrPanel h1 {
color: red;
}
.vrPanel h1, h2, h3, .stereoscope {
font-family: "Gill Sans", "Gill Sans MT", Calibri, sans-serif;
}
.vrPanel ul {
margin: 0 0;
margin-left: 250px;
list-style-position: inside;
}
.vrPanel .floatLeft {
float: left;
width: 256px;
}
.vrPanel .imageButtons {
width: 15%;
height: 15%;
padding: 1em;
}
.header {
display: flex;
align-items: center;
justify-content: center;
}
.header span {
font-size: 200%;
color: red;
font-weight: bold;
}
.header img {
width: 256px;
margin: 0 1em;
}
.button, .toggleButton {
display: inline-block;
padding: 1em;
font-weight: bold;
color: red;
border: 3px solid red;
margin: 0.5em 0;
}
.toggleButton {
color: red;
border: 3px solid red;
cursor: pointer;
}
.toggleButton.active {
color: green;
border-color: green;
background: rgba(0,255,0,0.25);
}
.centered {
text-align: center;
}
span.fancy {
color: white;
text-shadow: 0 0 5px blue;
}
.credits p {
font-size: 50%;
}
.credits cite {
font-weight: bold;
display: block;
}
.compass {
width: 512px;
height: 512px;
}
.dragon {
max-width: 90%;
max-height: 90%;
}
</style>
<!-- Required: The THREE.js library and VREffect are used for rendering -->
<script src="lib/third-party/three/three.min.js"></script>
<script src="lib/third-party/three/VREffect.js"></script>
<!-- Optional: The WebVR Polyfill allows the demo to run on browsers that do not support WebVR -->
<script>
WebVRConfig = {
ALWAYS_APPEND_POLYFILL_DISPLAY: true
};
</script>
<script src="lib/third-party/webvr-polyfill/webvr-polyfill.js"></script>
<!-- Optional: The Leap Motion libraries allow for control of the interface using your hands -->
<script src="https://js.leapmotion.com/leap-0.6.4.min.js"></script>
<script src="https://js.leapmotion.com/leap-plugins-0.1.12.min.js"></script>
<!-- Required: Choose either the dist-ecma5 or src-ecma6 versions
of the html2three code. Use the files in "dist-ecma5" for best
compatibility. For rapid testing without recompilation, use a
modern browser and src-ecma6 files. Do not use both types at once.
-->
<!-- Compatibility (best compatibility): -->
<script src="js/dist-ecma5/MotionTracker.js"></script>
<script src="js/dist-ecma5/Skydome.js"></script>
<script src="js/dist-ecma5/HTMLElements.js"></script>
<script src="js/dist-ecma5/Controllers.js"></script>
<script src="js/dist-ecma5/Soundscape.js"></script>
<script src="js/dist-ecma5/AirCanvas.js"></script>
<script src="js/dist-ecma5/DebugOverlay.js"></script>
<script src="js/dist-ecma5/Main.js"></script>
<!-- Alternative (good for rapid testing without compilation): -->
<!--<script src="js/src-ecma6/MotionTracker.js"></script>
<script src="js/src-ecma6/Skydome.js"></script>
<script src="js/src-ecma6/HTMLElements.js"></script>
<script src="js/src-ecma6/Controllers.js"></script>
<script src="js/src-ecma6/Soundscape.js"></script>
<script src="js/src-ecma6/AirCanvas.js"></script>
<script src="js/src-ecma6/DebugOverlay.js"></script>
<script src="js/src-ecma6/Main.js"></script>-->
<!-- end of alternative -->
</head>
<body>
<!-- The body of the page consists of one of more DIVs that can be individually positioned in VR -->
<div id="vrPanel1" class="vrPanel centered">
<p class="header">
<img src="textures/stereoscope-clipart-illustration-512px.png">
<span class="title">html2three</span>
</p>
<h2>Make virtual reality web pages using HTML and CSS.</h2>
<p>
Double-tap headset to reset front-facing orientation
</p>
<div class="button" id="enterVR">Enter VR</div>
</div>
<div id="vrPanelFeatures" class="vrPanel">
<img class="floatLeft" src="textures/johnny-automatic-pointing-hand-512px.png">
<ul>
<li>Embed <strong>images</strong> using <img> tags
<li>Use <strong>stylesheets</strong> for sophisticated <span class="fancy">text formatting</span>
<li>See <strong>your hands</strong> using a Leap Motion controller
<li>Easy-to-use, no WebGL or THREE.js knowledge required</li>
<li><strong>Open-source</strong>, released under the Affero GPL license</li>
</ul>
</div>
<div id="vrPanelInteractive" class="vrPanel centered">
<h1>Interactive Elements</h1>
<div class="toggleButton">Push me</div>
<div class="toggleButton">Me too</div>
<div class="toggleButton">Me three</div>
<p>
<img id="moonBtn" class="imageButtons" src="textures/johnny-automatic-angry-moon-256px.png">
<img id="sunBtn" class="imageButtons" src="textures/johnny-automatic-sun-woodcut-256px.png">
</p>
<p>
Hyperlinking in VR currently only works in Firefox
<div class="button" id="hyperlinkBtn">Next Page</div>
</p>
</div>
<div id="vrPanelTurnAssist" class="vrPanel centered">
<img class="owl" src="textures/fromoldbooks.org-barn-own-512px.png">
<h1>Turn Assist</h1>
<h2>Turn your neck like an owl</h2>
<p>
Look straight back while seated!
</p>
<div id="turnAssistBtn" class="toggleButton">Enable</div>
</div>
<div id="vrPanelCredits" class="vrPanel centered credits">
<h1>Image Credits</h1>
<p>
<cite>"Stereoscope Clipart Illustration", public domain (Karen Arnold)</cite> http://www.publicdomainpictures.net/pictures/170000/velka/stereoscope-clipart-illustration.jpg#.WGVOvB9YeKQ.link</p>
<p><cite>"Wind rose / compass" by urwald</cite>https://openclipart.org/detail/3256/wind-rose-compass-rose</p>
<p><cite>"Barn Owl", by Arthur Watts, "A Painter's Anthology" (1924)</cite> http://www.fromoldbooks.org/ArthurWatts-PaintersAnthology/pages/025-owl/</p>
<p><cite>"Pointing hand", by johnny_automatic</cite>https://openclipart.org/detail/1006/pointing-hand</p>
<p><cite>"Angry moon", by johnny_automatic</cite>https://openclipart.org/detail/3261/angry-moon</p>
<p><cite>"Sun woodcut", by johnny_automatic</cite>https://openclipart.org/detail/551/sun-woodcut</p>
<p><cite>"Dragon behind the Door"</cite>https://www.oldbookillustrations.com/illustrations/dragon-door/</p>
<p><cite>"The Milky Way panorama", CC-BY 4.0 ESO/S. Brunier</cite>https://www.eso.org/public/usa/images/eso0932a/</p>
<p><cite>"sky_sunbeams1", by 0ptikz</cite> https://blenderartists.org/forum/showthread.php?24038-Free-high-res-skymaps-(Massive-07-update!)
</p>
</div>
<div id="vrPanelSouth" class="vrPanel centered vrOnly">
<h1>Look out behind you!</h1>
<img class="dragon" src="textures/dragon-door-1200px.jpg">
</div>
<div id="vrCompass" class="vrOnly compass">
<img src="textures/urwald-wind-rose-compass-rose-512px.png">
</div>
<div id="vrCelestialBody" class="vrOnly">
<img id="sun" src="textures/johnny-automatic-sun-woodcut-256px.png">
<img id="moon" src="textures/johnny-automatic-angry-moon-256px.png">
</div>
<script>
/* Add interactive elements */
var btns = document.getElementsByClassName("toggleButton");
for(var i = 0; i < btns.length; i++) {
btns[i].addEventListener("click",
function(e) {
if(e.target.classList.contains("active")) {
e.target.classList.remove("active");
} else {
e.target.classList.add("active");
}
}
);
}
function enterVRMode() {
HTML2VR.toggleVR();
document.getElementById("enterVR").innerText = HTML2VR.inVR ? "Exit VR" : "Enter VR";
}
function daylightMode() {
HTML2VR.setBackground("textures/sky-day.jpg", true);
document.getElementById("moon").style.display = "none";
document.getElementById("sun").style.display = "block";
}
function nighttimeMode() {
HTML2VR.setBackground("textures/sky-night.jpg", false);
document.getElementById("moon").style.display = "block";
document.getElementById("sun").style.display = "none";
}
function toggleTurnAssist() {
var mode = document.getElementById("turnAssistBtn").classList.contains("active");
HTML2VR.seatedExperience = mode;
}
function doNavigation() {
window.location.href = "hyperlink.html";
}
document.getElementById("sunBtn").addEventListener("click", daylightMode);
document.getElementById("moonBtn").addEventListener("click", nighttimeMode);
document.getElementById("enterVR").addEventListener("click", enterVRMode);
document.getElementById("turnAssistBtn").addEventListener("click", toggleTurnAssist);
document.getElementById("hyperlinkBtn").addEventListener("click", doNavigation);
/* Define the VR layout using the HTML2VR library */
HTML2VR.init();
HTML2VR.setBackground("textures/sky-day.jpg");
HTML2VR.setStylesheet("#vrStyles");
HTML2VR.setVrOnlyStylesheet("inVR");
HTML2VR.add("#vrPanelFeatures", {azimuth: -120});
HTML2VR.add("#vrPanelInteractive", {azimuth: -60});
HTML2VR.add("#vrPanel1", {azimuth: 0});
HTML2VR.add("#vrPanelTurnAssist", {azimuth: 60});
HTML2VR.add("#vrPanelCredits", {azimuth: 120});
HTML2VR.add("#vrPanelSouth", {azimuth: 180});
HTML2VR.add("#vrCelestialBody", {azimuth: 30, elevation: 70});
HTML2VR.add("#vrCompass", {azimuth: 0, elevation: -90});
daylightMode();
</script>
<!-- Fork me on github ribbon -->
<a href="https://github.com/marciot"><img style="position: absolute; top: 0; right: 0; border: 0; z-index: 101;" src="https://camo.githubusercontent.com/365986a132ccd6a44c23a9169022c0b5c890c387/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"></a>
<!-- End of fork me on github ribbon -->
</body>
</head>