Skip to content

Commit

Permalink
Merge pull request #12641 from Kos/patch-1
Browse files Browse the repository at this point in the history
Docs: clarify requestAnimationFrame speed
  • Loading branch information
mrdoob authored Nov 14, 2017
2 parents 3ca5eeb + 6eccc28 commit dfff0c8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/manual/introduction/Creating-a-scene.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ <h2>Rendering the scene</h2>
animate();
</code>

<div>This will create a loop that causes the renderer to draw the scene 60 times per second. If you're new to writing games in the browser, you might say <em>"why don't we just create a setInterval ?"</em> The thing is - we could, but <strong>requestAnimationFrame</strong> has a number of advantages. Perhaps the most important one is that it pauses when the user navigates to another browser tab, hence not wasting their precious processing power and battery life.</div>
<div>This will create a loop that causes the renderer to draw the scene every time the screen is refreshed (on a typical screen this means 60 times per second). If you're new to writing games in the browser, you might say <em>"why don't we just create a setInterval ?"</em> The thing is - we could, but <strong>requestAnimationFrame</strong> has a number of advantages. Perhaps the most important one is that it pauses when the user navigates to another browser tab, hence not wasting their precious processing power and battery life.</div>

<h2>Animating the cube</h2>

Expand All @@ -113,7 +113,7 @@ <h2>Animating the cube</h2>
cube.rotation.y += 0.1;
</code>

<div>This will be run every frame (60 times per second), and give the cube a nice rotation animation. Basically, anything you want to move or change while the app is running has to go through the animate loop. You can of course call other functions from there, so that you don't end up with a <strong>animate</strong> function that's hundreds of lines.
<div>This will be run every frame (normally 60 times per second), and give the cube a nice rotation animation. Basically, anything you want to move or change while the app is running has to go through the animate loop. You can of course call other functions from there, so that you don't end up with a <strong>animate</strong> function that's hundreds of lines.
</div>

<h2>The result</h2>
Expand Down

0 comments on commit dfff0c8

Please sign in to comment.