Code viewer for World: Tutorial 18.5 (clone by Oc...

// Cloned by Octavian on 30 Nov 2022 from World "Tutorial 18.5" by "Coding Train" project 
// Please leave this clone trail here.
 


// Tutorial 18.4 with translate() to get the camera to move with mouse 
 
 
    
// Daniel Shiffman
// http://codingtra.in
// http://patreon.com/codingtrain

// Video: https://youtu.be/O1mYw-3Wl_Q

let angle = 4;
let kitten;
let cam;

function preload() {
  kitten = loadImage('/uploads/codingtrain/kitten0.jpg');
  kitten = loadImage('/uploads/starter/pacman.jpg'        );
}

function setup() {
  createCanvas( ABWorld.fullwidth(), ABWorld.fullheight(),  WEBGL );

/*
// access webcam 
// https://p5js.org/examples/dom-video-capture.html
  cam = createCapture(VIDEO);
  cam.size(320, 240);
  cam.hide();
*/

}

function draw() {
    
  translate ( 0, 0, mouseX );
  
  let dx = mouseX - width / 2;
  let dy = mouseY - height / 2;
  let v = createVector(dx, dy, 0);
  v.div(100);

  // ambientLight(255);
  directionalLight(255, 255, 255, v);
  background(175);
background("LightBlue");

  push();
  rotateX(angle);
  rotateY(angle * 0.3);
  rotateZ(angle * 1.2);

  noStroke();
  //ambientMaterial(0, 0, 255);
  
  /*
 // webcam as texture:
   texture(cam);
 */
 
 texture(kitten);
  //torus(100, 25);
  box(100);
  pop();

  translate(0, 100);
  rotateX(HALF_PI);
  ambientMaterial(255);
  plane(500, 500);

  angle += 0.03;
}