I need to disable the rotation (.enableRotate
) and panning (.enablePan
) on my perspectiveCamera with OrbitControls.
I attempted to set them to false, but it didn't work. As a workaround, I used:
controls.maxPolarAngle = 0;
controls.maxAzimuthAngle = - Math.PI;
However, since there isn't a similar option for .enablePan
, I'm unable to achieve what I want. Could there be an issue with how I implemented it?
If you prefer to work on it or try it yourself, here is the CodePen link: https://codepen.io/greg_o/pen/jdwZYZ
The part of the code that may interest you is:
function init() {
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 1000);
camera.position.z = 68;
controls = new THREE.OrbitControls(camera);
controls.maxDistance = 300;
controls.minDistance = 30;
controls.enableRotate = false;
controls.maxPolarAngle = 0;
controls.maxAzimuthAngle = - Math.PI;
controls.enablePan = false;
}
Just to mention, the original Pen belongs to Nikita Skargovskii.