From 251625624088ab6af6db03f29334ef845dbc3359 Mon Sep 17 00:00:00 2001 From: Matt Braddock Date: Tue, 1 Jan 2019 13:33:51 -0500 Subject: fixed frame timing from debug info --- main.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'main.js') diff --git a/main.js b/main.js index 66e1e10..1deac10 100644 --- a/main.js +++ b/main.js @@ -8,8 +8,10 @@ function compute() { let seconds = 0; let milliseconds = 0; let frameRate = parseInt(framerate); - let diff = (endObj.lct - startObj.lct) * frameRate; - let frames = diff; + let frameFromObj = (time, fps) => Math.floor(time * fps) / fps; //round to the nearest frame + let startFrame = frameFromObj(startObj.lct, frameRate); + let endFrame = frameFromObj(endObj.lct, frameRate); + let frames = (endFrame - startFrame) * frameRate; if (frames >= frameRate) { seconds = Math.floor(frames / frameRate); frames = frames % frameRate; -- cgit v1.2.3