最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - THREE.TrackballControls rotation center - Stack Overflow

programmeradmin5浏览0评论

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

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

Share Improve this question asked May 29, 2013 at 9:08 ZhedenZheden 5932 gold badges12 silver badges38 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

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

发布评论

评论列表(0)

  1. 暂无评论