简体   繁体   English

如何使用OrbitControls无限旋转

[英]How to rotate with OrbitControls, without limits

Right now i'm using orbit controls, and i can only rotate 180 degrees in the up-and-down direction. 现在,我正在使用轨道控制,并且只能沿上下方向旋转180度。 In another direction i can rotate forever, i think it is the z direction. 在另一个方向上,我可以永远旋转,我认为这是z方向。 Anyways, how can i make it completely limiteless for all rotation directions? 无论如何,我如何才能完全不受所有旋转方向的限制?

here's my code now, i tried it with and without infinity: 这是我的代码,我尝试了无穷大:

this.scene_threeD = new THREE.Scene();
this.camera_threeD = new THREE.PerspectiveCamera( 75, width_threeD / height_threeD, 0.1, 1000 );
this.renderer_threeD = new THREE.WebGLRenderer({ canvas: threeDCanvas,
                               preserveDrawingBuffer: true,
                               antialias: true });
this.renderer_threeD.setSize( width_threeD, height_threeD);
controls = new THREE.OrbitControls(this.camera_threeD, this.renderer_threeD.domElement);
        controls.maxPolarAngle = Infinity;
        controls.minPolarAngle = -Infinity;
        controls.maxAzimuthAngle = Infinity;
        controls.minAzimuthAngle=-Infinity;
        controls.update();

The problem with an "orbital camera" is that (by definition) it always tries to keep the camera "up" pointing upwards . “轨道摄像机”的问题是(根据定义)它总是试图使摄像机“向上”指向上方 This means the camera orientation is undefined when you are looking straight up or down. 这意味着当您向上或向下直视时,摄像机方向不确定 That is why three.js implements a makeSafe() method that keeps the polar angle just within a +/- 90 degrees angle. 这就是为什么three.js实现了makeSafe()方法,该方法将极角保持在+/- 90度角内。

If you were to remove this limitation, you would probably see the camera instantly flip directions when passing the 90 degrees angle (or worse). 如果要取消此限制,则可能会在90度角(或更糟)的情况下看到相机立即翻转方向。 This is generally undesired behaviour in an application. 这通常是应用程序中的不良行为。

To sum things up: if you want limitless rotation, you don't want an orbital camera. 综上所述:如果您想无限旋转,就不需要轨道摄像机。 This is not a technical but a conceptual limitation. 这不是技术上的限制,而是概念上的限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM