From 72e6e899a6daa5a4118b8bc9b39db71685959d5d Mon Sep 17 00:00:00 2001 From: liabru Date: Mon, 14 Aug 2023 23:53:22 +0100 Subject: [PATCH] added high delta warning to Matter.Engine --- src/core/Engine.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/Engine.js b/src/core/Engine.js index 91b55ac..bc5ce0a 100644 --- a/src/core/Engine.js +++ b/src/core/Engine.js @@ -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. @@ -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;