From 7e52e1ec0844399197c4940b4c18c0a61177bf59 Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Thu, 21 May 2015 16:59:17 +0200 Subject: [PATCH] Ok --- static/js/Logger.js | 11 ++++++----- static/js/PointerCamera.js | 2 +- static/js/ReplayCamera.js | 17 +++++++++++++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/static/js/Logger.js b/static/js/Logger.js index 7f847db..44e5cc3 100644 --- a/static/js/Logger.js +++ b/static/js/Logger.js @@ -9,11 +9,12 @@ BD.Private.sendData = function(url, data) { xhr.open("POST", url, true); xhr.setRequestHeader("Content-type", "application/json;charset=UTF-8"); - xhr.onreadystatechange = function() { - if(xhr.readyState == 4 && xhr.status == 200) { - console.log(xhr.responseText); - } - } + // xhr.onreadystatechange = function() { + // if(xhr.readyState == 4 && xhr.status == 200) { + // console.log(xhr.responseText); + // } + // } + xhr.send(JSON.stringify(data)); } diff --git a/static/js/PointerCamera.js b/static/js/PointerCamera.js index f3e9620..dd9b277 100644 --- a/static/js/PointerCamera.js +++ b/static/js/PointerCamera.js @@ -92,7 +92,7 @@ PointerCamera.prototype.hermiteMotion = function(time) { this.target = Tools.sum(this.position, this.hermiteAngles.eval(this.t)); this.t += 0.01 * time / 20; - +fayt if (this.t > 1) { this.movingHermite = false; this.anglesFromVectors(); diff --git a/static/js/ReplayCamera.js b/static/js/ReplayCamera.js index 7052d48..5653959 100644 --- a/static/js/ReplayCamera.js +++ b/static/js/ReplayCamera.js @@ -44,7 +44,7 @@ ReplayCamera.prototype.look = function() { ReplayCamera.prototype.update = function(time) { if (this.started) { if (this.event.type == 'camera') { - this.linearMotion(time); + this.cameraMotion(time); } else if (this.event.type == 'previousnext') { this.linearMotion(time / 5); } else if (this.event.type == 'arrow') { @@ -62,7 +62,6 @@ ReplayCamera.prototype.linearMotion = function(time) { this.position.x = tmp.x; this.position.y = tmp.y; this.position.z = tmp.z; - this.target = Tools.sum(Tools.mul(this.old_target, 1-this.t), Tools.mul(this.new_target, this.t)); this.t += 0.1 * time / 20; if (this.t > 1) { @@ -70,6 +69,20 @@ ReplayCamera.prototype.linearMotion = function(time) { } } +ReplayCamera.prototype.cameraMotion = function(time) { + + var tmp = Tools.sum(Tools.mul(this.old_position, 1-this.t), Tools.mul(this.new_position, this.t)); + this.position.x = tmp.x; + this.position.y = tmp.y; + this.position.z = tmp.z; + this.target = Tools.sum(Tools.mul(this.old_target, 1-this.t), Tools.mul(this.new_target, this.t)); + this.t += 1 / (((new Date(this.path[this.counter].time)).getTime() - (new Date(this.path[this.counter-1].time)).getTime()) / 20); + + if (this.t > 1) { + this.nextEvent(); + } +} + ReplayCamera.prototype.hermiteMotion = function(time) { var eval = this.hermitePosition.eval(this.t); this.position.x = eval.x;