Short question: is there a way to roll the camera in BabylonJS, like so?
I’m specifically using ArcRotateCamera, without interfering with any other functionality. I.e., I’d like to activate the roll rotation while holding the SHIFT key. If anyone’s got any Playground examples, I’d be interested to see.
I had initially tried this, but it seems that the roll rotation got a bit laggy at times instead of being smooth (especially when I’m zoomed up close to a shape), so I was wondering if someone had successfully achieved this before.
The upVector would be the easiest way to get the roll to work for the ArcRotateCamera. I’d be curious to see how you’ve implemented the roll. Also, just out of curiosity, any there any reason why you’re using the ArcRotateCamera?
Here’s the implementation (to trigger the camera roll, hold the CTRL key while clicking + dragging):
As you can see, the roll isn’t super smooth – it shakes a bit at times.
Another implementation that didn’t go very well:
In the second one, it seems that the camera doesn’t quite roll around its pointing axis. This can be observed by the fact that different sides of the cube are being revealed as you try to roll the camera, instead of simply rotating the frame.
Also, just out of curiosity, any there any reason why you’re using the ArcRotateCamera?
I started using the ArcRotateCamera and it’s been working quite well for my CAD-viewing app, so I’d rather not switch to another camera type just for this if possible.
After playing around a bit with your PGs, it looks like you’re almost there with this first one. I think something might be incorrect with how you’re calculating the upVector though. When I tried to track how your upVectors were looking by drawing lines for them, it created more of rounded shape, rather than a circular plane.
Okay, for generating your upVectors, I’d recommend using something like camera.getDirection(BABYLON.Axis.Y) to get the up direction, with respect to how the camera is facing. From there, you should be able to rotate it around the forward vector.
Sorry, allow me to clarify, what I meant to say was that, for your initialUpVector, you should use camera.getDirection(BABYLON.Axis.Y) as that was the easiest way to get an upVector that you could rotate around. Looking back at this though, this may not actually be the best answer because this could effectively mess up your alpha and beta angle values.