Skip to content
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

Set min and max angles for camera #13

Open
Carpetfizz opened this issue Jan 13, 2016 · 5 comments
Open

Set min and max angles for camera #13

Carpetfizz opened this issue Jan 13, 2016 · 5 comments

Comments

@Carpetfizz
Copy link

It would be great if there was an API to set max and min horizontal and vertical rotation. For example, if I wanted my camera to rotate from [Math.PI, 0] on the y-axis. Orbit Controls has the ability to camera.minPolarAngle or camera.maxAzimuthAngle

@ob6160
Copy link

ob6160 commented Mar 13, 2016

Out of curiosity has anyone managed to solve this issue?

@Carpetfizz
Copy link
Author

@ob6160 I didn't actually, I just changed my application to get around the issue, which wasn't the best solution

@ob6160
Copy link

ob6160 commented Mar 13, 2016

If I knew more maths than I did I'd have a go at solving this haha

@Carpetfizz
Copy link
Author

@ob6160 haha same, I haven't taken linear algebra yet 😛

@ob6160
Copy link

ob6160 commented Mar 19, 2016

I found a solution which works for me :)

After the quaternion has been set, to limit the rotation of the camera on either side I just ran this:

this.object.rotation.y = Math.min(Math.max(this.object.rotation.y, -Math.PI*0.5), Math.PI*0.5);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants