Is there a way to implement the three.js script TrackballControls on a moving object while still allowing the camera to zoom and rotate? For example, I want to track a moving planet with the camera while giving the user the freedom to zoom in and rotate around the planet. A basic jsfiddle example can be found here:
http://jsfiddle.net/mareid/8egUM/3/
(Please note that mouse control may not work correctly on jsfiddle).
I want to attach the camera to a red sphere so it moves with it, but still maintain the ability to zoom and rotate. I attempted to make the camera follow the sphere by adding certain lines to the render() function:
mouseControls.target = new THREE.Vector3(object.position);
camera.position.set(object.position.x,object.position.y,object.position.z+20);
However, this method interferes with the zoom and rotation functionalities of TrackballControls. I believe it should be possible to adjust the TrackballControls calculations to revolve around the center of the red sphere mathematically, but I'm struggling to achieve this. I have experimented with various vector additions to the position of the red sphere in the TrackballControls.js file with no success.
Any advice or assistance on this matter would be greatly appreciated. Thank you!