Hi @amoebachant, thanks for looking into this. I really appreciate it.
Regarding your instructions, I tried increasing both delays to a couple different values (500, 1000, 2000). Sadly, I experienced the same issue.
I don’t want to just reply ‘that didn’t work’, so I tried tweaking each variable of the macro and tested it to see what would happen. I’m now confident I know where the randomness comes from, but perhaps more importantly, why I have such a hard time using Babylon’s camera controller.
There is some kind of input threshold before inertia activates. If the mouse is moving fast, the camera has inertia as expected. However, when below a threshold, the camera has no inertia at all. I tested and confirmed that it (that is, moving the mouse slow enough to be under the threshold) yields identical motion when camera.inertia = 0
vs on.
This threshold is more apparent/reproducible in this playground:
^^^^
Here, the inertia is set to 1
. Thus, when you get the camera moving, it should never stop. But, if you drag slowly, you can see that the camera sticks to your cursor. No inertia. Only after moving the mouse fast enough does it begin spinning forever like it’s supposed to.
As to where the randomness comes from: my testing revealed that the culprit is crossing the threshold. My guess is that the frame when the mouse velocity goes from one side of the threshold to the other can vary a little bit. Now, this randomness is annoying, but I’m not sure I should care about it. I think its just noticeable because of the bigger issue here.
That issue is the dramatic jump in speed when inertia kicks in.
This leap in speed makes the camera very difficult to control (anecdotally, anyway) because I move the mouse in a feedback loop with I see on my screen. When I accelerate my mouse just a little and the camera moves a little faster in response, perfect. But, when I accelerate it just a little more (crossing the threshold) and it goes flying, it is rather annoying. I often end up straddling the threshold and fighting the camera. I tell it to move slower, but then the speed plumets because it dropped below the threshold, making the camera feel stuck. I try to speed back up, but then it overshoots. It’s a battle.
After playing more with three.js’s camera, I see that they are smoothing all mouse movement, regardless of speed or distance. Even one pixel of cursor movement produces an eased camera animation. It tells the camera it needs to move some amount, then the camera applies that motion over time. I suspect that they are using the ‘approach’ technique and that their inertia calculation doesn’t jump when ‘activating’ like Babylon’s current implementation does.
I apologize for any repetition or wordiness. I’m having a hard time explaining the issue. Please feel free to ask any follow up questions. I’d be happy to answer.