THREE.TrackballControls旋转中心 [英] THREE.TrackballControls rotation center

查看:1318
本文介绍了THREE.TrackballControls旋转中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在场景中有1个物体,想要相对于它的轴旋转它。我使用THREE.TrackballControls。但是当我的物体不在屏幕中心时,旋转不好(它相对于屏幕中心旋转)。在创建控件之前,我尝试更改相机位置。但它不起作用。

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 );

是否可以在TrackballControls中指定相机旋转的中心? (所以对象将旋转不是相对中心的场景)

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

谢谢,
Zhenya

Thanks, Zhenya

推荐答案

TrackballControls 正在旋转相机,而不是对象。

TrackballControls is rotating the camera, not the object.

您可以像这样设置 controls.target

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

three.js r.58

three.js r.58

这篇关于THREE.TrackballControls旋转中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆