Limit the rotation of PerspectiveCamera

Hello,

I have a 360 equirectangular pano viewer set up but I would like the limit the angle of rotation allowed on the Y axis. Would anyone be able to advise me on the best way to go about this please?

Here is a JSFiddle of my current set up.

I would like to experiment with the angle of rotation so if anyone can direct me to the area of code I should be paying attention to that would be much appreciated.

I must mention that I’m a newbie to all of this so apologies for this rather rudimental request.

Many thanks in advance.

Have you considered to use OrbitControls for this use case? You can then make use of OrbitControls.minAzimuthAngle and OrbitControls.maxAzimuthAngle to restrict horizontal orbiting.

Thank you @Mugen87 I will give this a try.

The only problem is that you have to re-implement your zoom. However, you overall save a lot of code since you can use the existing features of OrbitControls. And don’t have to implement custom controls from scratch.