Limit camera panning bounds


I am new to graphics programming and really love working with babylon so far.

I hope someone can point me in a direction to solve my problem. I am trying to limit the camera to certain bounds to prevent it from going over my scene. My camera behaviour is similar to a RTS game like warcraft or red alert, but I am moving around on the x-y axis. The z-axis will be for zooming only… When you get to the edges of the map the camera should stop moving.

I have managed to get panning working using the ArcRotateCamera, but there is only one property I can see to set the limits which is panningDistanceLimit. This property seems to be creating radius limit where I am looking more for a bounding box limit.

I would also like to anchor the camera to have 0,0 be top left.

I have uploaded a image to demonstrate what I am trying to achieve with the camera.

1 Like

Adding @PolygonalSun our camera Wizard.


Hey @Gerhard_Meyer,

So, if I’m understanding correctly, if you have some plane/area that represents your game area, you don’t want your camera to be able to move such that it can view outside of that game area. For this to happen, you’d need your camera to know where the end of your terrain is. Potentially, you could create a housing for your camera with meshes that have checkCollisions set to true then you could just move around until you hit something. (Camera Collisions | Babylon.js Documentation (

If something like that wouldn’t work, you could also leverage the camera’s frustum (View Frustum - Interactive 3D Graphics - YouTube) and put some kind of marker at the end of your maps and if isInFrustum is true (the camera can see it), don’t move. This is a more complex approach and may require a bit of research but might pull off the desired results.

I’d recommend looking into the camera collisions first and see what you can make.