Skip to content

Commit

Permalink
added high delta warning to Matter.Engine
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Aug 14, 2023
1 parent 7ec38a1 commit 72e6e89
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/Engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var Body = require('../body/Body');

(function() {

Engine._deltaMax = 1000 / 60;

/**
* Creates a new engine. The options parameter is an object that specifies any properties you wish to override the defaults.
* All properties have default values, and many are pre-calculated automatically based on other properties.
Expand Down Expand Up @@ -88,6 +90,13 @@ var Body = require('../body/Body');
timestamp = timing.timestamp,
i;

// warn if high delta
if (delta > Engine._deltaMax) {
Common.warnOnce(
'Matter.Engine.update: delta argument is recommended to be less than or equal to', Engine._deltaMax.toFixed(3), 'ms.'
);
}

delta = typeof delta !== 'undefined' ? delta : Common._baseDelta;
delta *= timing.timeScale;

Expand Down

0 comments on commit 72e6e89

Please sign in to comment.