Home Reference Source
import {Timer} from 'postprocessing'
public class | source

Timer

Implements:

A timer.

Original implementation by Michael Herzog (Mugen87).

See:

  • https://github.com/mrdoob/three.js/pull/17912

TODO:

  • Remove if Timer replaces Clock in three.js.

Constructor Summary

Public Constructor
public

Constructs a new timer.

Method Summary

Public Methods
public

Disposes this timer.

public

Returns the delta time.

public

Returns the elapsed time.

public

Returns the fixed delta time.

public

Returns the timescale.

public

handleEvent(event: Event)

Handles events.

public

Resets this timer.

public

Enables or disables auto reset based on page visibility.

public

setFixedDelta(fixedDelta: Number): Timer

Sets the fixed delta time.

public

Enables or disables the fixed time step.

public

setTimescale(timescale: Number): Timer

Sets the timescale.

public

update(timestamp: Number): Timer

Updates this timer.

Public Constructors

public constructor() source

Constructs a new timer.

Public Methods

public dispose() source

Disposes this timer.

public getDelta(): Number source

Returns the delta time.

Return:

Number

The delta time in seconds.

public getElapsed(): Number source

Returns the elapsed time.

Return:

Number

The elapsed time in seconds.

public getFixedDelta(): Number source

Returns the fixed delta time.

Return:

Number

The fixed delta time in seconds.

public getTimescale(): Number source

Returns the timescale.

Return:

Number

The timescale.

public handleEvent(event: Event) source

Handles events.

Params:

NameTypeAttributeDescription
event Event

The event.

public reset(): Timer source

Resets this timer.

Return:

Timer

This timer.

public setAutoResetEnabled(enabled: Boolean): Timer source

Enables or disables auto reset based on page visibility.

If enabled, the timer will be reset when the page becomes visible. This effectively pauses the timer when the page is hidden. Has no effect if the API is not supported.

Params:

NameTypeAttributeDescription
enabled Boolean

Whether the timer should be reset on visibility change.

Return:

Timer

This timer.

See:

  • https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API

public setFixedDelta(fixedDelta: Number): Timer source

Sets the fixed delta time.

Params:

NameTypeAttributeDescription
fixedDelta Number

The delta time in seconds.

Return:

Timer

This timer.

public setFixedDeltaEnabled(enabled: Boolean): Timer source

Enables or disables the fixed time step.

Params:

NameTypeAttributeDescription
enabled Boolean

Whether the fixed delta time should be used.

Return:

Timer

This timer.

public setTimescale(timescale: Number): Timer source

Sets the timescale.

Params:

NameTypeAttributeDescription
timescale Number

The timescale.

Return:

Timer

This timer.

public update(timestamp: Number): Timer source

Updates this timer.

Params:

NameTypeAttributeDescription
timestamp Number
  • optional

The current time in milliseconds.

Return:

Timer

This timer.