Skip to content

Commit

Permalink
Timer: Fix multiple instance usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed Jul 24, 2023
1 parent 9776f48 commit 665bb49
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions examples/jsm/misc/Timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Timer {

this._previousTime = 0;
this._currentTime = 0;
this._startTime = now();

this._delta = 0;
this._elapsed = 0;
Expand Down Expand Up @@ -81,7 +82,7 @@ class Timer {

reset() {

this._currentTime = this._now();
this._currentTime = now() - this._startTime;

return this;

Expand Down Expand Up @@ -112,7 +113,7 @@ class Timer {
} else {

this._previousTime = this._currentTime;
this._currentTime = ( timestamp !== null ) ? timestamp : this._now();
this._currentTime = ( timestamp !== null ) ? timestamp : ( now() - this._startTime );

this._delta = this._currentTime - this._previousTime;

Expand All @@ -126,13 +127,11 @@ class Timer {

}

// private

_now() {
}

return ( typeof performance === 'undefined' ? Date : performance ).now();
function now() {

}
return ( typeof performance === 'undefined' ? Date : performance ).now();

}

Expand Down

0 comments on commit 665bb49

Please sign in to comment.