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);