3d-camera-interaction

Align mouse input with 3D model drag and zoom in Three.js.

2.4k|275|Updated Jun 29, 2025
One-click install
npx skills add https://github.com/Project-N-E-K-O/N.E.K.O --skill 3d-camera-interaction
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: 3d-camera-interaction
Source: https://github.com/Project-N-E-K-O/N.E.K.O/tree/main/.agent/skills/3d-interaction
Command: npx skills add https://github.com/Project-N-E-K-O/N.E.K.O --skill 3d-camera-interaction

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill addresses the misalignment between user input (mouse/touch) and 3D model movement in Three.js during drag and zoom interactions, preventing jitter and invisible boundaries.

Core Features & Use Cases

  • Drag translation: move the model consistently with pointer movement, regardless of camera distance.
  • Dynamic zoom handling: adjust drag calculations as the camera FOV and distance change.
  • Boundary visibility: keep the model within the viewport by calculating screen-space bounds from the model's bounding box.

Quick Start

Use the 3d-camera-interaction skill to drag a 3D model with the mouse, zoom with the wheel, and verify the model stays within the viewport.

Frequently Asked Questions about 3d-camera-interaction

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my Three.js 3D model move out of sync with the mouse during dragging?

Three.js 3D model dragging misaligns with pointer input when pixel-to-world mapping fails to account for varying camera distances and FOV. Dynamic drag calculations and responsive input handling are required to maintain consistent object translation.

How do I keep a 3D model within the viewport boundaries when dragging in Three.js?

To keep a 3D model within viewport boundaries during dragging, calculate screen-space bounds from the model's bounding box. This visibility check prevents the object from disappearing or moving into invisible areas outside the camera view.

How do I adjust Three.js drag calculations when zooming changes the camera distance?

Adjust Three.js drag calculations during zoom by applying dynamic pixel-to-world mapping that updates alongside camera FOV and distance changes. This ensures pointer input remains accurately mapped to 3D model movement at varying zoom levels.

What is the best way to handle mouse input alignment for 3D camera interaction in Three.js?

The best way to handle 3D camera interaction alignment is implementing dynamic pixel-to-world mapping combined with bounding-box based visibility checks. This approach preserves consistent dragging and zooming across different viewport sizes and camera distances.

Does this 3D camera interaction approach work for both mouse and touch pointer input?

Yes, the 3D camera interaction approach works for both mouse and touch pointer input. Responsive input handling maps user pointer movement to 3D model translation dynamically, preventing jitter regardless of the input device or camera distance.

Can I use bounding-box based boundary detection for interactive 3D model editors with varying viewport sizes?

Yes, bounding-box based boundary detection works for interactive 3D model editors with varying viewport sizes. Screen-space bounds calculated from the model's bounding box ensure visibility checks remain accurate across responsive viewport dimension changes.