Limit camera panning to the horizontal axis

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:

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();
    }

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

https://jsfiddle.net/n49ubxh0/1/