THREE.TrackballControls rotation center

烂漫一生 提交于 2019-12-12 11:15:20

问题


I have 1 object on scene and want to rotate it relative to its axis. I use THREE.TrackballControls. But when my object in not in the center of screen, rotation is bad (it is rotating relative to center of screen). I tried to change camera position before creating controls. But it did not work.

    var scene = new THREE.Scene();
    var camera = new THREE.PerspectiveCamera(75, 1, 0.1, 1000);
    camera.position.z = 3;
    camera.position.y = 10;

    controls = new THREE.TrackballControls( camera );

Is it possible to specify the center of camera rotation in TrackballControls? (So object will rotate not relatively center of scene)

Thanks, Zhenya


回答1:


TrackballControls is rotating the camera, not the object.

You can set the controls.target like so:

controls.target.set( x, y, z );

three.js r.58



来源:https://stackoverflow.com/questions/16809805/three-trackballcontrols-rotation-center

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!