Skip to content

Commit d31fab9

Browse files
committed
add contents to each tutorial
1 parent 1e1f5e3 commit d31fab9

File tree

8 files changed

+112
-138
lines changed

8 files changed

+112
-138
lines changed

demos/demoutil.js

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -79,58 +79,6 @@ function setRanges(ranges){
7979
}
8080
}
8181

82-
if(!BSplineCurve.uniform){
83-
BSplineCurve.clamped=function(controlPoints,degree,flags){
84-
return new BSplineCurve(controlPoints,
85-
BSplineCurve.clampedKnots(controlPoints.length,degree),flags)
86-
}
87-
BSplineCurve.uniform=function(controlPoints,degree,flags){
88-
return new BSplineCurve(controlPoints,
89-
BSplineCurve.uniformKnots(controlPoints.length,degree),flags)
90-
}
91-
BSplineSurface.clamped=function(controlPoints,degreeU,degreeV,flags){
92-
return new BSplineSurface(controlPoints,
93-
BSplineCurve.clampedKnots(controlPoints[0].length,degreeU),
94-
BSplineCurve.clampedKnots(controlPoints.length,degreeV),flags)
95-
}
96-
BSplineSurface.uniform=function(controlPoints,degreeU,degreeV,flags){
97-
return new BSplineSurface(controlPoints,
98-
BSplineCurve.uniformKnots(controlPoints[0].length,degreeU),
99-
BSplineCurve.uniformKnots(controlPoints.length,degreeV),flags)
100-
}
101-
BSplineCurve.uniformKnots=function(controlPoints,degree){
102-
if(typeof controlPoints=="object")
103-
controlPoints=controlPoints.length;
104-
if(controlPoints<degree+1)
105-
throw new Error("too few control points for degree "+degree+" curve")
106-
var order=degree+1;
107-
var ret=[]
108-
for(var i=0;i<controlPoints+order;i++){
109-
ret.push(i)
110-
}
111-
return ret;
112-
}
113-
BSplineCurve.clampedKnots=function(controlPoints,degree){
114-
if(typeof controlPoints=="object")
115-
controlPoints=controlPoints.length;
116-
if(controlPoints<degree+1)
117-
throw new Error("too few control points for degree "+degree+" curve")
118-
var order=degree+1;
119-
var extras=controlPoints-degree;
120-
var ret=[];
121-
for(var i=0;i<order;i++){
122-
ret.push(0)
123-
}
124-
for(var i=0;i<extras;i++){
125-
ret.push(i+1);
126-
}
127-
for(var i=0;i<order;i++){
128-
ret.push(extras+1);
129-
}
130-
return ret;
131-
}
132-
}
133-
13482
function saveString(string,type,filename){
13583
extension=".txt"
13684
type=type||"text/plain"
@@ -166,7 +114,12 @@ function updateShape(func){
166114
settings.appendChild(div)
167115
}
168116
}
169-
shapeGroup.removeShape(shapeGroup.shapes[0]);
117+
if(!shapeGroup.removeShape){
118+
// For compatibility with version 1.3.1
119+
shapeGroup.shapes.length=0;
120+
} else {
121+
shapeGroup.removeShape(shapeGroup.shapes[0]);
122+
}
170123
shapeGroup.addShape(scene.makeShape(func(allsettings)).setMaterial(
171124
new Material().setParams({
172125
"diffuse":"black",

tutorials/camera.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
## Introduction
1+
## Introduction <a id=Introduction></a>
22

33
This tip describes projection and view transforms commonly used in 3D graphics,
44
especially when using my [HTML 3D Library](http://peteroupc.github.io/html3dutil).
55

66
**Download the latest version of the library at the [HTML 3D Library's Releases page](https://github.com/peteroupc/html3dutil/releases).**
7+
## Contents <a id=Contents></a>
78

8-
## The "Camera" and the Projection and View Transforms
9+
[Introduction](#Introduction)<br>[Contents](#Contents)<br>[The "Camera" and the Projection and View Transforms](#The_Camera_and_the_Projection_and_View_Transforms)<br>&nbsp;&nbsp;[Overview of Transformations](#Overview_of_Transformations)<br>[Projection Transform](#Projection_Transform)<br>&nbsp;&nbsp;[Perspective Projection](#Perspective_Projection)<br>&nbsp;&nbsp;&nbsp;&nbsp;[Demo](#Demo)<br>&nbsp;&nbsp;[Orthographic Projection](#Orthographic_Projection)<br>&nbsp;&nbsp;[Other Projections](#Other_Projections)<br>[View Transform](#View_Transform)<br>[Other Pages](#Other_Pages)<br>
10+
11+
## The "Camera" and the Projection and View Transforms <a id=The_Camera_and_the_Projection_and_View_Transforms></a>
912

1013
The [`Scene3D`](http://peteroupc.github.io/html3dutil/glutil.Scene3D.html) class of the HTML 3D Library has a concept of a "projection transform" and a "view transform". If we use the concept of a "camera", the projection is like setting the camera's focus and lens, and the view transform is like setting its position and orientation. `Scene3D` has methods for setting all these attributes of this abstract "camera". Two of them are [`setPerspective()`](http://peteroupc.github.io/html3dutil/glutil.Scene3D.html#.setPerspective) and [`setLookAt()`](http://peteroupc.github.io/html3dutil/glutil.Scene3D.html#.setLookAt), which are shown in the example below.
1114

@@ -18,7 +21,7 @@ The [`Scene3D`](http://peteroupc.github.io/html3dutil/glutil.Scene3D.html) class
1821
// points at (0, 2, 0), that is, up 2 units.
1922
scene.setLookAt([0,0,30], [0,2,0]);
2023

21-
### Overview of Transformations
24+
### Overview of Transformations <a id=Overview_of_Transformations></a>
2225

2326
Here is an overview of transformations used in the graphics system and
2427
the HTML 3D library.
@@ -32,14 +35,14 @@ is not discussed in this page.
3235
clip space coordinates to _normalized device coordinates_, then _screen space_
3336
coordinates when drawing objects on the screen.
3437

35-
## Projection Transform
38+
## Projection Transform <a id=Projection_Transform></a>
3639

3740
A _projection matrix_ transforms coordinates in camera space to _clip space_.
3841

3942
Two commonly used projections in 3D graphics are the perspective projection and
4043
orthographic projection, described below.
4144

42-
### Perspective Projection
45+
### Perspective Projection <a id=Perspective_Projection></a>
4346

4447
A perspective projection gives the 3D scene a sense of depth. In this projection, closer objects
4548
look bigger than more distant objects with the same size, making the
@@ -97,11 +100,11 @@ bound the view volume. Their positions are chosen so that the result is a persp
97100
of where they meet the near clipping plane.
98101
* `near`, `far` - Distance from the camera to the near and far clipping planes.
99102

100-
#### Demo
103+
#### Demo <a id=Demo></a>
101104

102105
* [perspective.html](https://peteroupc.github.io/html3dutil/demos/perspective.html) - Demonstrates a perspective projection.
103106

104-
### Orthographic Projection
107+
### Orthographic Projection <a id=Orthographic_Projection></a>
105108

106109
An orthographic projection is one in which the left and right clipping planes are parallel to each other,
107110
and the top and bottom clipping planes are parallel to each other. This results in the near and far clipping
@@ -132,7 +135,7 @@ or squished in case the view volume's aspect ratio and the scene's aspect ratio
132135
* `aspect` - Aspect ratio of the viewport. May be omitted, in which case the scene's
133136
aspect ratio (`scene.getClientAspect()`) is used.
134137

135-
### Other Projections
138+
### Other Projections <a id=Other_Projections></a>
136139

137140
There are other kinds of possible projections, such as oblique projections
138141
or isometric projections. For these
@@ -146,7 +149,7 @@ This method allows you to set the projection matrix to an arbitrary [4x4 matrix]
146149

147150
* `matrix` - The 4x4 matrix to use.
148151

149-
## View Transform
152+
## View Transform <a id=View_Transform></a>
150153

151154
The view matrix transforms _world space_ coordinates, shared by every object in a scene, to _camera space_
152155
coordinates, in which the camera is located at the center of the coordinate system: (0, 0, 0). A view matrix essentially rotates the camera and moves it to a given position in world space. Specifically:
@@ -178,7 +181,7 @@ This method allows you to set the view matrix to an arbitrary [4x4 matrix]{@tuto
178181

179182
* `matrix` - The 4x4 matrix to use.
180183

181-
## Other Pages
184+
## Other Pages <a id=Other_Pages></a>
182185

183186
The following pages of mine on CodeProject also discuss this library:
184187

tutorials/filters.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
## Introduction
1+
## Introduction <a id=Introduction></a>
22

33
This page describes what graphics filters are and how they work in my
44
public domain [HTML 3D Library](http://peteroupc.github.io/html3dutil).
55
It also describes several examples of graphics filters.
66

77
**Download the latest version of the library at the [HTML 3D Library's Releases page](https://github.com/peteroupc/html3dutil/releases).**
8+
## Contents <a id=Contents></a>
89

9-
## Graphics Filters
10+
[Introduction](#Introduction)<br>[Contents](#Contents)<br>[Graphics Filters](#Graphics_Filters)<br>[Writing Graphics Filters](#Writing_Graphics_Filters)<br>[Using Graphics Filters](#Using_Graphics_Filters)<br>[Examples](#Examples)<br>&nbsp;&nbsp;[Grayscale](#Grayscale)<br>&nbsp;&nbsp;[Invert](#Invert)<br>&nbsp;&nbsp;[Red Tint](#Red_Tint)<br>&nbsp;&nbsp;[Mirror Filter](#Mirror_Filter)<br>&nbsp;&nbsp;[Matrix Filter](#Matrix_Filter)<br>&nbsp;&nbsp;[Pixelate Filter](#Pixelate_Filter)<br>&nbsp;&nbsp;[Wave Filter](#Wave_Filter)<br>&nbsp;&nbsp;[Waterpaint Filter](#Waterpaint_Filter)<br>[Other Pages](#Other_Pages)<br>
11+
12+
## Graphics Filters <a id=Graphics_Filters></a>
1013

1114
In the HTML 3D Library, graphics filters are functions used to modify the appearance
1215
of the screen after each frame. They are implemented in a language called GLSL, or GL
@@ -21,7 +24,7 @@ For graphics filters to work, the 3D scene must be rendered to an off-screen buf
2124
a _frame buffer_. The frame buffer acts like a 3D texture which will be rendered back to
2225
the screen with the help of the graphics filter's shader program.
2326

24-
## Writing Graphics Filters
27+
## Writing Graphics Filters <a id=Writing_Graphics_Filters></a>
2528

2629
In the HTML 3D Library, use the `makeEffect` method of the ShaderProgram class to create
2730
graphics filters:
@@ -73,7 +76,7 @@ A detailed treatment of GLSL is outside the scope of this page. More informatio
7376
be found by searching the Web; note that there are many versions of GLSL and the one used
7477
in HTML applications is relatively basic nowadays. Also see below for more examples of graphics filters.
7578

76-
## Using Graphics Filters
79+
## Using Graphics Filters <a id=Using_Graphics_Filters></a>
7780

7881
After a filter is created, it's very easy to use; it's simply set with the `useFilter` method of Scene3D. After
7982
a filter is set, here's how it works:
@@ -99,7 +102,7 @@ Currently, the HTML 3D Library only supports one filter at a time, so if the HTM
99102
than one effect, say, a grayscale and blur, both effects need to be combined in the same graphics filter
100103
shader.
101104

102-
## Examples
105+
## Examples <a id=Examples></a>
103106

104107
* [squares.html](https://peteroupc.github.io/html3dutil/demos/squares.html) - Demonstrates graphics filters.
105108

@@ -108,13 +111,13 @@ of graphics filters implemented as shaders.
108111

109112
Here are more details on the filters it includes.
110113

111-
### Grayscale
114+
### Grayscale <a id=Grayscale></a>
112115

113116
![Grayscale filtered image](filters1.png)
114117

115118
The grayscale filter, which converts the screen to black and white, was already given above.
116119

117-
### Invert
120+
### Invert <a id=Invert></a>
118121

119122
![Invert filtered image](filters2.png)
120123

@@ -132,7 +135,7 @@ This filter is implemented in the method `ShaderProgram.getInvertEffect()`:
132135
"}"].join("\n"));
133136
}
134137

135-
### Red Tint
138+
### Red Tint <a id=Red_Tint></a>
136139

137140
![Red Tint filtered image](filters9.png)
138141

@@ -146,7 +149,7 @@ The red tint filter adds a hint of red to the image.
146149
"}"].join("\n"));
147150
}
148151

149-
### Mirror Filter
152+
### Mirror Filter <a id=Mirror_Filter></a>
150153

151154
![Mirror filtered image](filters7.png)
152155

@@ -164,7 +167,7 @@ the current X coordinate).
164167

165168
With a simple change, this filter can be modified to do a vertical flip (`1.0-uvCoord.y`) or even both flips.
166169

167-
### Matrix Filter
170+
### Matrix Filter <a id=Matrix_Filter></a>
168171

169172
![Blur filtered image](filters4.png)
170173
![Edge detect filtered image](filters8.png)
@@ -189,7 +192,7 @@ This filter is implemented in the function `makeKernelMatrix` in the demo. It i
189192
the "blur" and "edge detect" effects. The filter shows how it's possible for filters to read neighboring
190193
pixels, not just the current pixel, when implementing their effect.
191194

192-
### Pixelate Filter
195+
### Pixelate Filter <a id=Pixelate_Filter></a>
193196

194197
![Pixelate filtered image](filters5.png)
195198

@@ -213,7 +216,7 @@ each "pixelated" pixel takes up.
213216

214217
The demo changes the "coarseness" parameter with time to animate the pixelation effect.
215218

216-
### Wave Filter
219+
### Wave Filter <a id=Wave_Filter></a>
217220

218221
![Wave filtered image](filters3.png)
219222

@@ -223,7 +226,7 @@ frame for the undulation effect.
223226

224227
This filter is implemented in the function `makeWave` in the demo.
225228

226-
### Waterpaint Filter
229+
### Waterpaint Filter <a id=Waterpaint_Filter></a>
227230

228231
![Waterpaint filtered image](filters6.png)
229232

@@ -232,7 +235,7 @@ named "Themaister".
232235

233236
This filter is implemented in the function `makeWaterpaint` in the demo.
234237

235-
## Other Pages
238+
## Other Pages <a id=Other_Pages></a>
236239

237240
The following pages of mine on CodeProject also discuss this library:
238241

0 commit comments

Comments
 (0)