# Enable/disable controls?

**URL:** https://discourse.threejs.org/t/enable-disable-controls/3055
**Category:** Questions
**Tags:** controls
**Created:** [June 7, 2018, 4:29pm UTC](https://discourse.threejs.org/t/enable-disable-controls/3055 "2018-06-07T16:29:55Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jauregui](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/jauregui/32/5119_2.png) [@jauregui](https://discourse.threejs.org/u/jauregui)
#### Post date: [June 7, 2018, 4:29pm UTC](https://discourse.threejs.org/t/enable-disable-controls/3055/1 "2018-06-07T16:29:55Z")

</div>

I working with an app and I need to give to the user the option of switching between these controls.

There is a way to enable or disable controls like device orientation and track ball?

---

<div class="post-metadata">

### Author: ![jauregui](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/jauregui/32/5119_2.png) [@jauregui](https://discourse.threejs.org/u/jauregui)
#### Post date: [June 7, 2018, 7:26pm UTC](https://discourse.threejs.org/t/enable-disable-controls/3055/3 "2018-06-07T19:26:11Z")

</div>

\*\*\* I extract part of the codes… Hope is clear, thanks\*\*  
_HTML area  
…  
In a button element … **onclick="switchmode()**"_  
…

\*inside init function

```auto
        vr = true; //variable to switch from vr mode (deviceorientation ctrl to trackBall crtl) to normal mode
      eyes = new THREE.Group();
      cameral = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.01, 5000);
            cameral.position.x = -5;
            camerar = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.01, 5000);
            camerar.position.x = 5;
            eyes.add(cameral);
            eyes.add(camerar);
            eyes.position.y=200;
            scene = new THREE.Scene();
            scene.add(eyes);
          controlvr= new THREE.DeviceOrientationControls(eyes);
         controltrack = new THREE.TrackballControls(cameral); //Creating it, makes cameral looks at -90deg offset to mamerar. 

...
  function switchmode(){ 
if(vr){
vr=false; //How could I desable deviceOrientation ctrl and enable trackBall ctrl.???
 }
else{vr=true: //How could I desable trackBall ctrl and enabledeviceOrientation ctrl.???
}

}
 function animate() {
            requestAnimationFrame(animate);
            if(vr) controlvr.update();
            else controltrack.update();
            render();
        }
        var rot = 0, vel = .01, peyes = {
                x: eyes.position.x,
                y: eyes.position.y,
                z: eyes.position.z
            };
      function render() {
            if (move != "stop") vel += 1;
                if (move === "go") {
                eyes.position.z = vel * mv.z + peyes.z;
                eyes.position.y = vel * mv.y + peyes.y;
                eyes.position.x = vel * mv.x + peyes.x;
            }

            if (vr) {
                renderer.setViewport(0, 0, window.innerWidth / 2, window.innerHeight);
                renderer.setScissor(0, 0, window.innerWidth / 2, window.innerHeight);
                renderer.setScissorTest(true);
                cameral.aspect = (window.innerWidth / 2) / window.innerHeight;
                cameral.updateProjectionMatrix();
                renderer.render(scene, cameral);

                renderer.setViewport(window.innerWidth / 2, 0, window.innerWidth / 2, window.innerHeight);
                renderer.setScissor(window.innerWidth / 2, 0, window.innerWidth / 2, window.innerHeight);
                renderer.setScissorTest(true);
                camerar.aspect = (window.innerWidth / 2) / window.innerHeight;
                camerar.updateProjectionMatrix();
            }
            renderer.render(scene, camerar);
            world.rotateY(.0004); //Sphere holding Equirectangular panorama
        }

```

---

<div class="post-metadata">

### Author: ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)
#### Post date: [June 7, 2018, 8:38pm UTC](https://discourse.threejs.org/t/enable-disable-controls/3055/4 "2018-06-07T20:38:28Z")

</div>

Thanks for the further information. `DeviceOrientationControls` and `TrackballControls` both have an `enabled` property. It’s set to `true` per default. Try to set it to `false` if you want to stop a certain control instance.

---

<div class="post-metadata">

### Author: ![jauregui](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/jauregui/32/5119_2.png) [@jauregui](https://discourse.threejs.org/u/jauregui)
#### Post date: [June 8, 2018, 1:24pm UTC](https://discourse.threejs.org/t/enable-disable-controls/3055/5 "2018-06-08T13:24:41Z")

</div>

Thanks a lot for your help,  
\*in the trackball control worked perfect, but in the orientation control once it was disabled and enable again it didn’t respond. I was checking the js file of the device orientation control and I found the methods **connect** and **disconnect** , I use them instead and worked perfect.

---

<div class="post-metadata">

### Author: ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)
#### Post date: [June 8, 2018, 2:20pm UTC](https://discourse.threejs.org/t/enable-disable-controls/3055/6 "2018-06-08T14:20:33Z")

</div>

> [@jauregui](#):
>
> \*in the trackball control worked perfect, but in the orientation control once it was disabled and enable again it didn’t respond.

That’s bad. If you have time, you might want to file a bug at github. Adding a simple [test case](https://jsfiddle.net/f2Lommf5/) would be fantastic.

---

<div class="post-metadata">

### Author: ![Gaara](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/gaara/32/22403_2.png) [@Gaara](https://discourse.threejs.org/u/Gaara)
#### Post date: [September 9, 2022, 6:28am UTC](https://discourse.threejs.org/t/enable-disable-controls/3055/7 "2022-09-09T06:28:45Z")

</div>

This exact bug still exists.

---

<div class="post-metadata">

### Author: ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)
#### Post date: [September 9, 2022, 7:49am UTC](https://discourse.threejs.org/t/enable-disable-controls/3055/8 "2022-09-09T07:49:40Z")

</div>

`DeviceOrientationControls` has been removed with `r134` so there is no official support for it anymore.
