Skip to content

Commit c38fe42

Browse files
committed
added glorp sun and planet textures #loveglorp
1 parent c39ce08 commit c38fe42

7 files changed

Lines changed: 23 additions & 18 deletions

File tree

public/textures/glorptest.png

52.8 KB
Loading

public/textures/suntexture.webp

1.22 KB
Loading

public/textures/texture1.webp

1.78 MB
Loading

public/textures/texture2.webp

4.23 MB
Loading

public/textures/texture3.webp

2.98 MB
Loading

src/pages/home/Home.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export default function Home() {
1010

1111
const [isVisible, setIsVisible] = useState(false);
1212
const [mountKey, setMountKey] = useState(0);
13-
const isMouseMoving = useMouseMoving(800); // fade back in after 800ms of no movement
13+
const isMouseMoving = useMouseMoving(2500);
14+
const hideUI = isMouseMoving || isVisible;
1415

1516
const handleOpen = () => {
1617
setMountKey(k => k + 1);
@@ -31,13 +32,12 @@ export default function Home() {
3132
return (
3233
<div>
3334
<header style={{
34-
transition: "opacity 0.6s ease",
35-
opacity: isMouseMoving ? 0 : 1,
36-
pointerEvents: isMouseMoving ? "none" : "auto",
37-
}}
35+
transition: "opacity 0.4s ease",
36+
opacity: hideUI ? 0 : 1,
37+
pointerEvents: hideUI ? "none" : "auto",
38+
}}
3839
>
3940
<div className={styles["header-brand"]}>
40-
4141
<h1>glorpython</h1>
4242
</div>
4343
</header>

src/pages/home/solarsystem.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@ const ZOOM_DIST = 5; // how close the camera gets (in planet radii + of
44
const TWEEN_SPEED = 0.07; // lerp factor for camera movement
55

66
export function main(canvas, onPlanetFocus) {
7-
7+
const loader = new THREE.TextureLoader();
88
const renderer = new THREE.WebGLRenderer({ antialias: true, canvas });
99
renderer.setPixelRatio(window.devicePixelRatio);
1010
renderer.toneMapping = THREE.ACESFilmicToneMapping;
1111
renderer.toneMappingExposure = 2.0;
1212

13+
const createRepeatingTexture = (path, repeatX = 2, repeatY = 1) => {
14+
const tex = loader.load(path);
15+
tex.wrapS = THREE.RepeatWrapping;
16+
tex.wrapT = THREE.RepeatWrapping;
17+
tex.repeat.set(repeatX, repeatY);
18+
return tex;
19+
};
20+
1321
const fov = 45;
1422
const aspect = canvas.clientWidth / canvas.clientHeight;
1523
const near = 0.1;
@@ -37,20 +45,19 @@ export function main(canvas, onPlanetFocus) {
3745
// Sun
3846
const sunGeo = new THREE.SphereGeometry(4.5, 64, 64);
3947
const sunMat = new THREE.MeshStandardMaterial({
40-
color: 0xe8ffff,
41-
emissive: 0x88ffee,
42-
emissiveIntensity: 3.2,
43-
roughness: 0.0,
44-
metalness: 0.0
48+
map: createRepeatingTexture('/textures/glorptest.png', 3, 3),
49+
emissiveMap: loader.load('/textures/suntexture.webp'), // same tex drives the glow
50+
emissive: 0x91ffaf,
51+
emissiveIntensity: 0.1,
4552
});
4653
const sun = new THREE.Mesh(sunGeo, sunMat);
4754
scene.add(sun);
4855

4956
// Planets
5057
const planetData = [
51-
{ radius: 1.1, orbitR: 14, speed: 0.8, tilt: 0.2, color: 0xff6644, emissive: 0x441100 },
52-
{ radius: 1.5, orbitR: 24, speed: 0.45, tilt: 0.35, color: 0x44aaff, emissive: 0x001133 },
53-
{ radius: 1.2, orbitR: 36, speed: 0.25, tilt: 0.15, color: 0x88dd55, emissive: 0x112200 },
58+
{ radius: 1.1, orbitR: 14, speed: 0.8, tilt: 0.2, color: 0xff6644, emissive: 0x441100, texture: '/textures/texture1.webp'},
59+
{ radius: 1.5, orbitR: 24, speed: 0.45, tilt: 0.35, color: 0x44aaff, emissive: 0x001133, texture: '/textures/texture2.webp' },
60+
{ radius: 1.2, orbitR: 36, speed: 0.25, tilt: 0.15, color: 0x88dd55, emissive: 0x112200, texture: '/textures/texture3.webp'},
5461
];
5562

5663
const planets = planetData.flatMap(d => {
@@ -72,9 +79,7 @@ export function main(canvas, onPlanetFocus) {
7279
return [0, 1, 2].map(i => {
7380
const geo = new THREE.SphereGeometry(d.radius, 36, 36);
7481
const mat = new THREE.MeshStandardMaterial({
75-
color: d.color,
76-
emissive: d.emissive,
77-
emissiveIntensity: 1.0,
82+
map: loader.load(d.texture),
7883
roughness: 0.65,
7984
metalness: 0.05
8085
});

0 commit comments

Comments
 (0)