admin管理员组文章数量:1431927
I've been using threejs for a while for the 3D of an image-based modeling application ( vmtklab.orobix ). 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: /
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
I've been using threejs for a while for the 3D of an image-based modeling application ( vmtklab.orobix. ). 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/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
Share Improve this question asked Feb 17, 2015 at 10:44 daron1337daron1337 711 silver badge5 bronze badges 5- Yes, the simulated trackball is in the center of the canvas. You appear to prefer to imagine the simulated trackball as being repositioned directly under the mouse on mousedown events. – WestLangley Commented Feb 17, 2015 at 14:55
- Thank you but I cannot understand how to manage the getMouseProjectionOnBall in order to do not always consider the center of the canvas as its center. Any ideas? tnx – daron1337 Commented Feb 17, 2015 at 15:49
- No, sorry - no quick fix ideas. I like your idea, BTW. – WestLangley Commented Feb 17, 2015 at 17:06
- I decided to implement a new control from scratch following the VTK camera controls style. I will submit a pull request asap. – daron1337 Commented Feb 18, 2015 at 12:51
- jsfiddle/e0s61k8f/1 – daron1337 Commented Feb 18, 2015 at 14:16
1 Answer
Reset to default 4Fixed: 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./mrdoob/three.js/pull/6096
本文标签: javascriptthreeJS Trackball Controls camera rotationStack Overflow
版权声明:本文标题:javascript - threeJS Trackball Controls camera rotation - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745593369a2665328.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论