Skip to content

Commit

Permalink
Use requestAnimationFrame timestamp for less noise in deltaTime
Browse files Browse the repository at this point in the history
  • Loading branch information
davepagurek committed Feb 1, 2024
1 parent b14f25e commit 44ac09a
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 @@ -391,8 +391,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 44ac09a

Please sign in to comment.