Timer

THREE.Timer
See theTimer companion object
class Timer extends Object

This class is an alternative to Clock with a different API design and behavior. The goal is to avoid the conceptual flaws that became apparent in Clock over time.

  • Timer has an update() method that updates its internal state. That makes it possible to call getDelta() and getElapsed() multiple times per simulation step without getting different values.
  • The class can make use of the Page Visibility API to avoid large time delta values when the app is inactive (e.g. tab switched or browser hidden).

Attributes

Since

r183

Companion
object
Graph
Supertypes
class Object
trait Any
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def connect(document: Document): Unit

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.

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.

Attributes

def disconnect(): Unit

Disconnects the timer from the DOM and also disables the usage of the Page Visibility API.

Disconnects the timer from the DOM and also disables the usage of the Page Visibility API.

Attributes

def dispose(): Unit

Can be used to free all internal resources. Usually called when the timer instance isn't required anymore.

Can be used to free all internal resources. Usually called when the timer instance isn't required anymore.

Attributes

def getDelta(): Double

Returns the time delta in seconds.

Returns the time delta in seconds.

Attributes

def getElapsed(): Double

Returns the elapsed time in seconds.

Returns the elapsed time in seconds.

Attributes

def getTimescale(): Double

Returns the timescale.

Returns the timescale.

Attributes

def reset(): Timer

Resets the time computation for the current simulation step.

Resets the time computation for the current simulation step.

Attributes

def setTimescale(timescale: Double): Timer

Sets the given timescale which scale the time delta computation in update().

Sets the given timescale which scale the time delta computation in update().

Attributes

def update(timestamp: UndefOr[Double] = ...): 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()).

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()).

Value parameters

timestamp

The current time in milliseconds. Can be obtained from the requestAnimationFrame callback argument. If not provided, the current time will be determined with performance.now.

Attributes

Inherited methods

def hasOwnProperty(v: String): Boolean

Attributes

Inherited from:
Object
def isPrototypeOf(v: Object): Boolean

Attributes

Inherited from:
Object
def propertyIsEnumerable(v: String): Boolean

Attributes

Inherited from:
Object
def toLocaleString(): String

Attributes

Inherited from:
Object
def valueOf(): Any

Attributes

Inherited from:
Object