-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlashLab.js
More file actions
159 lines (132 loc) · 4.83 KB
/
FlashLab.js
File metadata and controls
159 lines (132 loc) · 4.83 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
function CreateAnimation(animationName, attribute, from, to, duration)
{
const animation = document.createElement("a-animation");
animation.classList.add(animationName);
animation.setAttribute("attribute", attribute);
if (from)
animation.setAttribute("from", from);
animation.setAttribute("to", to);
animation.setAttribute("dur", duration.toString());
return animation;
}
function FadeAnimation(opacity, duration)
{
return CreateAnimation("fade-out-animation", "opacity", null, opacity.toString(), duration);
}
/////////////////////////////////////////////////////////
const scene = document.getElementById("Scene");
const cursor = document.getElementById("Cursor");
const mainScreen = document.getElementById("MainScreen");
// const musicMenuButton = document.getElementById("MusicMenuButton");
// const musicMenuButtonImage = document.getElementById("MusicMenuButtonImage");
const webcam = document.getElementById("Webcam");
const splashScreen = document.getElementById("SplashScreen");
const startButton = document.getElementById("StartButton");
const startButtonText = document.getElementById("StartButtonText");
const directionsScreen = document.getElementById("DirectionsScreen");
const continueButton = document.getElementById("ContinueButton");
const continueButtonText = document.getElementById("ContinueButtonText");
const slideImage = document.getElementById("SlideImage");
//scene.renderer.sortObjects = true;
window.setTimeout(() =>
{
startButton.addEventListener("mouseenter", () =>
{
const focusAnimation = CreateAnimation("focus-animation", "color", "#323232", "#980000", 1500);
startButton.appendChild(focusAnimation);
startButton.setAttribute("opacity", "1");
startButton.addEventListener("mouseleave", () =>
{
const focusAnimation = startButton.querySelector(".focus-animation");
if (focusAnimation)
focusAnimation.remove();
startButton.setAttribute("color", "#323232");
startButton.setAttribute("opacity", "0.5");
});
});
}, 6500);
startButton.addEventListener("click", () =>
{
// Hide button and fade out current screen
startButtonText.object3D.visible = false;
startButton.object3D.visible = false;
for (let child of splashScreen.children)
child.appendChild(FadeAnimation(0, 500));
// Hide screen and fade in next screen
window.setTimeout(() =>
{
splashScreen.object3D.visible = false;
directionsScreen.object3D.visible = true;
for (let child of directionsScreen.children)
child.emit("fadeInDirections");
const redLights = document.querySelectorAll(`a-light`);
redLights.forEach((redLight) => redLight.emit("raiseRedLights"));
}, 500)
SetupDirectionsScreen();
});
function SetupDirectionsScreen()
{
// Add continue button mouseenter event once screen has loaded
window.setTimeout(() =>
{
continueButton.addEventListener("mouseenter", () =>
{
const focusAnimation = CreateAnimation("focus-animation", "color", "#323232", "#980000", 1500);
continueButton.appendChild(focusAnimation);
continueButton.setAttribute("opacity", "1");
continueButton.addEventListener("mouseleave", () =>
{
const focusAnimation = continueButton.querySelector(".focus-animation");
if (focusAnimation)
focusAnimation.remove();
continueButton.setAttribute("color", "#323232");
continueButton.setAttribute("opacity", "0.5");
});
});
}, 6500);
continueButton.addEventListener("click", () =>
{
continueButton.object3D.visible = false;
continueButtonText.object3D.visible = false;
for (let child of directionsScreen.children)
child.appendChild(FadeAnimation(0, 500));
directionsScreen.appendChild(FadeAnimation(0,500));
// musicMenuButton.appendChild(FadeAnimation(0,500));
// musicMenuButtonImage.appendChild(FadeAnimation(0,500));
mainScreen.appendChild(FadeAnimation(0,500));
cursor.object3D.visible = false;
const redLights = document.querySelectorAll(`a-light[color="#BE0000"]`);
redLights.forEach((redLight) => redLight.emit("lowerRedLights"));
window.setTimeout(() =>
{
for (let child of directionsScreen.children)
{
if (child.object3D)
child.object3D.visible = false;
}
directionsScreen.object3D.visible = false;
// musicMenuButton.object3D.visible = false;
// musicMenuButtonImage.object3D.visible = false;
mainScreen.object3D.visible = false;
// webcam.object3D.visible = true;
}, 500)
window.setTimeout(() =>
{
this.ShowSlide("slide", 14, 1, 10000, 100);
}, 20000);
});
}
function ShowSlide(imagePrefix, numSlides, currentSlide, pauseTime, flashTime)
{
slideImage.object3D.visible = true;
window.setTimeout(() => {
slideImage.object3D.visible = false;
slideImage.setAttribute("src", "#" + imagePrefix + currentSlide);
if (currentSlide < numSlides)
{
window.setTimeout(() => {
this.ShowSlide(imagePrefix, numSlides, currentSlide++, pauseTime, flashTime);
}, pauseTime);
}
}, flashTime);
}