diff --git a/src/webgl/interaction.js b/src/webgl/interaction.js
index 3b9fed3baa..6245becfce 100644
--- a/src/webgl/interaction.js
+++ b/src/webgl/interaction.js
@@ -9,61 +9,154 @@ import p5 from '../core/main';
import * as constants from '../core/constants';
/**
- * Allows movement around a 3D sketch using a mouse or trackpad or touch.
+ * Allows the user to orbit around a 3D sketch using a mouse, trackpad, or
+ * touchscreen.
+ *
+ * 3D sketches are viewed through an imaginary camera. Calling
+ * `orbitControl()` within the draw() function allows
+ * the user to change the camera’s position:
+ *
+ *
+ * function draw() {
+ * background(200);
+ *
+ * // Enable orbiting with the mouse.
+ * orbitControl();
+ *
+ * // Rest of sketch.
+ * }
+ *
+ *
* Left-clicking and dragging or swipe motion will rotate the camera position
- * about the center of the sketch, right-clicking and dragging or multi-swipe
- * will pan the camera position without rotation, and using the mouse wheel
- * (scrolling) or pinch in/out will move the camera further or closer
- * from the center of the sketch. This function can be called with parameters
- * dictating sensitivity to mouse/touch movement along the X and Y axes.
- * Calling this function without parameters is equivalent to calling
- * orbitControl(1,1). To reverse direction of movement in either axis,
- * enter a negative number for sensitivity.
+ * about the center of the sketch. Right-clicking and dragging or multi-swipe
+ * will pan the camera position without rotation. Using the mouse wheel
+ * (scrolling) or pinch in/out will move the camera further or closer from the
+ * center of the sketch.
+ *
+ * The first three parameters, `sensitivityX`, `sensitivityY`, and
+ * `sensitivityZ`, are optional. They’re numbers that set the sketch’s
+ * sensitivity to movement along each axis. For example, calling
+ * `orbitControl(1, 2, -1)` keeps movement along the x-axis at its default
+ * value, makes the sketch twice as sensitive to movement along the y-axis,
+ * and reverses motion along the z-axis. By default, all sensitivity values
+ * are 1.
+ *
+ * The fourth parameter, `options`, is also optional. It’s an object that
+ * changes the behavior of orbiting. For example, calling
+ * `orbitControl(1, 1, 1, options)` keeps the default sensitivity values while
+ * changing the behaviors set with `options`. The object can have the
+ * following properties:
+ *
+ *
+ * let options = {
+ * // Setting this to false makes mobile interactions smoother by
+ * // preventing accidental interactions with the page while orbiting.
+ * // By default, it's true.
+ * disableTouchActions: true,
+ *
+ * // Setting this to true makes the camera always rotate in the
+ * // direction the mouse/touch is moving.
+ * // By default, it's false.
+ * freeRotation: false
+ * };
+ *
+ * orbitControl(1, 1, 1, options);
+ *
+ *
* @method orbitControl
* @for p5
- * @param {Number} [sensitivityX] sensitivity to mouse movement along X axis
- * @param {Number} [sensitivityY] sensitivity to mouse movement along Y axis
- * @param {Number} [sensitivityZ] sensitivity to scroll movement along Z axis
- * @param {Object} [options] An optional object that can contain additional settings,
- * disableTouchActions - Boolean, default value is true.
- * Setting this to true makes mobile interactions smoother by preventing
- * accidental interactions with the page while orbiting. But if you're already
- * doing it via css or want the default touch actions, consider setting it to false.
- * freeRotation - Boolean, default value is false.
- * By default, horizontal movement of the mouse or touch pointer rotates the camera
- * around the y-axis, and vertical movement rotates the camera around the x-axis.
- * But if setting this option to true, the camera always rotates in the direction
- * the pointer is moving. For zoom and move, the behavior is the same regardless of
- * true/false.
+ * @param {Number} [sensitivityX] sensitivity to movement along the x-axis. Defaults to 1.
+ * @param {Number} [sensitivityY] sensitivity to movement along the y-axis. Defaults to 1.
+ * @param {Number} [sensitivityZ] sensitivity to movement along the z-axis. Defaults to 1.
+ * @param {Object} [options] object with two optional properties, `disableTouchActions`
+ * and `freeRotation`. Both are `Boolean`s. `disableTouchActions`
+ * defaults to `true` and `freeRotation` defaults to `false`.
* @chainable
+ *
* @example
*
+ * // Click and drag the mouse to view the scene from different angles.
+ *
* function setup() {
* createCanvas(100, 100, WEBGL);
- * normalMaterial();
- * describe(
- * 'Camera orbits around a box when mouse is hold-clicked & then moved.'
- * );
- * camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);
- * perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));
+ *
+ * describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.');
* }
+ *
* function draw() {
* background(200);
*
- * // If you execute the line commented out instead of next line, the direction of rotation
- * // will be the direction the mouse or touch pointer moves, not around the X or Y axis.
+ * // Enable orbiting with the mouse.
* orbitControl();
- * // orbitControl(1, 1, 1, {freeRotation: true});
*
- * rotateY(0.5);
+ * // Style the box.
+ * normalMaterial();
+ *
+ * // Draw the box.
+ * box(30, 50);
+ * }
+ *
+ *
+ * // Click and drag the mouse to view the scene from different angles.
+ *
+ * function setup() {
+ * createCanvas(100, 100, WEBGL);
+ *
+ * describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.');
+ * }
+ *
+ * function draw() {
+ * background(200);
+ *
+ * // Enable orbiting with the mouse.
+ * // Make the interactions 3X sensitive.
+ * orbitControl(3, 3, 3);
+ *
+ * // Style the box.
+ * normalMaterial();
+ *
+ * // Draw the box.
* box(30, 50);
* }
*
*
+ * // Click and drag the mouse to view the scene from different angles.
+ *
+ * function setup() {
+ * createCanvas(100, 100, WEBGL);
+ *
+ * describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.');
+ * }
+ *
+ * function draw() {
+ * background(200);
+ *
+ * // Create an options object.
+ * let options = {
+ * disableTouchActions: false,
+ * freeRotation: true
+ * };
+ *
+ * // Enable orbiting with the mouse.
+ * // Prevent accidental touch actions on touchscreen devices
+ * // and enable free rotation.
+ * orbitControl(1, 1, 1, options);
+ *
+ * // Style the box.
+ * normalMaterial();
+ *
+ * // Draw the box.
+ * box(30, 50);
+ * }
+ *
+ *
+ * // Click and drag the mouse to view the scene from different angles.
+ *
* function setup() {
* createCanvas(100, 100, WEBGL);
- * camera(0, -30, 100, 0, 0, 0, 0, 1, 0);
- * perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));
- * normalMaterial();
+ *
+ * // Enable debug mode.
* debugMode();
- * 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.'
- * );
+ *
+ * describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box.');
* }
*
* function draw() {
* background(200);
+ *
+ * // Enable orbiting with the mouse.
* orbitControl();
- * box(15, 30);
- * // Press the spacebar to turn debugMode off!
- * if (keyIsDown(32)) {
- * noDebugMode();
- * }
- * }
- *
- *
- * function setup() {
- * createCanvas(100, 100, WEBGL);
- * camera(0, -30, 100, 0, 0, 0, 0, 1, 0);
- * perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));
+ * // Style the box.
* normalMaterial();
- * debugMode(GRID);
- * describe('a 3D box is centered on a grid in a 3D sketch.');
- * }
*
- * function draw() {
- * background(200);
- * orbitControl();
- * box(15, 30);
+ * // Draw the box.
+ * box(20, 40);
* }
*
*
+ * // Click and drag the mouse to view the scene from different angles.
+ *
* function setup() {
* createCanvas(100, 100, WEBGL);
- * camera(0, -30, 100, 0, 0, 0, 0, 1, 0);
- * perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));
- * normalMaterial();
+ *
+ * // Enable debug mode.
+ * // Only display the axes icon.
* debugMode(AXES);
- * describe(
- * '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.'
- * );
+ *
+ * describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box.');
* }
*
* function draw() {
* background(200);
+ *
+ * // Enable orbiting with the mouse.
* orbitControl();
- * box(15, 30);
+ *
+ * // Style the box.
+ * normalMaterial();
+ *
+ * // Draw the box.
+ * box(20, 40);
* }
*
*
+ * // Click and drag the mouse to view the scene from different angles.
+ *
* function setup() {
* createCanvas(100, 100, WEBGL);
- * camera(0, -30, 100, 0, 0, 0, 0, 1, 0);
- * perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));
- * normalMaterial();
- * debugMode(GRID, 100, 10, 0, 0, 0);
- * describe('a 3D box is centered on a grid in a 3D sketch');
+ *
+ * // Enable debug mode.
+ * // Only display the grid and customize it:
+ * // - size: 50
+ * // - divisions: 10
+ * // - offsets: 0, 20, 0
+ * debugMode(GRID, 50, 10, 0, 20, 0);
+ *
+ * describe('A multicolor box on a gray background. A grid is displayed below the box.');
* }
*
* function draw() {
* background(200);
+ *
+ * // Enable orbiting with the mouse.
* orbitControl();
- * box(15, 30);
+ *
+ * // Style the box.
+ * normalMaterial();
+ *
+ * // Draw the box.
+ * box(20, 40);
* }
*
*
+ * // Click and drag the mouse to view the scene from different angles.
+ *
* function setup() {
* createCanvas(100, 100, WEBGL);
- * camera(0, -30, 100, 0, 0, 0, 0, 1, 0);
- * perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));
- * normalMaterial();
- * debugMode(100, 10, 0, 0, 0, 20, 0, -40, 0);
- * 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.'
- * );
+ *
+ * // Enable debug mode.
+ * // Display the grid and axes icon and customize them:
+ * // Grid
+ * // ----
+ * // - size: 50
+ * // - divisions: 10
+ * // - offsets: 0, 20, 0
+ * // Axes
+ * // ----
+ * // - size: 50
+ * // - offsets: 0, 0, 0
+ * debugMode(50, 10, 0, 20, 0, 50, 0, 0, 0);
+ *
+ * describe('A multicolor box on a gray background. A grid is displayed below the box. An axes icon is displayed at the center of the box.');
* }
*
* function draw() {
- * noStroke();
* background(200);
+ *
+ * // Enable orbiting with the mouse.
* orbitControl();
- * box(15, 30);
- * // set the stroke color and weight for the grid!
- * stroke(255, 0, 150);
- * strokeWeight(0.8);
+ *
+ * // Style the box.
+ * normalMaterial();
+ *
+ * // Draw the box.
+ * box(20, 40);
* }
*
*
+ * // Click and drag the mouse to view the scene from different angles.
+ *
* function setup() {
* createCanvas(100, 100, WEBGL);
- * camera(0, -30, 100, 0, 0, 0, 0, 1, 0);
- * perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));
- * normalMaterial();
+ *
+ * // Enable debug mode.
* debugMode();
- * 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.'
- * );
+ *
+ * describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box. They disappear when the user double-clicks.');
* }
*
* function draw() {
* background(200);
+ *
+ * // Enable orbiting with the mouse.
* orbitControl();
- * box(15, 30);
- * // Press the spacebar to turn debugMode off!
- * if (keyIsDown(32)) {
- * noDebugMode();
- * }
+ *
+ * // Style the box.
+ * normalMaterial();
+ *
+ * // Draw the box. box(20, 40);
+ * }
+ *
+ * // Disable debug mode when the user double-clicks.
+ * function doubleClicked() {
+ * noDebugMode();
* }
*
*