@@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from 'react';
22import PropTypes from 'prop-types' ;
33import * 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
486494Starfield . propTypes = {
487495 onSkyboxLoaded : PropTypes . func ,
488- uiVisible : PropTypes . bool ,
489496 disableScrollMotion : PropTypes . bool
490497} ;
491498
0 commit comments