Skip to content

Commit

Permalink
Merge pull request #6785 from davepagurek/deltatime-variance
Browse files Browse the repository at this point in the history
Use requestAnimationFrame timestamp for less noise in deltaTime
  • Loading branch information
limzykenneth authored May 28, 2024
2 parents 8e6ceff + 44ac09a commit 40ff3f9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,8 @@ class p5 {
this.callRegisteredHooksFor('afterSetup');
};

this._draw = () => {
const now = window.performance.now();
this._draw = requestAnimationFrameTimestamp => {
const now = requestAnimationFrameTimestamp || window.performance.now();
const time_since_last = now - this._lastTargetFrameTime;
const target_time_between_frames = 1000 / this._targetFrameRate;

Expand Down

0 comments on commit 40ff3f9

Please sign in to comment.