Current Setup
- Three.js version: Using
three.min.js(local) - Controls:
OrbitControls - Camera:
PerspectiveCamerawith FOV-based zoom (custom implementation) - Rotation Constraints:
minPolarAngle = maxPolarAngle = Math.PI / 2(horizontal rotation only)minAzimuthAngle = -Math.PI / 2,maxAzimuthAngle = Math.PI / 2
- Zoom: Custom FOV zoom (disabled
enableZoom, using wheel event to adjust FOV instead of camera distance)
Problem Description
I need to implement a drag-to-move feature for a 3D model (OBJ file). The desired behavior is:
- Right-click drag: Move the model in screen space (translate model position)
- Left-click drag: Rotate camera around the model (OrbitControls rotation)
- After dragging the model: When rotating, the camera should orbit around the model’s NEW position, not the original center
Current Issue: After dragging the model to a new position, when I rotate the camera:
- The rotation center stays at the original point (0,0,0), causing a “spinning around a pole” effect
- The model appears to orbit around the wrong point, not its current center
- The model also seems to get larger when closer and smaller when farther (perspective distortion)
What I’ve Tried
- Dynamic
controls.targetupdates: Updatedcontrols.targetto the model’s current center after dragging, but the camera position gets reset or the model snaps back changeevent listener: Tried listening to OrbitControlschangeevent to sync rotation center, but it caused issues when mouse is released- Freeze frames approach: Added delays/freeze frames after drag ends, but didn’t solve the root issue
- Group container approach: Wrapped model in a
THREE.Group, moving model inside group while keeping group at origin - didn’t work - Camera-controls library: Attempted to switch to
camera-controlslibrary but ran into event handling conflicts
Code Structure
- Model is loaded using
OBJLoader - Model position is updated directly:
currentModel.position.add(moveVector) - After dragging, I calculate model center:
box.getCenter(new THREE.Vector3()) - I try to update
controls.targetto the new center, but rotation still happens around old center
Question
How can I make OrbitControls’ rotation center dynamically follow the model’s position after dragging, without the model snapping back or the camera position being reset? Is there a better approach or library that handles this use case?
Any suggestions or working examples would be greatly appreciated!