add-mouse-driven-orbit
하는 일
이 스킬은 웹 페이지의 3D 장면에 가볍고 포인터에 반응하는 입체감을 더하도록 AI 에이전트를 안내합니다. 방문자가 돌려 볼 수 있는 제품 뷰어보다, 차분하고 영화 같은 히어로를 원하는 디자이너를 위한 스킬입니다.
사용하는 경우
- ✓페이지의 3D 히어로가 마우스에 부드럽게 반응하기를 원할 때.
- ✓방문자가 장면을 끌어 돌리지 않아도 장면이 살아 있는 느낌이 필요할 때.
- ✓3D 배경이 움직이는 동안 제목과 카드는 계속 읽혀야 하는 경우.
스킬 링크
https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/add-mouse-driven-orbit/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“내 홈페이지의 3D 배경이 마우스를 따라 살짝 움직이게 해 주세요. 텍스트는 가리지 않게 해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 포인터 위치를 기록하고 시간에 따라 부드럽게 만든 뒤, 카메라를 조금 움직이고 물체를 약간 돌립니다. 포인터가 벗어나면 장면을 되돌립니다. 터치 화면에서는 기본 시점을 유지합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Add Mouse-Driven Orbit
Turn one damped pointer target into a shallow camera arc and smaller object rotations. Reach for threejs with OrbitControls when the user must inspect a product directly; reach for build-game-camera-controls for drag, zoom, occlusion, or gameplay cameras. This Skill is passive cinematic depth, not direct manipulation.
Extracted from inner-green-3d.html, where a procedural moss root had to turn toward the pointer without sliding away from the headline, cards, and pinned silhouette landmarks.
Record intent, not layout
In the pointer handler, write normalized coordinates only:
function recordPointer(event) {
if (event.pointerType === "touch") return;
target.x = (event.clientX / viewport.width) * 2 - 1;
target.y = (event.clientY / viewport.height) * 2 - 1;
}
Cache the interactive rectangle from ResizeObserver. Do not call getBoundingClientRect() for every layer on every pointermove; synchronous layout turns a light effect into frame spikes.
On pointerleave, set the target back to 0, 0. On coarse pointers, keep the authored center pose. Passive orbit should never require touch dragging to reveal content.
Dampen in the frame loop
The source uses 0.055 per 60 Hz frame. Preserve that feel across refresh rates:
const alpha = 1 - Math.pow(1 - 0.055, dt * 60);
smooth.x += (target.x - smooth.x) * alpha;
smooth.y += (target.y - smooth.y) * alpha;
Clamp dt to 1/30 s and reset the time base after resume. A fixed per-frame lerp feels heavy at 30 Hz and twitchy at 120 Hz; an unclamped delta jumps after backgrounding.
Stop style or uniform writes once the rounded value settles. Three decimals are finer than one pixel of the landed travel:
const x = Math.round(smooth.x * 1000) / 1000;
const y = Math.round(smooth.y * 1000) / 1000;
if (x !== lastX || y !== lastY) publish(x, y);
Split the motion
Use opposing, unequal layers so the scene pivots rather than translates as one slab:
camera.position.x = -smooth.x * 26;
camera.position.y = smooth.y * 16;
camera.lookAt(camera.position.x * 0.42, camera.position.y * 0.42, 0);
nearGroup.rotation.y = smooth.x * 0.055;
nearGroup.rotation.x = smooth.y * 0.026;
farGroup.rotation.y = smooth.x * 0.030;
Treat these as the landed values for a scene framed in stage-pixel world units:
| layer | horizontal | vertical | reason |
|---|---|---|---|
| camera translation | -26 | +16 | establishes the shallow arc |
| camera look-at carry | 42% | 42% | keeps the subject near its pinned composition |
| near object yaw | 0.055 rad | — | exposes surface depth without showing its flank |
| near object pitch | — | 0.026 rad | prevents the top surface from flattening |
| far object yaw | 0.030 rad | — | separates planes without matching the foreground |
Do not rotate everything by the same amount. Equal movement reads as a flat poster following the cursor. Do not aim the camera at the fixed origin while translating it; the subject visibly slides away from the layout.
Apply CSS parallax from the same smooth pair, but give text and controls smaller depth coefficients than the 3D form. Keep transforms free for parallax; use clip, opacity, or child wrappers for unrelated reveals so animations do not overwrite each other.
Preserve framing across sizes
Build the center pose first at every breakpoint. Recalculate camera aspect and any stage-to-world scale from a ResizeObserver, guard zero-sized roots, then apply orbit offsets. Verify both extreme pointer corners: no copy collision, card clipping, or exposed empty edge.
Use keyboard-operable X and Y range controls in a demo or configurator. They prove the orbit is parameterised and give non-pointer users access to the same authored states. Keep focus visible and announce motion-mode changes.
Respect motion and lifecycle
- Under
prefers-reduced-motion: reduce, render a designed three-quarter still at approximatelyx=.28, y=-.12; keep the range controls live and redraw their selected still without interpolation. - Pause while hidden or offscreen and resume with a reset time base.
- Cap DPR at 2 and clamp
dtto 1/30 s. - Keep the canvas decorative unless the 3D object carries information. Preserve all labels and controls in semantic HTML.
- On teardown, cancel the frame, disconnect observers, remove pointer/media listeners, and dispose Three.js resources.
State the cost honestly
The orbit math is negligible. The expensive work
자주 묻는 질문
방문자가 장면을 돌릴 수 있나요?
아닙니다. 이 효과는 수동적인 입체감을 위한 것이므로, 방문자가 장면을 끌거나 확대할 수 없습니다.
휴대폰에서는 어떻게 되나요?
터치 화면에서는 설정된 중앙 시점을 유지하므로, 예상치 못하게 움직이는 것이 없습니다.
OrbitControls와 같은가요?
아닙니다. OrbitControls는 사람이 제품을 직접 살펴보게 하지만, 이 효과는 부드러운 움직임만 더합니다.
상세 정보
작성자의 원본 설명
Add restrained mouse-driven orbit and parallax depth to a Three.js hero by damping one pointer target and splitting it across camera translation, look-at, and small object rotations. Use for passive cinematic 3D heroes, pointer-responsive scenes, organic model parallax, and interactive depth where OrbitControls would feel like a product viewer.
repo: MengTo/Skills
인기도
- GitHub 스타
- 7.2k
- 순위
- #13392
- 라이선스
- MIT
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
3d-cloth-material
7.2k에이전트가 Three.js에서 실 짜임, 부드러운 광택, 자연스러운 주름, 단, 솔기를 갖춘 실제 직물처럼 보이는 천을 만들도록 돕습니다.
3d-falling-leaves
7.2k에이전트가 3D 장면에 나뭇잎이 구르고 바람에 흩날리며 카메라 움직임에 따라 재사용되는 낙엽 효과를 추가하도록 돕습니다.
3d-four-seasons
7.2k에이전트가 3D 장면의 나무, 빛, 하늘, 눈을 바꿔 장면을 다시 만들지 않고 봄, 여름, 가을, 겨울을 표현하도록 돕습니다.
3d-high-poly-models
7.2k에이전트가 매끄러운 형태와 자연스러운 모서리를 가진 세밀한 3D 모델을 만들고, 웹에서 잘 돌아가는 가벼운 버전을 준비하도록 돕습니다.
비슷한 스킬
angular-developer
280k에이전트가 Angular 코드를 만들고 프로젝트 구조를 조언하도록 돕습니다. 새 프로젝트 시작, 코드 부분 생성, 성능과 접근성 개선에 유용합니다.
frontend-a11y
280k모든 사람이 웹 인터페이스를 쓸 수 있도록 에이전트를 돕습니다. 웹사이트와 앱이 화면 읽기 프로그램과 키보드 탐색에서 잘 작동하도록 합니다.
frontend-patterns
280k프론트엔드 개발의 현대적인 패턴을 적용하도록 에이전트를 돕습니다. React와 Next.js에서 성능을 최적화하고, 상태를 관리하며, 모범 사례를 따릅니다.