Three.js Limit Pan In OrbitControls
In Three.js, wow do I add or put limits on how far left/right/up/down a user can pan when using OrbitControls? I'd prefer not to be able to pan so far away that you are unable to s
Solution 1:
In the current version of OrbitControls.js, the position is updated with the panning changes here.
Now if you want to limit the panning to some boundaries, you can simply check if the new position of the camera lies within this boundaries, otherwise you do not update the position:
var newX = this.target.x + pan.x;
var newY = this.target.y + pan.y;
if (newX <= this.maxXPan && newX >= this.minXPan
&& newY <= this.maxYPan && newY >= this.minYPan) {
this.target.add( pan );
}
Post a Comment for "Three.js Limit Pan In OrbitControls"