-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinalChallenge.html
More file actions
437 lines (371 loc) · 12.9 KB
/
finalChallenge.html
File metadata and controls
437 lines (371 loc) · 12.9 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
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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Viking Funeral Ritual</title>
<script src="https://cdn.jsdelivr.net/gh/aframevr/aframe@master/dist/aframe-master.js"></script>
<script src="https://unpkg.com/aframe-event-set-component/dist/aframe-event-set-component.min.js"></script>
<script src="https://unpkg.com/aframe-extras@7.5.0/dist/aframe-extras.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/aframe-particle-system-component@1.1.4/dist/aframe-particle-system-component.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/n5ro/aframe-physics-system@v4.0.1/dist/aframe-physics-system.min.js"></script>
<script src="js/handedness-setup.js"></script>
<script src="js/thumbstick-movement.js"></script>
<script src="js/grip-grab-combat.js"></script>
</head>
<body>
<a-scene physics="debug: true;">
<!-- Assets -->
<a-assets>
<a-asset-item
id="forest-scene"
src="models_final_room/Challenge/scene.glb"
></a-asset-item>
<a-asset-item
id="boat-asset"
src="models_final_room/Challenge/death_boat.glb"
></a-asset-item>
<a-asset-item
id="animated-fire-asset"
src="models_final_room/Challenge/animated_fire.glb"
></a-asset-item>
<a-asset-item
id="tocha-asset"
src="models_final_room/torch.glb"
></a-asset-item>
<a-asset-item
id="escudo-asset"
src="models_adulthood_room/viking_shield/scene.gltf"
></a-asset-item>
<a-asset-item
id="amuleto-asset"
src="models_final_room/amuleto.glb"
></a-asset-item>
<a-asset-item
id="volva-asset"
src="models_final_room/volva.glb"
></a-asset-item>
<!-- Skybox 360° de Aurora Boreal -->
<img
id="aurora-sky"
src="models_marriage_room/images/NightSkyHDRI007_4K_TONEMAPPED.jpg"
/>
<!-- Audio explicativo -->
<audio
id="ceremony-explanation"
src="audio_final/audiochallenge1.mp3"
preload="auto"
></audio>
<audio
id="second-speech"
src="audio_final/audiochallenge2.mp3"
preload="auto"
></audio>
<audio
id="final-speech"
src="audio_final/audiochallenge3.mp3"
preload="auto"
></audio>
<audio
id="ambient-sound"
src="audio/ambient-sounds-at-night-243045.mp3"
preload="auto"
></audio>
<audio
id="fire-sound"
src="audio/copyright-free-fire-crackling-427409.mp3"
preload="auto"
></audio>
</a-assets>
<!-- Camera rig (player) -->
<a-entity
id="player"
position="0 0.8 0"
thumbstick-movement="speed: 2.5"
movement-controls="fly: false; speed: 0.25"
wasd-controls
vr-hands
>
<a-entity
id="camera"
camera
position="0 3 0"
look-controls
cursor="rayOrigin: mouse; fuse: false"
raycaster="objects: .clickable, .grabbable"
>
</a-entity>
<a-entity id="right-hand"></a-entity>
<a-entity id="left-hand"></a-entity>
</a-entity>
<!-- Ambiente floresta -->
<a-entity
gltf-model="#forest-scene"
position="0 0 0"
scale="2 2 2"
></a-entity>
<!-- Tocha com som de fogo -->
<a-entity
id="tocha"
gltf-model="#tocha-asset"
visible="false"
position="-1.847 1.272 -2.644"
scale="0.6 0.6 0.6"
class="grabbable interactive"
sound="src: #fire-sound; loop: true; volume: 0.7"
animation__float="property: position; to:-1.847 1.044 -2.644; dir: alternate; dur: 1500; loop: true; easing: easeInOutSine"
>
<a-entity
particle-system="preset: fire; color: #FF4400, #FF8800; particleCount: 150; velocityValue: 0 0.5 0"
position="0 0.5 0"
scale="0.3 0.3 0.3"
></a-entity>
</a-entity>
<!-- Céu de inverno nórdico com Aurora Boreal -->
<a-sky src="#aurora-sky"></a-sky>
<!-- Luz ambiente fria (inverno) -->
<a-entity
light="type: ambient; color: #b3c9d9; intensity: 0.6"
></a-entity>
<a-entity
light="type: directional; color: #dde5ed; intensity: 0.8"
position="5 10 5"
></a-entity>
<!-- NPC Viking no ritual -->
<a-entity
id="volva"
gltf-model="#volva-asset"
position="-0.076 0 -13.5"
scale="2.5 2.5 2.5"
class="clickable"
></a-entity>
<!-- Painel de subtítulos -->
<a-entity
id="npc-subtitle"
position="-0.076 4 -13.5"
visible="false"
>
<a-plane color="#000000" opacity="0.7" width="6" height="0.8"></a-plane>
<a-text
id="subtitle-text"
value=""
position="0 0 0.01"
align="center"
color="#FFFFFF"
width="5.5"
wrap-count="50"
>
</a-text>
</a-entity>
<!-- Boat -->
<a-entity
id="boat"
gltf-model="#boat-asset"
position="0.728 0.172 -8.6"
scale="4 4 4"
rotation="0 -90 0"
class="interactive"
>
<a-entity
id="animated-fire"
gltf-model="#animated-fire-asset"
position="0 0.105 0"
scale="2 2 5"
visible="false"> </a-entity>
</a-entity>
<a-entity
id="boat-zone"
position="0 1 -1"
scale="1.5 1 1.5"
>
<a-box
position="0 0 0"
width="3"
height="0.5"
depth="3"
material="color: #00FF00; opacity: 0.3; transparent: true"
visible="false"
id="boat-zone-visual"
></a-box>
</a-entity>
<!-- Escudo do jogador -->
<a-entity
id="escudo"
gltf-model="#escudo-asset"
position="5.148 2.1 -2.219"
scale="0.04 0.04 0.04"
rotation="0 -90 0"
class="grabbable"
animation__float="property: position; to: 5.148 1.9 -2.219; dir: alternate; dur: 1500; loop: true; easing: easeInOutSine"
>
</a-entity>
<!-- Anel -->
<a-entity
id="amuleto"
gltf-model="#amuleto-asset"
position="5.148 2.17 0.358"
scale="0.01 0.01 0.01"
rotation="0 90 0"
class="grabbable"
animation__float="property: position; to: 5.148 1.9 0.358; dir: alternate; dur: 1500; loop: true; easing: easeInOutSine"
>
</a-entity>
<!-- Zona de troca -->
<a-ring position="1.451 0.250 -8.883" rotation="-90 0 0" scale="7 1.5 1" radius-inner="1" radius-outer="1.5" color="#FFD700"
opacity="0.5" material="side: double">
<a-animation attribute="rotation" from="-90 0 0" to="-90 360 0" dur="4000" repeat="indefinite"
easing="linear">
</a-animation>
</a-text>
</a-ring>
<!-- Detecção -->
<a-box
id="exchange-zone"
position="0.763 1.052 -8.691"
width="20"
height="5"
depth="5"
opacity="0"
material="transparent: true; opacity: 0"
exchange-zone>
</a-box>
<!-- Portal Final -->
<a-entity
id="return-portal"
position="-4.972 3.2 -13"
rotation="0 30 0"
visible="false"
>
<a-text
value="Challenge Complete!"
position="0 0 0.2"
align="center"
color="#FFFFFF"
width="3"
>
</a-text>
<a-link
href="EndingScene.html"
title="You have completed the Final Challenge!"
position="0 0 0"
scale="2 3 1"
class="clickable"
>
</a-link>
</a-entity>
<!-- Som ambiente geral -->
<a-entity
sound="src: #ambient-sound; autoplay: true; loop: true; volume: 0.5"
></a-entity>
<script>
document.addEventListener("DOMContentLoaded", () => {
const volva = document.querySelector("#volva");
const subtitlePanel = document.querySelector("#npc-subtitle");
const subtitleText = document.querySelector("#subtitle-text");
const audio1 = document.querySelector("#ceremony-explanation");
const audio2 = document.querySelector("#second-speech");
const audio3 = document.querySelector("#final-speech");
const shield = document.querySelector("#escudo");
const amulet = document.querySelector("#amuleto");
const boat = document.querySelector("#boat");
const boatFire = document.querySelector("#animated-fire");
const torch = document.querySelector("#tocha");
const portal = document.querySelector("#return-portal");
let itemsPlaced = 0;
let ritualStage = 0;
function playSpeech(audio, subtitles) {
let index = 0;
subtitlePanel.setAttribute("visible", true);
subtitleText.setAttribute("value", "");
audio1.pause();
audio2.pause();
audio3.pause();
audio.currentTime = 0;
audio.play();
audio.ontimeupdate = () => {
if (index < subtitles.length && audio.currentTime >= subtitles[index].time) {
subtitleText.setAttribute("value", subtitles[index].text);
index++;
}
};
audio.onended = () => {
subtitlePanel.setAttribute("visible", false);
};
}
/* =========================
DISCURSO INICIAL
========================== */
setTimeout(() => {
playSpeech(audio1, [
{ time: 0, text: "Here lies the one who has departed." },
{ time: 3, text: "The body is washed and dressed in linen." },
{ time: 6, text: "Objects placed with the body speak of their life." },
{ time: 10, text: "A shield for protection and an amulet for luck." },
{ time: 15, text: "They remind the gods of the person’s status, and the tasks they carried out in life." },
{ time: 22, text: "Now, place these items on the boat." }
]);
}, 1000);
function isInsideZone(item, zone) {
zone.object3D.updateMatrixWorld(true);
const itemPos = new THREE.Vector3();
item.object3D.getWorldPosition(itemPos);
const box = new THREE.Box3().setFromObject(zone.object3D);
return box.containsPoint(itemPos);
}
const exchangeZone = document.querySelector("#exchange-zone");
function placeInExchangeZone(item) {
item.addEventListener("onSqueezeEnd", () => {
if (item.dataset.placed) return;
if (!isInsideZone(item, exchangeZone)) return;
item.dataset.placed = "true";
if (item === shield || item === amulet) {
itemsPlaced++;
item.setAttribute("position", exchangeZone.object3D.position);
item.setAttribute("scale", "0.001 0.001 0.001");
if (itemsPlaced === 2 && ritualStage === 0) {
ritualStage = 1;
audio1.pause();
audio1.currentTime = 0;
startSecondSpeech();
torch.setAttribute("visible", "true");
torch.components.sound.playSound();
}
}
// TOCHA
else if (item === torch && ritualStage === 1) {
ritualStage = 2;
torch.setAttribute("visible", "false");
audio2.pause();
audio2.currentTime = 0;
startFinalSpeech()
boatFire.setAttribute("visible", "true");
audio3.onended = () => {
subtitlePanel.setAttribute("visible", false);
portal.setAttribute("visible", "true");
},1000;
}
});
}
placeInExchangeZone(shield);
placeInExchangeZone(amulet);
placeInExchangeZone(torch);
function startSecondSpeech() {
playSpeech(audio2, [
{ time: 0, text: "This ship will carry the spirit to its new home." },
{ time: 5, text: "Ships were symbols of passage, freedom, and honour." },
{ time: 11, text: "Only those of great standing were given this rite." },
{ time: 18, text: "Among the Norse, cremation was a path to purification." },
{ time: 24, text: "The flames carry the essence toward the gods." }
]);
}
function startFinalSpeech() {
playSpeech(audio3, [
{ time: 0, text: "Now the ship burns fiercely." },
{ time: 4, text: "The spirit is free, carried by fire, wind and memory." },
{ time: 9, text: "We who remain honour their path and guard their story so it will not fade." }
]);
}
});
</script>
</a-scene>
</body>
</html>