From f934a4f86c9a108c9a7906a093eece5cce67d354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Fri, 23 Jul 2021 15:17:31 +0300 Subject: [PATCH] delta<1 --- 340.слежение.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/340.слежение.js b/340.слежение.js index 24f78ee..5bab23f 100644 --- a/340.слежение.js +++ b/340.слежение.js @@ -118,6 +118,11 @@ } // Плавно. function lerp(v0, v1, t) { + // Убираем мельтешение. + var delta = Math.abs(v0 - v1); + if (delta < 1) { + return v0; + } return v0 * (1 - t) + v1 * t; } var x = lerp(x0, x1, скорость);