Skip to content

Commit 71abe99

Browse files
authored
Merge pull request #79 from ZackGoldblum/starfield-revamp
Create /stars page (no UI)
2 parents 9e9353c + 920d9fe commit 71abe99

File tree

5 files changed

+68
-72
lines changed

5 files changed

+68
-72
lines changed

src/App.jsx

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Research from './pages/Research';
66
import Projects from './pages/Projects';
77
import Bookshelf from './pages/Bookshelf';
88
import About from './pages/About';
9-
import Space from './pages/Space';
9+
import Stars from './pages/Stars';
1010
import NotFound from './pages/NotFound';
1111
import Starfield from './components/Starfield';
1212
import './index.css';
@@ -16,7 +16,7 @@ const Router = BrowserRouter;
1616
function App() {
1717
function AppContent() {
1818
const location = useLocation();
19-
const isSpacePage = location.pathname === '/space';
19+
const isStarsPage = location.pathname === '/stars';
2020
const [uiVisible, setUiVisible] = useState(false);
2121

2222
// Handle skybox loaded - trigger UI fade in
@@ -29,27 +29,33 @@ function App() {
2929
return (
3030
<>
3131
<Starfield onSkyboxLoaded={handleSkyboxLoaded} uiVisible={uiVisible} />
32-
<div
33-
style={{
34-
position: 'relative',
35-
zIndex: 1,
36-
opacity: uiVisible ? 1 : 0,
37-
transition: 'opacity 0.5s ease-in-out'
38-
}}
39-
>
40-
{!isSpacePage && <Header />}
41-
<main>
42-
<Routes>
43-
<Route path="/" element={<Home />} />
44-
<Route path="/research" element={<Research />} />
45-
<Route path="/projects" element={<Projects />} />
46-
<Route path="/bookshelf" element={<Bookshelf />} />
47-
<Route path="/about" element={<About />} />
48-
<Route path="/space" element={<Space />} />
49-
<Route path="*" element={<NotFound />} />
50-
</Routes>
51-
</main>
52-
</div>
32+
{!isStarsPage && (
33+
<div
34+
style={{
35+
position: 'relative',
36+
zIndex: 1,
37+
opacity: uiVisible ? 1 : 0,
38+
transition: 'opacity 0.5s ease-in-out'
39+
}}
40+
>
41+
<Header />
42+
<main>
43+
<Routes>
44+
<Route path="/" element={<Home />} />
45+
<Route path="/research" element={<Research />} />
46+
<Route path="/projects" element={<Projects />} />
47+
<Route path="/bookshelf" element={<Bookshelf />} />
48+
<Route path="/about" element={<About />} />
49+
<Route path="*" element={<NotFound />} />
50+
</Routes>
51+
</main>
52+
</div>
53+
)}
54+
{isStarsPage && (
55+
<Routes>
56+
<Route path="/stars" element={<Stars />} />
57+
</Routes>
58+
)}
5359
</>
5460
);
5561
}

src/components/Header.jsx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,11 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
33
import { faGithub, faLinkedin, faXTwitter, faGoogleScholar } from '@fortawesome/free-brands-svg-icons';
44
import { faEnvelope } from '@fortawesome/free-solid-svg-icons';
55

6-
// function Header({ isPaused, togglePause }) {
76
function Header() {
87
const location = useLocation();
98

109
return (
1110
<header style={{ margin: 0, padding: 0 }}>
12-
{/* <div id="buttonsContainer">
13-
<div id="starsButtonContainer">
14-
<Link to="/space">
15-
<img src="/buttons/stars.webp" id="starsButton" alt="Stars button" />
16-
</Link>
17-
</div>
18-
<div id="playpauseButtonContainer">
19-
<img
20-
src={isPaused ? "/buttons/play.webp" : "/buttons/pause.webp"}
21-
id="playpauseButton"
22-
alt="Play/pause button"
23-
onClick={togglePause}
24-
style={{ cursor: 'pointer' }}
25-
/>
26-
</div>
27-
</div> */}
2811
<h1>
2912
<Link to="/" style={{ color: 'var(--blue_color)', textDecoration: 'none' }}>Zack Goldblum</Link>
3013
<span style={{ marginLeft: '20px' }}>
@@ -60,9 +43,4 @@ function Header() {
6043
);
6144
}
6245

63-
// Header.propTypes = {
64-
// isPaused: PropTypes.bool,
65-
// togglePause: PropTypes.func
66-
// };
67-
6846
export default Header;

src/components/Starfield.jsx

Lines changed: 18 additions & 8 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 }) => {
5+
const Starfield = ({ onSkyboxLoaded = () => { }, uiVisible = false, disableScrollMotion = false }) => {
66
// Three.js scene references
77
const mountRef = useRef(null);
88
const sceneRef = useRef(null);
@@ -318,7 +318,9 @@ const Starfield = ({ onSkyboxLoaded = () => { }, uiVisible = false }) => {
318318

319319
// Add event listeners
320320
window.addEventListener('resize', handleResize);
321-
window.addEventListener('scroll', handleScroll, { passive: true });
321+
if (!disableScrollMotion) {
322+
window.addEventListener('scroll', handleScroll, { passive: true });
323+
}
322324
document.addEventListener('visibilitychange', handleVisibilityChange);
323325

324326
// Initialize scroll tracking
@@ -332,7 +334,9 @@ const Starfield = ({ onSkyboxLoaded = () => { }, uiVisible = false }) => {
332334
// Cleanup function
333335
return () => {
334336
window.removeEventListener('resize', handleResize);
335-
window.removeEventListener('scroll', handleScroll);
337+
if (!disableScrollMotion) {
338+
window.removeEventListener('scroll', handleScroll);
339+
}
336340
document.removeEventListener('visibilitychange', handleVisibilityChange);
337341
cancelAnimationFrame(animationFrameRef.current);
338342

@@ -382,8 +386,13 @@ const Starfield = ({ onSkyboxLoaded = () => { }, uiVisible = false }) => {
382386
scrollVelocityRef.current *= ANIMATION_CONFIG.velocityDecay;
383387

384388
// Convert scroll velocity to speed multiplier (restore original values)
385-
const velocityFactor = Math.min(scrollVelocityRef.current / ANIMATION_CONFIG.maxVelocity, 1.0);
386-
const scrollAmplification = 2.5 + velocityFactor * 40;
389+
let velocityFactor = 0;
390+
let scrollAmplification = 2.5;
391+
392+
if (!disableScrollMotion) {
393+
velocityFactor = Math.min(scrollVelocityRef.current / ANIMATION_CONFIG.maxVelocity, 1.0);
394+
scrollAmplification = 2.5 + velocityFactor * 40;
395+
}
387396

388397
starLayersRef.current.forEach((starLayer) => {
389398
if (starLayer && starLayer.userData) {
@@ -398,7 +407,7 @@ const Starfield = ({ onSkyboxLoaded = () => { }, uiVisible = false }) => {
398407
// Only animate star movement if animation is enabled
399408
if (starsAnimatingRef.current && starLayer.material.opacity > 0) {
400409
// Flying through space motion - stars move toward camera (restore original speed)
401-
const baseFlightSpeed = 0.5;
410+
const baseFlightSpeed = 0.7;
402411
const flightSpeed = baseFlightSpeed * scrollAmplification;
403412

404413
// Update star positions
@@ -455,7 +464,7 @@ const Starfield = ({ onSkyboxLoaded = () => { }, uiVisible = false }) => {
455464

456465
// Return cleanup function
457466
return cleanup;
458-
}, []); // Empty dependency array - only run once
467+
}, [disableScrollMotion]); // Include disableScrollMotion dependency
459468

460469
return (
461470
<div
@@ -476,7 +485,8 @@ const Starfield = ({ onSkyboxLoaded = () => { }, uiVisible = false }) => {
476485
// PropTypes validation
477486
Starfield.propTypes = {
478487
onSkyboxLoaded: PropTypes.func,
479-
uiVisible: PropTypes.bool
488+
uiVisible: PropTypes.bool,
489+
disableScrollMotion: PropTypes.bool
480490
};
481491

482492
export default Starfield;

src/pages/Space.jsx

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/pages/Stars.jsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { useState } from 'react';
2+
import Starfield from '../components/Starfield';
3+
4+
const Stars = () => {
5+
const [uiVisible, setUiVisible] = useState(false);
6+
7+
// Handle skybox loaded - but we don't need to show any UI
8+
const handleSkyboxLoaded = () => {
9+
// No UI to show, just keep stars visible
10+
setUiVisible(true);
11+
};
12+
13+
return (
14+
<>
15+
<Starfield onSkyboxLoaded={handleSkyboxLoaded} uiVisible={uiVisible} disableScrollMotion={true} />
16+
{/* No additional UI elements - just the starfield */}
17+
</>
18+
);
19+
};
20+
21+
export default Stars;

0 commit comments

Comments
 (0)