diff --git a/src/webgl/p5.Camera.js b/src/webgl/p5.Camera.js index a1e5572ed3..539c5f4648 100644 --- a/src/webgl/p5.Camera.js +++ b/src/webgl/p5.Camera.js @@ -1058,6 +1058,64 @@ p5.Camera = class Camera { ); } + /** + * Rolling rotates the camera view in forward direction. + * @method roll + * @param {Number} angle amount to rotate camera in current + * angleMode units. + * Greater than 0 values rotate counterclockwise (to the left). + * @example + *
+ * let cam;
+ * let delta = 0.01;
+ *
+ * function setup() {
+ * createCanvas(100, 100, WEBGL);
+ * normalMaterial();
+ * cam = createCamera();
+ * // set initial pan angle
+ * cam.roll(-0.8);
+ * }
+ *
+ * function draw() {
+ * background(200);
+ *
+ * // pan camera according to angle 'delta'
+ * cam.roll(delta);
+ *
+ * // every 160 frames, switch direction
+ * if (frameCount % 160 === 0) {
+ * delta *= -1;
+ * }
+ *
+ * rotateX(frameCount * 0.01);
+ * translate(0, 0, -100);
+ * box(20);
+ * translate(0, 0, 35);
+ * box(20);
+ * translate(0, 0, 35);
+ * box(20);
+ * translate(0, 0, 35);
+ * box(20);
+ * translate(0, 0, 35);
+ * box(20);
+ * translate(0, 0, 35);
+ * box(20);
+ * translate(0, 0, 35);
+ * box(20);
+ * }
+ *
+ *