From 5d75d771f8b2166e2e276c62476a5587aac5dd00 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 24 Jan 2023 13:43:15 +0000 Subject: [PATCH] Wrap shouldn't adjust a value already in the range --- src/math/Wrap.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/math/Wrap.js b/src/math/Wrap.js index b4e01e9d0..465231d6b 100644 --- a/src/math/Wrap.js +++ b/src/math/Wrap.js @@ -18,6 +18,12 @@ */ var Wrap = function (value, min, max) { + if (value >= min && value <= max) + { + // Skip modulo if already in range + return value; + } + var range = max - min; return (min + ((((value - min) % range) + range) % range));