From e55e17a76219bbdf649362e59a94124cfa29310f Mon Sep 17 00:00:00 2001 From: Micho Date: Sun, 19 May 2013 09:56:40 +0200 Subject: [PATCH] interpolate between intervals --- clients/anim/main.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/clients/anim/main.js b/clients/anim/main.js index 56eba8a..3060b53 100644 --- a/clients/anim/main.js +++ b/clients/anim/main.js @@ -111,10 +111,20 @@ function updateData() { }) data.matrix.forEach(function (times, index) { - var timeId = time2index[Math.floor(currentTime + 15*random[index])]; + var timeId = time2index[Math.floor(currentTime)]; var point = undefined; - if (isFinite(times[timeId])) point = times[timeId]; + + var t0 = data.times[timeId]; if (isNaN(t0)) t0 = 0; + var t1 = data.times[timeId+1]; if (isNaN(t1)) t1 = 1e10; + + var offset = (currentTime-t0)/(t1-t0); + + if (offset < random[index]) { + point = times[timeId-1]; + } else { + point = times[timeId]; + } var client = clients[index]; if (client.point != point) {