forked from MoeDevs1/Nasa-Hackathon-Ocean-Garden
-
Notifications
You must be signed in to change notification settings - Fork 1
/
scene-three.js
88 lines (69 loc) · 2.7 KB
/
scene-three.js
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
let dialogues = [
{ role: 'scientist', text: 'Scientist first message.' },
{ role: 'character', text: 'Character response to scientist.' },
{ role: 'scientist', text: 'Scientist second message.' },
{ role: 'scientist', text: 'LET ME SEE MY GUAGE.' },
{ role: 'scientist', text: 'BYE NOW!' },
];
let currentIndex = 0;
function slideGuageLabel() {
setTimeout(function() {
label.animate({
opacity: 1,
transform: 't' + (katiesNumber - minGuageFill)
}, 700, mina.easeout);
}, 150);
}
function fillGuage() {
fill.animate({
transform: 't' + katiesNumber
}, 700, mina.easeout);
}
function updateDialogue() {
if (currentIndex >= dialogues.length) {
document.removeEventListener("click", updateDialogue);
return;
}
let currentDialogue = dialogues[currentIndex];
if (currentDialogue.text === 'LET ME SEE MY GUAGE.') {
document.getElementById("co2guage").style.display = "block";
slideGuageLabel();
fillGuage();
} else {
document.getElementById("co2guage").style.display = "none";
}
if (currentDialogue.role === 'scientist') {
document.querySelector("#scientist-quote p").textContent = currentDialogue.text;
document.querySelector("#scientist-quote").style.display = "block";
document.querySelector("#character-quote").style.display = "none";
} else if (currentDialogue.role === 'character') {
document.querySelector("#character-quote p").textContent = currentDialogue.text;
document.querySelector("#scientist-quote").style.display = "none";
document.querySelector("#character-quote").style.display = "block";
}
if (currentIndex === dialogues.length - 1 && currentDialogue.text === 'BYE NOW!') {
document.getElementById("start-journey-prompt").style.display = "block";
}
currentIndex++;
}
document.addEventListener("click", updateDialogue);
updateDialogue();
var guage = Snap.select("#co2guage"),
fill = guage.select('#guageFill'),
label = guage.select('#guageLabel'),
text = guage.select('#guageText');
var guageWidth = 1051.59,
minGuageFill = 60,
katiesNumber = 600;
if (katiesNumber <= minGuageFill){
katiesNumber = minGuageFill;
$('.co2-guage_text').attr('text-anchor','start');
}
else if (katiesNumber >= (guageWidth - 100)){!
$('.co2-guage_text').attr('text-anchor','end').attr({x: "23"});}
document.getElementById("start-journey-btn").addEventListener("click", function() {
document.querySelector(".boat2").classList.add("boat-exit-left");
setTimeout(function() {
window.location.href = "PageTwo.html";
}, 1000); // This will redirect to PageTwo.html after the 1s animation completes.
});