OrbitControl 或 TrackballControl [英] OrbitControl or TrackballControl

查看:177
本文介绍了OrbitControl 或 TrackballControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了很多关于这两个控件的文章,目前我正在使用 TrackballControls.

I've read a lot about these 2 controls and currently I'm using TrackballControls.

我需要沿所有三个轴旋转对象(两个控件都已经这样做了),但有时我还需要手动设置新的相机位置/旋转.而这真的行不通.

I need to rotate an object along all three axis (Both controls already do that), but I also need to set sometimes a new camera position/rotation by hand. And this doesn't really work.

我的解决方法是禁用轨迹球控件,获取新位置的四元数对象,将这些应用到 camera.up然后开启相机

My workaround is to disable the trackballcontrols, get the quaternions-object of the new position, apply these to camera.up and then enable the camera

但如前所述,这并不能真正稳定地工作.

But as mentioned, this doesn't really work stable.

我读到 OrbitControls 可能是此类任务的更好解决方案.但是 OrbitControls 对对象的垂直旋转有一个限制",我需要无限制地旋转我的对象.

I read that OrbitControls could be a better solution for such a task. But OrbitControls has a "limit" on vertical rotation of objects and I need to rotate my objects without limits.

所以我的问题是:

1.哪种控制系统更适合我的任务

1. Which Controls System is more suitable for my task

2. 如果是轨迹球 - 您将如何手动设置新的相机位置和旋转?如果是轨道 - 有没有办法禁用这个垂直旋转限制?

2. If it's Trackball - how would you set manually a new camera position and rotation? And if it's Orbit - is there a way to disable this vertical rotation limit?

非常感谢!!

问候 - 米莎

推荐答案

首先,TrackballControlsOrbitControls 旋转相机,而不是对象.

First of all, TrackballControls and OrbitControls rotate the camera, not the objects.

其次,OrbitControls 强制相机up 方向,TrackballControls 允许相机倒置.

Second, OrbitControls enforces the camera up direction, and TrackballControls allows the camera to rotate upside-down.

TrackballControls 有一个 reset() 方法,可以恢复target(旋转中心),camera position> 和相机 up 向量到它们的原始设置.

TrackballControls has a reset() method, which restores the target (center of rotation), camera position, and camera up vector to their original settings.

controls.reset();

以上代码将恢复原来的positiontargetup向量.如果需要,您也可以在调用 controls.reset() 之前更改这些设置.

The above code will restore the original position, target, and up vector. You can change those too, if you want, before you call controls.reset().

controls.position0.set( 0, 0, 10 ); // set a new desired position
controls.target0.set( 0, 0, 0 ); // set a new target
controls.up0.set( 0, 1, 0 ); // set a new up vector
controls.reset();

阅读 reset() 函数源代码,了解它在做什么.

Read the reset() function source code so you understand what it is doing.

OrbitControls 现在也有一个 reset() 方法.检查源代码.

OrbitControls now has a reset() method, too. Check the source code.

three.js r.82

three.js r.82

这篇关于OrbitControl 或 TrackballControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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