Skip to content

Commit 3e25740

Browse files
committed
docs(src/webgl): Use describe() instead of @alt
Addresses #5139
1 parent 6df9a16 commit 3e25740

File tree

8 files changed

+181
-235
lines changed

8 files changed

+181
-235
lines changed

src/webgl/3d_primitives.js

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,11 @@ import * as constants from '../core/constants';
3333
* function draw() {
3434
* background(200);
3535
* plane(50, 50);
36+
* describe(`A white plane (shaped like a square).
37+
* Black lines show that the plane is built from 2 triangles.`);
3638
* }
3739
* </code>
3840
* </div>
39-
*
40-
* @alt
41-
* Nothing displayed on canvas
42-
* Rotating interior view of a box with sides that change color.
43-
* 3d red and green gradient.
44-
* Rotating interior view of a cylinder with sides that change color.
45-
* Rotating view of a cylinder with sides that change color.
46-
* 3d red and green gradient.
47-
* rotating view of a multi-colored cylinder with concave sides.
4841
*/
4942
p5.prototype.plane = function(width, height, detailX, detailY) {
5043
this._assert3d('plane');
@@ -121,6 +114,7 @@ p5.prototype.plane = function(width, height, detailX, detailY) {
121114
* rotateX(frameCount * 0.01);
122115
* rotateY(frameCount * 0.01);
123116
* box(50);
117+
* describe(`Rotating view of a 3D box with sides of length 50.`);
124118
* }
125119
* </code>
126120
* </div>
@@ -239,6 +233,9 @@ p5.prototype.box = function(width, height, depth, detailX, detailY) {
239233
* function draw() {
240234
* background(205, 102, 94);
241235
* sphere(40);
236+
* describe(`A white sphere with a diameter of 40.
237+
* Black lines on its surface show how the sphere is built out of
238+
* many small triangles.`);
242239
* }
243240
* </code>
244241
* </div>
@@ -262,6 +259,14 @@ p5.prototype.box = function(width, height, depth, detailX, detailY) {
262259
* background(205, 105, 94);
263260
* rotateY(millis() / 1000);
264261
* sphere(40, detailX.value(), 16);
262+
* describe(`A white rotating sphere-like shape with a diameter of 40.
263+
* Its actual shape is similar to a clam shell.
264+
* Black lines on its surface show how the sphere is built out of
265+
* many small triangles.
266+
* When adjusting the slider below the drawing, the shape increases
267+
* the number of small triangles making up the sphere, making the
268+
* final shape increasingly round as the slider approaches its
269+
* maximum setting.`);
265270
* }
266271
* </code>
267272
* </div>
@@ -285,6 +290,15 @@ p5.prototype.box = function(width, height, depth, detailX, detailY) {
285290
* background(205, 105, 94);
286291
* rotateY(millis() / 1000);
287292
* sphere(40, 16, detailY.value());
293+
* describe(`A white rotating sphere-like shape with a diameter of 40.
294+
* Its actual shape is like a cylinder with the top and bottom
295+
* surface protruding outward.
296+
* Black lines on its surface show how the sphere is built out of
297+
* many small triangles.
298+
* When adjusting the slider below the drawing, the shape increases
299+
* the number of small triangles making up the sphere, making the
300+
* final shape increasingly round as the slider approaches its
301+
* maximum setting.`);
288302
* }
289303
* </code>
290304
* </div>
@@ -458,6 +472,9 @@ const _truncatedCone = function(
458472
* rotateX(frameCount * 0.01);
459473
* rotateZ(frameCount * 0.01);
460474
* cylinder(20, 50);
475+
* describe(`A spinning view of a white cylinder.
476+
* Black lines on its surface show how the cylinder is built out of
477+
* many small triangles.`);
461478
* }
462479
* </code>
463480
* </div>
@@ -481,6 +498,11 @@ const _truncatedCone = function(
481498
* background(205, 105, 94);
482499
* rotateY(millis() / 1000);
483500
* cylinder(20, 75, detailX.value(), 1);
501+
* describe(`A spinning view of what appears to be a white plane.
502+
* Black lines on its surface show how the shape is built out of
503+
* many small triangles.
504+
* As you increase the slider below the canvas, the shape gradually
505+
* becomes smoother and closer to a cylinder.`);
484506
* }
485507
* </code>
486508
* </div>
@@ -504,6 +526,12 @@ const _truncatedCone = function(
504526
* background(205, 105, 94);
505527
* rotateY(millis() / 1000);
506528
* cylinder(20, 75, 16, detailY.value());
529+
* describe(`A spinning view of a white cylinder.
530+
* Black lines on its surface show how the shape is built out of
531+
* many small triangles.
532+
* As you increase the slider below the canvas, the shape increases
533+
* the number of triangles on the outer (round) surface, but the
534+
* smoothness of the shape remains the same.`);
507535
* }
508536
* </code>
509537
* </div>

src/webgl/interaction.js

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ import * as constants from '../core/constants';
3939
* orbitControl();
4040
* rotateY(0.5);
4141
* box(30, 50);
42+
* describe(`Camera orbits around a box when mouse moved while
43+
* holding the button down.`);
4244
* }
4345
* </code>
4446
* </div>
45-
*
46-
* @alt
47-
* Camera orbits around a box when mouse is hold-clicked & then moved.
4847
*/
4948

5049
// implementation based on three.js 'orbitControls':
@@ -183,14 +182,14 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) {
183182
* if (keyIsDown(32)) {
184183
* noDebugMode();
185184
* }
185+
* describe(`a 3D box is centered on a grid in a 3D sketch.
186+
* an icon indicates the direction of each axis:
187+
* a red line points +X, a green line +Y, and a blue line +Z.
188+
* the grid and icon disappear when the spacebar is pressed.`);
186189
* }
187190
* </code>
188191
* </div>
189-
* @alt
190-
* a 3D box is centered on a grid in a 3D sketch. an icon
191-
* indicates the direction of each axis: a red line points +X,
192-
* a green line +Y, and a blue line +Z. the grid and icon disappear when the
193-
* spacebar is pressed.
192+
*
194193
*
195194
* @example
196195
* <div>
@@ -207,11 +206,10 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) {
207206
* background(200);
208207
* orbitControl();
209208
* box(15, 30);
209+
* describe(`a 3D box is centered on a grid in a 3D sketch.`);
210210
* }
211211
* </code>
212212
* </div>
213-
* @alt
214-
* a 3D box is centered on a grid in a 3D sketch.
215213
*
216214
* @example
217215
* <div>
@@ -230,13 +228,12 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) {
230228
* background(200);
231229
* orbitControl();
232230
* box(15, 30);
231+
* describe(`a 3D box is centered in a 3D sketch.
232+
* an icon indicates the direction of each axis:
233+
* a red line points +X, a green line +Y, and a blue line +Z.`);
233234
* }
234235
* </code>
235236
* </div>
236-
* @alt
237-
* a 3D box is centered in a 3D sketch. an icon
238-
* indicates the direction of each axis: a red line points +X,
239-
* a green line +Y, and a blue line +Z.
240237
*
241238
* @example
242239
* <div>
@@ -253,11 +250,10 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) {
253250
* background(200);
254251
* orbitControl();
255252
* box(15, 30);
253+
* describe(`a 3D box is centered on a grid in a 3D sketch`);
256254
* }
257255
* </code>
258256
* </div>
259-
* @alt
260-
* a 3D box is centered on a grid in a 3D sketch
261257
*
262258
* @example
263259
* <div>
@@ -280,13 +276,12 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) {
280276
* // set the stroke color and weight for the grid!
281277
* stroke(255, 0, 150);
282278
* strokeWeight(0.8);
279+
* describe(`a 3D box is centered on a grid in a 3D sketch.
280+
* an icon indicates the direction of each axis:
281+
* a red line points +X, a green line +Y, and a blue line +Z.`);
283282
* }
284283
* </code>
285284
* </div>
286-
* @alt
287-
* a 3D box is centered on a grid in a 3D sketch. an icon
288-
* indicates the direction of each axis: a red line points +X,
289-
* a green line +Y, and a blue line +Z.
290285
*/
291286

292287
/**
@@ -388,14 +383,13 @@ p5.prototype.debugMode = function(...args) {
388383
* if (keyIsDown(32)) {
389384
* noDebugMode();
390385
* }
386+
* describe(`a 3D box is centered on a grid in a 3D sketch.
387+
* an icon indicates the direction of each axis:
388+
* a red line points +X, a green line +Y, and a blue line +Z.
389+
* the grid and icon disappear when the spacebar is pressed.`);
391390
* }
392391
* </code>
393392
* </div>
394-
* @alt
395-
* a 3D box is centered on a grid in a 3D sketch. an icon
396-
* indicates the direction of each axis: a red line points +X,
397-
* a green line +Y, and a blue line +Z. the grid and icon disappear when the
398-
* spacebar is pressed.
399393
*/
400394
p5.prototype.noDebugMode = function() {
401395
this._assert3d('noDebugMode');

src/webgl/light.js

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ import * as constants from '../core/constants';
4747
* }
4848
* </code>
4949
* </div>
50-
* @alt
51-
* sphere with coral color under black light
5250
*
5351
* @example
5452
* <div>
@@ -66,8 +64,6 @@ import * as constants from '../core/constants';
6664
* }
6765
* </code>
6866
* </div>
69-
* @alt
70-
* sphere with coral color under white light
7167
*/
7268

7369
/**
@@ -147,7 +143,9 @@ p5.prototype.ambientLight = function(v1, v2, v3, a) {
147143
* createCanvas(100, 100, WEBGL);
148144
* noStroke();
149145
* describe(
150-
* 'Sphere with specular highlight. Clicking the mouse toggles the specular highlight color between red and the default white.'
146+
* `Sphere with specular highlight.
147+
* Clicking the mouse toggles the specular highlight color between
148+
* red and the default white.`
151149
* );
152150
* }
153151
*
@@ -180,9 +178,6 @@ p5.prototype.ambientLight = function(v1, v2, v3, a) {
180178
* </code>
181179
* </div>
182180
*
183-
* @alt
184-
* Sphere with specular highlight. Clicking the mouse toggles the
185-
* specular highlight color between red and the default white.
186181
*/
187182

188183
/**
@@ -262,7 +257,8 @@ p5.prototype.specularColor = function(v1, v2, v3) {
262257
* function setup() {
263258
* createCanvas(100, 100, WEBGL);
264259
* describe(
265-
* 'scene with sphere and directional light. The direction of the light is controlled with the mouse position.'
260+
* `Scene with sphere and directional light. The direction of
261+
* the light is controlled with the mouse position.`
266262
* );
267263
* }
268264
* function draw() {
@@ -276,10 +272,6 @@ p5.prototype.specularColor = function(v1, v2, v3) {
276272
* }
277273
* </code>
278274
* </div>
279-
*
280-
* @alt
281-
* scene with sphere and directional light. The direction of
282-
* the light is controlled with the mouse position.
283275
*/
284276

285277
/**
@@ -383,7 +375,8 @@ p5.prototype.directionalLight = function(v1, v2, v3, x, y, z) {
383375
* function setup() {
384376
* createCanvas(100, 100, WEBGL);
385377
* describe(
386-
* 'scene with sphere and point light. The position of the light is controlled with the mouse position.'
378+
* `Scene with sphere and point light. The position of
379+
* the light is controlled with the mouse position.`
387380
* );
388381
* }
389382
* function draw() {
@@ -404,10 +397,6 @@ p5.prototype.directionalLight = function(v1, v2, v3, x, y, z) {
404397
* }
405398
* </code>
406399
* </div>
407-
*
408-
* @alt
409-
* scene with sphere and point light. The position of
410-
* the light is controlled with the mouse position.
411400
*/
412401

413402
/**
@@ -492,7 +481,7 @@ p5.prototype.pointLight = function(v1, v2, v3, x, y, z) {
492481
* <code>
493482
* function setup() {
494483
* createCanvas(100, 100, WEBGL);
495-
* describe('the light is partially ambient and partially directional');
484+
* describe('The light is partially ambient and partially directional');
496485
* }
497486
* function draw() {
498487
* background(0);
@@ -504,9 +493,6 @@ p5.prototype.pointLight = function(v1, v2, v3, x, y, z) {
504493
* }
505494
* </code>
506495
* </div>
507-
*
508-
* @alt
509-
* the light is partially ambient and partially directional
510496
*/
511497
p5.prototype.lights = function() {
512498
this._assert3d('lights');
@@ -547,7 +533,7 @@ p5.prototype.lights = function() {
547533
* createCanvas(100, 100, WEBGL);
548534
* noStroke();
549535
* describe(
550-
* 'Two spheres with different falloff values show different intensity of light'
536+
* 'Two spheres with different falloff values show different intensities of light'
551537
* );
552538
* }
553539
* function draw() {
@@ -574,9 +560,6 @@ p5.prototype.lights = function() {
574560
* }
575561
* </code>
576562
* </div>
577-
*
578-
* @alt
579-
* Two spheres with different falloff values show different intensity of light
580563
*/
581564
p5.prototype.lightFalloff = function(
582565
constantAttenuation,
@@ -670,7 +653,8 @@ p5.prototype.lightFalloff = function(
670653
* function setup() {
671654
* createCanvas(100, 100, WEBGL);
672655
* describe(
673-
* 'scene with sphere and spot light. The position of the light is controlled with the mouse position.'
656+
* `Scene with sphere and spot light.
657+
* The position of the light is controlled with the mouse position.`
674658
* );
675659
* }
676660
* function draw() {
@@ -692,10 +676,6 @@ p5.prototype.lightFalloff = function(
692676
* }
693677
* </code>
694678
* </div>
695-
*
696-
* @alt
697-
* scene with sphere and spot light. The position of
698-
* the light is controlled with the mouse position.
699679
*/
700680
/**
701681
* @method spotLight
@@ -1028,10 +1008,6 @@ p5.prototype.spotLight = function(
10281008
* }
10291009
* </code>
10301010
* </div>
1031-
*
1032-
* @alt
1033-
* Three white spheres. Each appears as a different
1034-
* color due to lighting.
10351011
*/
10361012
p5.prototype.noLights = function() {
10371013
this._assert3d('noLights');

0 commit comments

Comments
 (0)