How Accurate is the Clock

At the moment, i’m using the Clock.ElapsedTime method to measure the amount of seconds to transform a block back and forward. Then resetting the clock. But after a 2-3 cycles it goes really out of phase. It this because of the accuracy of using a clock?

Is it specifically because the clock.start() method takes time to reload?

Thanks.

The clock uses Performance.now with fallback to Date.now.

Pretty much all browsers support Performance.now so you can assume you’re using that. The accuracy depends on the browser, and is slightly reduced for security reasons. I think it’s accurate to about 1ms.

Unfortunately, there’s no way of getting more accurate timing than this in a browser.

2 Likes

It must be the way my functions are written then. Cheers