ArcRotateCamera Target position limit

Hi

I got a scene in which I want the user to orbit around a shape. I can have a box around that shape and will like to have an ArcRotateCamera Target always be inside of it. Like a boundary for panning but not to the camera, but to the target of the camera.

And this box might be rotated.

How to do it?

“panningDistanceLimit” is not doing the trick here.

I created a startup PB. The sphere is just to visualize the camera target. The box is the limiting area.

https://playground.babylonjs.com/#VVP3MM

Regards
Peter

Pinging @PolygonalSun

Hey @peterimg, so if I’m understanding this correctly, you want to have a shape that you can move around, within the dimensions of a box. In addition, you want to make it so that the camera’s target is always set to that shape also, have the ability to rotate around things, is that correct?

I want to pan the camera and I want the camera target to be in a box. And stop panning if it’s out of it.

The sphere is just to show where the target is.

And on top of that, have all other ArcRotationCamera features but i need to limit target movement to a box while panning.

So off of the top of my head, I don’t think that panningDistanceLimit would work for limiting with respect to the space of a cube as it just prevents the camera from panning outside of the given limit (think of it like a sphere shaped limit). You might have to custom make an input that checks if your camera’s axes are some value from a given point and stops movement: Customizing Camera Inputs | Babylon.js Documentation (eg. x, y, or z can only be +/- 5 from 0)

I try to understand this but it’s not coming to me how to achieve this.

Can you make some simple PG with example?

Regards
Peter