diff --git a/src/webgl/3d_primitives.js b/src/webgl/3d_primitives.js index 55bd9e60ab..6e9856a5dd 100644 --- a/src/webgl/3d_primitives.js +++ b/src/webgl/3d_primitives.js @@ -33,18 +33,11 @@ import * as constants from '../core/constants'; * function draw() { * background(200); * plane(50, 50); + * describe(`A white plane (shaped like a square). + * Black lines show that the plane is built from 2 triangles.`); * } * * - * - * @alt - * Nothing displayed on canvas - * Rotating interior view of a box with sides that change color. - * 3d red and green gradient. - * Rotating interior view of a cylinder with sides that change color. - * Rotating view of a cylinder with sides that change color. - * 3d red and green gradient. - * rotating view of a multi-colored cylinder with concave sides. */ p5.prototype.plane = function(width, height, detailX, detailY) { this._assert3d('plane'); @@ -121,6 +114,7 @@ p5.prototype.plane = function(width, height, detailX, detailY) { * rotateX(frameCount * 0.01); * rotateY(frameCount * 0.01); * box(50); + * describe(`Rotating view of a 3D box with sides of length 50.`); * } * * @@ -239,6 +233,9 @@ p5.prototype.box = function(width, height, depth, detailX, detailY) { * function draw() { * background(205, 102, 94); * sphere(40); + * describe(`A white sphere with a diameter of 40. + * Black lines on its surface show how the sphere is built out of + * many small triangles.`); * } * * @@ -262,6 +259,12 @@ p5.prototype.box = function(width, height, depth, detailX, detailY) { * background(205, 105, 94); * rotateY(millis() / 1000); * sphere(40, detailX.value(), 16); + * describe(`A rotating shape, resembling a clam shell or + * “flattened” sphere, with white surface and a diameter of 40. + * The shape is built from many small triangles, which each have + * a black stroke to visually isolate. + * Below the drawing is a slider. Increasing it adds more + * triangles, such that the overall shape becomes rounder as the slider approaches its maximum.`); * } * * @@ -285,6 +288,15 @@ p5.prototype.box = function(width, height, depth, detailX, detailY) { * background(205, 105, 94); * rotateY(millis() / 1000); * sphere(40, 16, detailY.value()); + * describe(`A white rotating sphere-like shape with a diameter of 40. + * Its actual shape is like a cylinder with the top and bottom + * surface protruding outward. + * Black lines on its surface show how the sphere is built out of + * many small triangles. + * When adjusting the slider below the drawing, the shape increases + * the number of small triangles making up the sphere, making the + * final shape increasingly round as the slider approaches its + * maximum setting.`); * } * * @@ -458,6 +470,9 @@ const _truncatedCone = function( * rotateX(frameCount * 0.01); * rotateZ(frameCount * 0.01); * cylinder(20, 50); + * describe(`A spinning view of a white cylinder. + * Black lines on its surface show how the cylinder is built out of + * many small triangles.`); * } * * @@ -481,6 +496,11 @@ const _truncatedCone = function( * background(205, 105, 94); * rotateY(millis() / 1000); * cylinder(20, 75, detailX.value(), 1); + * describe(`A spinning view of what appears to be a white plane. + * Black lines on its surface show how the shape is built out of + * many small triangles. + * As you increase the slider below the canvas, the shape gradually + * becomes smoother and closer to a cylinder.`); * } * * @@ -504,6 +524,12 @@ const _truncatedCone = function( * background(205, 105, 94); * rotateY(millis() / 1000); * cylinder(20, 75, 16, detailY.value()); + * describe(`A spinning view of a white cylinder. + * Black lines on its surface show how the shape is built out of + * many small triangles. + * As you increase the slider below the canvas, the shape increases + * the number of triangles on the outer (round) surface, but the + * smoothness of the shape remains the same.`); * } * * diff --git a/src/webgl/interaction.js b/src/webgl/interaction.js index d13a9acd3e..b56aac8cf1 100644 --- a/src/webgl/interaction.js +++ b/src/webgl/interaction.js @@ -39,12 +39,11 @@ import * as constants from '../core/constants'; * orbitControl(); * rotateY(0.5); * box(30, 50); + * describe(`Camera orbits around a box when mouse moved while + * holding the button down.`); * } * * - * - * @alt - * Camera orbits around a box when mouse is hold-clicked & then moved. */ // implementation based on three.js 'orbitControls': @@ -183,14 +182,14 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) { * if (keyIsDown(32)) { * noDebugMode(); * } + * describe(`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.`); * } * * - * @alt - * 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. + * * * @example *
* function setup() {
* createCanvas(100, 100, WEBGL);
- * describe('the light is partially ambient and partially directional');
+ * describe('The light is partially ambient and partially directional');
* }
* function draw() {
* background(0);
@@ -504,9 +493,6 @@ p5.prototype.pointLight = function(v1, v2, v3, x, y, z) {
* }
*
*
- *
- * @alt
- * the light is partially ambient and partially directional
*/
p5.prototype.lights = function() {
this._assert3d('lights');
@@ -547,7 +533,7 @@ p5.prototype.lights = function() {
* createCanvas(100, 100, WEBGL);
* noStroke();
* describe(
- * 'Two spheres with different falloff values show different intensity of light'
+ * 'Two spheres with different falloff values show different intensities of light'
* );
* }
* function draw() {
@@ -574,9 +560,6 @@ p5.prototype.lights = function() {
* }
*
*
- *
- * @alt
- * Two spheres with different falloff values show different intensity of light
*/
p5.prototype.lightFalloff = function(
constantAttenuation,
@@ -670,7 +653,8 @@ p5.prototype.lightFalloff = function(
* function setup() {
* createCanvas(100, 100, WEBGL);
* describe(
- * 'scene with sphere and spot light. The position of the light is controlled with the mouse position.'
+ * `Scene with sphere and spot light.
+ * The position of the light is controlled with the mouse position.`
* );
* }
* function draw() {
@@ -692,10 +676,6 @@ p5.prototype.lightFalloff = function(
* }
*
*
- *
- * @alt
- * scene with sphere and spot light. The position of
- * the light is controlled with the mouse position.
*/
/**
* @method spotLight
@@ -1028,10 +1008,6 @@ p5.prototype.spotLight = function(
* }
*
*
- *
- * @alt
- * Three white spheres. Each appears as a different
- * color due to lighting.
*/
p5.prototype.noLights = function() {
this._assert3d('noLights');
diff --git a/src/webgl/loading.js b/src/webgl/loading.js
index 039eba7fea..3381b2d049 100755
--- a/src/webgl/loading.js
+++ b/src/webgl/loading.js
@@ -58,12 +58,11 @@ import './p5.Geometry';
* rotateX(frameCount * 0.01);
* rotateY(frameCount * 0.01);
* model(octahedron);
+ * describe(`Vertically rotating 3-d octahedron.`);
* }
*
*
*
- * @alt
- * Vertically rotating 3-d octahedron.
*
* @example
*
@@ -498,11 +492,10 @@ p5.prototype.resetShader = function() {
* vertex(40, 40, 1, 1);
* vertex(-40, 40, 0, 1);
* endShape();
+ * describe(`quad with a texture, mapped using normalized coordinates`);
* }
*
*
* function setup() {
* createCanvas(100, 100, WEBGL);
- * describe('sphere with green emissive material');
+ * describe('Sphere with green emissive material');
* }
* function draw() {
* background(0);
@@ -866,12 +853,10 @@ p5.prototype.ambientMaterial = function(v1, v2, v3) {
* ambientLight(0);
* emissiveMaterial(130, 230, 0);
* sphere(40);
+ * describe(`Radiating light source from top right of canvas`);
* }
*
*
- *
- * @alt
- * sphere with green emissive material
*/
/**
@@ -949,11 +934,11 @@ p5.prototype.emissiveMaterial = function(v1, v2, v3, a) {
* specularMaterial(250);
* shininess(50);
* torus(30, 10, 64, 64);
+ *
+ * describe(`torus with specular material`);
* }
*
*
- * @alt
- * torus with specular material
*/
/**
@@ -1003,7 +988,7 @@ p5.prototype.specularMaterial = function(v1, v2, v3, alpha) {
*
* function setup() {
* createCanvas(100, 100, WEBGL);
- * describe('two spheres, one more shiny than the other');
+ * describe('Two spheres, one more shiny than the other');
* }
* function draw() {
* background(0);
@@ -1019,11 +1004,10 @@ p5.prototype.specularMaterial = function(v1, v2, v3, alpha) {
* translate(50, 0, 0);
* shininess(20);
* sphere(20);
+ * describe(`Shininess on Camera changes position with mouse`);
* }
*
*
- * @alt
- * two spheres, one more shiny than the other
*/
p5.prototype.shininess = function(shine) {
this._assert3d('shininess');
diff --git a/src/webgl/p5.Camera.js b/src/webgl/p5.Camera.js
index 380b0ef145..1f825a982a 100644
--- a/src/webgl/p5.Camera.js
+++ b/src/webgl/p5.Camera.js
@@ -52,6 +52,8 @@ import p5 from '../core/main';
* //move the camera away from the plane by a sin wave
* camera(0, 0, 20 + sin(frameCount * 0.01) * 10, 0, 0, 0, 0, 1, 0);
* plane(10, 10);
+ * describe(`White square repeatedly grows to fill canvas and
+ * then shrinks.`);
* }
*
*
@@ -101,13 +103,12 @@ import p5 from '../core/main';
* stroke(255);
* fill(255, 102, 94);
* box(85);
+ * describe(`An interactive example of a red cube with 3 sliders
+ * for moving it across x, y, and z axis and 3 sliders for shifting
+ * its center.`);
* }
*
*
- * @alt
- * White square repeatedly grows to fill canvas and then shrinks.
- * An interactive example of a red cube with 3 sliders for moving it across x, y,
- * z axis and 3 sliders for shifting its center.
*/
p5.prototype.camera = function(...args) {
this._assert3d('camera');
@@ -166,12 +167,12 @@ p5.prototype.camera = function(...args) {
* translate(15, 0, sin(frameCount / 30 + PI) * 95);
* box(30);
* pop();
+ *
+ * describe(`Two colored 3D boxes move back and forth, rotating as
+ * mouse is dragged.`);
* }
*
*
- *
- * @alt
- * two colored 3D boxes move back and forth, rotating as mouse is dragged.
*/
p5.prototype.perspective = function(...args) {
this._assert3d('perspective');
@@ -229,12 +230,12 @@ p5.prototype.perspective = function(...args) {
* translate(15, 0, sin(frameCount / 30 + PI) * 65);
* box(30);
* pop();
+ *
+ * describe(`Two 3D boxes move back and forth along same plane,
+ * rotating as mouse is dragged.`);
* }
*
*
- *
- * @alt
- * two 3D boxes move back and forth along same plane, rotating as mouse is dragged.
*/
p5.prototype.ortho = function(...args) {
this._assert3d('ortho');
@@ -295,12 +296,12 @@ p5.prototype.ortho = function(...args) {
* translate(15, 0, sin(frameCount / 30 + PI) * 25);
* box(30);
* pop();
+ *
+ * describe(`Two 3D boxes move back and forth along same plane, rotating
+ * as mouse is dragged.`);
* }
*
*
- *
- * @alt
- * two 3D boxes move back and forth along same plane, rotating as mouse is dragged.
*/
p5.prototype.frustum = function(...args) {
this._assert3d('frustum');
@@ -348,11 +349,9 @@ p5.prototype.frustum = function(...args) {
* camera.lookAt(0, 0, 0);
* camera.setPosition(sin(frameCount / 60) * 200, 0, 100);
* box(20);
+ * describe(`An example that creates a camera and moves it around the box.`);
* }
*
- *
- * @alt
- * An example that creates a camera and moves it around the box.
*/
p5.prototype.createCamera = function() {
this._assert3d('createCamera');
@@ -443,12 +442,12 @@ p5.prototype.createCamera = function() {
* box(20);
* translate(35, 0, 0);
* box(20);
+ *
+ * describe(`Camera view pans left and right across a series of
+ * rotating 3D boxes.`);
* }
*
*
- *
- * @alt
- * camera view pans left and right across a series of rotating 3D boxes.
*/
p5.Camera = function(renderer) {
this._renderer = renderer;
@@ -479,12 +478,9 @@ p5.Camera = function(renderer) {
* orbitControl();
* box(10);
* div.html('eyeX = ' + cam.eyeX);
+ * describe(`An example showing the use of camera object properties`);
* }
*
- *
- * @alt
- * An example showing the use of camera object properties
- *
*/
/**
@@ -507,12 +503,9 @@ p5.Camera = function(renderer) {
* orbitControl();
* box(10);
* div.html('eyeY = ' + cam.eyeY);
+ * describe(`An example showing the use of camera object properties`);
* }
*
- *
- * @alt
- * An example showing the use of camera object properties
- *
*/
/**
@@ -535,12 +528,9 @@ p5.Camera = function(renderer) {
* orbitControl();
* box(10);
* div.html('eyeZ = ' + cam.eyeZ);
+ * describe(`An example showing the use of camera object properties`);
* }
*
- *
- * @alt
- * An example showing the use of camera object properties
- *
*/
/**
@@ -564,12 +554,9 @@ p5.Camera = function(renderer) {
* function draw() {
* orbitControl();
* box(10);
+ * describe(`An example showing the use of camera object properties`);
* }
*
- *
- * @alt
- * An example showing the use of camera object properties
- *
*/
/**
@@ -593,12 +580,9 @@ p5.Camera = function(renderer) {
* function draw() {
* orbitControl();
* box(10);
+ * describe(`An example showing the use of camera object properties`);
* }
*
- *
- * @alt
- * An example showing the use of camera object properties
- *
*/
/**
@@ -622,12 +606,9 @@ p5.Camera = function(renderer) {
* function draw() {
* orbitControl();
* box(10);
+ * describe(`An example showing the use of camera object properties`);
* }
*
- *
- * @alt
- * An example showing the use of camera object properties
- *
*/
/**
@@ -645,13 +626,9 @@ p5.Camera = function(renderer) {
* div.position(0, 0);
* div.style('color', 'blue');
* div.style('font-size', '18px');
- * describe('An example showing the use of camera object properties');
+ * describe(`An example showing the use of camera object properties`);
* }
*
- *
- * @alt
- * An example showing the use of camera object properties
- *
*/
/**
@@ -672,10 +649,6 @@ p5.Camera = function(renderer) {
* describe('An example showing the use of camera object properties');
* }
*
- *
- * @alt
- * An example showing the use of camera object properties
- *
*/
/**
@@ -696,10 +669,6 @@ p5.Camera = function(renderer) {
* describe('An example showing the use of camera object properties');
* }
*
- *
- * @alt
- * An example showing the use of camera object properties
- *
*/
////////////////////////////////////////////////////////////////////////////////
@@ -745,11 +714,12 @@ p5.Camera = function(renderer) {
* translate(15, 0, sin(frameCount / 30 + PI) * 95);
* box(30);
* pop();
+ *
+ * describe(`Two colored 3D boxes move back and forth, rotating as
+ * mouse is dragged.`);
* }
*
*
- * @alt
- * two colored 3D boxes move back and forth, rotating as mouse is dragged.
*/
p5.Camera.prototype.perspective = function(fovy, aspect, near, far) {
this.cameraType = arguments.length > 0 ? 'custom' : 'default';
@@ -862,11 +832,12 @@ p5.Camera.prototype.perspective = function(fovy, aspect, near, far) {
* translate(15, 0, sin(frameCount / 30 + PI) * 65);
* box(30);
* pop();
+ *
+ * describe(`Two 3D boxes move back and forth along same plane, rotating
+ * as mouse is dragged.`);
* }
*
*
- * @alt
- * two 3D boxes move back and forth along same plane, rotating as mouse is dragged.
*/
p5.Camera.prototype.ortho = function(left, right, bottom, top, near, far) {
if (left === undefined) left = -this._renderer.width / 2;
@@ -958,11 +929,12 @@ p5.Camera.prototype.ortho = function(left, right, bottom, top, near, far) {
* translate(15, 0, sin(frameCount / 30 + PI) * 25);
* box(30);
* pop();
+ *
+ * describe(`Two 3D boxes move back and forth along same plane, rotating
+ * as mouse is dragged.`);
* }
*
*
- * @alt
- * two 3D boxes move back and forth along same plane, rotating as mouse is dragged.
*/
p5.Camera.prototype.frustum = function(left, right, bottom, top, near, far) {
if (left === undefined) left = -this._renderer.width / 2;
@@ -1113,12 +1085,12 @@ p5.Camera.prototype._rotateView = function(a, x, y, z) {
* box(20);
* translate(35, 0, 0);
* box(20);
+ *
+ * describe(`Camera view pans left and right across a series of
+ * rotating 3D boxes.`);
* }
*
*
- *
- * @alt
- * camera view pans left and right across a series of rotating 3D boxes.
*/
p5.Camera.prototype.pan = function(amount) {
const local = this._getLocalAxes();
@@ -1171,12 +1143,12 @@ p5.Camera.prototype.pan = function(amount) {
* box(20);
* translate(0, 35, 0);
* box(20);
+ *
+ * describe(`Camera view tilts up and down across a series of
+ * rotating 3D boxes.`);
* }
*
*
- *
- * @alt
- * camera view tilts up and down across a series of rotating 3D boxes.
*/
p5.Camera.prototype.tilt = function(amount) {
const local = this._getLocalAxes();
@@ -1224,13 +1196,12 @@ p5.Camera.prototype.tilt = function(amount) {
* box(20);
* translate(35, 0, 0);
* box(20);
+ *
+ * describe(`Camera view of rotating 3D cubes changes to look at a
+ * new random point every second.`);
* }
*
*
- *
- * @alt
- * camera view of rotating 3D cubes changes to look at a new random
- * point every second .
*/
p5.Camera.prototype.lookAt = function(x, y, z) {
this.camera(
@@ -1275,11 +1246,10 @@ p5.Camera.prototype.lookAt = function(x, y, z) {
* // Move the camera away from the plane by a sin wave
* cam.camera(0, 0, 20 + sin(frameCount * 0.01) * 10, 0, 0, 0, 0, 1, 0);
* plane(10, 10);
+ * describe(`White square repeatedly grows to fill canvas and then shrinks.`);
* }
*
*
- * @alt
- * White square repeatedly grows to fill canvas and then shrinks.
*
* @example
*