如何限制OrbitControl?

28 controls three.js

有没有办法限制OrbitControls.js?想象一下,我在地面上创造了一些东西,我不想让相机低于地面,知道我的意思吗?!放大和缩小也是一样的.有没有办法设置一些变量来限制,因为我不希望相机关闭或太远?

uhu*_*ura 56

OrbitControls源码

放大/缩小

this.minDistance = 0;
this.maxDistance = Infinity;
Run Code Online (Sandbox Code Playgroud)

停止轮换的地方:

this.minPolarAngle = 0; // radians
this.maxPolarAngle = Math.PI; // radians
Run Code Online (Sandbox Code Playgroud)

不要让它低于地面

controls.maxPolarAngle = Math.PI/2; 
Run Code Online (Sandbox Code Playgroud)

  • 还有一种限制水平旋转的方法吗? (9认同)
  • 叶,见[这个答案](http://stackoverflow.com/questions/25308943/limit-orbitcontrols-horizo​​ntal-rotation/25311658#25311658) (3认同)