我使用了轨道控制。我创建了2个按钮enable
和disable
。 controls.rotate=false
这不起作用。在我的代码下面。我做错了什么?
camera3D = new THREE.PerspectiveCamera(angle, width / height, near, far);
camera3D.position.set(0, 10, 500);
controls = new THREE.OrbitControls( camera3D, renderer3D.domElement );
controls.rotateSpeed = 0.50;
controls.zoomSpeed = 1.2;
this.disableMode = function(){
console.log('disable work');
controls.enabled = false;
controls.rotate = false;
controls.update();
}
答案 0 :(得分:0)
您需要做的就是将minPolarAngle和maxPolarAngle设置为相同的值。
尝试这个:
var controls = new THREE.OrbitControls(camera, DOMElement);
// controls.addEventListener( 'change', render ); // call this only in static scenes
// (i.e., if there is no animation loop)
controls.enableDamping = true;
// an animation loop is required when either damping or auto-rotation are enabled
controls.dampingFactor = 0.05;
controls.screenSpacePanning = true;
controls.minDistance = 22;
controls.maxDistance = 115;
// Angle in radians
// this can be used to fix your problem.
// Just setup to 0 or any other angle you needed...
// Must bve same value `minPolarAngle` and `maxPolarAngle`.
controls.minPolarAngle = 0; // 1.5 * Math.PI / 12;
controls.maxPolarAngle = 0; // 1.5 * Math.PI / 3;
controls.minAzimuthAngle = - Math.PI / 2;
controls.maxAzimuthAngle = - Math.PI / 2;
controls.target.set(1, 4, -8.5);