Some time has passed since this question was asked, but I ran into the same problem and did not find a lot of discussion on the Internet, so I decided to publish my solution.
If you must use TrackballControls and want a horizontal horizon, you can simply edit the TrackballControls.js library by adding the following line to the end of this.rotateCamera method
this.object.up = new THREE.Vector3 (0,1,0); This fixes the upward direction of the camera in the (0,1,0) direction (i.e., in the y direction). Then the entire modified function of the method will read:
this.rotateCamera = function () { var angle = Math.acos( _rotateStart.dot( _rotateEnd ) / _rotateStart.length() / _rotateEnd.length() ); if ( angle ) { var axis = ( new THREE.Vector3() ).crossVectors( _rotateStart, _rotateEnd ).normalize(); quaternion = new THREE.Quaternion(); angle *= _this.rotateSpeed; quaternion.setFromAxisAngle( axis, -angle ); _eye.applyQuaternion( quaternion ); _this.object.up.applyQuaternion( quaternion ); _rotateEnd.applyQuaternion( quaternion ); if ( _this.staticMoving ) { _rotateStart.copy( _rotateEnd ); } else { quaternion.setFromAxisAngle( axis, angle * ( _this.dynamicDampingFactor - 1.0 ) ); _rotateStart.applyQuaternion( quaternion ); } }
Daniel Kocevski
source share