Skip to content

Commit

Permalink
Use internal Timer
Browse files Browse the repository at this point in the history
Addresses #611
  • Loading branch information
vanruesc committed Mar 10, 2024
1 parent b56fb9b commit 3ea7c03
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/core/EffectComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
WebGLRenderTarget
} from "three";

import { Timer } from "three/examples/jsm/misc/Timer.js";
import { Timer } from "./Timer.js";
import { ClearMaskPass, CopyPass, MaskPass } from "../passes/index.js";

/**
Expand Down
13 changes: 13 additions & 0 deletions src/core/Timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const SECONDS_TO_MILLISECONDS = 1e3;
* Original implementation by Michael Herzog (Mugen87).
*
* @deprecated Use `three/addons/misc/Timer.js` instead.
* @implements {ImmutableTimer}
* @implements {EventListenerObject}
* @implements {Disposable}
*/
Expand Down Expand Up @@ -199,6 +200,18 @@ export class Timer {

}

getDelta() {

return this.delta;

}

getElapsed() {

return this.elapsed;

}

handleEvent(e) {

if(!document.hidden) {
Expand Down
11 changes: 6 additions & 5 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ declare module "postprocessing" {
Data3DTexture
} from "three";

import { Timer as Timer3 } from "three/examples/jsm/misc/Timer.js";

/**
* A color channel enumeration.
*
Expand Down Expand Up @@ -4785,7 +4783,7 @@ declare module "postprocessing" {
*
* @return {Timer} The timer.
*/
getTimer(): Timer3;
getTimer(): Timer;
/**
* Returns the renderer.
*
Expand Down Expand Up @@ -5085,12 +5083,12 @@ declare module "postprocessing" {
* Original implementation by Michael Herzog (Mugen87).
*
* @deprecated Use `three/addons/misc/Timer.js` instead.
* @implements {ImmutableTimer}
* @implements {Disposable}
* @implements {EventListenerObject}
*/
export class Timer implements Disposable, EventListenerObject {
export class Timer implements Disposable, ImmutableTimer, EventListenerObject {
handleEvent(object: Event): void;

/**
* The current delta time in seconds.
*/
Expand Down Expand Up @@ -5122,6 +5120,9 @@ declare module "postprocessing" {
*/
get autoReset(): boolean;
set autoReset(value: boolean);

getDelta(): number;
getElapsed(): number;
/**
* Updates this timer.
*
Expand Down

0 comments on commit 3ea7c03

Please sign in to comment.