Scroll-Driven 3D
Pairing Three.js with GSAP ScrollTrigger lets the scroll position drive camera movement or object animation — the technique behind many high-end landing pages.
Setup
Load GSAP + ScrollTrigger as script tags before your module script, then register:
gsap.registerPlugin(ScrollTrigger);
The body has height 400vh so there’s room to scroll. The canvas stays position: fixed.
Animating the Camera
gsap.to(camera.position, {
z: -5,
y: 2,
scrollTrigger: {
trigger: document.body,
start: 'top top',
end: 'bottom bottom',
scrub: 1,
}
});
Rotating an Object on Scroll
gsap.to(mesh.rotation, {
y: Math.PI * 2,
x: Math.PI * 0.5,
scrollTrigger: {
scrub: 1,
start: 'top top',
end: 'bottom bottom',
}
});
What to Experiment With
- Change
scrub: 1toscrub: 0.3for snappier response - Animate
camera.fovand callcamera.updateProjectionMatrix()for zoom-in - Add multiple sections with separate ScrollTrigger instances
Three.js와 GSAP ScrollTrigger를 결합하면 스크롤 위치로 카메라 이동이나 오브젝트 애니메이션을 구동할 수 있습니다 — 고급 랜딩 페이지에서 자주 사용되는 기법입니다.
설정
GSAP + ScrollTrigger를 모듈 스크립트 이전에 script 태그로 로드한 뒤 등록합니다:
gsap.registerPlugin(ScrollTrigger);
body는 height: 400vh로 스크롤 공간을 확보하고, 캔버스는 position: fixed로 고정합니다.
카메라 애니메이션
gsap.to(camera.position, {
z: -5,
y: 2,
scrollTrigger: {
trigger: document.body,
start: 'top top',
end: 'bottom bottom',
scrub: 1,
}
});
스크롤로 오브젝트 회전
gsap.to(mesh.rotation, {
y: Math.PI * 2,
x: Math.PI * 0.5,
scrollTrigger: {
scrub: 1,
start: 'top top',
end: 'bottom bottom',
}
});
실험해보기
scrub: 1을scrub: 0.3으로 바꿔 더 빠릿한 반응camera.fov를 애니메이션하고camera.updateProjectionMatrix()호출로 줌 인 효과- 별도 ScrollTrigger 인스턴스로 여러 섹션 추가