New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TrackballControls don't work if camera.position is on the y-axis #10161
Comments
Reopening... I think this is a problem with @h-a-n-n-e-s You code should be written like so function alignX() { controls.position0.set( distance, 0, 0 ); controls.reset(); }
function alignY() { controls.position0.set( 0, distance, 0 ); controls.reset(); }
function alignZ() { controls.position0.set( 0, 0, distance ); controls.reset(); } But the issue remains. This is going to take some work, if anyone is interested in looking at it. |
+1 |
Yes, the problem is that camera.up defaults to the y-axis. if ( objectSidewaysDirection.lengthSq() < EPS ) {
var a = - Math.sign(_this.object.position.y);
_this.object.up.set(0,0,a);
objectUpDirection.set(0,0,a);
objectSidewaysDirection.set(a,0,0);
} at line 170 in TrackballControls.js |
@h-a-n-n-e-s I doubt the solution can ignore the value of Also, Also, |
@WestLangley true, In the critical case Anyway, there should be a short and simple solution to this, I was just playing around with it for fun (Currently I'm not using threejs anyway). |
@h-a-n-n-e-s this helped me greatly, and for anyone else, changing my camera's up after construction also works this.camera.up.set(0, 0, 1); |
I think when you set up your camera, it by default "looks at" the origin. Also, by default its "up" vector is [0, 1, 0] That means that when you click "ALIGN Y", you are moving the camera to [0, 2.2, 0] and it is "looking" down the Y axis to see the origin at [0, 0, 0] Here's the problem: You repositioned the camera, but you didn't change the When you have |
@WestLangley Do you wan to continue keep this issue open? |
I do not. BTW, I provided much simpler Trackball update logic here. Unlike the existing |
In the example below, if
camera.position
is set to(0,distance,0)
wheredistance
is some positive number, the trackball controls don't work properly anymore. Instead there is only zooming if the left mouse button is pressed and the mouse is moved around. Just press the "ALIGN Y" button to see this. The behavior is not observed pressing the "ALIGN X" or "ALIGN Z" button.`
<title>TrackballControls test</title>Three.js version
Browser
OS
The text was updated successfully, but these errors were encountered: