From be99ba00e6b77544eebc5e7181c424af61d9142f Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Mon, 15 Jun 2015 08:45:42 +0200 Subject: [PATCH] Corrected bugs of time in old files Provoked by the fact that Camera.update needs a time --- js/bouncing/BouncingMain.js | 5 ++++- js/multisphere/MultiSphere.js | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/js/bouncing/BouncingMain.js b/js/bouncing/BouncingMain.js index 1cae98b..6ec5a02 100644 --- a/js/bouncing/BouncingMain.js +++ b/js/bouncing/BouncingMain.js @@ -2,6 +2,7 @@ var renderer, scene, camera, controls, cube, container, plane, mouse= {x:0, y:0} var raycaster; var objects = []; var container_size = new Object(); +var previousTime; container_size.width = 1067; container_size.height = 600; @@ -57,7 +58,9 @@ function animate() { cube.update(); - camera.update(); + var currentTime = Date.now() - previousTime; + camera.update(isNaN(currentTime) ? 20 : currentTime); + previousTime = Date.now(); camera.look(); renderer.render(scene, camera); diff --git a/js/multisphere/MultiSphere.js b/js/multisphere/MultiSphere.js index 4e3c2c1..3c09d73 100644 --- a/js/multisphere/MultiSphere.js +++ b/js/multisphere/MultiSphere.js @@ -5,7 +5,7 @@ var objects = []; var spheres = new Array(mesh_number); var visible = 0; -var loader; +var loader, previousTime; var container_size = new Object(); container_size.width = 1067; @@ -79,7 +79,10 @@ function animate() { // on appelle la fonction animate() récursivement à chaque frame requestAnimationFrame(animate); - camera.update(); + var currentTime = Date.now() - previousTime; + camera.update(isNaN(currentTime) ? 20 : currentTime); + previousTime = Date.now(); + camera.look(); renderer.render(scene, camera);