Skip to content

Commit fb257e0

Browse files
committed
edit docs
1 parent 8443047 commit fb257e0

File tree

4 files changed

+32
-20
lines changed

4 files changed

+32
-20
lines changed

glutil-mesh.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,12 @@ Mesh._recalcNormalsLines=function(vertices,faces,stride,offset,flat,inward){
199199
* Future vertices will be drawn as primitives of the new type.
200200
* The primitive type can be set to the same mode, in which
201201
* case future vertices given will not build upon previous
202-
* vertices.
202+
* vertices.<p>
203+
* Note that a Mesh object can contain primitives of different
204+
* types, such as triangles and lines. For example, it's allowed
205+
* to have a mesh with triangles, then call this method, say,
206+
* with <code>Mesh.LINE_STRIP</code> to add line segments
207+
* to that mesh.
203208
* @param {number} m A primitive type. One of the following:
204209
* Mesh.TRIANGLES, Mesh.LINES, Mesh.LINE_STRIP, Mesh.TRIANGLE_STRIP,
205210
* Mesh.TRIANGLE_FAN, Mesh.QUADS, Mesh.QUAD_STRIP.

glutil_min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

surfaces.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
}
3838
}
3939

40-
4140
var RevolutionSurface=function(func,minval,maxval){
4241
this.func=func
4342
this.minval=minval
@@ -51,7 +50,6 @@
5150
}
5251
}
5352

54-
5553
var KleinBottle=function(){
5654
this.evaluate=function(u,v){
5755
u*=Math.PI*2;
@@ -94,8 +92,6 @@
9492
}
9593
}
9694

97-
98-
9995
var ColorGradient={
10096
evaluate:function(u,v){
10197
return [1-u,v,u];

tutorials/shapes.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ the built-in shapes.
1515
* [platonic.html](https://peteroupc.github.io/html3dutil/platonic.html) - A demo featuring the five
1616
platonic solids. Demonstrates how vertex and index arrays are built up to create geometric meshes.
1717

18-
Here are the methods for creating built-in shapes. All methods described
19-
below return a `Mesh` object that describes the triangles they
18+
### Built-In Shapes
19+
20+
The `Meshes` class includes several handy methods for creating built-in shapes.
21+
All methods described below return a `Mesh` object that describes the triangles they
2022
are composed of. See "Custom Shapes" below for more on meshes.
2123

22-
### 3D Figures
24+
**3D Figures:**
2325

2426
* [Meshes.createBox()]{@link glutil.Meshes.createBox} - Creates a cube or box.
2527
* [Meshes.createCylinder()]{@link glutil.Meshes.createCylinder} - Creates a cylinder or cone, not including the base
@@ -28,7 +30,7 @@ are composed of. See "Custom Shapes" below for more on meshes.
2830
* [Meshes.createTorus()]{@link glutil.Meshes.createTorus} - Creates a torus (doughnut shape).
2931
* [Meshes.createSphere()]{@link glutil.Meshes.createSphere} - Creates a sphere.
3032

31-
### 2D Figures
33+
**2D Figures:**
3234

3335
* [Meshes.createDisk()]{@link glutil.Meshes.createDisk} - Creates a circular disk or a regular polygon, possibly
3436
with a hole in the middle.
@@ -39,7 +41,7 @@ are composed of. See "Custom Shapes" below for more on meshes.
3941
### Custom Shapes
4042

4143
Also included is a `Mesh` class for defining shapes not given among the built-in ones.
42-
Shapes can consist of triangles or lines.
44+
Shapes can consist of triangles, lines of points.
4345

4446
There are two ways for specifying shapes: through the Mesh constructor, or through
4547
methods that specify the mesh's data vertex by vertex.
@@ -176,10 +178,19 @@ Example:
176178
### Normals
177179

178180
For lighting and shading to work correctly, you must specify normals for all the
179-
vertices in the mesh. After generating a mesh, you can use the recalcNormals()
180-
method, described below, to help in this.
181+
vertices in the mesh.
182+
183+
#### What Are Normals?
184+
185+
A surface normal vector is generally perpendicular to a surface's edges, and points
186+
away from the surface. When light hits an object's surface, it will shine depending
187+
on how directly the light points to the surface. It will shine the most if the light
188+
is directly opposite to its normal, and not at all if the light is perpendicular to the
189+
normal or in the same direction as the normal.
190+
191+
#### Normals on Built-in Shapes
181192

182-
Note that the built-in methods that generate meshes will automatically
193+
The `Meshes` class includes built-in methods that will automatically
183194
specify the proper normals.
184195

185196
#### recalcNormals()
@@ -245,8 +256,8 @@ Examples for setting position:
245256
// rotate the shape 40 units about X axis, 20 units about Y axis,
246257
// and 50 units about Z axis
247258
shape.setQuaternion(GLMath.quatFromEuler(40,20,50));
248-
// rotate the shape 20 units about X axis and Y axis
249-
shape.setQuaternion(GLMath.quatFromAxisAngle(20,1,1,0));
259+
// rotate the shape 20 units about Y axis
260+
shape.setQuaternion(GLMath.quatFromAxisAngle(20,0,1,0));
250261
// scale the shape by 2x in all axes
251262
shape.setScale(2,2,2);
252263
// same, but passing an array

0 commit comments

Comments
 (0)