Skip to content

Commit 0992e6b

Browse files
committed
Docs: Set max linewidth to ~100chars.
1 parent e4c51a3 commit 0992e6b

File tree

2 files changed

+32
-26
lines changed

2 files changed

+32
-26
lines changed

docs/manual/introduction/Creating-a-scene.html

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
<body>
1111
<h1>[name]</h1><br />
1212

13-
<div>The goal of this section is to give a brief introduction to three.js. We will start by setting up a scene, with a spinning cube. A working example is provided at the bottom of the page in case you get stuck and need help.</div>
13+
<p>The goal of this section is to give a brief introduction to three.js. We will start by setting up a scene, with a spinning cube. A working example is provided at the bottom of the page in case you get stuck and need help.</p>
1414

1515
<h2>Before we start</h2>
1616

17-
<div>Before you can use three.js, you need somewhere to display it. Save the following HTML to a file on your computer, along with a copy of <a href="http://threejs.org/build/three.js">three.js</a> in the js/ directory, and open it in your browser.</div>
17+
<p>Before you can use three.js, you need somewhere to display it. Save the following HTML to a file on your computer, along with a copy of <a href="http://threejs.org/build/three.js">three.js</a> in the js/ directory, and open it in your browser.</p>
1818

1919
<code>
2020
&lt;!DOCTYPE html&gt;
@@ -36,11 +36,11 @@ <h2>Before we start</h2>
3636
&lt;/html&gt;
3737
</code>
3838

39-
<div>That's all. All the code below goes into the empty &lt;script&gt; tag.</div>
39+
<p>That's all. All the code below goes into the empty &lt;script&gt; tag.</p>
4040

4141
<h2>Creating the scene</h2>
4242

43-
<div>To actually be able to display anything with three.js, we need three things: scene, camera and renderer, so that we can render the scene with camera.</div>
43+
<p>To actually be able to display anything with three.js, we need three things: scene, camera and renderer, so that we can render the scene with camera.</p>
4444

4545
<code>
4646
var scene = new THREE.Scene();
@@ -51,25 +51,25 @@ <h2>Creating the scene</h2>
5151
document.body.appendChild( renderer.domElement );
5252
</code>
5353

54-
<div>Let's take a moment to explain what's going on here. We have now set up the scene, our camera and the renderer.</div>
54+
<p>Let's take a moment to explain what's going on here. We have now set up the scene, our camera and the renderer.</p>
5555

56-
<div>There are a few different cameras in three.js. For now, let's use a <strong>PerspectiveCamera</strong>.</div>
56+
<p>There are a few different cameras in three.js. For now, let's use a <strong>PerspectiveCamera</strong>.</p>
5757

58-
<div>The first attribute is the <strong>field of view</strong>. FOV is the extent of the scene that is seen on the display at any given moment. The value is in degrees.</div>
58+
<p>The first attribute is the <strong>field of view</strong>. FOV is the extent of the scene that is seen on the display at any given moment. The value is in degrees.</p>
5959

60-
<div>The second one is the <strong>aspect ratio</strong>. You almost always want to use the width of the element divided by the height, or you'll get the same result as when you play old movies on a widescreen TV - the image looks squished.</div>
60+
<p>The second one is the <strong>aspect ratio</strong>. You almost always want to use the width of the element divided by the height, or you'll get the same result as when you play old movies on a widescreen TV - the image looks squished.</p>
6161

62-
<div>The next two attributes are the <strong>near</strong> and <strong>far</strong> clipping plane. What that means, is that objects further away from the camera than the value of <strong>far</strong> or closer than <strong>near</strong> won't be rendered. You don't have to worry about this now, but you may want to use other values in your apps to get better performance.</div>
62+
<p>The next two attributes are the <strong>near</strong> and <strong>far</strong> clipping plane. What that means, is that objects further away from the camera than the value of <strong>far</strong> or closer than <strong>near</strong> won't be rendered. You don't have to worry about this now, but you may want to use other values in your apps to get better performance.</p>
6363

64-
<div>Next up is the renderer. This is where the magic happens. In addition to the WebGLRenderer we use here, three.js comes with a few others, often used as fallbacks for users with older browsers or for those who don't have WebGL support for some reason.</div>
64+
<p>Next up is the renderer. This is where the magic happens. In addition to the WebGLRenderer we use here, three.js comes with a few others, often used as fallbacks for users with older browsers or for those who don't have WebGL support for some reason.</p>
6565

66-
<div>In addition to creating the renderer instance, we also need to set the size at which we want it to render our app. It's a good idea to use the width and height of the area we want to fill with our app - in this case, the width and height of the browser window. For performance intensive apps, you can also give <strong>setSize</strong> smaller values, like <strong>window.innerWidth/2</strong> and <strong>window.innerHeight/2</strong>, which will make the app render at half size.</div>
66+
<p>In addition to creating the renderer instance, we also need to set the size at which we want it to render our app. It's a good idea to use the width and height of the area we want to fill with our app - in this case, the width and height of the browser window. For performance intensive apps, you can also give <strong>setSize</strong> smaller values, like <strong>window.innerWidth/2</strong> and <strong>window.innerHeight/2</strong>, which will make the app render at half size.</p>
6767

68-
<div>If you wish to keep the size of your app but render it at a lower resolution, you can do so by calling <strong>setSize</strong> with false as <strong>updateStyle</strong> (the third argument). For example, <strong>setSize(window.innerWidth/2, window.innerHeight/2, false)</strong> will render your app at half resolution, given that your &lt;canvas&gt; has 100% width and height.</div>
68+
<p>If you wish to keep the size of your app but render it at a lower resolution, you can do so by calling <strong>setSize</strong> with false as <strong>updateStyle</strong> (the third argument). For example, <strong>setSize(window.innerWidth/2, window.innerHeight/2, false)</strong> will render your app at half resolution, given that your &lt;canvas&gt; has 100% width and height.</p>
6969

70-
<div>Last but not least, we add the <strong>renderer</strong> element to our HTML document. This is a &lt;canvas&gt; element the renderer uses to display the scene to us.</div>
70+
<p>Last but not least, we add the <strong>renderer</strong> element to our HTML document. This is a &lt;canvas&gt; element the renderer uses to display the scene to us.</p>
7171

72-
<div><em>"That's all good, but where's that cube you promised?"</em> Let's add it now.</div>
72+
<p><em>"That's all good, but where's that cube you promised?"</em> Let's add it now.</p>
7373

7474
<code>
7575
var geometry = new THREE.BoxGeometry( 1, 1, 1 );
@@ -80,17 +80,17 @@ <h2>Creating the scene</h2>
8080
camera.position.z = 5;
8181
</code>
8282

83-
<div>To create a cube, we need a <strong>BoxGeometry</strong>. This is an object that contains all the points (<strong>vertices</strong>) and fill (<strong>faces</strong>) of the cube. We'll explore this more in the future.</div>
83+
<p>To create a cube, we need a <strong>BoxGeometry</strong>. This is an object that contains all the points (<strong>vertices</strong>) and fill (<strong>faces</strong>) of the cube. We'll explore this more in the future.</p>
8484

85-
<div>In addition to the geometry, we need a material to color it. Three.js comes with several materials, but we'll stick to the <strong>MeshBasicMaterial</strong> for now. All materials take an object of properties which will be applied to them. To keep things very simple, we only supply a color attribute of <strong>0x00ff00</strong>, which is green. This works the same way that colors work in CSS or Photoshop (<strong>hex colors</strong>).</div>
85+
<p>In addition to the geometry, we need a material to color it. Three.js comes with several materials, but we'll stick to the <strong>MeshBasicMaterial</strong> for now. All materials take an object of properties which will be applied to them. To keep things very simple, we only supply a color attribute of <strong>0x00ff00</strong>, which is green. This works the same way that colors work in CSS or Photoshop (<strong>hex colors</strong>).</p>
8686

87-
<div>The third thing we need is a <strong>Mesh</strong>. A mesh is an object that takes a geometry, and applies a material to it, which we then can insert to our scene, and move freely around.</div>
87+
<p>The third thing we need is a <strong>Mesh</strong>. A mesh is an object that takes a geometry, and applies a material to it, which we then can insert to our scene, and move freely around.</p>
8888

89-
<div>By default, when we call <strong>scene.add()</strong>, the thing we add will be added to the coordinates <strong>(0,0,0)</strong>. This would cause both the camera and the cube to be inside each other. To avoid this, we simply move the camera out a bit.</div>
89+
<p>By default, when we call <strong>scene.add()</strong>, the thing we add will be added to the coordinates <strong>(0,0,0)</strong>. This would cause both the camera and the cube to be inside each other. To avoid this, we simply move the camera out a bit.</p>
9090

9191
<h2>Rendering the scene</h2>
9292

93-
<div>If you copied the code from above into the HTML file we created earlier, you wouldn't be able to see anything. This is because we're not actually rendering anything yet. For that, we need what's called a <strong>render or animate loop</strong>.</div>
93+
<p>If you copied the code from above into the HTML file we created earlier, you wouldn't be able to see anything. This is because we're not actually rendering anything yet. For that, we need what's called a <strong>render or animate loop</strong>.</p>
9494

9595
<code>
9696
function animate() {
@@ -100,26 +100,26 @@ <h2>Rendering the scene</h2>
100100
animate();
101101
</code>
102102

103-
<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>
103+
<p>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.</p>
104104

105105
<h2>Animating the cube</h2>
106106

107-
<div>If you insert all the code above into the file you created before we began, you should see a green box. Let's make it all a little more interesting by rotating it.</div>
107+
<p>If you insert all the code above into the file you created before we began, you should see a green box. Let's make it all a little more interesting by rotating it.</p>
108108

109-
<div>Add the following right above the <strong>renderer.render</strong> call in your <strong>animate</strong> function:</div>
109+
<p>Add the following right above the <strong>renderer.render</strong> call in your <strong>animate</strong> function:</p>
110110

111111
<code>
112112
cube.rotation.x += 0.1;
113113
cube.rotation.y += 0.1;
114114
</code>
115115

116-
<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.
116+
<p>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 p.
117117
</div>
118118

119119
<h2>The result</h2>
120-
<div>Congratulations! You have now completed your first three.js application. It's simple, you have to start somewhere.</div>
120+
<p>Congratulations! You have now completed your first three.js application. It's simple, you have to start somewhere.</p>
121121

122-
<div>The full code is available below. Play around with it to get a better understanding of how it works.</div>
122+
<p>The full code is available below. Play around with it to get a better understanding of how it works.</p>
123123

124124
<code>
125125
&lt;html&gt;

docs/page.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ h3 {
4545
margin-top: 40px;
4646
}
4747

48+
p {
49+
margin-top: 0;
50+
margin-bottom: 20px;
51+
max-width: 780px;
52+
}
53+
4854
div {
4955
/* padding-left: 30px; */
5056
margin-bottom: 20px;
@@ -123,4 +129,4 @@ span.param {
123129

124130
a.param:hover {
125131
color: #777;
126-
}
132+
}

0 commit comments

Comments
 (0)