How to Lerp ArcRotateCamera alpha using the shortest angle?

See PG (use 1 and 2 keys to switch between alpha values):

Note that it takes the longest, least natural path.

What’s the easiest way to ensure Lerp always uses the shortest route/angle i.e. if the difference between Lerp start and end > PI, then move in the opposite, shortest angle?

This approach seems to do what I want, but just wondering if there’s a better way? it seems like the sort of thing that is useful/common enough to warrant a Scalar static method. Is there one I’ve overlooked?

Use 1, 2 and 3 keys to switch between alpha values.

There’s MoveTowardsAngle: Babylon.js/math.scalar.ts at master · BabylonJS/Babylon.js (

1 Like

Thanks @carolhmj . I’ll give that a try.

Just a side question, does anyone know the rationale behind why some of these Scalar methods accept arguments in degrees when radians are used everywhere else in the engine? What’s the use-case? Doesn’t it mean extra steps having to convert to degrees before calling the method then converting the result back to radians?

I would blame us not noticing during the PR when it happened and then we do not break back compat :slight_smile:

Any chance we could add an extra, optional method argument like useDegrees: boolean = true and internally use degrees or radians depending on that, in order to alleviate conversions but also not break backwards compatibility? Or is that just making the API worse?

It’s easy enough for the user to do the conversions I guess, but I worry about the potential performance overhead for computationally intensive calculations.

Or maybe units: Angle.UNITS_RADIANS | Angle.UNITS_DEGREES = Angle.UNITS_DEGREES which makes it even clearer.