Methods
.connect( document : Document )
Connect the timer to the given document.Calling this method is not mandatory to use the timer but enables the usage of the Page Visibility API to avoid large time delta values.
| document |
The document. |
.disconnect()
Disconnects the timer from the DOM and also disables the usage of the Page Visibility API.
.dispose()
Can be used to free all internal resources. Usually called when the timer instance isn't required anymore.
.getDelta() : number
Returns the time delta in seconds.
- Returns: The time delta in second.
.getElapsed() : number
Returns the elapsed time in seconds.
- Returns: The elapsed time in second.
.getTimescale() : number
Returns the timescale.
- Returns: The timescale.
.reset() : Timer
Resets the time computation for the current simulation step.
- Returns: A reference to this timer.
.setTimescale( timescale : number ) : Timer
Sets the given timescale which scale the time delta computation
in update().
| timescale |
The timescale to set. |
- Returns: A reference to this timer.
.update( timestamp : number ) : Timer
Updates the internal state of the timer. This method should be called
once per simulation step and before you perform queries against the timer
(e.g. via getDelta()).
| timestamp |
The current time in milliseconds. Can be obtained
from the |
- Returns: A reference to this timer.