Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OrbitControl or TrackballControl

Tags:

three.js

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.

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.

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.

So my questions are:

1. Which Controls System is more suitable for my task

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?

Thanks a lot!!

Regards - Misa

like image 209
Kosha Misa Avatar asked Sep 02 '13 21:09

Kosha Misa


1 Answers

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

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

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

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

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

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

three.js r.82

like image 155
WestLangley Avatar answered Sep 22 '22 06:09

WestLangley