@@ -83,7 +83,12 @@ function App() {
8383 const [ isClosing , setIsClosing ] = useState ( false )
8484
8585 // Mobile Detection
86- const [ isMobile , setIsMobile ] = useState ( false )
86+ // Compute initial mobile state synchronously so the scene effect can use it
87+ const isMobileInitial = typeof window !== 'undefined' && (
88+ / A n d r o i d | w e b O S | i P h o n e | i P a d | i P o d | B l a c k B e r r y | I E M o b i l e | O p e r a M i n i / i. test ( navigator . userAgent ) ||
89+ ( ( 'ontouchstart' in window || navigator . maxTouchPoints > 0 ) && window . innerWidth <= 768 )
90+ )
91+ const [ isMobile , setIsMobile ] = useState ( isMobileInitial )
8792 const [ showMobileMenu , setShowMobileMenu ] = useState ( false )
8893 const [ isMobileMenuClosing , setIsMobileMenuClosing ] = useState ( false )
8994 const [ isMobileMenuAnimating , setIsMobileMenuAnimating ] = useState ( false ) // Guards hamburger button against re-trigger during close animation
@@ -532,7 +537,7 @@ function App() {
532537
533538 // Load simplified Earth texture
534539 const earthTexture = new THREE . TextureLoader ( ) . load (
535- '/earth-texture.png' ,
540+ isMobile ? '/earth-texture-mobile.png' : '/earth-texture.png' ,
536541 ( ) => {
537542 earthTexture . anisotropy = renderer . capabilities . getMaxAnisotropy ( )
538543 checkAllLoaded ( )
@@ -541,12 +546,12 @@ function App() {
541546 ( error ) => console . error ( 'Error loading texture:' , error )
542547 )
543548
544- const oceanMaskTexture = new THREE . TextureLoader ( ) . load ( '/ocean-mask.png' , ( ) => {
549+ const oceanMaskTexture = new THREE . TextureLoader ( ) . load ( isMobile ? '/ocean-mask-mobile.png' : '/ocean-mask.png' , ( ) => {
545550 oceanMaskTexture . anisotropy = renderer . capabilities . getMaxAnisotropy ( )
546551 oceanMaskTextureRef . current = oceanMaskTexture
547552 } )
548553
549- const bumpTexture = new THREE . TextureLoader ( ) . load ( '/earth-bump.jpg' , ( ) => {
554+ const bumpTexture = new THREE . TextureLoader ( ) . load ( isMobile ? '/earth-bump-mobile.jpg' : '/earth-bump.jpg' , ( ) => {
550555 bumpTexture . anisotropy = renderer . capabilities . getMaxAnisotropy ( )
551556 } )
552557
0 commit comments