Rolling/twisting an ArcRotateCamera

Hello,

im currently struggling to properly roll/twist an ArcRotateCamera. My goal right now is to add a roll/twist to an ArcRotateCamera which basically means rotating the camera based on its forward axis. I’ve stumbled upon a few topics that asked a similiar questions, however none of the solutions actually implement my expected behaviour.

Most of the time it is suggested to modify the camera.upVector property, however that doesn’t exactly work as expected. It seems like the this vector is in world space, which means once I further rotate my camera the roll/twist is no longer in the expected direction (rotation based on forward axis). I’ve added a GIF below to illustrate this behaviour (also added the playground: UpVector Example).

upvector-example

As you can see in the GIF above, once the camera is further rotated the roll/twist is in the wrong direction (not aligned with cameras forward axis anymore). Ideally I would like to be able to rotate an ArcRotateCamera using its local rotation which would result in rolling/twisting the camera based on its forward axis. I’ve added a GIF below to illustrate this behaviour. Currently it seems like the local rotation of the camera is not being used at all (setting it in code).

gizmo-rotate

Is there a way to implement this behaviour?

1 Like

@PolygonalSun might have a trick for this or unfortunately it would require geometry work.

@sebavan @PolygonalSun
Hi guys,

I would also be very interested if there is any solution or workaround for this.

Thank you.

As far as I know, the banking/rolling is not part of this type of camera.
There’s been a recent post around the subject where some of us stated that it would be a ‘nice to have’ but nobody has made it a feature request or opened a PR for it yet.
If more are interested, you’d have also ‘my vote’ for this adding to the arcRotateCamera (for whatever good it does :wink:).

Hi,

It’s a bit hacky, but you may use a camera (camera2) parented to the first ArcRotateCamera (camera1), and rotate camera2 relatively to camera1.

Camera1 need to be active for its inputs to work so you need to keep it active, but with a layermask = 0x00000000 I guess camera1 render pass will not be very expensive.

Demo here : Babylon.js Playground , use keyboard A and D to rotate around Z axis.

3 Likes

Hey @murphy,
Lemme think about this for a bit and see if something comes to mind.

So, by itself, there isn’t any obvious way to roll the camera and the first thought that came to mind was to try rotating the upVector based off of the way that the camera rolled while accounting for the ArcRotateCamera’s alpha and beta but the solution that @SvenFrankson provided is pretty simple and works well. Parenting your visual camera to the ArcRotateCamera’s movements is pretty clever. The only other way to handle this that comes to mind is to just create a FreeCamera with custom controls to add ArcRotateCamera-like movement to it.

2 Likes

Smart thinking. Rather than ‘hacky’ I would call it ‘creative’ :grin: GJ,

2 Likes

Thanks for the ‘hacky’ solution :wink: - this should be enough for my use case right now.

If I need any more complex functionality I will probably just create a FreeCamera and add custom controls which mimics the ArcRotateCamera (+ additional functionality like roll) as suggested by @PolygonalSun.