-
Notifications
You must be signed in to change notification settings - Fork 0
/
final.html
293 lines (227 loc) · 13.6 KB
/
final.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Medieval Age</title>
<meta name="description" content="Medieval Age in VR">
<!-- <script src="https://aframe.io/releases/1.3.0/aframe.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/donmccurdy/aframe-extras@v6.1.1/dist/aframe-extras.min.js"></script> -->
<script src="./assets/js/aframe.min.js"></script>
<script src="./assets/js/aframe-extras.min.js"></script>
<script src="./assets/js/rounded.min.js"></script>
</head>
<body>
<audio class="playback" data-audioId="1" src="./assets/audio/1.mp3"></audio>
<audio class="playback" data-audioId="2" src="./assets/audio/2.mp3"></audio>
<audio class="playback" data-audioId="3" src="./assets/audio/3.mp3"></audio>
<audio class="playback" data-audioId="4" src="./assets/audio/4.mp3"></audio>
<audio class="playback" data-audioId="5" src="./assets/audio/5.mp3"></audio>
<audio class="playback" data-audioId="6" src="./assets/audio/6.mp3"></audio>
<audio class="playback" data-audioId="7" src="./assets/audio/7.mp3"></audio>
<audio class="playback" data-audioId="8" src="./assets/audio/8.mp3"></audio>
<audio class="playback" data-audioId="9" src="./assets/audio/9.mp3"></audio>
<audio class="playback" data-audioId="10" src="./assets/audio/10.mp3"></audio>
<audio class="playback" data-audioId="11" src="./assets/audio/11.mp3"></audio>
<audio class="playback" data-audioId="12" src="./assets/audio/12.mp3"></audio>
<audio class="playback" data-audioId="13" src="./assets/audio/13.mp3"></audio>
<audio id="backgroundPlayback" data-audioType="background" src="./assets/audio/medieval.mp3" autoplay></audio>
<a-scene renderer="antialias: true;
colorManagement: true;
sortObjects: true;
physicallyCorrectLights: true;
maxCanvasWidth: 1920;
maxCanvasHeight: 1920;">
<a-entity id="anchor" position="-25.90 24.508 -16.557" rotation="0 220 0" movement-controls="fly: true">
<a-entity camera look-controls wasd-controls="acceleration: 20">
<a-entity position="0 0 -3" geometry="primitive: ring; radiusInner: 0.02; radiusOuter: 0.03;"
material="color: cyan; shader: flat" cursor="maxDistance: 30; fuse: true">
<a-animation begin="click" easing="ease-in" attribute="scale" fill="forwards" from="0.2 0.2 0.2"
to="1 1 1" dur="150"></a-animation>
<a-animation begin="fusing" easing="ease-in" attribute="scale" fill="backwards" from="1 1 1"
to="0.2 0.2 0.2" dur="500"></a-animation>
<a-text id="nextDetect" value="Next detect in 9s" position="0 2.7 -0.5" color="white" width="3"
align="center" font="./fonts/KelsonSans.fnt"></a-text>
<a-text id="HUD" value="Welcome to Medieval Age" position="0 2.5 -0.5" color="white" width="4"
align="center" font="./fonts/KelsonSans.fnt"></a-text>
<a-text id="tfjsOutput" value="Loading Image Recognition..." position="0 2 -0.5" color="white"
width="3" align="center" font="./fonts/KelsonSans.fnt"></a-text>
</a-entity>
</a-entity>
</a-entity>
<!-- <a-entity light="type:point; castShadow:true;" position="0 1 0"></a-entity> -->
<a-assets>
<a-asset-item id="scene" src="/assets/models/scene.gltf">
<a-animation attribute="rotation" begin="mouseenter" end="click" dur="1000" to="0 360 0"
repeat="indefinite">
</a-animation>
</a-asset-item>
<a-asset-item id="king" src="/assets/models/king.gltf">
<a-animation attribute="rotation" begin="mouseenter" end="click" dur="1000" to="0 360 0"
repeat="indefinite">
</a-animation>
</a-asset-item>
<a-asset-item id="sheep" src="/assets/models/sheep.gltf">
<a-animation attribute="rotation" begin="mouseenter" end="click" dur="1000" to="0 360 0"
repeat="indefinite">
</a-animation>
</a-asset-item>
<a-asset-item id="deer" src="/assets/models/deer.gltf">
<a-animation attribute="rotation" begin="mouseenter" end="click" dur="1000" to="0 360 0"
repeat="indefinite">
</a-animation>
</a-asset-item>
<a-asset-item id="sdeer" src="/assets/models/sdeer.gltf">
<a-animation attribute="rotation" begin="mouseenter" end="click" dur="1000" to="0 360 0"
repeat="indefinite">
</a-animation>
</a-asset-item>
<a-asset-item id="eagle" src="/assets/models/eagle.gltf">
<a-animation attribute="rotation" begin="mouseenter" end="click" dur="1000" to="0 360 0"
repeat="indefinite">
</a-animation>
</a-asset-item>
<img alt="3D Image" id="archDiagram" src="assets/images/vrbook.png">
</a-assets>
<a-entity static-body gltf-model="#scene" scale="1 1 1" position="0 0 0" animation-mixer></a-entity>
<a-entity static-body="" gltf-model="#king" scale="0.05 0.05 0.05" position="-10.05767 6.6285 -17.01348"
animation-mixer="" rotation="0 90 0"></a-entity>
<a-entity static-body="" gltf-model="#sheep" scale="0.5 0.5 0.5" position="18.56107 -1.42189 12.32625"
animation-mixer="" rotation=""></a-entity>
<a-entity static-body="" gltf-model="#sheep" scale="0.5 0.5 0.5" position="20.7766 -1.54032 14.32518"
animation-mixer="" rotation="0 270 0"></a-entity>
<a-entity static-body="" gltf-model="#sheep" scale="0.5 0.5 0.5" position="17.8142 -1.3038 13.70107"
animation-mixer="" rotation="0 90 0"></a-entity>
<a-entity static-body="" gltf-model="#deer" position="-22.78293 -1.08515 16.82087" scale="" animation-mixer=""
rotation="0 45 9"></a-entity>
<a-entity static-body="" gltf-model="#sdeer" position="-22.63632 -0.30669 15.62931" scale="0.7 0.7 0.7"
animation-mixer="" rotation="-10 90 9"></a-entity>
<a-entity static-body="" gltf-model="#eagle" position="-19.00025 20.47782 10.11307" scale="0.005 0.005 0.005"
animation-mixer="" rotation="-10 90 9"></a-entity>
<a-rounded-box radius="0.1" material="color:#44bd32" id="nextStart" data-go="secondSpot"
position="-23.90 19.508 -16.557" height="1" width="1" depth="1"></a-rounded-box>
<a-box id="playFirst" data-id="firstMusic" position="-8.57353 -1.23247 0.16611" height="0.3" width="0.3"
depth="0.3" color="#8e44ad" material="" geometry=""></a-box>
<a-box id="nextFirst" data-go="secondSpot" position="-8.57353 -1.23247 0.643" height="0.3" width="0.3"
depth="0.3" color="#0070f3" material="" geometry=""></a-box>
<a-box id="playSecond" data-id="secondMusic" position="-0.20274 -1.23172 8.531" height="0.3" width="0.3"
depth="0.3" color="#8e44ad" material="" geometry=""></a-box>
<a-box id="nextSecond" data-id="thirdSpot" position="-0.2002 -1.23247 8.9" height="0.3" width="0.3" depth="0.3"
color="#0070f3" material="" geometry=""></a-box>
<a-box id="playThird" data-id="secondMusic" position="-0.37728 -1.72135 20.03462" height="0.3" width="0.3"
depth="0.3" color="#8e44ad" material="" geometry=""></a-box>
<a-box id="nextThird" data-id="thirdSpot" position="-0.37728 -1.72135 20.43462" height="0.3" width="0.3"
depth="0.3" color="#0070f3" material="" geometry=""></a-box>
<a-box id="playFourth" data-id="secondMusic" position="-38.12311 -3.90954 29.03931" height="0.3" width="0.3"
depth="0.3" color="#8e44ad" material="" geometry=""></a-box>
<a-box id="nextFourth" data-id="thirdSpot" position="-37.60 -3.90954 29.03931" height="0.3" width="0.3"
depth="0.3" color="#0070f3" material="" geometry=""></a-box>
<a-box id="playFifth" data-id="secondMusic" position="-22.27742 0.83515 15.47123" height="0.3" width="0.3"
depth="0.3" color="#8e44ad" material="" geometry=""></a-box>
<a-box id="nextFifth" data-id="thirdSpot" position="-22.27742 0.83515 14.97123" height="0.3" width="0.3"
depth="0.3" color="#0070f3" material="" geometry=""></a-box>
<a-box id="playSeventh" data-id="secondMusic" position="-13.37973 0.15889 -13.24781" height="0.3" width="0.3"
depth="0.3" color="#8e44ad" material="" geometry=""></a-box>
<a-box id="nextSeventh" data-id="thirdSpot" position="-13.37973 0.15889 -13.74781" height="0.3" width="0.3"
depth="0.3" color="#0070f3" material="" geometry=""></a-box>
<a-box id="playSixth" data-id="secondMusic" position="10.62167 0.83933 -14.67578" height="0.3" width="0.3"
depth="0.3" color="#8e44ad" material="" geometry=""></a-box>
<a-box id="nextSixth" data-id="thirdSpot" position="10.62167 0.83933 -14.27578" height="0.3" width="0.3"
depth="0.3" color="#0070f3" material="" geometry=""></a-box>
<a-box id="playEighth" data-id="secondMusic" position="24.00367 -2.61342 11.22261" height="0.3" width="0.3"
depth="0.3" color="#8e44ad" material="" geometry=""></a-box>
<a-box id="nextEighth" data-id="thirdSpot" position="23.60367 -2.61342 11.22261" height="0.3" width="0.3"
depth="0.3" color="#0070f3" material="" geometry=""></a-box>
<a-image id="architecture" src="#archDiagram" position="-17.37973 4 -11.44781" rotation="10 180 0"
scale="7 7 7"></a-image>
<a-sky color="#a3bdbf"></a-sky>
<script src="./assets/js/model.js"></script>
<script>
let scene = document.querySelector('a-scene');
let screenshot = scene.components.screenshot;
let working = false
// function getCroppedCanvas(canvas) {
// console.time('CANVAS_CROPPING');
// // convert to image first
// let image = new Image();
// image.src = canvas.toDataURL();
// let newCanvas = document.createElement('canvas');
// let newContext = newCanvas.getContext('2d');
// newCanvas.width = 256;
// newCanvas.height = 256;
// newContext.drawImage(image, 0, 0, 256, 256);
// console.timeEnd('CANVAS_CROPPING');
// return newCanvas;
// }
function detect() {
working = true
console.time("CREATE_WORKER")
let worker = new Worker('./assets/js/worker.js')
console.timeEnd("CREATE_WORKER")
worker.onmessage = function (e) {
let data = e.data
document.querySelector('#tfjsOutput').setAttribute('value', data);
working = false
}
console.time("CANVAS_GENERATION")
let canvas = screenshot.getCanvas('perspective');
console.timeEnd("CANVAS_GENERATION")
console.time("CANVAS_TO_WORKER")
worker.postMessage({ canvasData: canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height) });
console.timeEnd("CANVAS_TO_WORKER")
}
function startDetecting() {
let nextDetect = document.querySelector('#nextDetect');
nextDetect.setAttribute('value', 'Detecting...');
nextDetect.setAttribute('color', 'red');
}
// function readyToDetect() {
// let limit = 15
// setInterval(async () => {
// if (limit == 0) {
// detect()
// await sleep(5000)
// limit = 15
// }
// let nextDetect = document.querySelector('#nextDetect');
// nextDetect.setAttribute('value', 'Next Detect in ' + limit + ' seconds');
// nextDetect.setAttribute('color', 'white');
// limit = limit - 1;
// }, 1000);
// }
// async function readyToDetect() {
// if(working) {
// await sleep(1000)
// readyToDetect()
// }
// let limit = 30
// for (let i = 0; i < 30; i++) {
// await sleep(1000)
// let nextDetect = document.querySelector('#nextDetect');
// nextDetect.setAttribute('value', 'Next Detect in ' + limit + ' seconds');
// nextDetect.setAttribute('color', 'white');
// limit = limit - 1;
// }
// startDetecting()
// detect()
// await sleep(2000)
// readyToDetect()
// }
async function readyToDetect() {
await sleep(30000)
startDetecting()
detect()
}
setInterval(readyToDetect, 30000)
readyToDetect()
// function to download a canvas as png
function downloadCanvas(canvas) {
let link = document.createElement('a');
link.download = 'image.png';
link.href = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
link.click();
}
</script>
</a-scene>
</body>
</html>