Skip to content

Commit 4cb6496

Browse files
committed
updated and corrected text
1 parent f8cfec5 commit 4cb6496

File tree

2 files changed

+21
-73
lines changed

2 files changed

+21
-73
lines changed

src/templates/pages/learn/getting-started-in-webgl-coords-and-transform.hbs

Lines changed: 11 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ slug: learn/
7070
<p>Working in 3D introduces a lot of complexity, especially when a sketch involves motion, texture, lighting, and
7171
more.
7272

73-
Luckily for us computers have special hardware that is particularly
73+
Luckily for us, computers have special hardware that is particularly
7474
well suited to performing those calculations, the graphics processing unit (GPU). The GPU is capable of
7575
processing many
7676
things simultaneously, which is especially important when we're dealing with pixels and many shapes in space.
@@ -193,60 +193,28 @@ slug: learn/
193193
..
194194
</code></pre>
195195

196-
<div class="additionalInformation">
197-
There's a lot more to rotation in 3d space. Check out this resource if you'd like to learn more about
198-
transformation and rotation in 3D:
199-
TODO: FIND LINK TO A RELIABLE RESOURCE
200-
</div>
201-
202196
<h3>scale(): Size in Space</h3>
203197

204198
{{!-- sketch illustrating scaling of geometry --}}
205199
<iframe src="{{assets}}/learn/basic3D/scaleExample.html" width="720" height="350">
206200
</iframe>
207201

208202
<p><a class="code" href="{{root}}/reference/#/p5/scale">scale()</a> changes the size of whatever is
209-
drawn after it. </p>
203+
drawn after it. Like the other methods described so far, it accepts arguments for x, y, and z values.</p>
210204

211205
<h2 id="order">Order</h2>
212206

213207
<p>Something that can feel unpredictable at first is the order of transformations. Each transformation can affect
214-
the next one. For example if you call rotate(), followed by translate(), the direction of that translation will
215-
be affected by the rotation. You can think of it as your entire coordinate system rotating and moving, not just
216-
the object itself.</p>
217-
218-
<p>The order that you use will depend on what you’re trying to do, but a good place to start is to follow the
219-
order of <strong>translate</strong>, <strong>rotate</strong>, and then <strong>scale</strong>. If you perform
220-
these out of order you might find that your
221-
transformations don’t act the way that you expect them to.
208+
the next one. For example, if <a class="code">rotate()</a> is called, followed by <a class="code">translate()</a>, the direction of that translation will
209+
be affected by the rotation. The entire coordinate system is rotating and moving, not just the shape itself.
222210
</p>
223211

212+
<p>Transformations can be performed in any order, but using <strong>translate</strong>, <strong>rotate</strong>, and then <strong>scale</strong> will be the most intuitive.</p>
213+
224214
<p>In the below example, try changing the order of <a class="code">translate()</a> and <a
225215
class="code">rotateY()</a> and see how it affects where the object is
226216
drawn.</p>
227217

228-
{{!--
229-
<pre><code class="language-javascript">
230-
...
231-
//
232-
translate(100,0,0);
233-
rotateZ(QUARTER_PI);
234-
scale(2);
235-
236-
box();
237-
...
238-
239-
...
240-
//
241-
rotateZ(QUARTER_PI);
242-
translate(100,0,0);
243-
244-
scale(2);
245-
246-
box();
247-
...
248-
</code></pre> --}}
249-
250218
<script type="text/p5" data-autoplay data-p5-version="{{ version }}">
251219
function setup() {
252220
createCanvas(150, 216, WEBGL);
@@ -269,10 +237,10 @@ function draw(){
269237
<p>Another tool we have in p5.js is <a class="code" href="{{root}}/reference/#/p5/push">push()</a> and <a
270238
class="code" href="{{root}}/reference/#/p5/pop">pop()</a>. <a class="code">push()</a> and <a
271239
class="code">pop()</a> makes it easier to move objects
272-
individually. <a class="code">push()</a> saves and sets aside our
273-
current transformations (and certain styling, like <a class="code">stroke()</a> or <a class="code">fill()</a>),
274-
which allows you to perform other
275-
transformations. <a class="code">pop()</a> restores those transformations. If you don’t use <a
240+
individually. The <a class="code">push()</a> method saves and sets aside the
241+
current transformations. The <a class="code">pop()</a> method restores those transformations. Whatever transformations that
242+
are made between <a
243+
class="code">push()</a> and <a class="code">pop()</a> will be isolated to that portion of the code. If you don’t use <a
276244
class="code">push()</a> and
277245
<a class="code">pop()</a>, you have to keep track of whatever transformations have already taken place, which
278246
can get complicated
@@ -323,7 +291,7 @@ function draw(){
323291
transformations affect the second object
324292
that is drawn. </p>
325293

326-
{{!-- TODO push and pop example --}}
294+
{{!-- push and pop example --}}
327295
<script type="text/p5" data-autoplay data-p5-version="{{ version }}">
328296
function setup() {
329297
createCanvas(windowWidth, windowHeight, WEBGL);
@@ -343,7 +311,6 @@ function draw(){
343311
}
344312
</script>
345313

346-
{{!-- <h2>3D Primitives: Basic Shapes</h2> --}}
347314
<h2 id="basic_shapes">Basic Shapes in 3D</h2>
348315

349316
<p>So far we have only been using <a class="code">box()</a> but p5.js has seven different predefined geometries
@@ -371,8 +338,6 @@ function draw(){
371338
Geometry tutorial</a>.
372339
</p>
373340

374-
{{!-- TODO create a separate tutorial and link to it from here --}}
375-
376341
<h2 id="glossary">Glossary</h2>
377342

378343
{{!-- <h3>World Space</h3>

src/templates/pages/learn/getting-started-in-webgl-custom-geometry.hbs

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,13 @@ slug: learn/
4545

4646
<h1>Creating Custom Geometry in WebGL</h1>
4747

48-
<p>p5.js has a number of 3D primitives that can be used to create basic shapes, like box() or sphere(), but p5.js
48+
<p>p5.js has a number of 3D primitives that can be used to create basic shapes, like <a class="code">box()</a> or <a class="code">sphere()</a>, but p5.js
4949
is also capable of rendering complex custom geometry, either from files that are created in other 3D software
5050
(like Blender) or from code. This tutorial will walk through how to import 3D models into p5.js, as well as how
5151
to create a basic geometry from scratch. </p>
5252

5353
<div class="additionalInformation">If you are new to 3D it's recommended that you check out the <a
54-
href="{{root}}/learn/getting-started-in-webgl-coords-and-transform.html">Getting Started
55-
With 3D</a> tutorial before continuing with this tutorial. </div>
54+
href="{{root}}/learn/getting-started-in-webgl-coords-and-transform.html">Coordinates and Transformations</a> tutorial before continuing with this tutorial. </div>
5655

5756
<div class="toc">
5857
<h3>Table of Contents</h3>
@@ -67,11 +66,11 @@ slug: learn/
6766

6867
<p>Custom geometry can be imported into p5.js using either OBJ or STL files. These files are usually generated in
6968
a 3D modeling tool like Blender, which offers much more control when constructing a 3D scene. This is done using
70-
the loadModel method, which should be used within preload().</p>
69+
the <a class="code" href="{{root}}/reference/#/p5/loadModel">loadModel()</a> method, which should be used within <a class="code">preload()</a>.</p>
7170

7271
<p>A common issue that can come up with custom models is scaling. Depending on how the model is constructed, it
7372
might be a much different size when rendered in p5.js, or even be too small to be rendered at all. The
74-
loadModel() method includes a normalize parameter that will resize the model to something that works better in
73+
<a class="code">loadModel()</a> method includes a normalize parameter that will resize the model to something that works better in
7574
p5.js.</p>
7675

7776
{{!-- Widget example of teapot model and loadModel --}}
@@ -95,33 +94,19 @@ function draw(){
9594
</script>
9695

9796
<div class="additionalInformation">Note that there is currently no support for STL files with color, although you
98-
can add color using materials or textures, which you can learn about in the (LINKED NAME OF MATERIAL TUTORIAL).
97+
can add color using materials or textures, which you can learn about in the <a href="{{root}}/learn/getting-started-in-webgl-appearance.html">Styling and Appearance</a> tutorial.
9998
</div>
10099

101100
<h2 id="proceduralGeometry">Creating Basic Procedural Geometry</h2>
101+
102102
<p>Geometry can also be defined procedurally using code. This is a great way to create geometry that moves or is
103103
formed using your own set of rules. There are a number of methods that can be used to create 3D geometry in a
104104
way that is similar to 2D drawing in p5.js.</p>
105105

106106

107107
{{!-- Example using triangle and quad --}}
108+
{{!-- PENDING WebGL quad / triangle bug fix --}}
108109
<script type="text/p5" data-autoplay data-p5-version="{{ version }}">
109-
function setup() {
110-
createCanvas(windowWidth, windowHeight, WEBGL);
111-
}
112-
113-
function draw(){
114-
background(255);
115-
//
116-
push(); // detach our coordinate system
117-
// draw a box 100 units to the right
118-
translate(100,0,0);
119-
box();
120-
pop(); // return to our original coordinate system
121-
122-
translate(-100,0,0);
123-
box();
124-
}
125110
</script>
126111

127112
<p>There are also methods that offer greater control of the geometry. A shape can be defined point-by-point using
@@ -160,7 +145,7 @@ function draw(){
160145
}
161146
</script>
162147

163-
<p>There is also a powerful class, p5.Geometry, which p5 uses internally for loadModel() but can also be used to
148+
<p>There is also a powerful class, p5.Geometry, which p5 uses internally for <a class="code">loadModel()</a> but can also be used to
164149
define custom geometry, offering tools that can be helpful in calculating faces and normals. </p>
165150

166151

@@ -170,9 +155,7 @@ var myGeometry
170155
171156
function setup() {
172157
createCanvas(400, 400, WEBGL);
173-
174-
// debugMode()
175-
158+
176159
let detailX = 20;
177160
let detailY = 20;
178161
myGeometry = new p5.Geometry(detailX,detailY, function() {
@@ -201,7 +184,7 @@ function draw() {
201184
202185
orbitControl()
203186
204-
//set a basic light
187+
//set a basic light to see that normals are calculated
205188
pointLight(255,255,0,0,50,-50)
206189
207190
push();

0 commit comments

Comments
 (0)