@Cassie thanks, works perfectly.
I finished the animation but ended up having too many lines of code and probably not organized in the most effective way. Any chance I can combine codes or use a nested timeline structure. I failed doing the latter so any help is appreciated. Here is the code
var tl = gsap.timeline();
// 3D animation ThreeJS
tl.from(mesh1.rotation, {
duration: 6,
ease: "none",
x: Math.PI * 0.5,
y: -Math.PI * 5 })
.from(mesh1.position, { duration: 6, x: -20, y: -10 }, "<")
.from(
mesh2.rotation,
{
duration: 6,
ease: "none",
x: Math.PI * 0.5,
y: Math.PI * 5 },
"<")
.from(mesh2.position, { duration: 6, x: 20, y: -10 }, "<")
.from(
mesh3.rotation,
{
duration: 6,
ease: "none",
z: Math.PI * 0.5,
x: -Math.PI * 5 },
"<")
.from(mesh3.position, { duration: 6, x: 0, y: 10 }, "<")
// HMTL elements animation
.to(".mainLogo", { duration: 1, opacity: 1 }, "+=1")
.to(".sword", {duration:1, opacity: 1}, "<")
.from(".sword", { duration: 0.3, y: -600, ease: "none" })
.to(".flashWhite", {duration: 0.05, opacity: 1})
.to(".flashWhite", {duration: 0.05, opacity: 0})
.to(".flashRed", {duration: 0.05, opacity: 1})
.to(".flashRed", {duration: 0.05, opacity: 0})
.to(".flashWhite", {duration: 0.05, opacity: 1})
.to(".flashWhite", {duration: 0.05, opacity: 0})
.to(".flashRed", {duration: 0.05, opacity: 1})
.to(".flashRed", {duration: 0.05, opacity: 0})
.to(".flashWhite", {duration: 0.05, opacity: 1})
.to(".flashWhite", {duration: 0.05, opacity: 0})
.to(".flashRed", {duration: 0.05, opacity: 1})
.to(".flashRed", {duration: 0.05, opacity: 0})
.to(".background", {duration: 0.3, opacity: 1}, "<");
Also I failed to make a button element glow/flash using GSAP so I had to fall back on CSS keyframes which I try to avoid.
#play {
position:absolute;
top: 50vh;
left:44vw;
background-color: rgb(32, 32, 32);
color: #FFD700;
font-family: 'VT323', monospace;
font-size: 35px;
z-index:10;
}
#play {
animation: glowing 1300ms infinite;
}
@keyframes glowing {
0% {
box-shadow: 0 0 5px #FFD700;
}
50% {
box-shadow: 0 0 20px #FFD700;
}
100% {
box-shadow: 0 0 5px #FFD700;
}
}
Codepen
Thanks in advance