Detecting When Idle

What is the best way of detecting when nothing is interacting with the scene for a specific period of time? So when user input (but not necessary scene animations, ext…) are idle for a specified period of time?

Make a timer that is constantly counting down. If any event is triggered, aka keyboard input/ mouse movement etc… just reset the timer.

1 Like

I thought about that, is that the most optimized approach?

It seems Babylon must have a built in method as the auto-rotate of the arc rotate camera gets triggered after a wait. Is there a built in accessible method?

For the ArcRotate Camera you can use camera.autoRotationBehavior.rotationInProgress boolean.

Fine tune with idleRotationWaitTime parameter.

  • idleRotationWaitTime : Time (in milliseconds) to wait after user interaction before the camera starts rotating

Yes that makes sense, but the thought was that if a loop was already running to check for idle, extending that loop would make sense just to save another loop running. Perhaps it is more trouble than it is worth.

If you don’t want to use scene.onRender loop you may use counter with pointer/keyboard events, as @msDestiny14 suggested.