Grms
Grms

Reputation: 407

Three.js OrbitControls enableRotate/Pan = false don't seem to work

I want to set .enableRotate and .enablePan to false on my perspectiveCamera with OrbiteControls

I already tried to set them, as it was not working I find a work around using:

controls.maxPolarAngle = 0;
controls.maxAzimuthAngle = - Math.PI;

But as there is not something like that for .enablePan I am stuck there. Maybe there is something wrong with the way I used it ?

Here is the code pen if you prefer work on it or try it : https://codepen.io/greg_o/pen/jdwZYZ

I guess this is the part of the code that interest you :

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 wanna say that the pen is originally from Nikita Skargovskii

Upvotes: 1

Views: 1545

Answers (1)

Mugen87
Mugen87

Reputation: 31026

Using the latest version of three.js and OrbitControls seems to solve the issue: https://codepen.io/anon/pen/exRQYo

You have used release 84 before which is more than two years old. Always use the latest revision of three.js and also ensure that files from the example directory (like OrbitControls) match the version of your three.js file.

Upvotes: 2

Related Questions