Lock camera movement and rotation to x and y axes, get frustum corner points

I have a game board with hexagonal tiles. I create a pane of them on the x/y layer. Above them i have an ArcRotateCamera. I want to lock that camera, so it can only be moved along x and y axis, also i dont want it to rotate on the z axis only x and y. When the camera is moved, i need the corner points of the frustum, so i know which more tiles to load from server. I was playing and googling around all day and end up frustrated. Is it possible this cannot be done without rewriting the whole input controls? I cant be the first person who needs to lock the camera controls along axes. What am I missing?

Summoning our camera / input grandmaster @PolygonalSun

Hey @gwendolon, just to make sure that I’m understanding correctly, you want to be able to move a camera parallel to your “game board”. Additionally, you want to be able to rotate the camera, using the camera’s position as the pivot point, up and down (like noding YES) and left and right (like shaking your head NO). Is this correct?

Yes, pan it like google maps and rotate left/right but no up/down rotation. Player is always forced to look at the board, they never see the sky :slight_smile:
Rotating the camera should look like only the map is rotating and zoom does only go within predefined range in predefined steps.
A classical strategy game board.

Thanks for the quick reply.

Well, my first thought is that for camera panning/movement, you may need to write something to move both the camera and target vectors. As far as limiting rotation, you could always make use of the beta and alpha limit properties:

// Example to prevent looking up and down, if staring forward
camera.upperBetaLimit = BABYLON.Angle.FromDegrees(90).radians();  
camera.lowerBetaLimit = BABYLON.Angle.FromDegrees(90).radians();

Here’s a PG showing the rotation prevention: Lock Beta Example | Babylon.js Playground

Is this closer to what you’re looking for?

1 Like