diff --git a/examples/webgl_geometry_minecraft.html b/examples/webgl_geometry_minecraft.html index 862d9738acc09be2cc909e062716e8d8a13a3997..84a0440180fbd3af96f17e04f65fa6e4b858d215 100644 --- a/examples/webgl_geometry_minecraft.html +++ b/examples/webgl_geometry_minecraft.html @@ -45,6 +45,7 @@ + @@ -56,6 +57,8 @@ document.getElementById( 'container' ).innerHTML = ""; } + + window.onload = init; var container, stats; @@ -77,10 +80,6 @@ var windowHalfY = window.innerHeight / 2; - init(); - setInterval( loop, 1000 / 60 ); - - function init() { container = document.getElementById( 'container' ); @@ -188,19 +187,11 @@ document.addEventListener( 'keydown', onDocumentKeyDown, false ); document.addEventListener( 'keyup', onDocumentKeyUp, false ); + + loop(); } - function generateAO( image, sides ) { - - var c = document.createElement('canvas'); - c.width = image.width; - c.height = image.height; - c.getContext( "2d" ).drawImage( image, 0, 0 ); - - return c; - - } function loadTexture( path ) { @@ -308,6 +299,8 @@ function loop() { + requestAnimationFrame( loop, renderer.domElement ); + if ( moveForward ) camera.translateZ( - 15 ); if ( moveBackward ) camera.translateZ( 15 ); diff --git a/examples/webgl_geometry_minecraft_ao.html b/examples/webgl_geometry_minecraft_ao.html index e9d0aeae278618430ec48738cc801ea90006a1eb..27c8f077f8710b9c85946bb5ad781f53e7713e15 100644 --- a/examples/webgl_geometry_minecraft_ao.html +++ b/examples/webgl_geometry_minecraft_ao.html @@ -52,6 +52,7 @@ + @@ -64,6 +65,8 @@ } + window.onload = init; + var fogExp2 = true; var container, stats; @@ -86,10 +89,6 @@ var windowHalfY = window.innerHeight / 2; - init(); - setInterval( loop, 1000 / 60 ); - - function init() { container = document.getElementById( 'container' ); @@ -487,6 +486,8 @@ document.getElementById( "bao" ).addEventListener( "click", function() { mat.map = m_ao.map; }, false ); document.getElementById( "baot" ).addEventListener( "click", function() { mat.map = m_aot.map; }, false ); document.getElementById( "bt" ).addEventListener( "click", function() { mat.map = m_t.map; }, false ); + + loop(); } @@ -880,6 +881,8 @@ } function loop() { + + requestAnimationFrame( loop, renderer.domElement ); if ( moveForward ) camera.translateZ( - 15 ); if ( moveBackward ) camera.translateZ( 15 ); diff --git a/examples/webgl_lines_colors.html b/examples/webgl_lines_colors.html index b4706efd7cc64f5989f7e08068d2169ca08dfe3d..dc25b2c47a5a576d3f7921d2bc958d7423183414 100644 --- a/examples/webgl_lines_colors.html +++ b/examples/webgl_lines_colors.html @@ -50,6 +50,8 @@ if ( ! THREE.Detector.webgl ) THREE.Detector.addGetWebGLMessage(); + window.onload = init; + var mouseX = 0, mouseY = 0, windowHalfX = window.innerWidth / 2, @@ -63,8 +65,6 @@ var cameraOrtho, sceneScreen, rtTexture1, rtTexture2, rtTexture3, materialScreen, materialConvolution, blurx, blury, quadScreen; - init(); - setInterval( loop, 1000 / 60 ); function init() { @@ -197,6 +197,8 @@ document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false ); + loop(); + } // port of Processing Java code by Thomas Diewald @@ -274,6 +276,8 @@ // function loop() { + + requestAnimationFrame( loop, renderer.domElement ); camera.position.x += ( mouseX - camera.position.x ) * .05; camera.position.y += ( - mouseY + 200 - camera.position.y ) * .05; diff --git a/examples/webgl_lines_cubes.html b/examples/webgl_lines_cubes.html index 7dd1d3d80b232010646f7b32564e0aba1e75f94a..2c1c903a983792e3dcd784a625b0580e31bb60b0 100644 --- a/examples/webgl_lines_cubes.html +++ b/examples/webgl_lines_cubes.html @@ -50,6 +50,8 @@ if ( ! THREE.Detector.webgl ) THREE.Detector.addGetWebGLMessage(); + window.onload = init; + var mouseX = 0, mouseY = 0, windowHalfX = window.innerWidth / 2, @@ -59,9 +61,6 @@ stats; - init(); - setInterval( loop, 1000 / 60 ); - function init() { var i, material, container; @@ -125,6 +124,9 @@ document.addEventListener( 'mousemove', onDocumentMouseMove, false ); document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false ); + + loop(); + } // port of Processing Java code by Thomas Diewald @@ -203,6 +205,8 @@ function loop() { + requestAnimationFrame( loop, renderer.domElement ); + camera.position.x += ( mouseX - camera.position.x ) * .05; camera.position.y += ( - mouseY + 200 - camera.position.y ) * .05; camera.updateMatrix(); diff --git a/examples/webgl_lines_sphere.html b/examples/webgl_lines_sphere.html index ebb2c6788c5f81de4b871edb17ce83302020bb30..d9651e1b68f6f83a58a474b07ab8a8103bcd7510 100644 --- a/examples/webgl_lines_sphere.html +++ b/examples/webgl_lines_sphere.html @@ -49,6 +49,8 @@ if ( ! THREE.Detector.webgl ) THREE.Detector.addGetWebGLMessage(); + window.onload = init; + var SCREEN_WIDTH = window.innerWidth, SCREEN_HEIGHT = window.innerHeight, @@ -63,9 +65,6 @@ stats; - init(); - setInterval( loop, 1000 / 60 ); - function init() { var container; @@ -129,6 +128,8 @@ document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false ); + loop(); + } function onDocumentMouseMove(event) { @@ -166,6 +167,8 @@ function loop() { + requestAnimationFrame( loop, renderer.domElement ); + //camera.position.x += ( mouseX - camera.position.x ) * .05; camera.position.y += ( - mouseY + 200 - camera.position.y ) * .05; camera.updateMatrix();