Thanks for your quick response. Using the extra lines of code you provided worked, kind of. You can still pan beyond the limit then it snaps back. This is a bit ugly. What would be better is if the pano hits a wall at the limit, can't go any further, and doesn't render anything beyond the limit. Is this possible?
Also, I note that when using the Canvas renderer, there is warping of the images (straight lines get drawn squiggly) and there are vertical lines at the image joins. Can this be fixed? WebGL doesn't have these issues so I'm just using that instead.