Strange behavior of angularSpeed when change it between 0.001111 and 0.001112

I observe very strange behavior when changing angularSpeed between 0.001111 and 0.001112 values.
When I set the value to 0.001112, the camera doesn’t rotate smoothly enough as I want:
camera.inputs.attached.keyboard.angularSpeed = 0.001112;

When I set the value to 0.001111, the camera rotate too slow:
camera.inputs.attached.keyboard.angularSpeed = 0.001111;

Therefore, I cannot set the sensitivity I need :frowning:
Help me please

Would be great if you could reproduce the issue in the playground so that we could all have a look in order to help you the best we can.

It might be a precision issue in the generated matrices and I do hope it is not :frowning:

https://www.babylonjs-playground.com/#14KRGG#263

Is there any other way to change the sensitivity?

Could you share a screen cap of your issue, it does work all great for me :frowning: also your browser and version might help.

I take turns hitting the right and left arrows on the video:


Sorry, I didn’t specify that I mean the rotation of the camera with the arrows on the keyboard.

Moreover, when angularSpeed less than 0.001112 and you give initial rotation speed with the mouse, and continue to rotate with the arrows, then the speed seems to become normal.

I am still unsure to see the issue on the video :frowning: @RaananW or @Evgeni_Popov might have an idea ?

What about trying in-between values like 0.0011115?

Note that using 0.001111 or 0.001112 on my local computer does not change anything, or at least I can’t see any difference.

Have you tried in other browsers?

For values less than 0.001111111111111111 I have this issue. I think this value is periodic fraction 0.00(1), just the type precision is limited.

I tried on 5 computers in different browsers, the behavior is the same everywhere.

Could you record a screencast using = 0.001111 please?

Sorry, I missed the part where you said one must use the keyboard!

So, I reproduced the problem and it comes from some epsilon used in the code.

More precisely, if camera.inertia * camera.inertialAlphaOffset < epsilon, inertialAlphaOffset is set to 0.

In your sample, inertialAlphaOffset = angularSpeed = 0.001111 at start. camera.inertia = 0.9, so inertialAlphaOffset * inertia = 0.0009999. As epsilon = 0.001, inertialAlphaOffset is reset to 0…

So, you can fix your problem by raising a little inertia when using angularSpeed = 0.001111:

https://playground.babylonjs.com/#3AHG5Y#1

I wonder if we should let the user be able to change this epsilon value… @Deltakosh, @PolygonalSun, @sebavan?

2 Likes

It was cool to be able to access epsilon because I actually need a value around angularSpeed = 0.0007, then camera.inertia must be at least 1.43 which is a bad value.

The Epsilon value should be configurable. It is not defined as const, so technically changing the imported value. Does it work when changing the value directly?

Setting BABYLON.Epsilon = 0.0001; does not work, the value is not retained.

1 Like

Yep, you are right. Seems like Webpack converts the Epsilon value to a getter function, which prevents the value from being changed (detailed here - Allow module system that does not rely on getters in Webpack 4 · Issue #6979 · webpack/webpack · GitHub). We will probably need to allow some sort of setter to an epsilon outside of this scope to allow the user to change the epsilon value

2 Likes