Skip to content

Commit a262091

Browse files
authored
Merge pull request #5706 from aceslowman/main
added describe() to all 3d reference examples
2 parents f625ed4 + cce628b commit a262091

File tree

7 files changed

+136
-0
lines changed

7 files changed

+136
-0
lines changed

src/webgl/3d_primitives.js

+37
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import * as constants from '../core/constants';
2727
* // with width 50 and height 50
2828
* function setup() {
2929
* createCanvas(100, 100, WEBGL);
30+
* describe('a white plane with black wireframe lines');
3031
* }
3132
*
3233
* function draw() {
@@ -112,6 +113,7 @@ p5.prototype.plane = function(width, height, detailX, detailY) {
112113
* // with width, height and depth of 50
113114
* function setup() {
114115
* createCanvas(100, 100, WEBGL);
116+
* describe('a white box rotating in 3D space');
115117
* }
116118
*
117119
* function draw() {
@@ -231,6 +233,7 @@ p5.prototype.box = function(width, height, depth, detailX, detailY) {
231233
* // draw a sphere with radius 40
232234
* function setup() {
233235
* createCanvas(100, 100, WEBGL);
236+
* describe('a white sphere with black wireframe lines');
234237
* }
235238
*
236239
* function draw() {
@@ -250,6 +253,9 @@ p5.prototype.box = function(width, height, depth, detailX, detailY) {
250253
* detailX = createSlider(3, 24, 3);
251254
* detailX.position(10, height + 5);
252255
* detailX.style('width', '80px');
256+
* describe(
257+
* 'a white sphere with low detail on the x-axis, including a slider to adjust detailX'
258+
* );
253259
* }
254260
*
255261
* function draw() {
@@ -270,6 +276,9 @@ p5.prototype.box = function(width, height, depth, detailX, detailY) {
270276
* detailY = createSlider(3, 16, 3);
271277
* detailY.position(10, height + 5);
272278
* detailY.style('width', '80px');
279+
* describe(
280+
* 'a white sphere with low detail on the y-axis, including a slider to adjust detailY'
281+
* );
273282
* }
274283
*
275284
* function draw() {
@@ -441,6 +450,7 @@ const _truncatedCone = function(
441450
* // with radius 20 and height 50
442451
* function setup() {
443452
* createCanvas(100, 100, WEBGL);
453+
* describe('a rotating white cylinder');
444454
* }
445455
*
446456
* function draw() {
@@ -462,6 +472,9 @@ const _truncatedCone = function(
462472
* detailX = createSlider(3, 24, 3);
463473
* detailX.position(10, height + 5);
464474
* detailX.style('width', '80px');
475+
* describe(
476+
* 'a rotating white cylinder with limited X detail, with a slider that adjusts detailX'
477+
* );
465478
* }
466479
*
467480
* function draw() {
@@ -482,6 +495,9 @@ const _truncatedCone = function(
482495
* detailY = createSlider(1, 16, 1);
483496
* detailY.position(10, height + 5);
484497
* detailY.style('width', '80px');
498+
* describe(
499+
* 'a rotating white cylinder with limited Y detail, with a slider that adjusts detailY'
500+
* );
485501
* }
486502
*
487503
* function draw() {
@@ -576,6 +592,7 @@ p5.prototype.cylinder = function(
576592
* // with radius 40 and height 70
577593
* function setup() {
578594
* createCanvas(100, 100, WEBGL);
595+
* describe('a rotating white cone');
579596
* }
580597
*
581598
* function draw() {
@@ -597,6 +614,9 @@ p5.prototype.cylinder = function(
597614
* detailX = createSlider(3, 16, 3);
598615
* detailX.position(10, height + 5);
599616
* detailX.style('width', '80px');
617+
* describe(
618+
* 'a rotating white cone with limited X detail, with a slider that adjusts detailX'
619+
* );
600620
* }
601621
*
602622
* function draw() {
@@ -617,6 +637,9 @@ p5.prototype.cylinder = function(
617637
* detailY = createSlider(3, 16, 3);
618638
* detailY.position(10, height + 5);
619639
* detailY.style('width', '80px');
640+
* describe(
641+
* 'a rotating white cone with limited Y detail, with a slider that adjusts detailY'
642+
* );
620643
* }
621644
*
622645
* function draw() {
@@ -692,6 +715,7 @@ p5.prototype.cone = function(radius, height, detailX, detailY, cap) {
692715
* // with radius 30, 40 and 40.
693716
* function setup() {
694717
* createCanvas(100, 100, WEBGL);
718+
* describe('a white 3d ellipsoid');
695719
* }
696720
*
697721
* function draw() {
@@ -711,6 +735,9 @@ p5.prototype.cone = function(radius, height, detailX, detailY, cap) {
711735
* detailX = createSlider(2, 24, 12);
712736
* detailX.position(10, height + 5);
713737
* detailX.style('width', '80px');
738+
* describe(
739+
* 'a rotating white ellipsoid with limited X detail, with a slider that adjusts detailX'
740+
* );
714741
* }
715742
*
716743
* function draw() {
@@ -731,6 +758,9 @@ p5.prototype.cone = function(radius, height, detailX, detailY, cap) {
731758
* detailY = createSlider(2, 24, 6);
732759
* detailY.position(10, height + 5);
733760
* detailY.style('width', '80px');
761+
* describe(
762+
* 'a rotating white ellipsoid with limited Y detail, with a slider that adjusts detailY'
763+
* );
734764
* }
735765
*
736766
* function draw() {
@@ -826,6 +856,7 @@ p5.prototype.ellipsoid = function(radiusX, radiusY, radiusZ, detailX, detailY) {
826856
* // with ring radius 30 and tube radius 15
827857
* function setup() {
828858
* createCanvas(100, 100, WEBGL);
859+
* describe('a rotating white torus');
829860
* }
830861
*
831862
* function draw() {
@@ -847,6 +878,9 @@ p5.prototype.ellipsoid = function(radiusX, radiusY, radiusZ, detailX, detailY) {
847878
* detailX = createSlider(3, 24, 3);
848879
* detailX.position(10, height + 5);
849880
* detailX.style('width', '80px');
881+
* describe(
882+
* 'a rotating white torus with limited X detail, with a slider that adjusts detailX'
883+
* );
850884
* }
851885
*
852886
* function draw() {
@@ -867,6 +901,9 @@ p5.prototype.ellipsoid = function(radiusX, radiusY, radiusZ, detailX, detailY) {
867901
* detailY = createSlider(3, 16, 3);
868902
* detailY.position(10, height + 5);
869903
* detailY.style('width', '80px');
904+
* describe(
905+
* 'a rotating white torus with limited Y detail, with a slider that adjusts detailY'
906+
* );
870907
* }
871908
*
872909
* function draw() {

src/webgl/interaction.js

+17
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ import * as constants from '../core/constants';
3030
* function setup() {
3131
* createCanvas(100, 100, WEBGL);
3232
* normalMaterial();
33+
* describe(
34+
* 'Camera orbits around a box when mouse is hold-clicked & then moved.'
35+
* );
3336
* }
3437
* function draw() {
3538
* background(200);
@@ -167,6 +170,9 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) {
167170
* camera(0, -30, 100, 0, 0, 0, 0, 1, 0);
168171
* normalMaterial();
169172
* debugMode();
173+
* describe(
174+
* 'a 3D box is centered on a grid in a 3D sketch. an icon indicates the direction of each axis: a red line points +X, a green line +Y, and a blue line +Z. the grid and icon disappear when the spacebar is pressed.'
175+
* );
170176
* }
171177
*
172178
* function draw() {
@@ -194,6 +200,7 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) {
194200
* camera(0, -30, 100, 0, 0, 0, 0, 1, 0);
195201
* normalMaterial();
196202
* debugMode(GRID);
203+
* describe('a 3D box is centered on a grid in a 3D sketch.');
197204
* }
198205
*
199206
* function draw() {
@@ -214,6 +221,9 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) {
214221
* camera(0, -30, 100, 0, 0, 0, 0, 1, 0);
215222
* normalMaterial();
216223
* debugMode(AXES);
224+
* describe(
225+
* 'a 3D box is centered in a 3D sketch. an icon indicates the direction of each axis: a red line points +X, a green line +Y, and a blue line +Z.'
226+
* );
217227
* }
218228
*
219229
* function draw() {
@@ -236,6 +246,7 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) {
236246
* camera(0, -30, 100, 0, 0, 0, 0, 1, 0);
237247
* normalMaterial();
238248
* debugMode(GRID, 100, 10, 0, 0, 0);
249+
* describe('a 3D box is centered on a grid in a 3D sketch');
239250
* }
240251
*
241252
* function draw() {
@@ -256,6 +267,9 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) {
256267
* camera(0, -30, 100, 0, 0, 0, 0, 1, 0);
257268
* normalMaterial();
258269
* debugMode(100, 10, 0, 0, 0, 20, 0, -40, 0);
270+
* describe(
271+
* 'a 3D box is centered on a grid in a 3D sketch. an icon indicates the direction of each axis: a red line points +X, a green line +Y, and a blue line +Z.'
272+
* );
259273
* }
260274
*
261275
* function draw() {
@@ -361,6 +375,9 @@ p5.prototype.debugMode = function(...args) {
361375
* camera(0, -30, 100, 0, 0, 0, 0, 1, 0);
362376
* normalMaterial();
363377
* debugMode();
378+
* describe(
379+
* 'a 3D box is centered on a grid in a 3D sketch. an icon indicates the direction of each axis: a red line points +X, a green line +Y, and a blue line +Z. the grid and icon disappear when the spacebar is pressed.'
380+
* );
364381
* }
365382
*
366383
* function draw() {

src/webgl/light.js

+21
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import * as constants from '../core/constants';
3737
* function setup() {
3838
* createCanvas(100, 100, WEBGL);
3939
* noStroke();
40+
* describe('sphere with coral color under black light');
4041
* }
4142
* function draw() {
4243
* background(100);
@@ -55,6 +56,7 @@ import * as constants from '../core/constants';
5556
* function setup() {
5657
* createCanvas(100, 100, WEBGL);
5758
* noStroke();
59+
* describe('sphere with coral color under white light');
5860
* }
5961
* function draw() {
6062
* background(100);
@@ -144,6 +146,9 @@ p5.prototype.ambientLight = function(v1, v2, v3, a) {
144146
* function setup() {
145147
* createCanvas(100, 100, WEBGL);
146148
* noStroke();
149+
* describe(
150+
* 'Sphere with specular highlight. Clicking the mouse toggles the specular highlight color between red and the default white.'
151+
* );
147152
* }
148153
*
149154
* function draw() {
@@ -256,6 +261,9 @@ p5.prototype.specularColor = function(v1, v2, v3) {
256261
* <code>
257262
* function setup() {
258263
* createCanvas(100, 100, WEBGL);
264+
* describe(
265+
* 'scene with sphere and directional light. The direction of the light is controlled with the mouse position.'
266+
* );
259267
* }
260268
* function draw() {
261269
* background(0);
@@ -374,6 +382,9 @@ p5.prototype.directionalLight = function(v1, v2, v3, x, y, z) {
374382
* <code>
375383
* function setup() {
376384
* createCanvas(100, 100, WEBGL);
385+
* describe(
386+
* 'scene with sphere and point light. The position of the light is controlled with the mouse position.'
387+
* );
377388
* }
378389
* function draw() {
379390
* background(0);
@@ -481,6 +492,7 @@ p5.prototype.pointLight = function(v1, v2, v3, x, y, z) {
481492
* <code>
482493
* function setup() {
483494
* createCanvas(100, 100, WEBGL);
495+
* describe('the light is partially ambient and partially directional');
484496
* }
485497
* function draw() {
486498
* background(0);
@@ -534,6 +546,9 @@ p5.prototype.lights = function() {
534546
* function setup() {
535547
* createCanvas(100, 100, WEBGL);
536548
* noStroke();
549+
* describe(
550+
* 'Two spheres with different falloff values show different intensity of light'
551+
* );
537552
* }
538553
* function draw() {
539554
* ortho();
@@ -654,6 +669,9 @@ p5.prototype.lightFalloff = function(
654669
* <code>
655670
* function setup() {
656671
* createCanvas(100, 100, WEBGL);
672+
* describe(
673+
* 'scene with sphere and spot light. The position of the light is controlled with the mouse position.'
674+
* );
657675
* }
658676
* function draw() {
659677
* background(0);
@@ -985,6 +1003,9 @@ p5.prototype.spotLight = function(
9851003
* <code>
9861004
* function setup() {
9871005
* createCanvas(100, 100, WEBGL);
1006+
* describe(
1007+
* 'Three white spheres. Each appears as a different color due to lighting.'
1008+
* );
9881009
* }
9891010
* function draw() {
9901011
* background(200);

src/webgl/loading.js

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import './p5.Geometry';
5050
*
5151
* function setup() {
5252
* createCanvas(100, 100, WEBGL);
53+
* describe('Vertically rotating 3-d octahedron.');
5354
* }
5455
*
5556
* function draw() {
@@ -77,6 +78,7 @@ import './p5.Geometry';
7778
*
7879
* function setup() {
7980
* createCanvas(100, 100, WEBGL);
81+
* describe('Vertically rotating 3-d teapot with red, green and blue gradient.');
8082
* }
8183
*
8284
* function draw() {
@@ -602,6 +604,7 @@ function parseASCIISTL(model, lines) {
602604
*
603605
* function setup() {
604606
* createCanvas(100, 100, WEBGL);
607+
* describe('Vertically rotating 3-d octahedron.');
605608
* }
606609
*
607610
* function draw() {

0 commit comments

Comments
 (0)