Skip to content

Commit 4f0ca33

Browse files
authored
Merge pull request #80 from ZackGoldblum/starfield-revamp
Update starfield and UI fade-in timing
2 parents 71abe99 + 450aed9 commit 4f0ca33

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

src/App.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ function App() {
2323
const handleSkyboxLoaded = () => {
2424
setTimeout(() => {
2525
setUiVisible(true);
26-
}, 500);
26+
}, 1000);
2727
};
2828

2929
return (
3030
<>
31-
<Starfield onSkyboxLoaded={handleSkyboxLoaded} uiVisible={uiVisible} />
31+
<Starfield onSkyboxLoaded={handleSkyboxLoaded} />
3232
{!isStarsPage && (
3333
<div
3434
style={{
3535
position: 'relative',
3636
zIndex: 1,
3737
opacity: uiVisible ? 1 : 0,
38-
transition: 'opacity 0.5s ease-in-out'
38+
transition: 'opacity 2.0s ease-in-out'
3939
}}
4040
>
4141
<Header />

src/components/Starfield.jsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from 'react';
22
import PropTypes from 'prop-types';
33
import * as THREE from 'three';
44

5-
const Starfield = ({ onSkyboxLoaded = () => { }, uiVisible = false, disableScrollMotion = false }) => {
5+
const Starfield = ({ onSkyboxLoaded = () => { }, disableScrollMotion = false }) => {
66
// Three.js scene references
77
const mountRef = useRef(null);
88
const sceneRef = useRef(null);
@@ -40,12 +40,12 @@ const Starfield = ({ onSkyboxLoaded = () => { }, uiVisible = false, disableScrol
4040
starsAnimatingRef.current = starsAnimating;
4141
}, [starsAnimating]);
4242

43-
// Start animation when UI becomes visible
43+
// Start animation when stars become visible (independent of UI)
4444
useEffect(() => {
45-
if (uiVisible && starsVisible && !starsAnimating) {
45+
if (starsVisible && !starsAnimating) {
4646
setStarsAnimating(true);
4747
}
48-
}, [uiVisible, starsVisible, starsAnimating]);
48+
}, [starsVisible, starsAnimating]);
4949

5050
useEffect(() => {
5151
let scene, camera, renderer, skyboxMesh;
@@ -97,7 +97,7 @@ const Starfield = ({ onSkyboxLoaded = () => { }, uiVisible = false, disableScrol
9797
velocityDecay: 0.95,
9898
maxVelocity: 2000,
9999
scrollAmplification: { base: 2.5, max: 40 },
100-
fadeInDuration: 2.0
100+
fadeInDuration: 10.0
101101
};
102102

103103
// Function to create a layer of stars
@@ -228,20 +228,28 @@ const Starfield = ({ onSkyboxLoaded = () => { }, uiVisible = false, disableScrol
228228

229229
scene.add(skyboxMesh);
230230

231-
// Initialize stars and notify completion
232-
onSkyboxLoadedRef.current();
231+
// Initialize stars and start animation immediately
233232
setStarsVisible(true);
234233

235234
// Start the animation loop
236235
animate();
236+
237+
// Delay the UI trigger until stars are visible
238+
setTimeout(() => {
239+
onSkyboxLoadedRef.current();
240+
}, 2000);
237241
},
238242
undefined, // Progress callback not needed
239243
(error) => {
240244
console.error('Failed to load galaxy texture:', error);
241245
// No fallback - just proceed with black background and stars
242-
onSkyboxLoadedRef.current();
243246
setStarsVisible(true);
244247
animate();
248+
249+
// Delay the UI trigger until stars are visible
250+
setTimeout(() => {
251+
onSkyboxLoadedRef.current();
252+
}, 2000);
245253
}
246254
);
247255

@@ -485,7 +493,6 @@ const Starfield = ({ onSkyboxLoaded = () => { }, uiVisible = false, disableScrol
485493
// PropTypes validation
486494
Starfield.propTypes = {
487495
onSkyboxLoaded: PropTypes.func,
488-
uiVisible: PropTypes.bool,
489496
disableScrollMotion: PropTypes.bool
490497
};
491498

src/index.css

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,8 @@ h3 {
693693
/* 100%*num_slides */
694694
height: 100%;
695695
position: relative;
696-
-webkit-animation: slide 30s infinite;
697-
animation: slide 30s infinite;
696+
-webkit-animation: slide 30s infinite 6s;
697+
animation: slide 30s infinite 6s;
698698
}
699699

700700
.slider {
@@ -755,8 +755,8 @@ h3 {
755755
height: 100%;
756756
border-radius: 50%;
757757
position: relative;
758-
-webkit-animation: on 30s infinite;
759-
animation: on 30s infinite;
758+
-webkit-animation: on 30s infinite 6s;
759+
animation: on 30s infinite 6s;
760760
}
761761

762762
@keyframes slide {
@@ -889,21 +889,22 @@ h3 {
889889
}
890890

891891
.switch>ul>li:nth-child(1) {
892-
animation: indicator1 30s infinite;
892+
animation: indicator1 30s infinite 6s;
893+
background-color: var(--blue_color);
893894
}
894895

895896
.switch>ul>li:nth-child(2) {
896-
animation: indicator2 30s infinite;
897+
animation: indicator2 30s infinite 6s;
897898
}
898899

899900
.switch>ul>li:nth-child(3) {
900-
animation: indicator3 30s infinite;
901+
animation: indicator3 30s infinite 6s;
901902
}
902903

903904
.switch>ul>li:nth-child(4) {
904-
animation: indicator4 30s infinite;
905+
animation: indicator4 30s infinite 6s;
905906
}
906907

907908
.switch>ul>li:nth-child(5) {
908-
animation: indicator5 30s infinite;
909+
animation: indicator5 30s infinite 6s;
909910
}

0 commit comments

Comments
 (0)