Skip to content

Commit

Permalink
Timer: Add connect()/disconnect(). (#1547)
Browse files Browse the repository at this point in the history
* Update

* Update three.js
  • Loading branch information
Methuselah96 authored Feb 23, 2025
1 parent 68a335f commit 198e1ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions types/three/examples/jsm/misc/Timer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*
* - {@link Timer} has an {@link .update()} method that updates its internal state. That makes it possible to call
* {@link .getDelta()} and {@link .getElapsed()} multiple times per simulation step without getting different values.
* - The class uses the Page Visibility API to avoid large time delta values when the app is inactive (e.g. tab switched
* or browser hidden).
* - 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).
*
* @example
* const timer = new Timer();
Expand All @@ -22,12 +22,18 @@
* @see https://threejs.org/examples/#webgl_morphtargets_sphere
*/
export class Timer {
constructor();

/**
* Connects 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(document: Document): void;

/**
* Whether to use the Page Visibility API to avoid large time delta values in inactive tabs or not.
* @default true
* @param usePageVisibilityAPI
* Disconnects the timer from the DOM and also disables the usage of the Page Visibility API.
*/
constructor(usePageVisibilityAPI?: boolean);
disconnect(): void;

/**
* Returns the time delta in seconds.
Expand Down

0 comments on commit 198e1ca

Please sign in to comment.