How to disable pan y axis and set min max to x and z

Hello there,

const orbit = new OrbitControls(camera, renderer.domElement);
orbit.enableDamping = true;
orbit.maxPolarAngle = MAX_POLAR_ANGLE;
orbit.maxDistance = MAX_DISTANCE;

I have created this for controls. But I don’t want the user to move so the Y target gets higher or lower than zero. (He won’t be able to target something higher or lower than zero). I also want to set minimums and maximums for x and z axes so the user doesn’t go far away from the map.

Thank you for your help :wink:

In your requestAnimationFrame callback, first call controls.update, then apply any constraints to the camera position, then call renderer.render (it’s important you call controls update manually, so that it happens in this specific order.)

Thank you very much!

I have another question related, I would like to disable the polarangle change when I right click and move to the top or the bottom (It does it already w/ the left click and the right click is supposed to move the map).
Is there a solution also to move in the map with keys ? (like wasd or the arrows)

Thanks