forked from A-HK/PESU-IO-Hall-Of-Fame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
290 lines (271 loc) · 10.4 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hall of Fame</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- import the webpage's stylesheet -->
<link rel="stylesheet" href="/style.css" />
<script>
// WebXR requires HTTPS, so the site doesn't work if someone manually enters
// the URL and ends up using HTTP. To work around this, force redirect from
// http to https for non-localhost addresses.
if (
window.location.protocol == "http:" &&
window.location.hostname != "localhost" &&
window.location.hostname != "127.0.0.1" &&
window.location.hostname != "[::1]"
) {
window.location = window.location.href.replace("http:", "https:");
}
</script>
<!-- import the webpage's javascript files -->
<script src="https://aframe.io/releases/1.0.3/aframe.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/aframe-extras.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/aframe-environment-component.min.js"></script>
<script src="https://unpkg.com/aframe-text-geometry-component@^0.5.0/dist/aframe-text-geometry-component.min.js"></script>
<script>
// Define a few custom components useful for AR mode. While these are somewhat reusable,
// I recommend checking if there are officially supported alternatives before copying
// these into new projects.
// See also https://github.com/aframevr/aframe/pull/4356
AFRAME.registerComponent("hide-in-ar-mode", {
// Set this object invisible while in AR mode.
init: function () {
this.el.sceneEl.addEventListener("enter-vr", (ev) => {
this.wasVisible = this.el.getAttribute("visible");
if (this.el.sceneEl.is("ar-mode")) {
this.el.setAttribute("visible", false);
}
});
this.el.sceneEl.addEventListener("exit-vr", (ev) => {
if (this.wasVisible) this.el.setAttribute("visible", true);
});
}
});
AFRAME.registerComponent("ar-shadows", {
// Swap an object's material to a transparent shadows-only material while
// in AR mode. Intended for use with a ground plane. The object is also
// set visible while in AR mode, this is useful if it's hidden in other
// modes due to them using a 3D environment.
schema: {
opacity: { default: 0.3 }
},
init: function () {
this.el.sceneEl.addEventListener("enter-vr", (ev) => {
this.wasVisible = this.el.getAttribute("visible");
if (this.el.sceneEl.is("ar-mode")) {
this.savedMaterial = this.el.object3D.children[0].material;
this.el.object3D.children[0].material = new THREE.ShadowMaterial();
this.el.object3D.children[0].material.opacity = this.data.opacity;
this.el.setAttribute("visible", true);
}
});
this.el.sceneEl.addEventListener("exit-vr", (ev) => {
if (this.savedMaterial) {
this.el.object3D.children[0].material = this.savedMaterial;
this.savedMaterial = null;
}
if (!this.wasVisible) this.el.setAttribute("visible", false);
});
}
});
</script>
</head>
<body>
<a-scene>
<a-assets timeout="80000">
<!-- Model source: https://sketchfab.com/3d-models/spinosaurus-2135501583704537907645bf723685e7
Model author: https://sketchfab.com/VapTor
Model license: CC Attribution -->
<img id="image-2" src="./assets/profile_card_AHK.png" />
<a-asset-item
id="optimerBoldFont"
src="https://rawgit.com/mrdoob/three.js/dev/examples/fonts/optimer_bold.typeface.json"
></a-asset-item>
<!-- <video id="ar-glass-vid" muted="true" src="./assets/ar_glasses_translation.mp4" autoplay loop="true" playsinline webkit-playsinline controls></video>-->
<a-asset-item
id="spinosaurus"
src="https://cdn.glitch.com/324a5290-5aa7-4efc-92d6-ae0736433b12%2Fspinosaurus.glb"
response-type="arraybuffer"
></a-asset-item>
<img
id="pink"
src="https://img.gs/bbdkhfbzkk/stretch/http://i.imgur.com/1hyyIUi.jpg"
crossorigin="anonymous"
/>
<img
src="https://img.gs/bbdkhfbzkk/stretch/https://i.imgur.com/25P1geh.png"
id="grid"
crossorigin="anonymous"
/>
<img
src="https://img.gs/bbdkhfbzkk/2048x1024,stretch/http://i.imgur.com/WMNH2OF.jpg"
id="chrome"
crossorigin="anonymous"
/>
<img
id="sky"
src="https://img.gs/bbdkhfbzkk/2048x2048,stretch/http://i.imgur.com/WqlqEkq.jpg"
crossorigin="anonymous"
/>
<a-asset-item
id="dawningFont"
src="./assets/fonts/dawningOfANewDayRegular.typeface.json"
></a-asset-item>
<a-asset-item
id="exoFont"
src="./assets/fonts/exo2Black.typeface.json"
></a-asset-item>
<a-asset-item
id="exoItalicFont"
src="./assets/fonts/exo2BlackItalic.typeface.json"
></a-asset-item>
</a-assets>
<a-camera position="0 1.2 0"></a-camera>
<!-- Environment for 2D and VR viewing. It's auto-hidden in AR mode. -->
<a-entity
environment="preset: forest; lighting: none; shadow: none; lightPosition: 0 2.15 0"
hide-in-ar-mode
></a-entity>
<a-entity id="dino" position="-1 2 -3" scale="0.5 0.5 0.5">
<!--
<a-entity
position="0 2.15 0"
rotation="0 55 0"
gltf-model="#spinosaurus"
animation-mixer
shadow="cast: true; receive: false"
></a-entity>
-->
<a-image
src="#my-image"
position="0 0 -10"
height="4"
width="4"
></a-image>
<a-image
src="#image-2"
position="0 0 -5"
height="4"
width="4"
></a-image>
<!--<a-video src="#ar-glass-vid" position="0 0.5 0" play="true"></a-video>-->
</a-entity>
<a-entity
scale="2 2 2"
geometry="primitive: torusKnot"
position="0 6 -10"
material="color: white; metalness:1; roughness: 0.1; sphericalEnvMap: #sky;"
>
<a-animation
easing="linear"
attribute="rotation"
dur="10000"
to="0 0 360"
repeat="indefinite"
></a-animation>
</a-entity>
<a-entity position="-3 1 -6" rotation="5 0 0">
<a-entity
rotation="0 0 5"
position="0 2 0.2"
text-geometry="value: WebXR; font: #dawningFont; bevelEnabled: true; bevelSize: 0.05; bevelThickness: 0.05; curveSegments: 12; size: 1; height: 0;"
material="color:lavenderblush; metalness:1; roughness: 0; sphericalEnvMap: #pink;"
></a-entity>
<a-entity
position="-0.5 0.5 -0.5"
scale="0.6 1.2 1"
text-geometry="value: THE HALL OF FAME; font: #exoFont; bevelEnabled: true; bevelSize: 0.1; bevelThickness: 0.1; curveSegments: 1; size: 1.5; height: 0.5;"
material="color:pink; metalness:0.9; roughness: 0.05; sphericalEnvMap: #chrome;"
></a-entity>
<a-entity
position="1 0 0.3"
text-geometry="value: Three.js; font: #exoItalicFont; style: italic; size: 0.8; weight: bold; height: 0;"
material="shader: flat; color: white"
></a-entity>
<a-entity
position="1 0 0.3"
text-geometry="value: Aesthetic; font: #exoItalicFont; style: italic; size: 0.8; weight: bold; height: 0; bevelEnabled: true; bevelSize: 0.04; bevelThickness: 0.04; curveSegments: 1"
material="shader: flat; color: white; transparent: true; opacity: 0.4"
></a-entity>
</a-entity>
<a-entity light="type: ambient; intensity: 0.5;"></a-entity>
<a-light
type="directional"
light="castShadow: true;
shadowMapHeight: 1024;
shadowMapWidth: 1024;
shadowCameraLeft: -7;
shadowCameraRight: 5;
shadowCameraBottom: -5;
shadowCameraTop: 5;"
id="light"
target="dino"
position="-5 3 1.5"
></a-light>
<!-- This shadow-receiving plane is only visible in AR mode. -->
<a-plane
height="15"
width="15"
position="0 0 -3"
rotation="-90 0 0"
shadow="receive: true"
ar-shadows="opacity: 0.3"
visible="false"
></a-plane>
</a-scene>
<div id="text">
<h1>A-Frame PESU IO Sample</h1>
<p>
This requires browser support for WebXR's AR mode, for example an
<a href="https://developers.google.com/ar/discover/supported-devices"
>ARCore-compatible</a
>
Android phone with Chrome version 81 or higher.
</p>
<p>
Powered by
<a href="https://aframe.io/blog/aframe-v1.0.0/">A-Frame v1.0.0</a>.
</p>
</div>
<script>
function setSize(scale) {
document
.getElementById("dino")
.setAttribute("scale", { x: scale, y: scale, z: scale });
}
document.getElementById("btn_full").onclick = setSize.bind(this, 1);
document.getElementById("btn_half").onclick = setSize.bind(this, 0.5);
document.getElementById("btn_quarter").onclick = setSize.bind(this, 0.25);
</script>
<!-- include the Glitch button to show what the webpage is about and
to make it easier for folks to view source and remix -->
<div
class="glitchButton"
style="position: fixed; top: 20px; right: 20px;"
></div>
<script src="https://button.glitch.me/button.js"></script>
<script>
/* window.addEventListener('click', function () {
var video = document.querySelector('#vid');
if (video.paused == true) {
video.play();
} else {
video.pause();
}
}, false);*/
</script>
<script>
/* window.addEventListener('click', function () {
var video = document.querySelector('#ar-glass-vid')
if (video.paused == true) {
video.play();
} else {
video.pause();
}
}, false);*/
</script>
</body>
</html>