Clock - Verge3D User Manual - Soft8Soft
Description: Learn how to use Clock in your interactive 3D apps made with Verge3D

# Clock

Object for keeping track of time. This uses performance.now if it is available, otherwise it reverts to the less accurate Date.now.

## Constructor

### Clock(autoStart : Boolean)

autoStart — (optional) whether to automatically start the clock when .getDelta() is called for the first time. Default is `true`.

## Properties

### # .autoStart : Boolean

If set, starts the clock automatically when .getDelta() is called for the first time. Default is `true`.

### # .startTime : Float

Holds the time at which the clock's .start method was last called. Default is `0`.

### # .oldTime : Float

Holds the time at which the clock's .start, .getElapsedTime() or .getDelta() methods were last called. Default is `0`.

### # .elapsedTime : Float

Keeps track of the total time that the clock has been running. Default is `0`.

### # .running : Boolean

Whether the clock is running or not. Default is `false`.

## Methods

### # .start()

Starts clock. Also sets the .startTime and .oldTime to the current time, sets .elapsedTime to `0` and .running to `true`.

### # .stop()

Stops clock and sets .oldTime to the current time.

### # .getElapsedTime() → Float

Get the seconds passed since the clock started and sets .oldTime to the current time. If .autoStart is `true` and the clock is not running, also starts the clock.

### # .getDelta() → Float

Get the seconds passed since the time .oldTime was set and sets .oldTime to the current time. If .autoStart is `true` and the clock is not running, also starts the clock.

## Puzzles

There are numerous time puzzles to manage time and data in a code-less manner.

## Source

For more info on how to obtain the source code of this module see this page.