Skip to content

Commit f504044

Browse files
fix(HeroScene): refine parallax rotation calculations for improved visual stability
1 parent f8866e0 commit f504044

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/app/globals.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,11 @@ textarea {
18211821
}
18221822

18231823
.site-content > #projects.section {
1824-
background: var(--section-bg, var(--content-bg));
1824+
background: none;
1825+
}
1826+
1827+
.site-content > #projects.section::before {
1828+
background: none;
18251829
}
18261830

18271831
.section-inner {

src/components/hero/HeroScene.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,10 +1967,22 @@ function SceneContent({
19671967
if (!allowParallax) {
19681968
parallax.current.lerp(parallaxZeroRef.current, 0.12);
19691969
}
1970-
const rotY = allowParallax ? parallax.current.x * 0.18 * parallaxDamp : 0;
1971-
const rotX = allowParallax ? parallax.current.y * 0.14 * parallaxDamp : 0;
1972-
group.rotation.y = rotY;
1973-
group.rotation.x = rotX;
1970+
const maxYaw = 0.08;
1971+
const maxPitch = 0.06;
1972+
const targetYaw = allowParallax
1973+
? Math.min(
1974+
maxYaw,
1975+
Math.max(-maxYaw, parallax.current.x * 0.08 * parallaxDamp),
1976+
)
1977+
: 0;
1978+
const targetPitch = allowParallax
1979+
? Math.min(
1980+
maxPitch,
1981+
Math.max(-maxPitch, -parallax.current.y * 0.06 * parallaxDamp),
1982+
)
1983+
: 0;
1984+
group.rotation.y = targetYaw;
1985+
group.rotation.x = targetPitch;
19741986
}
19751987

19761988
const palette = bgPaletteRef.current;

0 commit comments

Comments
 (0)