Skip to content

Commit 73b2c2a

Browse files
committed
add language tags to code blocks
1 parent 58b88b1 commit 73b2c2a

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

webgl/lessons/webgl-3d-camera.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Let's make a 3D scene with a circle of 'F's like the diagrams above.
5353
First, because we are drawing 5 things and they all use the same
5454
projection matrix we'll compute that outside the loop
5555

56-
```
56+
```js
5757

5858
// Compute the projection matrix
5959
var aspect = gl.canvas.clientWidth / gl.canvas.clientHeight;
@@ -70,7 +70,7 @@ radius * 1.5 distance out and looking at the origin.
7070

7171
{{{diagram url="resources/camera-move-camera.html?mode=3" caption="camera movement" }}}
7272

73-
```
73+
```js
7474
var numFs = 5;
7575
var radius = 200;
7676

@@ -88,22 +88,22 @@ In this case the supplied matrix would move the camera to some position
8888
and orientation relative to the origin. The inverse of that is a matrix
8989
that will move everything else such that the camera is at the origin.
9090

91-
```
91+
```js
9292
// Make a view matrix from the camera matrix.
9393
var viewMatrix = m4.inverse(cameraMatrix);
9494
```
9595

9696
Now we combine the view and projection matrix into a view projection matrix.
9797

98-
```
98+
```js
9999
// Compute a view projection matrix
100100
var viewProjectionMatrix = m4.multiply(projectionMatrix, viewMatrix);
101101
```
102102

103103
Finally we draw a circle of Fs. For each F we start with the
104104
view projection matrix, then rotate and move out radius units.
105105

106-
```
106+
```js
107107
for (var ii = 0; ii < numFs; ++ii) {
108108
var angle = ii * Math.PI * 2 / numFs;
109109
var x = Math.cos(angle) * radius;
@@ -216,7 +216,7 @@ matrix that will orient something that points at the `target` from the
216216

217217
Here's the code to compute the cross product of 2 vectors.
218218

219-
```
219+
```js
220220
function cross(a, b) {
221221
return [a[1] * b[2] - a[2] * b[1],
222222
a[2] * b[0] - a[0] * b[2],
@@ -226,15 +226,15 @@ function cross(a, b) {
226226

227227
Here's the code to subtract two vectors.
228228

229-
```
229+
```js
230230
function subtractVectors(a, b) {
231231
return [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
232232
}
233233
```
234234

235235
Here's the code to normalize a vector (make it into a unit vector).
236236

237-
```
237+
```js
238238
function normalize(v) {
239239
var length = Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
240240
// make sure we don't divide by 0.
@@ -248,7 +248,7 @@ function normalize(v) {
248248

249249
Here's the code to compute a "lookAt" matrix.
250250

251-
```
251+
```js
252252
var m4 = {
253253
lookAt: function(cameraPosition, target, up) {
254254
var zAxis = normalize(
@@ -271,7 +271,7 @@ var m4 = {
271271
And here is how we might use it to make the camera point at a specific 'F'
272272
as we move it.
273273
274-
```
274+
```js
275275
...
276276

277277
// Compute the position of the first F

webgl/lessons/webgl-environment-maps.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Here's an environment map from the lobby of the Computer History Museum in Mount
2424

2525
Based on [the code in the previous article](webgl-cube-maps.html) let's load those 6 images instead of the images we generated
2626

27-
```
27+
```js
2828
// Create a texture.
2929
var texture = gl.createTexture();
3030
gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture);
@@ -154,7 +154,7 @@ Now that we know how reflection works and that we can use it to look up values f
154154

155155
First in the vertex shader we'll compute the world position and world oriented normal of the vertices and pass those to the fragment shader as varyings. This is similar to what we did in [the article on spotlights](webgl-3d-lighting-spot.html).
156156

157-
```
157+
```glsl
158158
attribute vec4 a_position;
159159
attribute vec3 a_normal;
160160
@@ -181,7 +181,7 @@ Then in the fragment shader we normalize the worldNormal since it's being interp
181181

182182
And finally we use `reflect` which is a built in GLSL function that implements the formula we went over above. We use the result to get a color from the cubemap.
183183

184-
```
184+
```glsl
185185
precision highp float;
186186
187187
// Passed in from the vertex shader.
@@ -207,7 +207,7 @@ We also need real normals for this example. We need real normals so the faces of
207207

208208
At init time
209209

210-
```
210+
```js
211211
// Create a buffer to put normals in
212212
var normalBuffer = gl.createBuffer();
213213
// Bind it to ARRAY_BUFFER (think of it as ARRAY_BUFFER = normalBuffer)
@@ -218,7 +218,7 @@ setNormals(gl);
218218

219219
and at render time
220220

221-
```
221+
```js
222222
// Bind the normal buffer.
223223
gl.bindBuffer(gl.ARRAY_BUFFER, normalBuffer);
224224

0 commit comments

Comments
 (0)