मुख्य सामग्री पर जाएँ
Skillpedia
वेबसाइट और UI (frontend)7.2k · #13392

add-mouse-driven-orbit

यह क्या करती है

यह स्किल एजेंट को वेब पेज के 3D दृश्य में पॉइंटर से चलने वाली हल्की गहराई जोड़ना सिखाती है। यह उन डिज़ाइनरों के लिए है जिन्हें शांत और सिनेमाई हीरो चाहिए, न कि ऐसा प्रोडक्ट व्यूअर जिसे लोग घुमा सकें।

कब इस्तेमाल करें

  • ✓जब आप चाहते हैं कि पेज पर 3D हीरो माउस पर धीरे से प्रतिक्रिया दे।
  • ✓जब दृश्य जीवंत लगे, लेकिन विज़िटर उसे खींच या घुमा न सकें।
  • ✓जब 3D पृष्ठभूमि चलती रहे, फिर भी हेडलाइन और कार्ड पढ़ने में आसान रहें।

Skill का लिंक

https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/add-mouse-driven-orbit/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/add-mouse-driven-orbit/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे होमपेज की 3D पृष्ठभूमि माउस के साथ हल्के से खिसके, पर टेक्स्ट पर कुछ न ढके, ऐसा कीजिए।”

हर हफ़्ते 5 नई skills, 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 approximately x=.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 dt to 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
अपडेट की गई
1/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

3d-cloth-material

7.2k

आपके एजेंट को Three.js में असली बुने हुए कपड़े जैसा दिखने वाला मटीरियल बनाने में मदद करती है, जिसमें धागों की बुनाई, हल्की चमक, प्राकृतिक सिलवटें, किनारे और सीवन हों।

कोडिंगवेबसाइट और UI (frontend)

3d-falling-leaves

7.2k

आपके एजेंट को 3D दृश्य में असली लगने वाली गिरती पत्तियाँ जोड़ने देती है, जो लुढ़कती हैं, हवा के साथ बहती हैं और कैमरा हिलने पर दोबारा इस्तेमाल होती हैं।

कोडिंगवेबसाइट और UI (frontend)

3d-four-seasons

7.2k

आपके एजेंट को 3D दृश्य में वसंत, गर्मी, शरद और सर्दी के रूप जोड़ने देती है, जिसमें हरियाली, रोशनी, आसमान और बर्फ़ बिना दृश्य दोबारा बनाए बदलते हैं।

कोडिंगवेबसाइट और UI (frontend)

3d-high-poly-models

7.2k

आपके एजेंट को चिकने आकार और विश्वसनीय किनारों वाले विस्तृत 3D मॉडल बनाने देती है, और फिर वेब पर अच्छे चलने वाले हल्के संस्करण तैयार करती है।

कोडिंगवेबसाइट और UI (frontend)

मिलती-जुलती skills