Skip to content

Commit 69135f1

Browse files
committed
docs(src/webgl): Use describe() instead of @alt
Addresses #5139
1 parent 0112c3a commit 69135f1

File tree

8 files changed

+180
-212
lines changed

8 files changed

+180
-212
lines changed

src/webgl/3d_primitives.js

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,11 @@ import * as constants from '../core/constants';
3232
* function draw() {
3333
* background(200);
3434
* plane(50, 50);
35+
* describe(`A white plane (shaped like a square).
36+
* Black lines show that the plane is built from 2 triangles.`);
3537
* }
3638
* </code>
3739
* </div>
38-
*
39-
* @alt
40-
* Nothing displayed on canvas
41-
* Rotating interior view of a box with sides that change color.
42-
* 3d red and green gradient.
43-
* Rotating interior view of a cylinder with sides that change color.
44-
* Rotating view of a cylinder with sides that change color.
45-
* 3d red and green gradient.
46-
* rotating view of a multi-colored cylinder with concave sides.
4740
*/
4841
p5.prototype.plane = function(width, height, detailX, detailY) {
4942
this._assert3d('plane');
@@ -119,6 +112,7 @@ p5.prototype.plane = function(width, height, detailX, detailY) {
119112
* rotateX(frameCount * 0.01);
120113
* rotateY(frameCount * 0.01);
121114
* box(50);
115+
* describe(`Rotating view of a 3D box with sides of length 50.`);
122116
* }
123117
* </code>
124118
* </div>
@@ -236,6 +230,9 @@ p5.prototype.box = function(width, height, depth, detailX, detailY) {
236230
* function draw() {
237231
* background(205, 102, 94);
238232
* sphere(40);
233+
* describe(`A white sphere with a diameter of 40.
234+
* Black lines on its surface show how the sphere is built out of
235+
* many small triangles.`);
239236
* }
240237
* </code>
241238
* </div>
@@ -256,6 +253,14 @@ p5.prototype.box = function(width, height, depth, detailX, detailY) {
256253
* background(205, 105, 94);
257254
* rotateY(millis() / 1000);
258255
* sphere(40, detailX.value(), 16);
256+
* describe(`A white rotating sphere-like shape with a diameter of 40.
257+
* Its actual shape is similar to a clam shell.
258+
* Black lines on its surface show how the sphere is built out of
259+
* many small triangles.
260+
* When adjusting the slider below the drawing, the shape increases
261+
* the number of small triangles making up the sphere, making the
262+
* final shape increasingly round as the slider approaches its
263+
* maximum setting.`);
259264
* }
260265
* </code>
261266
* </div>
@@ -276,6 +281,15 @@ p5.prototype.box = function(width, height, depth, detailX, detailY) {
276281
* background(205, 105, 94);
277282
* rotateY(millis() / 1000);
278283
* sphere(40, 16, detailY.value());
284+
* describe(`A white rotating sphere-like shape with a diameter of 40.
285+
* Its actual shape is like a cylinder with the top and bottom
286+
* surface protruding outward.
287+
* Black lines on its surface show how the sphere is built out of
288+
* many small triangles.
289+
* When adjusting the slider below the drawing, the shape increases
290+
* the number of small triangles making up the sphere, making the
291+
* final shape increasingly round as the slider approaches its
292+
* maximum setting.`);
279293
* }
280294
* </code>
281295
* </div>
@@ -448,6 +462,9 @@ const _truncatedCone = function(
448462
* rotateX(frameCount * 0.01);
449463
* rotateZ(frameCount * 0.01);
450464
* cylinder(20, 50);
465+
* describe(`A spinning view of a white cylinder.
466+
* Black lines on its surface show how the cylinder is built out of
467+
* many small triangles.`);
451468
* }
452469
* </code>
453470
* </div>
@@ -468,6 +485,11 @@ const _truncatedCone = function(
468485
* background(205, 105, 94);
469486
* rotateY(millis() / 1000);
470487
* cylinder(20, 75, detailX.value(), 1);
488+
* describe(`A spinning view of what appears to be a white plane.
489+
* Black lines on its surface show how the shape is built out of
490+
* many small triangles.
491+
* As you increase the slider below the canvas, the shape gradually
492+
* becomes smoother and closer to a cylinder.`);
471493
* }
472494
* </code>
473495
* </div>
@@ -488,6 +510,12 @@ const _truncatedCone = function(
488510
* background(205, 105, 94);
489511
* rotateY(millis() / 1000);
490512
* cylinder(20, 75, 16, detailY.value());
513+
* describe(`A spinning view of a white cylinder.
514+
* Black lines on its surface show how the shape is built out of
515+
* many small triangles.
516+
* As you increase the slider below the canvas, the shape increases
517+
* the number of triangles on the outer (round) surface, but the
518+
* smoothness of the shape remains the same.`);
491519
* }
492520
* </code>
493521
* </div>
@@ -1245,7 +1273,7 @@ p5.RendererGL.prototype.quad = function(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4,
12451273

12461274
const gId =
12471275
`quad|${x1}|${y1}|${z1}|${x2}|${y2}|${z2}|${x3}|${y3}|${z3}|${x4}|${y4}|${z4}|${detailX}|${detailY}`;
1248-
1276+
12491277
if (!this.geometryInHash(gId)) {
12501278
const quadGeom = new p5.Geometry(detailX, detailY, function() {
12511279
//algorithm adapted from c++ to js
@@ -1273,7 +1301,7 @@ p5.RendererGL.prototype.quad = function(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4,
12731301
}
12741302
}
12751303
});
1276-
1304+
12771305
quadGeom.faces = [];
12781306
for(let y = 0; y < detailY-1; y++){
12791307
for(let x = 0; x < detailX-1; x++){

src/webgl/interaction.js

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ import * as constants from '../core/constants';
3636
* orbitControl();
3737
* rotateY(0.5);
3838
* box(30, 50);
39+
* describe(`Camera orbits around a box when mouse moved while
40+
* holding the button down.`);
3941
* }
4042
* </code>
4143
* </div>
42-
*
43-
* @alt
44-
* Camera orbits around a box when mouse is hold-clicked & then moved.
4544
*/
4645

4746
// implementation based on three.js 'orbitControls':
@@ -177,14 +176,14 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) {
177176
* if (keyIsDown(32)) {
178177
* noDebugMode();
179178
* }
179+
* describe(`a 3D box is centered on a grid in a 3D sketch.
180+
* an icon indicates the direction of each axis:
181+
* a red line points +X, a green line +Y, and a blue line +Z.
182+
* the grid and icon disappear when the spacebar is pressed.`);
180183
* }
181184
* </code>
182185
* </div>
183-
* @alt
184-
* a 3D box is centered on a grid in a 3D sketch. an icon
185-
* indicates the direction of each axis: a red line points +X,
186-
* a green line +Y, and a blue line +Z. the grid and icon disappear when the
187-
* spacebar is pressed.
186+
*
188187
*
189188
* @example
190189
* <div>
@@ -200,11 +199,10 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) {
200199
* background(200);
201200
* orbitControl();
202201
* box(15, 30);
202+
* describe(`a 3D box is centered on a grid in a 3D sketch.`);
203203
* }
204204
* </code>
205205
* </div>
206-
* @alt
207-
* a 3D box is centered on a grid in a 3D sketch.
208206
*
209207
* @example
210208
* <div>
@@ -220,13 +218,12 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) {
220218
* background(200);
221219
* orbitControl();
222220
* box(15, 30);
221+
* describe(`a 3D box is centered in a 3D sketch.
222+
* an icon indicates the direction of each axis:
223+
* a red line points +X, a green line +Y, and a blue line +Z.`);
223224
* }
224225
* </code>
225226
* </div>
226-
* @alt
227-
* a 3D box is centered in a 3D sketch. an icon
228-
* indicates the direction of each axis: a red line points +X,
229-
* a green line +Y, and a blue line +Z.
230227
*
231228
* @example
232229
* <div>
@@ -242,11 +239,10 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) {
242239
* background(200);
243240
* orbitControl();
244241
* box(15, 30);
242+
* describe(`a 3D box is centered on a grid in a 3D sketch`);
245243
* }
246244
* </code>
247245
* </div>
248-
* @alt
249-
* a 3D box is centered on a grid in a 3D sketch
250246
*
251247
* @example
252248
* <div>
@@ -266,13 +262,12 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) {
266262
* // set the stroke color and weight for the grid!
267263
* stroke(255, 0, 150);
268264
* strokeWeight(0.8);
265+
* describe(`a 3D box is centered on a grid in a 3D sketch.
266+
* an icon indicates the direction of each axis:
267+
* a red line points +X, a green line +Y, and a blue line +Z.`);
269268
* }
270269
* </code>
271270
* </div>
272-
* @alt
273-
* a 3D box is centered on a grid in a 3D sketch. an icon
274-
* indicates the direction of each axis: a red line points +X,
275-
* a green line +Y, and a blue line +Z.
276271
*/
277272

278273
/**
@@ -371,14 +366,13 @@ p5.prototype.debugMode = function(...args) {
371366
* if (keyIsDown(32)) {
372367
* noDebugMode();
373368
* }
369+
* describe(`a 3D box is centered on a grid in a 3D sketch.
370+
* an icon indicates the direction of each axis:
371+
* a red line points +X, a green line +Y, and a blue line +Z.
372+
* the grid and icon disappear when the spacebar is pressed.`);
374373
* }
375374
* </code>
376375
* </div>
377-
* @alt
378-
* a 3D box is centered on a grid in a 3D sketch. an icon
379-
* indicates the direction of each axis: a red line points +X,
380-
* a green line +Y, and a blue line +Z. the grid and icon disappear when the
381-
* spacebar is pressed.
382376
*/
383377
p5.prototype.noDebugMode = function() {
384378
this._assert3d('noDebugMode');

src/webgl/light.js

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import * as constants from '../core/constants';
2828
* ambientLight(0);
2929
* ambientMaterial(250);
3030
* sphere(40);
31+
* describe(`evenly distributed light across a sphere`);
3132
* </code>
3233
* </div>
3334
* <div>
@@ -40,12 +41,10 @@ import * as constants from '../core/constants';
4041
* ambientLight(100); // white light
4142
* ambientMaterial(255, 102, 94); // magenta material
4243
* box(30);
44+
* describe(`evenly distributed light across a rotating sphere`);
4345
* }
4446
* </code>
4547
* </div>
46-
* @alt
47-
* evenly distributed light across a sphere
48-
* evenly distributed light across a rotating sphere
4948
*/
5049

5150
/**
@@ -128,12 +127,10 @@ p5.prototype.ambientLight = function(v1, v2, v3, a) {
128127
* pointLight(0, 255, 0, 0, 50, 50);
129128
* specularMaterial(255);
130129
* sphere(40);
130+
* describe(`different specular light sources from top and bottom of canvas`);
131131
* }
132132
* </code>
133133
* </div>
134-
*
135-
* @alt
136-
* different specular light sources from top and bottom of canvas
137134
*/
138135

139136
/**
@@ -199,12 +196,10 @@ p5.prototype.specularColor = function(v1, v2, v3) {
199196
* directionalLight(250, 250, 250, -dirX, -dirY, -1);
200197
* noStroke();
201198
* sphere(40);
199+
* describe(`light source on canvas changeable with mouse position`);
202200
* }
203201
* </code>
204202
* </div>
205-
*
206-
* @alt
207-
* light source on canvas changeable with mouse position
208203
*/
209204

210205
/**
@@ -311,12 +306,10 @@ p5.prototype.directionalLight = function(v1, v2, v3, x, y, z) {
311306
* pointLight(250, 250, 250, locX, locY, 50);
312307
* noStroke();
313308
* sphere(40);
309+
* describe(`spotlight on canvas changes position with mouse`);
314310
* }
315311
* </code>
316312
* </div>
317-
*
318-
* @alt
319-
* spot light on canvas changes position with mouse
320313
*/
321314

322315
/**
@@ -401,12 +394,10 @@ p5.prototype.pointLight = function(v1, v2, v3, x, y, z) {
401394
* rotateY(millis() / 1000);
402395
* rotateZ(millis() / 1000);
403396
* box();
397+
* describe(`the light is partially ambient and partially directional`);
404398
* }
405399
* </code>
406400
* </div>
407-
*
408-
* @alt
409-
* the light is partially ambient and partially directional
410401
*/
411402
p5.prototype.lights = function() {
412403
this._assert3d('lights');
@@ -463,12 +454,12 @@ p5.prototype.lights = function() {
463454
* pointLight(250, 250, 250, locX + 25, locY, 50);
464455
* sphere(20);
465456
* pop();
457+
*
458+
* describe(`Two spheres with different falloff values show
459+
* different intensity of light`);
466460
* }
467461
* </code>
468462
* </div>
469-
*
470-
* @alt
471-
* Two spheres with different falloff values show different intensity of light
472463
*/
473464
p5.prototype.lightFalloff = function(
474465
constantAttenuation,
@@ -561,12 +552,11 @@ p5.prototype.lightFalloff = function(
561552
* spotLight(0, 250, 0, locX, locY, 100, 0, 0, -1, Math.PI / 16);
562553
* noStroke();
563554
* sphere(40);
555+
*
556+
* describe(`Spotlight on a sphere which changes position with mouse`);
564557
* }
565558
* </code>
566559
* </div>
567-
*
568-
* @alt
569-
* Spot light on a sphere which changes position with mouse
570560
*/
571561
/**
572562
* @method spotLight
@@ -887,13 +877,12 @@ p5.prototype.spotLight = function(
887877
* translate(30, 0, 0);
888878
* ambientMaterial(255);
889879
* sphere(13);
880+
*
881+
* describe(`Three white spheres. Each appears as a different
882+
* color due to lighting.`);
890883
* }
891884
* </code>
892885
* </div>
893-
*
894-
* @alt
895-
* Three white spheres. Each appears as a different
896-
* color due to lighting.
897886
*/
898887
p5.prototype.noLights = function() {
899888
this._assert3d('noLights');

0 commit comments

Comments
 (0)