OrbitControl - restrict panning movement

后端 未结 2 658
暗喜
暗喜 2021-01-14 04:38

Is there any way to restrict the panning movement of a camera in scene?

Tried altering the pan method in orbitControls but I\'m not really satisfied wit

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-14 05:13

    I have encountered the same problem. The solution is not to touch the pan() function but to check the limits in the update() function. Locate the line 162:

    // move target to panned location
    scope.target.add( panOffset );
    

    Do your limit calculations right after this line:

    if (scope.target.x > 1000)
        scope.target.setX(1000);
    if (scope.target.x < 0)
        scope.target.setX (0);
    ...
    

    This will clamp the target x-position. It works quite smoothly.

提交回复
热议问题