daron1337
daron1337

Reputation: 71

threeJS Trackball Controls camera rotation

I've been using threejs for a while for the 3D of an image-based modeling application ( vmtklab.orobix.com ). For camera rotation/translation/zooming I am using TrackballControls.js.

controls = new THREE.TrackballControls( camera, renderer.domElement );
controls.dynamicDampingFactor = 0.5;
controls.target.set( pos.x, pos.y, pos.z );

I'm used to camera movement as in vtk ( paraview, etc ) and I can not find how to replicate this behavior in threejs.

See: http://jsfiddle.net/ugxbktLt/5/

Basically, if I click on the canvas in the center and I move the mouse along the y axis the camera rotates as expected. If I click on the canvas in a point which is distant from the center ( example on the right side of the cube ), the camera rotates in two directions and not only following my mouse movement.

I was expecting that the camera rotates following only the vector between the start point ( mousedown ) and end point generated by mouse movement and NOT considering the position of the start point. It seems rotating around a sphere.

Any suggestions? Best regards Simone

Upvotes: 2

Views: 6217

Answers (1)

daron1337
daron1337

Reputation: 71

Fixed: With SymmetricTrackballControls.js we can rotate camera independently from the position of the mouse on the canvas but considering only the mouse movement. https://github.com/mrdoob/three.js/pull/6096

Upvotes: 4

Related Questions