# Limit camera panning to the horizontal axis

**URL:** <https://discourse.threejs.org/t/limit-camera-panning-to-the-horizontal-axis/17647>\
**Category:** Questions\
**Tags:** orbit-controls\
**Created:** [August 5, 2020, 6:43am UTC](https://discourse.threejs.org/t/limit-camera-panning-to-the-horizontal-axis/17647 "2020-08-05T06:43:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabrotich](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/fabrotich/32/12528_2.png) [@fabrotich](https://discourse.threejs.org/u/fabrotich)\
**Post date:** [August 5, 2020, 6:43am UTC](https://discourse.threejs.org/t/limit-camera-panning-to-the-horizontal-axis/17647/1 "2020-08-05T06:43:40Z")

</div>

Hello everyone,

I’d like to limit camera panning to the horizontal axis (Users shouldn’t be able to pan vertically). This is what I currently have:

```auto
initCamera() {
        const fov =
            (180 * (2 * Math.atan(window.innerHeight / 2 / this.perspective))) / Math.PI;

        this.camera = new THREE.PerspectiveCamera(
            fov,
            window.innerWidth / window.innerHeight,
            1,
            1000
        );
        this.orbitControls = new OrbitControls(this.camera, this.renderer.domElement);
        this.orbitControls.enableRotate = false;
        this.orbitControls.enableZoom = false;
        this.orbitControls.addEventListener('change', (event) => {
            this.orbitControls.target.y = 0;
            this.orbitControls.target.z = 0;
        });

        this.orbitControls.touches = {
            ONE: THREE.TOUCH.PAN,
            TWO: THREE.TOUCH.PAN
        };

        this.camera.position.set(0, 0, this.perspective);
        this.orbitControls.update();
    }

```

---

<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:** [August 5, 2020, 9:32am UTC](https://discourse.threejs.org/t/limit-camera-panning-to-the-horizontal-axis/17647/2 "2020-08-05T09:32:51Z")

</div>

I suggest you modify `OrbitControls` and comment out the calls of `panUp()`.

[https://jsfiddle.net/n49ubxh0/1/](https://jsfiddle.net/n49ubxh0/1/)
