From 55318a8f085656e54585661f011ad1d6f9ca7283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20L=C3=B8ve=20Selvik?= Date: Thu, 14 Dec 2017 17:05:41 -0800 Subject: [PATCH] Add interpolated BEAN number for animation use Adds new global variable INTERBEAN, which is a float that is interpolated between BEAN numbers, in a linear way between frames. This can be used to key animations without getting the lower frame rate of BEAN. --- nin/dasBoot/BEATBEAN.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nin/dasBoot/BEATBEAN.js b/nin/dasBoot/BEATBEAN.js index 7656290..dcfc2f1 100644 --- a/nin/dasBoot/BEATBEAN.js +++ b/nin/dasBoot/BEATBEAN.js @@ -26,7 +26,12 @@ const updateBeatBean = function(frame) { ((frame + 0.5) / framesPerBEAT) | 0) { window.BEAT = true; } - window.BEAN = (frame + 1.5) / framesPerBEAT | 0; + var bean = (frame + 1.5) / framesPerBEAT | 0; + window.BEAN = bean; + + var f = (frame - FRAME_FOR_BEAN(bean)) + / (FRAME_FOR_BEAN(bean+1) - FRAME_FOR_BEAN(bean)); + window.INTERBEAN = lerp(bean, bean+1, f); }; module.exports = {initBeatBean, updateBeatBean};