threeVR icon indicating copy to clipboard operation
threeVR copied to clipboard

Set min and max angles for camera

Open Carpetfizz opened this issue 8 years ago • 5 comments

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

Carpetfizz avatar Jan 13 '16 08:01 Carpetfizz

Out of curiosity has anyone managed to solve this issue?

ob6160 avatar Mar 13 '16 17:03 ob6160

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

Carpetfizz avatar Mar 13 '16 19:03 Carpetfizz

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

ob6160 avatar Mar 13 '16 19:03 ob6160

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

Carpetfizz avatar Mar 13 '16 21:03 Carpetfizz

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

ob6160 avatar Mar 19 '16 10:03 ob6160